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 259 of file ipid.cc.

260 {
261  if (s==NULL) return NULL;
262  if (root==NULL) return NULL;
263  idhdl h;
264  s=omStrDup(s);
265  // idhdl *save_root=root;
266  if (t==PACKAGE_CMD)
267  {
268  if (root!=&(basePack->idroot))
269  {
270  root=&(basePack->idroot);
271  }
272  }
273  // is it already defined in root ?
274  if ((h=(*root)->get(s,lev))!=NULL)
275  {
276  if (IDLEV(h)==lev)
277  {
278  if ((IDTYP(h) == t)||(t==DEF_CMD))
279  {
280  if ((IDTYP(h)==PACKAGE_CMD)
281  && (strcmp(s,"Top")==0))
282  {
283  goto errlabel;
284  }
285  if (BVERBOSE(V_REDEFINE))
286  Warn("redefining %s **",s);
287  if (s==IDID(h)) IDID(h)=NULL;
288  killhdl2(h,root,currRing);
289  }
290  else
291  goto errlabel;
292  }
293  }
294  // is it already defined in currRing->idroot ?
295  else if (search && (currRing!=NULL)&&((*root) != currRing->idroot))
296  {
297  if ((h=currRing->idroot->get(s,lev))!=NULL)
298  {
299  if (IDLEV(h)==lev)
300  {
301  if ((IDTYP(h) == t)||(t==DEF_CMD))
302  {
303  if (BVERBOSE(V_REDEFINE))
304  Warn("redefining %s **",s);
305  if (s==IDID(h)) IDID(h)=NULL;
306  killhdl2(h,&currRing->idroot,currRing);
307  }
308  else
309  goto errlabel;
310  }
311  }
312  }
313  // is it already defined in idroot ?
314  else if (search && (*root != IDROOT))
315  {
316  if ((h=IDROOT->get(s,lev))!=NULL)
317  {
318  if (IDLEV(h)==lev)
319  {
320  if ((IDTYP(h) == t)||(t==DEF_CMD))
321  {
322  if (BVERBOSE(V_REDEFINE))
323  Warn("redefining `%s` **",s);
324  if (s==IDID(h)) IDID(h)=NULL;
325  killhdl2(h,&IDROOT,NULL);
326  }
327  else
328  goto errlabel;
329  }
330  }
331  }
332  *root = (*root)->set(s, lev, t, init);
333 #ifndef SING_NDEBUG
334  checkall();
335 #endif
336  return *root;
337 
338  errlabel:
339  //Werror("identifier `%s` in use(lev h=%d,typ=%d,t=%d, curr=%d)",s,IDLEV(h),IDTYP(h),t,lev);
340  Werror("identifier `%s` in use",s);
341  //listall();
342  omFree((ADDRESS)s);
343  return NULL;
344 }
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:91
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:403
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:1017
#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:64
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:218
#define Warn
Definition: emacs.cc:80
#define omStrDup(s)
Definition: omAllocDecl.h:263
idhdl ggetid ( const char *  n,
BOOLEAN  ,
idhdl packhdl 
)

Definition at line 490 of file ipid.cc.

491 {
492  idhdl h = IDROOT->get(n,myynest);
493  idhdl h2=NULL;
494  *packhdl = NULL;
495  if ((currRing!=NULL) && ((h==NULL)||(IDLEV(h)!=myynest)))
496  {
497  h2 = currRing->idroot->get(n,myynest);
498  }
499  if (h2==NULL) return h;
500  return h2;
501 }
#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 503 of file ipid.cc.

504 {
505  idhdl h = IDROOT->get(n,myynest);
506  if ((h!=NULL)&&(IDLEV(h)==myynest)) return h;
507  idhdl h2=NULL;
508  if (currRing!=NULL)
509  {
510  h2 = currRing->idroot->get(n,myynest);
511  }
512  if (h2!=NULL) return h2;
513  if (h!=NULL) return h;
514  if (basePack!=currPack)
515  return basePack->idroot->get(n,myynest);
516  return NULL;
517 }
#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:64
package currPack
Definition: ipid.cc:63
static Poly * h
Definition: janet.cc:978
void* idrecDataInit ( int  t)

Definition at line 132 of file ipid.cc.

133 {
134  switch (t)
135  {
136  //the type with init routines:
137 #ifdef SINGULAR_4_1
138  case CNUMBER_CMD:
139  return (void*)n2Init(0,NULL);
140  case CMATRIX_CMD:
141 #endif
142  case BIGINTMAT_CMD:
143  return (void *)new bigintmat();
144  case INTVEC_CMD:
145  case INTMAT_CMD:
146  return (void *)new intvec();
147  case NUMBER_CMD:
148  return (void *) nInit(0);
149  case BIGINT_CMD:
150  return (void *) n_Init(0, coeffs_BIGINT);
151  case IDEAL_CMD:
152  case MODUL_CMD:
153  case MATRIX_CMD:
154  return (void*) idInit(1,1);
155  case MAP_CMD:
156  {
157  map m = (map)idInit(1,1);
158  m->preimage = omStrDup(IDID(currRingHdl));
159  return (void *)m;
160  }
161  case STRING_CMD:
162  return (void *)omAlloc0(1);
163  case LIST_CMD:
164  {
166  l->Init();
167  return (void*)l;
168  }
169  //the types with the standard init: set the struct to zero
170  case LINK_CMD:
171  return (void*) omAlloc0Bin(sip_link_bin);
172  case RING_CMD:
173  return (void*) omAlloc0Bin(sip_sring_bin);
174  case PACKAGE_CMD:
175  {
176  package pa=(package)omAlloc0Bin(sip_package_bin);
177  pa->language=LANG_NONE;
178  pa->loaded = FALSE;
179  return (void*)pa;
180  }
181  case PROC_CMD:
182  {
184  pi->ref=1;
185  pi->language=LANG_NONE;
186  return (void*)pi;
187  }
188  case RESOLUTION_CMD:
189  return (void *)omAlloc0(sizeof(ssyStrategy));
190  //other types: without init (int,script,poly,def,package)
191  #ifdef SINGULAR_4_1
192  case CRING_CMD:
193  #endif
194  case INT_CMD:
195  case DEF_CMD:
196  case POLY_CMD:
197  case VECTOR_CMD:
198  case QRING_CMD:
199  return (void*)0L;
200  default:
201  {
202  if (t>MAX_TOK)
203  {
204 #ifdef BLACKBOX_DEVEL
205  Print("bb-type %d\n",t);
206 #endif
207  blackbox *bb=getBlackboxStuff(t);
208  if (bb!=NULL)
209  return (void *)bb->blackbox_Init(bb);
210  }
211  else
212  Werror("unknown type in idrecDataInit:%d",t);
213  break;
214  }
215  }
216  return (void *)0L;
217 }
#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:51
Definition: tok.h:170
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:54
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:65
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 745 of file ipid.cc.

746 {
747  if (iiCurrArgs==NULL)
748  {
749  Werror("not enough arguments for proc %s",VoiceName());
750  p->CleanUp();
751  return TRUE;
752  }
754  iiCurrArgs=h->next;
755  h->next=NULL;
756  if (h->rtyp!=IDHDL)
757  {
758  BOOLEAN res=iiAssign(p,h);
759  h->CleanUp();
761  return res;
762  }
763  if ((h->Typ()!=p->Typ()) &&(p->Typ()!=DEF_CMD))
764  {
765  WerrorS("type mismatch");
766  return TRUE;
767  }
768  idhdl pp=(idhdl)p->data;
769  switch(pp->typ)
770  {
771 #ifdef SINGULAR_4_1
772  case CRING_CMD:
773  nKillChar((coeffs)pp);
774  break;
775 #endif
776  case DEF_CMD:
777  case INT_CMD:
778  break;
779  case INTVEC_CMD:
780  case INTMAT_CMD:
781  delete IDINTVEC(pp);
782  break;
783  case NUMBER_CMD:
784  nDelete(&IDNUMBER(pp));
785  break;
786  case BIGINT_CMD:
788  break;
789  case MAP_CMD:
790  {
791  map im = IDMAP(pp);
792  omFree((ADDRESS)im->preimage);
793  }
794  // continue as ideal:
795  case IDEAL_CMD:
796  case MODUL_CMD:
797  case MATRIX_CMD:
798  idDelete(&IDIDEAL(pp));
799  break;
800  case PROC_CMD:
801  case RESOLUTION_CMD:
802  case STRING_CMD:
803  omFree((ADDRESS)IDSTRING(pp));
804  break;
805  case LIST_CMD:
806  IDLIST(pp)->Clean();
807  break;
808  case LINK_CMD:
810  break;
811  // case ring: cannot happen
812  default:
813  Werror("unknown type %d",p->Typ());
814  return TRUE;
815  }
816  pp->typ=ALIAS_CMD;
817  IDDATA(pp)=(char*)h->data;
818  int eff_typ=h->Typ();
819  if ((RingDependend(eff_typ))
820  || ((eff_typ==LIST_CMD) && (lRingDependend((lists)h->Data()))))
821  {
822  ipSwapId(pp,IDROOT,currRing->idroot);
823  }
824  h->CleanUp();
826  return FALSE;
827 }
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
#define idDelete(H)
delete an ideal
Definition: ideals.h:31
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:24
coeffs coeffs_BIGINT
Definition: ipid.cc:54
int Typ()
Definition: subexpr.cc:969
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:321
void * Data()
Definition: subexpr.cc:1111
int typ
Definition: idrec.h:43
Definition: tok.h:96
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
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:579
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:488
void Werror(const char *fmt,...)
Definition: reporter.cc:199
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
Definition: ipassign.cc:1782
int iiS2I ( const char *  s)

Definition at line 72 of file ipid.cc.

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

Definition at line 519 of file ipid.cc.

520 {
521  if (hasFlag(h,FLAG_STD)) PrintS(" (SB)");
522 #ifdef HAVE_PLURAL
523  if (hasFlag(h,FLAG_TWOSTD)) PrintS(" (2SB)");
524 #endif
525 }
#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 604 of file ipid.cc.

605 {
606  if ((currRing!=NULL)&&(tomove!=NULL))
607  {
608  if (((QRING_CMD!=IDTYP(tomove)) && RingDependend(IDTYP(tomove)))
609  || ((IDTYP(tomove)==LIST_CMD) && (lRingDependend(IDLIST(tomove)))))
610  {
611  /*move 'tomove' to ring id's*/
612  if (ipSwapId(tomove,IDROOT,currRing->idroot))
613  ipSwapId(tomove,basePack->idroot,currRing->idroot);
614  }
615  else
616  {
617  /*move 'tomove' to global id's*/
618  ipSwapId(tomove,currRing->idroot,IDROOT);
619  }
620  }
621 }
#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:64
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:579
lists ipNameList ( idhdl  root)

Definition at line 527 of file ipid.cc.

528 {
529  idhdl h=root;
530  /* compute the length */
531  int l=0;
532  while (h!=NULL) { l++; h=IDNEXT(h); }
533  /* allocate list */
535  L->Init(l);
536  /* copy names */
537  h=root;
538  l=0;
539  while (h!=NULL)
540  {
541  /* list is initialized with 0 => no need to clear anything */
542  L->m[l].rtyp=STRING_CMD;
543  L->m[l].data=omStrDup(IDID(h));
544  l++;
545  h=IDNEXT(h);
546  }
547  return L;
548 }
#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 550 of file ipid.cc.

551 {
552  idhdl h=root;
553  /* compute the length */
554  int l=0;
555  while (h!=NULL) { if (IDLEV(h)==lev) l++; h=IDNEXT(h); }
556  /* allocate list */
558  L->Init(l);
559  /* copy names */
560  h=root;
561  l=0;
562  while (h!=NULL)
563  {
564  if (IDLEV(h)==lev)
565  {
566  /* list is initialized with 0 => no need to clear anything */
567  L->m[l].rtyp=STRING_CMD;
568  L->m[l].data=omStrDup(IDID(h));
569  l++;
570  }
571  h=IDNEXT(h);
572  }
573  return L;
574 }
#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 579 of file ipid.cc.

580 {
581  idhdl h;
582  /* search 'tomove' in root2 : if found -> do nothing */
583  h=root2;
584  while ((h!=NULL) && (h!=tomove)) h=IDNEXT(h);
585  if (h!=NULL) return FALSE; /*okay */
586  /* search predecessor of h in root1, remove 'tomove' */
587  h=root1;
588  if (tomove==h)
589  {
590  root1=IDNEXT(h);
591  }
592  else
593  {
594  while ((h!=NULL) && (IDNEXT(h)!=tomove)) h=IDNEXT(h);
595  if (h==NULL) return TRUE; /* not in the list root1 -> do nothing */
596  IDNEXT(h)=IDNEXT(tomove);
597  }
598  /* add to root2 list */
599  IDNEXT(tomove)=root2;
600  root2=tomove;
601  return FALSE;
602 }
#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 372 of file ipid.cc.

373 {
374  int t=IDTYP(h);
375  if (((BEGIN_RING<t) && (t<END_RING) && (t!=QRING_CMD))
376  || ((t==LIST_CMD) && (lRingDependend((lists)IDDATA(h)))))
377  killhdl2(h,&currRing->idroot,currRing);
378  else
379  {
380  if(t==PACKAGE_CMD)
381  {
382  killhdl2(h,&(basePack->idroot),NULL);
383  }
384  else
385  {
386  idhdl s=proot->idroot;
387  while ((s!=h) && (s!=NULL)) s=s->next;
388  if (s!=NULL)
389  killhdl2(h,&(proot->idroot),NULL);
390  else if (basePack!=proot)
391  {
392  idhdl s=basePack->idroot;
393  while ((s!=h) && (s!=NULL)) s=s->next;
394  if (s!=NULL)
395  killhdl2(h,&(basePack->idroot),currRing);
396  else
397  killhdl2(h,&(currRing->idroot),currRing);
398  }
399  }
400  }
401 }
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:403
idhdl next
Definition: idrec.h:38
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:64
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 403 of file ipid.cc.

404 {
405  //printf("kill %s, id %x, typ %d lev: %d\n",IDID(h),(int)IDID(h),IDTYP(h),IDLEV(h));
406  idhdl hh;
407 
408  if (TEST_V_ALLWARN
409  && (IDLEV(h)!=myynest)
410  &&(IDLEV(h)==0))
411  {
412  if (((*ih)==basePack->idroot)
413  || ((currRing!=NULL)&&((*ih)==currRing->idroot)))
414  Warn("kill global `%s` at line >>%s<<\n",IDID(h),my_yylinebuf);
415  }
416  if (h->attribute!=NULL)
417  {
418  //h->attribute->killAll(r); MEMORY LEAK!
419  h->attribute=NULL;
420  }
421  if (IDTYP(h) == PACKAGE_CMD)
422  {
423  if (strcmp(IDID(h),"Top")==0)
424  {
425  WarnS("can not kill `Top`");
426  return;
427  }
428  // any objects defined for this package ?
429  if ((IDPACKAGE(h)->ref<=0) && (IDPACKAGE(h)->idroot!=NULL))
430  {
431  if (currPack==IDPACKAGE(h))
432  {
435  }
436  idhdl * hd = &IDRING(h)->idroot;
437  idhdl hdh = IDNEXT(*hd);
438  idhdl temp;
439  while (hdh!=NULL)
440  {
441  temp = IDNEXT(hdh);
442  killhdl2(hdh,&(IDPACKAGE(h)->idroot),NULL);
443  hdh = temp;
444  }
445  killhdl2(*hd,hd,NULL);
446  if (IDPACKAGE(h)->libname!=NULL) omFree((ADDRESS)(IDPACKAGE(h)->libname));
447  }
448  paKill(IDPACKAGE(h));
451  }
452  else if ((IDTYP(h)==RING_CMD)||(IDTYP(h)==QRING_CMD))
453  rKill(h);
454  else if (IDDATA(h)!=NULL)
456  // general -------------------------------------------------------------
457  // now dechain it and delete idrec
458  if (IDID(h)!=NULL) // OB: ?????
459  omFree((ADDRESS)IDID(h));
460  IDID(h)=NULL;
461  IDDATA(h)=NULL;
462  if (h == (*ih))
463  {
464  // h is at the beginning of the list
465  *ih = IDNEXT(h) /* ==*ih */;
466  }
467  else if (ih!=NULL)
468  {
469  // h is somethere in the list:
470  hh = *ih;
471  loop
472  {
473  if (hh==NULL)
474  {
475  PrintS(">>?<< not found for kill\n");
476  return;
477  }
478  idhdl hhh = IDNEXT(hh);
479  if (hhh == h)
480  {
481  IDNEXT(hh) = IDNEXT(hhh);
482  break;
483  }
484  hh = hhh;
485  }
486  }
488 }
idhdl currPackHdl
Definition: ipid.cc:61
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:403
char my_yylinebuf[80]
Definition: febase.cc:48
const ring r
Definition: syzextra.cc:208
void rKill(ring r)
Definition: ipshell.cc:5999
omBin idrec_bin
Definition: ipid.cc:52
#define omFree(addr)
Definition: omAllocDecl.h:261
void s_internalDelete(const int t, void *d, const ring r)
Definition: subexpr.cc:478
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:64
#define IDRING(a)
Definition: ipid.h:126
package currPack
Definition: ipid.cc:63
Definition: tok.h:126
idhdl packFindHdl(package r)
Definition: ipid.cc:732
void iiCheckPack(package &p)
Definition: ipshell.cc:1512
#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 345 of file ipid.cc.

346 {
347  if (id!=NULL)
348  {
349  idhdl h = (*ih)->get(id,myynest);
350 
351  // id not found in global list, is it defined in current ring ?
352  if (h==NULL)
353  {
354  if ((currRing!=NULL) && (*ih != (currRing->idroot)))
355  {
356  h = currRing->idroot->get(id,myynest);
357  if (h!=NULL)
358  {
359  killhdl2(h,&(currRing->idroot),currRing);
360  return;
361  }
362  }
363  Werror("`%s` is not defined",id);
364  return;
365  }
366  killhdl2(h,ih,currRing);
367  }
368  else
369  Werror("kill what ?");
370 }
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:403
#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 732 of file ipid.cc.

733 {
734  idhdl h=basePack->idroot;
735  while (h!=NULL)
736  {
737  if ((IDTYP(h)==PACKAGE_CMD)
738  && (IDPACKAGE(h)==r))
739  return h;
740  h=IDNEXT(h);
741  }
742  return NULL;
743 }
#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:64
static Poly * h
Definition: janet.cc:978
void paCleanUp ( package  pack)

Definition at line 682 of file ipid.cc.

683 {
684  (pack->ref)--;
685  if (pack->ref < 0)
686  {
687 #ifndef HAVE_STATIC
688  if( pack->language == LANG_C)
689  {
690  Print("//dlclose(%s)\n",pack->libname);
691 #ifdef HAVE_DYNAMIC_LOADING
692  dynl_close (pack->handle);
693 #endif /* HAVE_DYNAMIC_LOADING */
694  }
695 #endif /* HAVE_STATIC */
696  omFree((ADDRESS)pack->libname);
697  memset((void *) pack, 0, sizeof(sip_package));
698  pack->language=LANG_NONE;
699  }
700 }
#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 647 of file ipid.cc.

648 {
650  while (p!=NULL)
651  {
652  if (p->pi==pi && pi->ref <= 1)
653  {
654  Warn("`%s` in use, can not be killed",pi->procname);
655  return TRUE;
656  }
657  p=p->next;
658  }
659  (pi->ref)--;
660  if (pi->ref <= 0)
661  {
662  if (pi->libname != NULL) // OB: ????
663  omFree((ADDRESS)pi->libname);
664  if (pi->procname != NULL) // OB: ????
665  omFree((ADDRESS)pi->procname);
666 
667  if( pi->language == LANG_SINGULAR)
668  {
669  if (pi->data.s.body != NULL) // OB: ????
670  omFree((ADDRESS)pi->data.s.body);
671  }
672  if( pi->language == LANG_C)
673  {
674  }
675  memset((void *) pi, 0, sizeof(procinfo));
676  pi->language=LANG_NONE;
678  }
679  return FALSE;
680 }
#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 623 of file ipid.cc.

624 {
625  if((pi == NULL)||(pi->language==LANG_NONE)) return "empty proc";
626  else if (strcmp(request, "libname") == 0) return pi->libname;
627  else if (strcmp(request, "procname") == 0) return pi->procname;
628  else if (strcmp(request, "type") == 0)
629  {
630  switch (pi->language)
631  {
632  case LANG_SINGULAR: return "singular"; break;
633  case LANG_C: return "object"; break;
634  case LANG_NONE: return "none"; break;
635  default: return "unknown language";
636  }
637  }
638  else if (strcmp(request, "ref") == 0)
639  {
640  char p[8];
641  sprintf(p, "%d", pi->ref);
642  return omStrDup(p); // MEMORY-LEAK
643  }
644  return "??";
645 }
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 64 of file ipid.cc.

idhdl basePackHdl = NULL

Definition at line 62 of file ipid.cc.

coeffs coeffs_BIGINT

Definition at line 54 of file ipid.cc.

package currPack =NULL

Definition at line 63 of file ipid.cc.

idhdl currPackHdl = NULL

Definition at line 61 of file ipid.cc.

idhdl currRingHdl = NULL

Definition at line 65 of file ipid.cc.

FILE* feFilePending

Definition at line 56 of file ipid.cc.

omBin idrec_bin = omGetSpecBin(sizeof(idrec))

Definition at line 52 of file ipid.cc.

const char* iiNoName ="_"

Definition at line 66 of file ipid.cc.

proclevel* procstack =NULL

Definition at line 58 of file ipid.cc.

omBin sip_command_bin = omGetSpecBin(sizeof(sip_command))

Definition at line 49 of file ipid.cc.

omBin sip_package_bin = omGetSpecBin(sizeof(sip_package))

Definition at line 50 of file ipid.cc.