Functions | Variables
ipid.cc File Reference
#include <kernel/mod2.h>
#include <omalloc/omalloc.h>
#include <misc/options.h>
#include <misc/intvec.h>
#include <coeffs/numbers.h>
#include <coeffs/bigintmat.h>
#include <polys/matpol.h>
#include <polys/monomials/ring.h>
#include <kernel/polys.h>
#include <kernel/ideals.h>
#include <kernel/GBEngine/syz.h>
#include <Singular/tok.h>
#include <Singular/ipshell.h>
#include <Singular/fevoices.h>
#include <Singular/lists.h>
#include <Singular/attrib.h>
#include <Singular/links/silink.h>
#include <Singular/ipid.h>
#include <Singular/blackbox.h>
#include <Singular/number2.h>
#include <polys/mod_raw.h>
#include <string.h>

Go to the source code of this file.

Functions

void paCleanUp (package pack)
 
int iiS2I (const char *s)
 
void * idrecDataInit (int t)
 
idhdl enterid (const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
 
void killid (const char *id, idhdl *ih)
 
void killhdl (idhdl h, package proot)
 
void killhdl2 (idhdl h, idhdl *ih, ring r)
 
idhdl ggetid (const char *n, BOOLEAN, idhdl *packhdl)
 
idhdl ggetid (const char *n)
 
void ipListFlag (idhdl h)
 
lists ipNameList (idhdl root)
 
lists ipNameListLev (idhdl root, int lev)
 
static int ipSwapId (idhdl tomove, idhdl &root1, idhdl &root2)
 
void ipMoveId (idhdl tomove)
 
const char * piProcinfo (procinfov pi, const char *request)
 
BOOLEAN piKill (procinfov pi)
 
idhdl packFindHdl (package r)
 
BOOLEAN iiAlias (leftv p)
 

Variables

omBin sip_command_bin = omGetSpecBin(sizeof(sip_command))
 
omBin sip_package_bin = omGetSpecBin(sizeof(sip_package))
 
omBin idrec_bin = omGetSpecBin(sizeof(idrec))
 
coeffs coeffs_BIGINT
 
FILE * feFilePending
 
proclevelprocstack =NULL
 
idhdl currPackHdl = NULL
 
idhdl basePackHdl = NULL
 
package currPack =NULL
 
package basePack =NULL
 
idhdl currRingHdl = NULL
 
const char * iiNoName ="_"
 

Function Documentation

idhdl enterid ( const char *  s,
int  lev,
int  t,
idhdl root,
BOOLEAN  init,
BOOLEAN  search 
)

Definition at line 256 of file ipid.cc.

257 {
258  if (s==NULL) return NULL;
259  if (root==NULL) return NULL;
260  idhdl h;
261  s=omStrDup(s);
262  // idhdl *save_root=root;
263  if (t==PACKAGE_CMD)
264  {
265  if (root!=&(basePack->idroot))
266  {
267  root=&(basePack->idroot);
268  }
269  }
270  // is it already defined in root ?
271  if ((h=(*root)->get(s,lev))!=NULL)
272  {
273  if (IDLEV(h)==lev)
274  {
275  if ((IDTYP(h) == t)||(t==DEF_CMD))
276  {
277  if ((IDTYP(h)==PACKAGE_CMD)
278  && (strcmp(s,"Top")==0))
279  {
280  goto errlabel;
281  }
282  if (BVERBOSE(V_REDEFINE))
283  Warn("redefining %s **",s);
284  if (s==IDID(h)) IDID(h)=NULL;
285  killhdl2(h,root,currRing);
286  }
287  else
288  goto errlabel;
289  }
290  }
291  // is it already defined in currRing->idroot ?
292  else if (search && (currRing!=NULL)&&((*root) != currRing->idroot))
293  {
294  if ((h=currRing->idroot->get(s,lev))!=NULL)
295  {
296  if (IDLEV(h)==lev)
297  {
298  if ((IDTYP(h) == t)||(t==DEF_CMD))
299  {
300  if (BVERBOSE(V_REDEFINE))
301  Warn("redefining %s **",s);
302  if (s==IDID(h)) IDID(h)=NULL;
303  killhdl2(h,&currRing->idroot,currRing);
304  }
305  else
306  goto errlabel;
307  }
308  }
309  }
310  // is it already defined in idroot ?
311  else if (search && (*root != IDROOT))
312  {
313  if ((h=IDROOT->get(s,lev))!=NULL)
314  {
315  if (IDLEV(h)==lev)
316  {
317  if ((IDTYP(h) == t)||(t==DEF_CMD))
318  {
319  if (BVERBOSE(V_REDEFINE))
320  Warn("redefining `%s` **",s);
321  if (s==IDID(h)) IDID(h)=NULL;
322  killhdl2(h,&IDROOT,NULL);
323  }
324  else
325  goto errlabel;
326  }
327  }
328  }
329  *root = (*root)->set(s, lev, t, init);
330 #ifndef SING_NDEBUG
331  checkall();
332 #endif
333  return *root;
334 
335  errlabel:
336  //Werror("identifier `%s` in use(lev h=%d,typ=%d,t=%d, curr=%d)",s,IDLEV(h),IDTYP(h),t,lev);
337  Werror("identifier `%s` in use",s);
338  //listall();
339  omFree((ADDRESS)s);
340  return NULL;
341 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define IDID(a)
Definition: ipid.h:121
#define IDROOT
Definition: ipid.h:20
void * ADDRESS
Definition: auxiliary.h:161
Definition: idrec.h:34
idhdl get(const char *s, int lev)
Definition: ipid.cc:90
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define IDTYP(a)
Definition: ipid.h:118
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:400
Definition: tok.h:58
#define omFree(addr)
Definition: omAllocDecl.h:261
int search(const CFArray &A, const CanonicalForm &F, int i, int j)
search for F in A between index i and j
void checkall()
Definition: misc_ip.cc:1016
#define IDLEV(a)
Definition: ipid.h:120
#define BVERBOSE(a)
Definition: options.h:33
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:63
static Poly * h
Definition: janet.cc:978
#define V_REDEFINE
Definition: options.h:43
void Werror(const char *fmt,...)
Definition: reporter.cc:199
idhdl set(const char *s, int lev, int t, BOOLEAN init=TRUE)
Definition: ipid.cc:215
#define Warn
Definition: emacs.cc:80
#define omStrDup(s)
Definition: omAllocDecl.h:263
idhdl ggetid ( const char *  n,
BOOLEAN  ,
idhdl packhdl 
)

Definition at line 487 of file ipid.cc.

488 {
489  idhdl h = IDROOT->get(n,myynest);
490  idhdl h2=NULL;
491  *packhdl = NULL;
492  if ((currRing!=NULL) && ((h==NULL)||(IDLEV(h)!=myynest)))
493  {
494  h2 = currRing->idroot->get(n,myynest);
495  }
496  if (h2==NULL) return h;
497  return h2;
498 }
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
#define IDROOT
Definition: ipid.h:20
Definition: idrec.h:34
int myynest
Definition: febase.cc:46
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define IDLEV(a)
Definition: ipid.h:120
#define NULL
Definition: omList.c:10
static Poly * h
Definition: janet.cc:978
idhdl ggetid ( const char *  n)

Definition at line 500 of file ipid.cc.

501 {
502  idhdl h = IDROOT->get(n,myynest);
503  if ((h!=NULL)&&(IDLEV(h)==myynest)) return h;
504  idhdl h2=NULL;
505  if (currRing!=NULL)
506  {
507  h2 = currRing->idroot->get(n,myynest);
508  }
509  if (h2!=NULL) return h2;
510  if (h!=NULL) return h;
511  if (basePack!=currPack)
512  return basePack->idroot->get(n,myynest);
513  return NULL;
514 }
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
#define IDROOT
Definition: ipid.h:20
Definition: idrec.h:34
int myynest
Definition: febase.cc:46
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define IDLEV(a)
Definition: ipid.h:120
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:63
package currPack
Definition: ipid.cc:62
static Poly * h
Definition: janet.cc:978
void* idrecDataInit ( int  t)

Definition at line 131 of file ipid.cc.

132 {
133  switch (t)
134  {
135  //the type with init routines:
136 #ifdef SINGULAR_4_1
137  case CNUMBER_CMD:
138  return (void*)n2Init(0,NULL);
139  case CMATRIX_CMD:
140 #endif
141  case BIGINTMAT_CMD:
142  return (void *)new bigintmat();
143  case INTVEC_CMD:
144  case INTMAT_CMD:
145  return (void *)new intvec();
146  case NUMBER_CMD:
147  return (void *) nInit(0);
148  case BIGINT_CMD:
149  return (void *) n_Init(0, coeffs_BIGINT);
150  case IDEAL_CMD:
151  case MODUL_CMD:
152  case MATRIX_CMD:
153  return (void*) idInit(1,1);
154  case MAP_CMD:
155  {
156  map m = (map)idInit(1,1);
157  m->preimage = omStrDup(IDID(currRingHdl));
158  return (void *)m;
159  }
160  case STRING_CMD:
161  return (void *)omAlloc0(1);
162  case LIST_CMD:
163  {
165  l->Init();
166  return (void*)l;
167  }
168  //the types with the standard init: set the struct to zero
169  case LINK_CMD:
170  return (void*) omAlloc0Bin(sip_link_bin);
171  case RING_CMD:
172  return (void*) omAlloc0Bin(sip_sring_bin);
173  case PACKAGE_CMD:
174  {
175  package pa=(package)omAlloc0Bin(sip_package_bin);
176  pa->language=LANG_NONE;
177  pa->loaded = FALSE;
178  return (void*)pa;
179  }
180  case PROC_CMD:
181  {
183  pi->ref=1;
184  pi->language=LANG_NONE;
185  return (void*)pi;
186  }
187  case RESOLUTION_CMD:
188  return (void *)omAlloc0(sizeof(ssyStrategy));
189  //other types: without init (int,script,poly,def,package)
190  case CRING_CMD:
191  case INT_CMD:
192  case DEF_CMD:
193  case POLY_CMD:
194  case VECTOR_CMD:
195  case QRING_CMD:
196  return (void*)0L;
197  default:
198  {
199  if (t>MAX_TOK)
200  {
201 #ifdef BLACKBOX_DEVEL
202  Print("bb-type %d\n",t);
203 #endif
204  blackbox *bb=getBlackboxStuff(t);
205  if (bb!=NULL)
206  return (void *)bb->blackbox_Init(bb);
207  }
208  else
209  Werror("unknown type %d",t);
210  break;
211  }
212  }
213  return (void *)0L;
214 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
CanonicalForm map(const CanonicalForm &primElem, const Variable &alpha, const CanonicalForm &F, const Variable &beta)
map from to such that is mapped onto
Definition: cf_map_ext.cc:400
#define Print
Definition: emacs.cc:83
Definition: tok.h:85
Definition: lists.h:22
#define IDID(a)
Definition: ipid.h:121
#define FALSE
Definition: auxiliary.h:140
Definition: tok.h:42
Matrices of numbers.
Definition: bigintmat.h:32
Definition: tok.h:167
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:539
language_defs language
Definition: subexpr.h:58
short ref
Definition: subexpr.h:59
coeffs coeffs_BIGINT
Definition: ipid.cc:53
omBin procinfo_bin
Definition: subexpr.cc:51
Definition: tok.h:56
static number2 n2Init(long i, coeffs c)
Definition: number2.h:17
Definition: intvec.h:16
Definition: tok.h:58
idhdl currRingHdl
Definition: ipid.cc:64
omBin sip_sring_bin
Definition: ring.cc:54
int m
Definition: cfEzgcd.cc:119
Definition: tok.h:88
INLINE_THIS void Init(int l=0)
Definition: lists.h:66
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define pi
Definition: libparse.cc:1143
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
Definition: tok.h:95
#define NULL
Definition: omList.c:10
slists * lists
Definition: mpr_numeric.h:146
Definition: tok.h:96
omBin slists_bin
Definition: lists.cc:23
Definition: tok.h:126
#define nInit(i)
Definition: numbers.h:24
void Werror(const char *fmt,...)
Definition: reporter.cc:199
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94
procinfo * procinfov
Definition: structs.h:63
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:20
#define omStrDup(s)
Definition: omAllocDecl.h:263
BOOLEAN iiAlias ( leftv  p)

Definition at line 742 of file ipid.cc.

743 {
744  if (iiCurrArgs==NULL)
745  {
746  Werror("not enough arguments for proc %s",VoiceName());
747  p->CleanUp();
748  return TRUE;
749  }
751  iiCurrArgs=h->next;
752  h->next=NULL;
753  if (h->rtyp!=IDHDL)
754  {
755  BOOLEAN res=iiAssign(p,h);
756  h->CleanUp();
758  return res;
759  }
760  if ((h->Typ()!=p->Typ()) &&(p->Typ()!=DEF_CMD))
761  {
762  WerrorS("type mismatch");
763  return TRUE;
764  }
765  idhdl pp=(idhdl)p->data;
766  switch(pp->typ)
767  {
768 #ifdef SINGULAR_4_1
769  case CRING_CMD:
770  nKillChar((coeffs)pp);
771  break;
772 #endif
773  case DEF_CMD:
774  case INT_CMD:
775  break;
776  case INTVEC_CMD:
777  case INTMAT_CMD:
778  delete IDINTVEC(pp);
779  break;
780  case NUMBER_CMD:
781  nDelete(&IDNUMBER(pp));
782  break;
783  case BIGINT_CMD:
785  break;
786  case MAP_CMD:
787  {
788  map im = IDMAP(pp);
789  omFree((ADDRESS)im->preimage);
790  }
791  // continue as ideal:
792  case IDEAL_CMD:
793  case MODUL_CMD:
794  case MATRIX_CMD:
795  idDelete(&IDIDEAL(pp));
796  break;
797  case PROC_CMD:
798  case RESOLUTION_CMD:
799  case STRING_CMD:
800  omFree((ADDRESS)IDSTRING(pp));
801  break;
802  case LIST_CMD:
803  IDLIST(pp)->Clean();
804  break;
805  case LINK_CMD:
807  break;
808  // case ring: cannot happen
809  default:
810  Werror("unknown type %d",p->Typ());
811  return TRUE;
812  }
813  pp->typ=ALIAS_CMD;
814  IDDATA(pp)=(char*)h->data;
815  int eff_typ=h->Typ();
816  if ((RingDependend(eff_typ))
817  || ((eff_typ==LIST_CMD) && (lRingDependend((lists)h->Data()))))
818  {
819  ipSwapId(pp,IDROOT,currRing->idroot);
820  }
821  h->CleanUp();
823  return FALSE;
824 }
CanonicalForm map(const CanonicalForm &primElem, const Variable &alpha, const CanonicalForm &F, const Variable &beta)
map from to such that is mapped onto
Definition: cf_map_ext.cc:400
#define IDLIST(a)
Definition: ipid.h:136
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
Definition: tok.h:85
#define IDLINK(a)
Definition: ipid.h:137
Definition: lists.h:22
#define IDINTVEC(a)
Definition: ipid.h:127
#define FALSE
Definition: auxiliary.h:140
Definition: tok.h:42
#define IDROOT
Definition: ipid.h:20
#define TRUE
Definition: auxiliary.h:144
#define IDIDEAL(a)
Definition: ipid.h:132
void * ADDRESS
Definition: auxiliary.h:161
void WerrorS(const char *s)
Definition: feFopen.cc:23
coeffs coeffs_BIGINT
Definition: ipid.cc:53
int Typ()
Definition: subexpr.cc:955
Definition: idrec.h:34
#define IDHDL
Definition: tok.h:35
poly pp
Definition: myNF.cc:296
void * data
Definition: subexpr.h:89
poly res
Definition: myNF.cc:322
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
int RingDependend(int t)
Definition: gentable.cc:23
Definition: tok.h:56
Definition: tok.h:58
#define omFree(addr)
Definition: omAllocDecl.h:261
The main handler for Singular numbers which are suitable for Singular polynomials.
#define IDSTRING(a)
Definition: ipid.h:135
idrec * idhdl
Definition: ring.h:18
omBin sleftv_bin
Definition: subexpr.cc:50
Definition: tok.h:88
const char * VoiceName()
Definition: fevoices.cc:66
#define nDelete(n)
Definition: numbers.h:16
#define IDMAP(a)
Definition: ipid.h:134
leftv next
Definition: subexpr.h:87
#define IDNUMBER(a)
Definition: ipid.h:131
Definition: tok.h:38
Definition: tok.h:95
#define NULL
Definition: omList.c:10
leftv iiCurrArgs
Definition: ipshell.cc:84
int rtyp
Definition: subexpr.h:92
void CleanUp(ring r=currRing)
Definition: subexpr.cc:307
void * Data()
Definition: subexpr.cc:1097
int typ
Definition: idrec.h:43
Definition: tok.h:96
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:456
#define IDDATA(a)
Definition: ipid.h:125
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
static Poly * h
Definition: janet.cc:978
int BOOLEAN
Definition: auxiliary.h:131
BOOLEAN lRingDependend(lists L)
Definition: lists.cc:199
static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
Definition: ipid.cc:576
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:488
void Werror(const char *fmt,...)
Definition: reporter.cc:199
void idDelete(ideal *h)
delete an ideal
Definition: ideals.h:31
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
Definition: ipassign.cc:1772
int iiS2I ( const char *  s)

Definition at line 71 of file ipid.cc.

72 {
73  int i;
74  i=s[0];
75  if (s[1]!='\0')
76  {
77  i=(i<<8)+s[1];
78  if (s[2]!='\0')
79  {
80  i=(i<<8)+s[2];
81  if (s[3]!='\0')
82  {
83  i=(i<<8)+s[3];
84  }
85  }
86  }
87  return i;
88 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
int i
Definition: cfEzgcd.cc:123
void ipListFlag ( idhdl  h)

Definition at line 516 of file ipid.cc.

517 {
518  if (hasFlag(h,FLAG_STD)) PrintS(" (SB)");
519 #ifdef HAVE_PLURAL
520  if (hasFlag(h,FLAG_TWOSTD)) PrintS(" (2SB)");
521 #endif
522 }
#define FLAG_TWOSTD
Definition: ipid.h:109
void PrintS(const char *s)
Definition: reporter.cc:294
#define FLAG_STD
Definition: ipid.h:108
#define hasFlag(A, F)
Definition: ipid.h:111
void ipMoveId ( idhdl  tomove)

Definition at line 601 of file ipid.cc.

602 {
603  if ((currRing!=NULL)&&(tomove!=NULL))
604  {
605  if (((QRING_CMD!=IDTYP(tomove)) && RingDependend(IDTYP(tomove)))
606  || ((IDTYP(tomove)==LIST_CMD) && (lRingDependend(IDLIST(tomove)))))
607  {
608  /*move 'tomove' to ring id's*/
609  if (ipSwapId(tomove,IDROOT,currRing->idroot))
610  ipSwapId(tomove,basePack->idroot,currRing->idroot);
611  }
612  else
613  {
614  /*move 'tomove' to global id's*/
615  ipSwapId(tomove,currRing->idroot,IDROOT);
616  }
617  }
618 }
#define IDLIST(a)
Definition: ipid.h:136
#define IDROOT
Definition: ipid.h:20
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define IDTYP(a)
Definition: ipid.h:118
int RingDependend(int t)
Definition: gentable.cc:23
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:63
Definition: tok.h:96
Definition: tok.h:126
BOOLEAN lRingDependend(lists L)
Definition: lists.cc:199
static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
Definition: ipid.cc:576
lists ipNameList ( idhdl  root)

Definition at line 524 of file ipid.cc.

525 {
526  idhdl h=root;
527  /* compute the length */
528  int l=0;
529  while (h!=NULL) { l++; h=IDNEXT(h); }
530  /* allocate list */
532  L->Init(l);
533  /* copy names */
534  h=root;
535  l=0;
536  while (h!=NULL)
537  {
538  /* list is initialized with 0 => no need to clear anything */
539  L->m[l].rtyp=STRING_CMD;
540  L->m[l].data=omStrDup(IDID(h));
541  l++;
542  h=IDNEXT(h);
543  }
544  return L;
545 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
sleftv * m
Definition: lists.h:45
Definition: lists.h:22
#define IDID(a)
Definition: ipid.h:121
#define IDNEXT(a)
Definition: ipid.h:117
Definition: idrec.h:34
void * data
Definition: subexpr.h:89
INLINE_THIS void Init(int l=0)
Definition: lists.h:66
#define NULL
Definition: omList.c:10
slists * lists
Definition: mpr_numeric.h:146
int rtyp
Definition: subexpr.h:92
omBin slists_bin
Definition: lists.cc:23
static Poly * h
Definition: janet.cc:978
int l
Definition: cfEzgcd.cc:94
#define omStrDup(s)
Definition: omAllocDecl.h:263
lists ipNameListLev ( idhdl  root,
int  lev 
)

Definition at line 547 of file ipid.cc.

548 {
549  idhdl h=root;
550  /* compute the length */
551  int l=0;
552  while (h!=NULL) { if (IDLEV(h)==lev) l++; h=IDNEXT(h); }
553  /* allocate list */
555  L->Init(l);
556  /* copy names */
557  h=root;
558  l=0;
559  while (h!=NULL)
560  {
561  if (IDLEV(h)==lev)
562  {
563  /* list is initialized with 0 => no need to clear anything */
564  L->m[l].rtyp=STRING_CMD;
565  L->m[l].data=omStrDup(IDID(h));
566  l++;
567  }
568  h=IDNEXT(h);
569  }
570  return L;
571 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
sleftv * m
Definition: lists.h:45
Definition: lists.h:22
#define IDID(a)
Definition: ipid.h:121
#define IDNEXT(a)
Definition: ipid.h:117
Definition: idrec.h:34
void * data
Definition: subexpr.h:89
#define IDLEV(a)
Definition: ipid.h:120
INLINE_THIS void Init(int l=0)
Definition: lists.h:66
#define NULL
Definition: omList.c:10
slists * lists
Definition: mpr_numeric.h:146
int rtyp
Definition: subexpr.h:92
omBin slists_bin
Definition: lists.cc:23
static Poly * h
Definition: janet.cc:978
int l
Definition: cfEzgcd.cc:94
#define omStrDup(s)
Definition: omAllocDecl.h:263
static int ipSwapId ( idhdl  tomove,
idhdl root1,
idhdl root2 
)
static

Definition at line 576 of file ipid.cc.

577 {
578  idhdl h;
579  /* search 'tomove' in root2 : if found -> do nothing */
580  h=root2;
581  while ((h!=NULL) && (h!=tomove)) h=IDNEXT(h);
582  if (h!=NULL) return FALSE; /*okay */
583  /* search predecessor of h in root1, remove 'tomove' */
584  h=root1;
585  if (tomove==h)
586  {
587  root1=IDNEXT(h);
588  }
589  else
590  {
591  while ((h!=NULL) && (IDNEXT(h)!=tomove)) h=IDNEXT(h);
592  if (h==NULL) return TRUE; /* not in the list root1 -> do nothing */
593  IDNEXT(h)=IDNEXT(tomove);
594  }
595  /* add to root2 list */
596  IDNEXT(tomove)=root2;
597  root2=tomove;
598  return FALSE;
599 }
#define FALSE
Definition: auxiliary.h:140
#define IDNEXT(a)
Definition: ipid.h:117
#define TRUE
Definition: auxiliary.h:144
Definition: idrec.h:34
#define NULL
Definition: omList.c:10
static Poly * h
Definition: janet.cc:978
void killhdl ( idhdl  h,
package  proot 
)

Definition at line 369 of file ipid.cc.

370 {
371  int t=IDTYP(h);
372  if (((BEGIN_RING<t) && (t<END_RING) && (t!=QRING_CMD))
373  || ((t==LIST_CMD) && (lRingDependend((lists)IDDATA(h)))))
374  killhdl2(h,&currRing->idroot,currRing);
375  else
376  {
377  if(t==PACKAGE_CMD)
378  {
379  killhdl2(h,&(basePack->idroot),NULL);
380  }
381  else
382  {
383  idhdl s=proot->idroot;
384  while ((s!=h) && (s!=NULL)) s=s->next;
385  if (s!=NULL)
386  killhdl2(h,&(proot->idroot),NULL);
387  else if (basePack!=proot)
388  {
389  idhdl s=basePack->idroot;
390  while ((s!=h) && (s!=NULL)) s=s->next;
391  if (s!=NULL)
392  killhdl2(h,&(basePack->idroot),currRing);
393  else
394  killhdl2(h,&(currRing->idroot),currRing);
395  }
396  }
397  }
398 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
Definition: lists.h:22
Definition: idrec.h:34
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define IDTYP(a)
Definition: ipid.h:118
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:400
idhdl next
Definition: idrec.h:38
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:63
Definition: tok.h:96
Definition: tok.h:126
#define IDDATA(a)
Definition: ipid.h:125
BOOLEAN lRingDependend(lists L)
Definition: lists.cc:199
void killhdl2 ( idhdl  h,
idhdl ih,
ring  r 
)

Definition at line 400 of file ipid.cc.

401 {
402  //printf("kill %s, id %x, typ %d lev: %d\n",IDID(h),(int)IDID(h),IDTYP(h),IDLEV(h));
403  idhdl hh;
404 
405  if (TEST_V_ALLWARN
406  && (IDLEV(h)!=myynest)
407  &&(IDLEV(h)==0))
408  {
409  if (((*ih)==basePack->idroot)
410  || ((currRing!=NULL)&&((*ih)==currRing->idroot)))
411  Warn("kill global `%s` at line >>%s<<\n",IDID(h),my_yylinebuf);
412  }
413  if (h->attribute!=NULL)
414  {
415  //h->attribute->killAll(r); MEMORY LEAK!
416  h->attribute=NULL;
417  }
418  if (IDTYP(h) == PACKAGE_CMD)
419  {
420  if (strcmp(IDID(h),"Top")==0)
421  {
422  WarnS("can not kill `Top`");
423  return;
424  }
425  // any objects defined for this package ?
426  if ((IDPACKAGE(h)->ref<=0) && (IDPACKAGE(h)->idroot!=NULL))
427  {
428  if (currPack==IDPACKAGE(h))
429  {
432  }
433  idhdl * hd = &IDRING(h)->idroot;
434  idhdl hdh = IDNEXT(*hd);
435  idhdl temp;
436  while (hdh!=NULL)
437  {
438  temp = IDNEXT(hdh);
439  killhdl2(hdh,&(IDPACKAGE(h)->idroot),NULL);
440  hdh = temp;
441  }
442  killhdl2(*hd,hd,NULL);
443  if (IDPACKAGE(h)->libname!=NULL) omFree((ADDRESS)(IDPACKAGE(h)->libname));
444  }
445  paKill(IDPACKAGE(h));
448  }
449  else if ((IDTYP(h)==RING_CMD)||(IDTYP(h)==QRING_CMD))
450  rKill(h);
451  else if (IDDATA(h)!=NULL)
453  // general -------------------------------------------------------------
454  // now dechain it and delete idrec
455  if (IDID(h)!=NULL) // OB: ?????
456  omFree((ADDRESS)IDID(h));
457  IDID(h)=NULL;
458  IDDATA(h)=NULL;
459  if (h == (*ih))
460  {
461  // h is at the beginning of the list
462  *ih = IDNEXT(h) /* ==*ih */;
463  }
464  else if (ih!=NULL)
465  {
466  // h is somethere in the list:
467  hh = *ih;
468  loop
469  {
470  if (hh==NULL)
471  {
472  PrintS(">>?<< not found for kill\n");
473  return;
474  }
475  idhdl hhh = IDNEXT(hh);
476  if (hhh == h)
477  {
478  IDNEXT(hh) = IDNEXT(hhh);
479  break;
480  }
481  hh = hhh;
482  }
483  }
485 }
idhdl currPackHdl
Definition: ipid.cc:60
loop
Definition: myNF.cc:98
#define IDID(a)
Definition: ipid.h:121
#define IDNEXT(a)
Definition: ipid.h:117
void * ADDRESS
Definition: auxiliary.h:161
#define WarnS
Definition: emacs.cc:81
void paKill(package pack)
Definition: ipid.h:51
Definition: idrec.h:34
#define IDPACKAGE(a)
Definition: ipid.h:138
int myynest
Definition: febase.cc:46
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define IDTYP(a)
Definition: ipid.h:118
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:400
char my_yylinebuf[80]
Definition: febase.cc:48
const ring r
Definition: syzextra.cc:208
void rKill(ring r)
Definition: ipshell.cc:5690
omBin idrec_bin
Definition: ipid.cc:51
#define omFree(addr)
Definition: omAllocDecl.h:261
void s_internalDelete(const int t, void *d, const ring r)
Definition: subexpr.cc:464
void PrintS(const char *s)
Definition: reporter.cc:294
#define IDLEV(a)
Definition: ipid.h:120
#define NULL
Definition: omList.c:10
attr attribute
Definition: idrec.h:41
package basePack
Definition: ipid.cc:63
#define IDRING(a)
Definition: ipid.h:126
package currPack
Definition: ipid.cc:62
Definition: tok.h:126
idhdl packFindHdl(package r)
Definition: ipid.cc:729
void iiCheckPack(package &p)
Definition: ipshell.cc:1504
#define IDDATA(a)
Definition: ipid.h:125
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
#define TEST_V_ALLWARN
Definition: options.h:135
#define Warn
Definition: emacs.cc:80
void killid ( const char *  id,
idhdl ih 
)

Definition at line 342 of file ipid.cc.

343 {
344  if (id!=NULL)
345  {
346  idhdl h = (*ih)->get(id,myynest);
347 
348  // id not found in global list, is it defined in current ring ?
349  if (h==NULL)
350  {
351  if ((currRing!=NULL) && (*ih != (currRing->idroot)))
352  {
353  h = currRing->idroot->get(id,myynest);
354  if (h!=NULL)
355  {
356  killhdl2(h,&(currRing->idroot),currRing);
357  return;
358  }
359  }
360  Werror("`%s` is not defined",id);
361  return;
362  }
363  killhdl2(h,ih,currRing);
364  }
365  else
366  Werror("kill what ?");
367 }
Definition: idrec.h:34
int myynest
Definition: febase.cc:46
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:400
#define NULL
Definition: omList.c:10
static Poly * h
Definition: janet.cc:978
void Werror(const char *fmt,...)
Definition: reporter.cc:199
idhdl packFindHdl ( package  r)

Definition at line 729 of file ipid.cc.

730 {
731  idhdl h=basePack->idroot;
732  while (h!=NULL)
733  {
734  if ((IDTYP(h)==PACKAGE_CMD)
735  && (IDPACKAGE(h)==r))
736  return h;
737  h=IDNEXT(h);
738  }
739  return NULL;
740 }
#define IDNEXT(a)
Definition: ipid.h:117
Definition: idrec.h:34
#define IDPACKAGE(a)
Definition: ipid.h:138
#define IDTYP(a)
Definition: ipid.h:118
const ring r
Definition: syzextra.cc:208
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:63
static Poly * h
Definition: janet.cc:978
void paCleanUp ( package  pack)

Definition at line 679 of file ipid.cc.

680 {
681  (pack->ref)--;
682  if (pack->ref < 0)
683  {
684 #ifndef HAVE_STATIC
685  if( pack->language == LANG_C)
686  {
687  Print("//dlclose(%s)\n",pack->libname);
688 #ifdef HAVE_DYNAMIC_LOADING
689  dynl_close (pack->handle);
690 #endif /* HAVE_DYNAMIC_LOADING */
691  }
692 #endif /* HAVE_STATIC */
693  omFree((ADDRESS)pack->libname);
694  memset((void *) pack, 0, sizeof(sip_package));
695  pack->language=LANG_NONE;
696  }
697 }
#define Print
Definition: emacs.cc:83
void * ADDRESS
Definition: auxiliary.h:161
Definition: subexpr.h:20
#define omFree(addr)
Definition: omAllocDecl.h:261
int dynl_close(void *handle)
Definition: mod_raw.cc:182
BOOLEAN piKill ( procinfov  pi)

Definition at line 644 of file ipid.cc.

645 {
647  while (p!=NULL)
648  {
649  if (p->pi==pi && pi->ref <= 1)
650  {
651  Warn("`%s` in use, can not be killed",pi->procname);
652  return TRUE;
653  }
654  p=p->next;
655  }
656  (pi->ref)--;
657  if (pi->ref <= 0)
658  {
659  if (pi->libname != NULL) // OB: ????
660  omFree((ADDRESS)pi->libname);
661  if (pi->procname != NULL) // OB: ????
662  omFree((ADDRESS)pi->procname);
663 
664  if( pi->language == LANG_SINGULAR)
665  {
666  if (pi->data.s.body != NULL) // OB: ????
667  omFree((ADDRESS)pi->data.s.body);
668  }
669  if( pi->language == LANG_C)
670  {
671  }
672  memset((void *) pi, 0, sizeof(procinfo));
673  pi->language=LANG_NONE;
675  }
676  return FALSE;
677 }
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
language_defs language
Definition: subexpr.h:58
#define TRUE
Definition: auxiliary.h:144
void * ADDRESS
Definition: auxiliary.h:161
short ref
Definition: subexpr.h:59
Definition: fevoices.h:57
Voice * next
Definition: fevoices.h:60
omBin procinfo_bin
Definition: subexpr.cc:51
char * procname
Definition: subexpr.h:56
Definition: subexpr.h:20
char * libname
Definition: subexpr.h:55
procinfo * pi
Definition: fevoices.h:63
#define omFree(addr)
Definition: omAllocDecl.h:261
procinfodata data
Definition: subexpr.h:62
#define NULL
Definition: omList.c:10
Voice * currentVoice
Definition: fevoices.cc:57
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
#define Warn
Definition: emacs.cc:80
const char* piProcinfo ( procinfov  pi,
const char *  request 
)

Definition at line 620 of file ipid.cc.

621 {
622  if((pi == NULL)||(pi->language==LANG_NONE)) return "empty proc";
623  else if (strcmp(request, "libname") == 0) return pi->libname;
624  else if (strcmp(request, "procname") == 0) return pi->procname;
625  else if (strcmp(request, "type") == 0)
626  {
627  switch (pi->language)
628  {
629  case LANG_SINGULAR: return "singular"; break;
630  case LANG_C: return "object"; break;
631  case LANG_NONE: return "none"; break;
632  default: return "unknow language";
633  }
634  }
635  else if (strcmp(request, "ref") == 0)
636  {
637  char p[8];
638  sprintf(p, "%d", pi->ref);
639  return omStrDup(p); // MEMORY-LEAK
640  }
641  return "??";
642 }
return P p
Definition: myNF.cc:203
language_defs language
Definition: subexpr.h:58
short ref
Definition: subexpr.h:59
char * procname
Definition: subexpr.h:56
Definition: subexpr.h:20
char * libname
Definition: subexpr.h:55
#define NULL
Definition: omList.c:10
#define omStrDup(s)
Definition: omAllocDecl.h:263

Variable Documentation

package basePack =NULL

Definition at line 63 of file ipid.cc.

idhdl basePackHdl = NULL

Definition at line 61 of file ipid.cc.

coeffs coeffs_BIGINT

Definition at line 53 of file ipid.cc.

package currPack =NULL

Definition at line 62 of file ipid.cc.

idhdl currPackHdl = NULL

Definition at line 60 of file ipid.cc.

idhdl currRingHdl = NULL

Definition at line 64 of file ipid.cc.

FILE* feFilePending

Definition at line 55 of file ipid.cc.

omBin idrec_bin = omGetSpecBin(sizeof(idrec))

Definition at line 51 of file ipid.cc.

const char* iiNoName ="_"

Definition at line 65 of file ipid.cc.

proclevel* procstack =NULL

Definition at line 57 of file ipid.cc.

omBin sip_command_bin = omGetSpecBin(sizeof(sip_command))

Definition at line 48 of file ipid.cc.

omBin sip_package_bin = omGetSpecBin(sizeof(sip_package))

Definition at line 49 of file ipid.cc.