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

§ enterid()

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

Definition at line 261 of file ipid.cc.

262 {
263  if (s==NULL) return NULL;
264  if (root==NULL) return NULL;
265  idhdl h;
266  s=omStrDup(s);
267  // idhdl *save_root=root;
268  if (t==PACKAGE_CMD)
269  {
270  if (root!=&(basePack->idroot))
271  {
272  root=&(basePack->idroot);
273  }
274  }
275  // is it already defined in root ?
276  if ((h=(*root)->get(s,lev))!=NULL)
277  {
278  if (IDLEV(h)==lev)
279  {
280  if ((IDTYP(h) == t)||(t==DEF_CMD))
281  {
282  if (IDTYP(h)==PACKAGE_CMD)
283  {
284  if (strcmp(s,"Top")==0)
285  {
286  goto errlabel;
287  }
288  else return *root;
289  }
290  else
291  {
292  if (BVERBOSE(V_REDEFINE))
293  Warn("redefining %s (%s)",s,my_yylinebuf);
294  if (s==IDID(h)) IDID(h)=NULL;
295  killhdl2(h,root,currRing);
296  }
297  }
298  else
299  goto errlabel;
300  }
301  }
302  // is it already defined in currRing->idroot ?
303  else if (search && (currRing!=NULL)&&((*root) != currRing->idroot))
304  {
305  if ((h=currRing->idroot->get(s,lev))!=NULL)
306  {
307  if (IDLEV(h)==lev)
308  {
309  if ((IDTYP(h) == t)||(t==DEF_CMD))
310  {
311  if (BVERBOSE(V_REDEFINE))
312  Warn("redefining %s (%s)",s,my_yylinebuf);
313  if (s==IDID(h)) IDID(h)=NULL;
314  killhdl2(h,&currRing->idroot,currRing);
315  }
316  else
317  goto errlabel;
318  }
319  }
320  }
321  // is it already defined in idroot ?
322  else if (search && (*root != IDROOT))
323  {
324  if ((h=IDROOT->get(s,lev))!=NULL)
325  {
326  if (IDLEV(h)==lev)
327  {
328  if ((IDTYP(h) == t)||(t==DEF_CMD))
329  {
330  if (BVERBOSE(V_REDEFINE))
331  Warn("redefining %s (%s)",s,my_yylinebuf);
332  if (s==IDID(h)) IDID(h)=NULL;
333  killhdl2(h,&IDROOT,NULL);
334  }
335  else
336  goto errlabel;
337  }
338  }
339  }
340  *root = (*root)->set(s, lev, t, init);
341 #ifndef SING_NDEBUG
342  checkall();
343 #endif
344  return *root;
345 
346  errlabel:
347  //Werror("identifier `%s` in use(lev h=%d,typ=%d,t=%d, curr=%d)",s,IDLEV(h),IDTYP(h),t,lev);
348  Werror("identifier `%s` in use",s);
349  //listall();
350  omFree((ADDRESS)s);
351  return NULL;
352 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define IDID(a)
Definition: ipid.h:119
#define IDROOT
Definition: ipid.h:20
void * ADDRESS
Definition: auxiliary.h:116
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:10
#define IDTYP(a)
Definition: ipid.h:116
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:411
char my_yylinebuf[80]
Definition: febase.cc:48
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
#define IDLEV(a)
Definition: ipid.h:118
#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:189
idhdl set(const char *s, int lev, int t, BOOLEAN init=TRUE)
Definition: ipid.cc:220
#define Warn
Definition: emacs.cc:80
#define omStrDup(s)
Definition: omAllocDecl.h:263

§ ggetid() [1/2]

idhdl ggetid ( const char *  n,
BOOLEAN  ,
idhdl packhdl 
)

Definition at line 498 of file ipid.cc.

499 {
500  idhdl h = IDROOT->get(n,myynest);
501  idhdl h2=NULL;
502  *packhdl = NULL;
503  if ((currRing!=NULL) && ((h==NULL)||(IDLEV(h)!=myynest)))
504  {
505  h2 = currRing->idroot->get(n,myynest);
506  }
507  if (h2==NULL) return h;
508  return h2;
509 }
#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:10
#define IDLEV(a)
Definition: ipid.h:118
#define NULL
Definition: omList.c:10
static Poly * h
Definition: janet.cc:978

§ ggetid() [2/2]

idhdl ggetid ( const char *  n)

Definition at line 511 of file ipid.cc.

512 {
513  idhdl h = IDROOT->get(n,myynest);
514  if ((h!=NULL)&&(IDLEV(h)==myynest)) return h;
515  idhdl h2=NULL;
516  if (currRing!=NULL)
517  {
518  h2 = currRing->idroot->get(n,myynest);
519  }
520  if (h2!=NULL) return h2;
521  if (h!=NULL) return h;
522  if (basePack!=currPack)
523  return basePack->idroot->get(n,myynest);
524  return NULL;
525 }
#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:10
#define IDLEV(a)
Definition: ipid.h:118
#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

§ idrecDataInit()

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_2
138  case CNUMBER_CMD:
139  return (void*)n2Init(0,NULL);
140  case CPOLY_CMD:
141  return (void*)p2Init(0,NULL);
142  case CMATRIX_CMD:
143 #endif
144  case BIGINTMAT_CMD:
145  return (void *)new bigintmat();
146  case INTVEC_CMD:
147  case INTMAT_CMD:
148  return (void *)new intvec();
149  case NUMBER_CMD:
150  return (void *) nInit(0);
151  case BIGINT_CMD:
152  return (void *) n_Init(0, coeffs_BIGINT);
153  case IDEAL_CMD:
154  case MODUL_CMD:
155  case MATRIX_CMD:
156  return (void*) idInit(1,1);
157  case MAP_CMD:
158  {
159  map m = (map)idInit(1,1);
160  m->preimage = omStrDup(IDID(currRingHdl));
161  return (void *)m;
162  }
163  case STRING_CMD:
164  return (void *)omAlloc0(1);
165  case LIST_CMD:
166  {
168  l->Init();
169  return (void*)l;
170  }
171  //the types with the standard init: set the struct to zero
172  case LINK_CMD:
173  return (void*) omAlloc0Bin(sip_link_bin);
174  case RING_CMD:
175  return NULL;
176  case PACKAGE_CMD:
177  {
178  package pa=(package)omAlloc0Bin(sip_package_bin);
179  pa->language=LANG_NONE;
180  pa->loaded = FALSE;
181  return (void*)pa;
182  }
183  case PROC_CMD:
184  {
186  pi->ref=1;
187  pi->language=LANG_NONE;
188  return (void*)pi;
189  }
190  case RESOLUTION_CMD:
191  return (void *)omAlloc0(sizeof(ssyStrategy));
192  //other types: without init (int,script,poly,def,package)
193  #ifdef SINGULAR_4_1
194  case CRING_CMD:
195  #endif
196  case INT_CMD:
197  case DEF_CMD:
198  case POLY_CMD:
199  case VECTOR_CMD:
200  case QRING_CMD:
201  return (void*)0L;
202  default:
203  {
204  if (t>MAX_TOK)
205  {
206 #ifdef BLACKBOX_DEVEL
207  Print("bb-type %d\n",t);
208 #endif
209  blackbox *bb=getBlackboxStuff(t);
210  if (bb!=NULL)
211  return (void *)bb->blackbox_Init(bb);
212  }
213  else
214  Werror("unknown type in idrecDataInit:%d",t);
215  break;
216  }
217  }
218  return (void *)0L;
219 }
#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
Definition: tok.h:48
#define Print
Definition: emacs.cc:83
Definition: tok.h:95
Definition: lists.h:22
#define IDID(a)
Definition: ipid.h:119
#define FALSE
Definition: auxiliary.h:95
Definition: tok.h:38
Matrices of numbers.
Definition: bigintmat.h:51
Definition: tok.h:215
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:542
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
Definition: intvec.h:14
Definition: tok.h:58
idhdl currRingHdl
Definition: ipid.cc:65
int m
Definition: cfEzgcd.cc:119
INLINE_THIS void Init(int l=0)
#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:116
#define NULL
Definition: omList.c:10
slists * lists
Definition: mpr_numeric.h:146
Definition: tok.h:117
omBin slists_bin
Definition: lists.cc:23
Definition: tok.h:157
#define nInit(i)
Definition: numbers.h:24
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#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:16
#define omStrDup(s)
Definition: omAllocDecl.h:263

§ iiAlias()

BOOLEAN iiAlias ( leftv  p)

Definition at line 751 of file ipid.cc.

752 {
753  if (iiCurrArgs==NULL)
754  {
755  Werror("not enough arguments for proc %s",VoiceName());
756  p->CleanUp();
757  return TRUE;
758  }
760  iiCurrArgs=h->next;
761  h->next=NULL;
762  if (h->rtyp!=IDHDL)
763  {
764  BOOLEAN res=iiAssign(p,h);
765  h->CleanUp();
767  return res;
768  }
769  if ((h->Typ()!=p->Typ()) &&(p->Typ()!=DEF_CMD))
770  {
771  WerrorS("type mismatch");
772  return TRUE;
773  }
774  idhdl pp=(idhdl)p->data;
775  switch(pp->typ)
776  {
777 #ifdef SINGULAR_4_1
778  case CRING_CMD:
779  nKillChar((coeffs)pp);
780  break;
781 #endif
782  case DEF_CMD:
783  case INT_CMD:
784  break;
785  case INTVEC_CMD:
786  case INTMAT_CMD:
787  delete IDINTVEC(pp);
788  break;
789  case NUMBER_CMD:
790  nDelete(&IDNUMBER(pp));
791  break;
792  case BIGINT_CMD:
794  break;
795  case MAP_CMD:
796  {
797  map im = IDMAP(pp);
798  omFree((ADDRESS)im->preimage);
799  }
800  // continue as ideal:
801  case IDEAL_CMD:
802  case MODUL_CMD:
803  case MATRIX_CMD:
804  idDelete(&IDIDEAL(pp));
805  break;
806  case PROC_CMD:
807  case RESOLUTION_CMD:
808  case STRING_CMD:
809  omFree((ADDRESS)IDSTRING(pp));
810  break;
811  case LIST_CMD:
812  IDLIST(pp)->Clean();
813  break;
814  case LINK_CMD:
816  break;
817  // case ring: cannot happen
818  default:
819  Werror("unknown type %d",p->Typ());
820  return TRUE;
821  }
822  pp->typ=ALIAS_CMD;
823  IDDATA(pp)=(char*)h->data;
824  int eff_typ=h->Typ();
825  if ((RingDependend(eff_typ))
826  || ((eff_typ==LIST_CMD) && (lRingDependend((lists)h->Data()))))
827  {
828  ipSwapId(pp,IDROOT,currRing->idroot);
829  }
830  h->CleanUp();
832  return FALSE;
833 }
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:134
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
Definition: tok.h:95
#define IDLINK(a)
Definition: ipid.h:135
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
Definition: lists.h:22
#define IDINTVEC(a)
Definition: ipid.h:125
#define FALSE
Definition: auxiliary.h:95
Definition: tok.h:38
#define IDROOT
Definition: ipid.h:20
#define TRUE
Definition: auxiliary.h:99
#define IDIDEAL(a)
Definition: ipid.h:130
void * ADDRESS
Definition: auxiliary.h:116
void WerrorS(const char *s)
Definition: feFopen.cc:24
coeffs coeffs_BIGINT
Definition: ipid.cc:54
int Typ()
Definition: subexpr.cc:1004
Definition: idrec.h:34
#define IDHDL
Definition: tok.h:31
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:10
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:133
idrec * idhdl
Definition: ring.h:18
omBin sleftv_bin
Definition: subexpr.cc:50
const char * VoiceName()
Definition: fevoices.cc:66
#define nDelete(n)
Definition: numbers.h:16
#define IDMAP(a)
Definition: ipid.h:132
leftv next
Definition: subexpr.h:87
#define IDNUMBER(a)
Definition: ipid.h:129
Definition: tok.h:34
Definition: tok.h:116
#define NULL
Definition: omList.c:10
leftv iiCurrArgs
Definition: ipshell.cc:80
int rtyp
Definition: subexpr.h:92
void CleanUp(ring r=currRing)
Definition: subexpr.cc:335
void * Data()
Definition: subexpr.cc:1146
int typ
Definition: idrec.h:43
Definition: tok.h:117
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
#define IDDATA(a)
Definition: ipid.h:123
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
static Poly * h
Definition: janet.cc:978
int BOOLEAN
Definition: auxiliary.h:86
BOOLEAN lRingDependend(lists L)
Definition: lists.cc:199
static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
Definition: ipid.cc:587
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:496
void Werror(const char *fmt,...)
Definition: reporter.cc:189
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
Definition: ipassign.cc:1792

§ iiS2I()

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

§ ipListFlag()

void ipListFlag ( idhdl  h)

Definition at line 527 of file ipid.cc.

528 {
529  if (hasFlag(h,FLAG_STD)) PrintS(" (SB)");
530 #ifdef HAVE_PLURAL
531  if (hasFlag(h,FLAG_TWOSTD)) PrintS(" (2SB)");
532 #endif
533 }
#define FLAG_TWOSTD
Definition: ipid.h:107
void PrintS(const char *s)
Definition: reporter.cc:284
#define FLAG_STD
Definition: ipid.h:106
#define hasFlag(A, F)
Definition: ipid.h:109

§ ipMoveId()

void ipMoveId ( idhdl  tomove)

Definition at line 612 of file ipid.cc.

613 {
614  if ((currRing!=NULL)&&(tomove!=NULL))
615  {
616  if (RingDependend(IDTYP(tomove))
617  || ((IDTYP(tomove)==LIST_CMD) && (lRingDependend(IDLIST(tomove)))))
618  {
619  /*move 'tomove' to ring id's*/
620  if (ipSwapId(tomove,IDROOT,currRing->idroot))
621  ipSwapId(tomove,basePack->idroot,currRing->idroot);
622  }
623  else
624  {
625  /*move 'tomove' to global id's*/
626  ipSwapId(tomove,currRing->idroot,IDROOT);
627  }
628  }
629 }
#define IDLIST(a)
Definition: ipid.h:134
#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:10
#define IDTYP(a)
Definition: ipid.h:116
int RingDependend(int t)
Definition: gentable.cc:23
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:64
Definition: tok.h:117
BOOLEAN lRingDependend(lists L)
Definition: lists.cc:199
static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
Definition: ipid.cc:587

§ ipNameList()

lists ipNameList ( idhdl  root)

Definition at line 535 of file ipid.cc.

536 {
537  idhdl h=root;
538  /* compute the length */
539  int l=0;
540  while (h!=NULL) { l++; h=IDNEXT(h); }
541  /* allocate list */
543  L->Init(l);
544  /* copy names */
545  h=root;
546  l=0;
547  while (h!=NULL)
548  {
549  /* list is initialized with 0 => no need to clear anything */
550  L->m[l].rtyp=STRING_CMD;
551  L->m[l].data=omStrDup(IDID(h));
552  l++;
553  h=IDNEXT(h);
554  }
555  return L;
556 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
sleftv * m
Definition: lists.h:45
Definition: lists.h:22
#define IDID(a)
Definition: ipid.h:119
#define IDNEXT(a)
Definition: ipid.h:115
Definition: idrec.h:34
void * data
Definition: subexpr.h:89
INLINE_THIS void Init(int l=0)
#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

§ ipNameListLev()

lists ipNameListLev ( idhdl  root,
int  lev 
)

Definition at line 558 of file ipid.cc.

559 {
560  idhdl h=root;
561  /* compute the length */
562  int l=0;
563  while (h!=NULL) { if (IDLEV(h)==lev) l++; h=IDNEXT(h); }
564  /* allocate list */
566  L->Init(l);
567  /* copy names */
568  h=root;
569  l=0;
570  while (h!=NULL)
571  {
572  if (IDLEV(h)==lev)
573  {
574  /* list is initialized with 0 => no need to clear anything */
575  L->m[l].rtyp=STRING_CMD;
576  L->m[l].data=omStrDup(IDID(h));
577  l++;
578  }
579  h=IDNEXT(h);
580  }
581  return L;
582 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
sleftv * m
Definition: lists.h:45
Definition: lists.h:22
#define IDID(a)
Definition: ipid.h:119
#define IDNEXT(a)
Definition: ipid.h:115
Definition: idrec.h:34
void * data
Definition: subexpr.h:89
#define IDLEV(a)
Definition: ipid.h:118
INLINE_THIS void Init(int l=0)
#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

§ ipSwapId()

static int ipSwapId ( idhdl  tomove,
idhdl root1,
idhdl root2 
)
static

Definition at line 587 of file ipid.cc.

588 {
589  idhdl h;
590  /* search 'tomove' in root2 : if found -> do nothing */
591  h=root2;
592  while ((h!=NULL) && (h!=tomove)) h=IDNEXT(h);
593  if (h!=NULL) return FALSE; /*okay */
594  /* search predecessor of h in root1, remove 'tomove' */
595  h=root1;
596  if (tomove==h)
597  {
598  root1=IDNEXT(h);
599  }
600  else
601  {
602  while ((h!=NULL) && (IDNEXT(h)!=tomove)) h=IDNEXT(h);
603  if (h==NULL) return TRUE; /* not in the list root1 -> do nothing */
604  IDNEXT(h)=IDNEXT(tomove);
605  }
606  /* add to root2 list */
607  IDNEXT(tomove)=root2;
608  root2=tomove;
609  return FALSE;
610 }
#define FALSE
Definition: auxiliary.h:95
#define IDNEXT(a)
Definition: ipid.h:115
#define TRUE
Definition: auxiliary.h:99
Definition: idrec.h:34
#define NULL
Definition: omList.c:10
static Poly * h
Definition: janet.cc:978

§ killhdl()

void killhdl ( idhdl  h,
package  proot 
)

Definition at line 380 of file ipid.cc.

381 {
382  int t=IDTYP(h);
383  if (((BEGIN_RING<t) && (t<END_RING))
384  || ((t==LIST_CMD) && (lRingDependend((lists)IDDATA(h)))))
385  killhdl2(h,&currRing->idroot,currRing);
386  else
387  {
388  if(t==PACKAGE_CMD)
389  {
390  killhdl2(h,&(basePack->idroot),NULL);
391  }
392  else
393  {
394  idhdl s=proot->idroot;
395  while ((s!=h) && (s!=NULL)) s=s->next;
396  if (s!=NULL)
397  killhdl2(h,&(proot->idroot),NULL);
398  else if (basePack!=proot)
399  {
400  idhdl s=basePack->idroot;
401  while ((s!=h) && (s!=NULL)) s=s->next;
402  if (s!=NULL)
403  killhdl2(h,&(basePack->idroot),currRing);
404  else
405  killhdl2(h,&(currRing->idroot),currRing);
406  }
407  }
408  }
409 }
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:10
#define IDTYP(a)
Definition: ipid.h:116
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:411
idhdl next
Definition: idrec.h:38
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:64
Definition: tok.h:117
#define IDDATA(a)
Definition: ipid.h:123
BOOLEAN lRingDependend(lists L)
Definition: lists.cc:199

§ killhdl2()

void killhdl2 ( idhdl  h,
idhdl ih,
ring  r 
)

Definition at line 411 of file ipid.cc.

412 {
413  //printf("kill %s, id %x, typ %d lev: %d\n",IDID(h),(int)IDID(h),IDTYP(h),IDLEV(h));
414  idhdl hh;
415 
416  if (TEST_V_ALLWARN
417  && (IDLEV(h)!=myynest)
418  &&(IDLEV(h)==0))
419  {
420  if (((*ih)==basePack->idroot)
421  || ((currRing!=NULL)&&((*ih)==currRing->idroot)))
422  Warn("kill global `%s` at line >>%s<<\n",IDID(h),my_yylinebuf);
423  }
424  if (h->attribute!=NULL)
425  {
426  //h->attribute->killAll(r); MEMORY LEAK!
427  h->attribute=NULL;
428  }
429  if (IDTYP(h) == PACKAGE_CMD)
430  {
431  if (strcmp(IDID(h),"Top")==0)
432  {
433  WarnS("can not kill `Top`");
434  return;
435  }
436  // any objects defined for this package ?
437  if ((IDPACKAGE(h)->ref<=0) && (IDPACKAGE(h)->idroot!=NULL))
438  {
439  if (currPack==IDPACKAGE(h))
440  {
443  }
444  idhdl * hd = &IDRING(h)->idroot;
445  idhdl hdh = IDNEXT(*hd);
446  idhdl temp;
447  while (hdh!=NULL)
448  {
449  temp = IDNEXT(hdh);
450  killhdl2(hdh,&(IDPACKAGE(h)->idroot),NULL);
451  hdh = temp;
452  }
453  killhdl2(*hd,hd,NULL);
454  if (IDPACKAGE(h)->libname!=NULL) omFree((ADDRESS)(IDPACKAGE(h)->libname));
455  }
456  paKill(IDPACKAGE(h));
459  }
460  else if (IDTYP(h)==RING_CMD)
461  rKill(h);
462  else if (IDDATA(h)!=NULL)
464  // general -------------------------------------------------------------
465  // now dechain it and delete idrec
466  if (IDID(h)!=NULL) // OB: ?????
467  omFree((ADDRESS)IDID(h));
468  IDID(h)=NULL;
469  IDDATA(h)=NULL;
470  if (h == (*ih))
471  {
472  // h is at the beginning of the list
473  *ih = IDNEXT(h) /* ==*ih */;
474  }
475  else if (ih!=NULL)
476  {
477  // h is somethere in the list:
478  hh = *ih;
479  loop
480  {
481  if (hh==NULL)
482  {
483  PrintS(">>?<< not found for kill\n");
484  return;
485  }
486  idhdl hhh = IDNEXT(hh);
487  if (hhh == h)
488  {
489  IDNEXT(hh) = IDNEXT(hhh);
490  break;
491  }
492  hh = hhh;
493  }
494  }
496 }
idhdl currPackHdl
Definition: ipid.cc:61
loop
Definition: myNF.cc:98
#define IDID(a)
Definition: ipid.h:119
#define IDNEXT(a)
Definition: ipid.h:115
void * ADDRESS
Definition: auxiliary.h:116
#define WarnS
Definition: emacs.cc:81
void paKill(package pack)
Definition: ipid.h:51
Definition: idrec.h:34
#define IDPACKAGE(a)
Definition: ipid.h:136
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:10
#define IDTYP(a)
Definition: ipid.h:116
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:411
char my_yylinebuf[80]
Definition: febase.cc:48
const ring r
Definition: syzextra.cc:208
void rKill(ring r)
Definition: ipshell.cc:6048
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:500
void PrintS(const char *s)
Definition: reporter.cc:284
#define IDLEV(a)
Definition: ipid.h:118
#define NULL
Definition: omList.c:10
attr attribute
Definition: idrec.h:41
package basePack
Definition: ipid.cc:64
#define IDRING(a)
Definition: ipid.h:124
package currPack
Definition: ipid.cc:63
idhdl packFindHdl(package r)
Definition: ipid.cc:738
void iiCheckPack(package &p)
Definition: ipshell.cc:1513
#define IDDATA(a)
Definition: ipid.h:123
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
#define TEST_V_ALLWARN
Definition: options.h:135
#define Warn
Definition: emacs.cc:80

§ killid()

void killid ( const char *  id,
idhdl ih 
)

Definition at line 353 of file ipid.cc.

354 {
355  if (id!=NULL)
356  {
357  idhdl h = (*ih)->get(id,myynest);
358 
359  // id not found in global list, is it defined in current ring ?
360  if (h==NULL)
361  {
362  if ((currRing!=NULL) && (*ih != (currRing->idroot)))
363  {
364  h = currRing->idroot->get(id,myynest);
365  if (h!=NULL)
366  {
367  killhdl2(h,&(currRing->idroot),currRing);
368  return;
369  }
370  }
371  Werror("`%s` is not defined",id);
372  return;
373  }
374  killhdl2(h,ih,currRing);
375  }
376  else
377  WerrorS("kill what ?");
378 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
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:10
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:411
#define NULL
Definition: omList.c:10
static Poly * h
Definition: janet.cc:978
void Werror(const char *fmt,...)
Definition: reporter.cc:189

§ packFindHdl()

idhdl packFindHdl ( package  r)

Definition at line 738 of file ipid.cc.

739 {
740  idhdl h=basePack->idroot;
741  while (h!=NULL)
742  {
743  if ((IDTYP(h)==PACKAGE_CMD)
744  && (IDPACKAGE(h)==r))
745  return h;
746  h=IDNEXT(h);
747  }
748  return NULL;
749 }
#define IDNEXT(a)
Definition: ipid.h:115
Definition: idrec.h:34
#define IDPACKAGE(a)
Definition: ipid.h:136
#define IDTYP(a)
Definition: ipid.h:116
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

§ paCleanUp()

void paCleanUp ( package  pack)

Definition at line 690 of file ipid.cc.

691 {
692  (pack->ref)--;
693  if (pack->ref < 0)
694  {
695 #ifndef HAVE_STATIC
696  if( pack->language == LANG_C)
697  {
698  Print("//dlclose(%s)\n",pack->libname);
699 #ifdef HAVE_DYNAMIC_LOADING
700  dynl_close (pack->handle);
701 #endif /* HAVE_DYNAMIC_LOADING */
702  }
703 #endif /* HAVE_STATIC */
704  omFree((ADDRESS)pack->libname);
705  memset((void *) pack, 0, sizeof(sip_package));
706  pack->language=LANG_NONE;
707  }
708 }
#define Print
Definition: emacs.cc:83
void * ADDRESS
Definition: auxiliary.h:116
Definition: subexpr.h:21
#define omFree(addr)
Definition: omAllocDecl.h:261
int dynl_close(void *handle)
Definition: mod_raw.cc:178

§ piKill()

BOOLEAN piKill ( procinfov  pi)

Definition at line 655 of file ipid.cc.

656 {
657  (pi->ref)--;
658  if (pi->ref <= 0)
659  {
661  while (p!=NULL)
662  {
663  if (p->pi==pi && pi->ref <= 1)
664  {
665  Warn("`%s` in use, can not be killed",pi->procname);
666  return TRUE;
667  }
668  p=p->next;
669  }
670  if (pi->libname != NULL) // OB: ????
671  omFree((ADDRESS)pi->libname);
672  if (pi->procname != NULL) // OB: ????
673  omFree((ADDRESS)pi->procname);
674 
675  if( pi->language == LANG_SINGULAR)
676  {
677  if (pi->data.s.body != NULL) // OB: ????
678  omFree((ADDRESS)pi->data.s.body);
679  }
680  if( pi->language == LANG_C)
681  {
682  }
683  memset((void *) pi, 0, sizeof(procinfo));
684  pi->language=LANG_NONE;
686  }
687  return FALSE;
688 }
#define FALSE
Definition: auxiliary.h:95
return P p
Definition: myNF.cc:203
language_defs language
Definition: subexpr.h:58
#define TRUE
Definition: auxiliary.h:99
void * ADDRESS
Definition: auxiliary.h:116
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:21
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

§ piProcinfo()

const char* piProcinfo ( procinfov  pi,
const char *  request 
)

Definition at line 631 of file ipid.cc.

632 {
633  if((pi == NULL)||(pi->language==LANG_NONE)) return "empty proc";
634  else if (strcmp(request, "libname") == 0) return pi->libname;
635  else if (strcmp(request, "procname") == 0) return pi->procname;
636  else if (strcmp(request, "type") == 0)
637  {
638  switch (pi->language)
639  {
640  case LANG_SINGULAR: return "singular"; break;
641  case LANG_C: return "object"; break;
642  case LANG_NONE: return "none"; break;
643  default: return "unknown language";
644  }
645  }
646  else if (strcmp(request, "ref") == 0)
647  {
648  char p[8];
649  sprintf(p, "%d", pi->ref);
650  return omStrDup(p); // MEMORY-LEAK
651  }
652  return "??";
653 }
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:21
char * libname
Definition: subexpr.h:55
#define NULL
Definition: omList.c:10
#define omStrDup(s)
Definition: omAllocDecl.h:263

Variable Documentation

§ basePack

package basePack =NULL

Definition at line 64 of file ipid.cc.

§ basePackHdl

idhdl basePackHdl = NULL

Definition at line 62 of file ipid.cc.

§ coeffs_BIGINT

coeffs coeffs_BIGINT

Definition at line 54 of file ipid.cc.

§ currPack

package currPack =NULL

Definition at line 63 of file ipid.cc.

§ currPackHdl

idhdl currPackHdl = NULL

Definition at line 61 of file ipid.cc.

§ currRingHdl

idhdl currRingHdl = NULL

Definition at line 65 of file ipid.cc.

§ feFilePending

FILE* feFilePending

Definition at line 56 of file ipid.cc.

§ idrec_bin

omBin idrec_bin = omGetSpecBin(sizeof(idrec))

Definition at line 52 of file ipid.cc.

§ iiNoName

const char* iiNoName ="_"

Definition at line 66 of file ipid.cc.

§ procstack

proclevel* procstack =NULL

Definition at line 58 of file ipid.cc.

§ sip_command_bin

omBin sip_command_bin = omGetSpecBin(sizeof(sip_command))

Definition at line 49 of file ipid.cc.

§ sip_package_bin

omBin sip_package_bin = omGetSpecBin(sizeof(sip_package))

Definition at line 50 of file ipid.cc.