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"

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)
 
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
 
proclevelprocstack =NULL
 
idhdl currPackHdl = NULL
 
idhdl basePackHdl = NULL
 
package currPack = NULL
 
package basePack = NULL
 
idhdl currRingHdl = NULL
 

Function Documentation

◆ enterid()

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

Definition at line 257 of file ipid.cc.

258 {
259  if (s==NULL) return NULL;
260  if (root==NULL) return NULL;
261  idhdl h;
262  s=omStrDup(s);
263  // idhdl *save_root=root;
264  if (t==PACKAGE_CMD)
265  {
266  if (root!=&(basePack->idroot))
267  {
268  root=&(basePack->idroot);
269  }
270  }
271  // is it already defined in root ?
272  if ((h=(*root)->get(s,lev))!=NULL)
273  {
274  if (IDLEV(h)==lev)
275  {
276  if ((IDTYP(h) == t)||(t==DEF_CMD))
277  {
278  if (IDTYP(h)==PACKAGE_CMD)
279  {
280  if (strcmp(s,"Top")==0)
281  {
282  goto errlabel;
283  }
284  else return h;
285  }
286  else
287  {
288  if (BVERBOSE(V_REDEFINE))
289  Warn("redefining %s (%s)",s,my_yylinebuf);
290  if (s==IDID(h)) IDID(h)=NULL;
291  killhdl2(h,root,currRing);
292  }
293  }
294  else
295  goto errlabel;
296  }
297  }
298  // is it already defined in currRing->idroot ?
299  else if (search && (currRing!=NULL)&&((*root) != currRing->idroot))
300  {
301  if ((h=currRing->idroot->get(s,lev))!=NULL)
302  {
303  if (IDLEV(h)==lev)
304  {
305  if ((IDTYP(h) == t)||(t==DEF_CMD))
306  {
307  if (BVERBOSE(V_REDEFINE))
308  Warn("redefining %s (%s)",s,my_yylinebuf);
309  if (s==IDID(h)) IDID(h)=NULL;
310  killhdl2(h,&currRing->idroot,currRing);
311  }
312  else
313  goto errlabel;
314  }
315  }
316  }
317  // is it already defined in idroot ?
318  else if (search && (*root != IDROOT))
319  {
320  if ((h=IDROOT->get(s,lev))!=NULL)
321  {
322  if (IDLEV(h)==lev)
323  {
324  if ((IDTYP(h) == t)||(t==DEF_CMD))
325  {
326  if (BVERBOSE(V_REDEFINE))
327  Warn("redefining %s (%s)",s,my_yylinebuf);
328  if (s==IDID(h)) IDID(h)=NULL;
329  killhdl2(h,&IDROOT,NULL);
330  }
331  else
332  goto errlabel;
333  }
334  }
335  }
336  *root = (*root)->set(s, lev, t, init);
337 #ifndef SING_NDEBUG
338  checkall();
339 #endif
340  return *root;
341 
342  errlabel:
343  //Werror("identifier `%s` in use(lev h=%d,typ=%d,t=%d, curr=%d)",s,IDLEV(h),IDTYP(h),t,lev);
344  Werror("identifier `%s` in use",s);
345  //listall();
346  omFree((ADDRESS)s);
347  return NULL;
348 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define IDID(a)
Definition: ipid.h:117
#define IDROOT
Definition: ipid.h:18
void * ADDRESS
Definition: auxiliary.h:133
Definition: idrec.h:34
idhdl get(const char *s, int lev)
Definition: ipid.cc:86
#define IDTYP(a)
Definition: ipid.h:114
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:407
char my_yylinebuf[80]
Definition: febase.cc:43
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:116
#define BVERBOSE(a)
Definition: options.h:35
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:60
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
static Poly * h
Definition: janet.cc:972
#define V_REDEFINE
Definition: options.h:45
void Werror(const char *fmt,...)
Definition: reporter.cc:189
idhdl set(const char *s, int lev, int t, BOOLEAN init=TRUE)
Definition: ipid.cc:216
#define Warn
Definition: emacs.cc:77
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ ggetid()

idhdl ggetid ( const char *  n)

Definition at line 513 of file ipid.cc.

514 {
515  idhdl h = IDROOT->get(n,myynest);
516  if ((h!=NULL)&&(IDLEV(h)==myynest)) return h;
517  if (currRing!=NULL)
518  {
519  idhdl h2 = currRing->idroot->get(n,myynest);
520  if (h2!=NULL) return h2;
521  }
522  if (h!=NULL) return h;
523  if (basePack!=currPack)
524  return basePack->idroot->get(n,myynest);
525  return NULL;
526 }
#define IDROOT
Definition: ipid.h:18
Definition: idrec.h:34
int myynest
Definition: febase.cc:41
#define IDLEV(a)
Definition: ipid.h:116
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:60
package currPack
Definition: ipid.cc:59
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
static Poly * h
Definition: janet.cc:972

◆ idrecDataInit()

void* idrecDataInit ( int  t)

Definition at line 127 of file ipid.cc.

128 {
129  switch (t)
130  {
131  //the type with init routines:
132 #ifdef SINGULAR_4_2
133  case CNUMBER_CMD:
134  return (void*)n2Init(0,NULL);
135  case CPOLY_CMD:
136  return (void*)p2Init(0,NULL);
137  case CMATRIX_CMD:
138 #endif
139  case BIGINTMAT_CMD:
140  return (void *)new bigintmat();
141  case INTVEC_CMD:
142  case INTMAT_CMD:
143  return (void *)new intvec();
144  case NUMBER_CMD:
145  {
146  if (currRing!=NULL) return (void *) nInit(0);
147  else return NULL;
148  }
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 NULL;
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  case CRING_CMD:
192  case INT_CMD:
193  case DEF_CMD:
194  case POLY_CMD:
195  case VECTOR_CMD:
196  case QRING_CMD:
197  return (void*)0L;
198  default:
199  {
200  if (t>MAX_TOK)
201  {
202 #ifdef BLACKBOX_DEVEL
203  Print("bb-type %d\n",t);
204 #endif
205  blackbox *bb=getBlackboxStuff(t);
206  if (bb!=NULL)
207  return (void *)bb->blackbox_Init(bb);
208  }
209  else
210  Werror("unknown type in idrecDataInit:%d",t);
211  break;
212  }
213  }
214  return (void *)0L;
215 }
#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:80
Definition: tok.h:96
Definition: lists.h:22
#define IDID(a)
Definition: ipid.h:117
#define FALSE
Definition: auxiliary.h:94
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:539
language_defs language
Definition: subexpr.h:59
short ref
Definition: subexpr.h:60
coeffs coeffs_BIGINT
Definition: ipid.cc:52
omBin procinfo_bin
Definition: subexpr.cc:47
Definition: tok.h:56
Definition: intvec.h:17
Definition: tok.h:58
idhdl currRingHdl
Definition: ipid.cc:61
int m
Definition: cfEzgcd.cc:121
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:37
Definition: tok.h:117
#define NULL
Definition: omList.c:10
slists * lists
Definition: mpr_numeric.h:146
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
Definition: tok.h:118
omBin slists_bin
Definition: lists.cc:23
Definition: tok.h:158
#define nInit(i)
Definition: numbers.h:25
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:93
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 755 of file ipid.cc.

756 {
757  if (iiCurrArgs==NULL)
758  {
759  Werror("not enough arguments for proc %s",VoiceName());
760  p->CleanUp();
761  return TRUE;
762  }
764  iiCurrArgs=h->next;
765  h->next=NULL;
766  if (h->rtyp!=IDHDL)
767  {
768  BOOLEAN res=iiAssign(p,h);
769  h->CleanUp();
771  return res;
772  }
773  if ((h->Typ()!=p->Typ()) &&(p->Typ()!=DEF_CMD))
774  {
775  WerrorS("type mismatch");
776  return TRUE;
777  }
778  idhdl pp=(idhdl)p->data;
779  switch(pp->typ)
780  {
781  case CRING_CMD:
782  nKillChar((coeffs)pp);
783  break;
784  case DEF_CMD:
785  case INT_CMD:
786  break;
787  case INTVEC_CMD:
788  case INTMAT_CMD:
789  delete IDINTVEC(pp);
790  break;
791  case NUMBER_CMD:
792  nDelete(&IDNUMBER(pp));
793  break;
794  case BIGINT_CMD:
796  break;
797  case MAP_CMD:
798  {
799  map im = IDMAP(pp);
800  omFree((ADDRESS)im->preimage);
801  }
802  // continue as ideal:
803  case IDEAL_CMD:
804  case MODUL_CMD:
805  case MATRIX_CMD:
806  idDelete(&IDIDEAL(pp));
807  break;
808  case PROC_CMD:
809  case RESOLUTION_CMD:
810  case STRING_CMD:
811  omFree((ADDRESS)IDSTRING(pp));
812  break;
813  case LIST_CMD:
814  IDLIST(pp)->Clean();
815  break;
816  case LINK_CMD:
818  break;
819  // case ring: cannot happen
820  default:
821  Werror("unknown type %d",p->Typ());
822  return TRUE;
823  }
824  pp->typ=ALIAS_CMD;
825  IDDATA(pp)=(char*)h->data;
826  int eff_typ=h->Typ();
827  if ((RingDependend(eff_typ))
828  || ((eff_typ==LIST_CMD) && (lRingDependend((lists)h->Data()))))
829  {
830  ipSwapId(pp,IDROOT,currRing->idroot);
831  }
832  h->CleanUp();
834  return FALSE;
835 }
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:132
Class used for (list of) interpreter objects.
Definition: subexpr.h:82
Definition: tok.h:96
#define IDLINK(a)
Definition: ipid.h:133
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
Definition: lists.h:22
#define IDINTVEC(a)
Definition: ipid.h:123
#define FALSE
Definition: auxiliary.h:94
Definition: tok.h:38
#define IDROOT
Definition: ipid.h:18
#define TRUE
Definition: auxiliary.h:98
#define IDIDEAL(a)
Definition: ipid.h:128
void * ADDRESS
Definition: auxiliary.h:133
void WerrorS(const char *s)
Definition: feFopen.cc:24
coeffs coeffs_BIGINT
Definition: ipid.cc:52
int Typ()
Definition: subexpr.cc:992
Definition: idrec.h:34
#define IDHDL
Definition: tok.h:31
void * data
Definition: subexpr.h:88
int RingDependend(int t)
Definition: gentable.cc:29
Definition: tok.h:56
CanonicalForm res
Definition: facAbsFact.cc:64
Definition: tok.h:58
#define omFree(addr)
Definition: omAllocDecl.h:261
The main handler for Singular numbers which are suitable for Singular polynomials.
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:253
#define IDSTRING(a)
Definition: ipid.h:131
idrec * idhdl
Definition: ring.h:21
omBin sleftv_bin
Definition: subexpr.cc:46
const char * VoiceName()
Definition: fevoices.cc:57
#define nDelete(n)
Definition: numbers.h:17
#define IDMAP(a)
Definition: ipid.h:130
leftv next
Definition: subexpr.h:86
#define IDNUMBER(a)
Definition: ipid.h:127
Definition: tok.h:34
Definition: tok.h:117
#define NULL
Definition: omList.c:10
leftv iiCurrArgs
Definition: ipshell.cc:78
int rtyp
Definition: subexpr.h:91
void CleanUp(ring r=currRing)
Definition: subexpr.cc:328
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
void * Data()
Definition: subexpr.cc:1134
int typ
Definition: idrec.h:43
Definition: tok.h:118
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:456
#define IDDATA(a)
Definition: ipid.h:121
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
static Poly * h
Definition: janet.cc:972
int BOOLEAN
Definition: auxiliary.h:85
BOOLEAN lRingDependend(lists L)
Definition: lists.cc:199
static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
Definition: ipid.cc:588
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:510
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 67 of file ipid.cc.

68 {
69  int i;
70  i=s[0];
71  if (s[1]!='\0')
72  {
73  i=(i<<8)+s[1];
74  if (s[2]!='\0')
75  {
76  i=(i<<8)+s[2];
77  if (s[3]!='\0')
78  {
79  i=(i<<8)+s[3];
80  }
81  }
82  }
83  return i;
84 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
int i
Definition: cfEzgcd.cc:125

◆ ipListFlag()

void ipListFlag ( idhdl  h)

Definition at line 528 of file ipid.cc.

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

◆ ipMoveId()

void ipMoveId ( idhdl  tomove)

Definition at line 613 of file ipid.cc.

614 {
615  if ((currRing!=NULL)&&(tomove!=NULL))
616  {
617  if (RingDependend(IDTYP(tomove))
618  || ((IDTYP(tomove)==LIST_CMD) && (lRingDependend(IDLIST(tomove)))))
619  {
620  /*move 'tomove' to ring id's*/
621  if (ipSwapId(tomove,IDROOT,currRing->idroot))
622  ipSwapId(tomove,basePack->idroot,currRing->idroot);
623  }
624  else
625  {
626  /*move 'tomove' to global id's*/
627  ipSwapId(tomove,currRing->idroot,IDROOT);
628  }
629  }
630 }
#define IDLIST(a)
Definition: ipid.h:132
#define IDROOT
Definition: ipid.h:18
#define IDTYP(a)
Definition: ipid.h:114
int RingDependend(int t)
Definition: gentable.cc:29
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:60
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
Definition: tok.h:118
BOOLEAN lRingDependend(lists L)
Definition: lists.cc:199
static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
Definition: ipid.cc:588

◆ ipNameList()

lists ipNameList ( idhdl  root)

Definition at line 536 of file ipid.cc.

537 {
538  idhdl h=root;
539  /* compute the length */
540  int l=0;
541  while (h!=NULL) { l++; h=IDNEXT(h); }
542  /* allocate list */
544  L->Init(l);
545  /* copy names */
546  h=root;
547  l=0;
548  while (h!=NULL)
549  {
550  /* list is initialized with 0 => no need to clear anything */
551  L->m[l].rtyp=STRING_CMD;
552  L->m[l].data=omStrDup(IDID(h));
553  l++;
554  h=IDNEXT(h);
555  }
556  return L;
557 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
sleftv * m
Definition: lists.h:45
Definition: lists.h:22
#define IDID(a)
Definition: ipid.h:117
#define IDNEXT(a)
Definition: ipid.h:113
Definition: idrec.h:34
void * data
Definition: subexpr.h:88
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:91
omBin slists_bin
Definition: lists.cc:23
static Poly * h
Definition: janet.cc:972
int l
Definition: cfEzgcd.cc:93
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ ipNameListLev()

lists ipNameListLev ( idhdl  root,
int  lev 
)

Definition at line 559 of file ipid.cc.

560 {
561  idhdl h=root;
562  /* compute the length */
563  int l=0;
564  while (h!=NULL) { if (IDLEV(h)==lev) l++; h=IDNEXT(h); }
565  /* allocate list */
567  L->Init(l);
568  /* copy names */
569  h=root;
570  l=0;
571  while (h!=NULL)
572  {
573  if (IDLEV(h)==lev)
574  {
575  /* list is initialized with 0 => no need to clear anything */
576  L->m[l].rtyp=STRING_CMD;
577  L->m[l].data=omStrDup(IDID(h));
578  l++;
579  }
580  h=IDNEXT(h);
581  }
582  return L;
583 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
sleftv * m
Definition: lists.h:45
Definition: lists.h:22
#define IDID(a)
Definition: ipid.h:117
#define IDNEXT(a)
Definition: ipid.h:113
Definition: idrec.h:34
void * data
Definition: subexpr.h:88
#define IDLEV(a)
Definition: ipid.h:116
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:91
omBin slists_bin
Definition: lists.cc:23
static Poly * h
Definition: janet.cc:972
int l
Definition: cfEzgcd.cc:93
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ ipSwapId()

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

Definition at line 588 of file ipid.cc.

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

◆ killhdl()

void killhdl ( idhdl  h,
package  proot 
)

Definition at line 376 of file ipid.cc.

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

◆ killhdl2()

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

Definition at line 407 of file ipid.cc.

408 {
409  //printf("kill %s, id %x, typ %d lev: %d\n",IDID(h),(int)IDID(h),IDTYP(h),IDLEV(h));
410  idhdl hh;
411 
412  if (TEST_V_ALLWARN
413  && (IDLEV(h)!=myynest)
414  &&(IDLEV(h)==0))
415  {
416  if (((*ih)==basePack->idroot)
417  || ((currRing!=NULL)&&((*ih)==currRing->idroot)))
418  Warn("kill global `%s` at line >>%s<<\n",IDID(h),my_yylinebuf);
419  }
420  if (h->attribute!=NULL)
421  {
422  if ((IDTYP(h)==RING_CMD)&&(IDRING(h)!=r))
423  h->attribute->killAll(IDRING(h));
424  else
425  h->attribute->killAll(r);
426  h->attribute=NULL;
427  }
428  if (IDTYP(h) == PACKAGE_CMD)
429  {
430  if (((IDPACKAGE(h)->language==LANG_C)&&(IDPACKAGE(h)->idroot!=NULL))
431  || (strcmp(IDID(h),"Top")==0))
432  {
433  Warn("cannot kill `%s`",IDID(h));
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)
463  s_internalDelete(IDTYP(h),IDDATA(h),r);
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 }
void killAll(const ring r)
Definition: attrib.cc:188
idhdl currPackHdl
Definition: ipid.cc:57
#define IDID(a)
Definition: ipid.h:117
#define IDNEXT(a)
Definition: ipid.h:113
void * ADDRESS
Definition: auxiliary.h:133
#define loop
Definition: structs.h:78
void paKill(package pack)
Definition: ipid.h:49
Definition: idrec.h:34
Definition: subexpr.h:22
#define IDPACKAGE(a)
Definition: ipid.h:134
int myynest
Definition: febase.cc:41
#define IDTYP(a)
Definition: ipid.h:114
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:407
char my_yylinebuf[80]
Definition: febase.cc:43
void rKill(ring r)
Definition: ipshell.cc:6076
omBin idrec_bin
Definition: ipid.cc:50
#define omFree(addr)
Definition: omAllocDecl.h:261
void s_internalDelete(const int t, void *d, const ring r)
Definition: subexpr.cc:491
void PrintS(const char *s)
Definition: reporter.cc:284
#define IDLEV(a)
Definition: ipid.h:116
#define NULL
Definition: omList.c:10
attr attribute
Definition: idrec.h:41
package basePack
Definition: ipid.cc:60
#define IDRING(a)
Definition: ipid.h:122
package currPack
Definition: ipid.cc:59
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
idhdl packFindHdl(package r)
Definition: ipid.cc:742
void iiCheckPack(package &p)
Definition: ipshell.cc:1536
#define IDDATA(a)
Definition: ipid.h:121
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
#define TEST_V_ALLWARN
Definition: options.h:140
#define Warn
Definition: emacs.cc:77

◆ killid()

void killid ( const char *  id,
idhdl ih 
)

Definition at line 349 of file ipid.cc.

350 {
351  if (id!=NULL)
352  {
353  idhdl h = (*ih)->get(id,myynest);
354 
355  // id not found in global list, is it defined in current ring ?
356  if (h==NULL)
357  {
358  if ((currRing!=NULL) && (*ih != (currRing->idroot)))
359  {
360  h = currRing->idroot->get(id,myynest);
361  if (h!=NULL)
362  {
363  killhdl2(h,&(currRing->idroot),currRing);
364  return;
365  }
366  }
367  Werror("`%s` is not defined",id);
368  return;
369  }
370  killhdl2(h,ih,currRing);
371  }
372  else
373  WerrorS("kill what ?");
374 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
Definition: idrec.h:34
int myynest
Definition: febase.cc:41
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:407
#define NULL
Definition: omList.c:10
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
static Poly * h
Definition: janet.cc:972
void Werror(const char *fmt,...)
Definition: reporter.cc:189

◆ packFindHdl()

idhdl packFindHdl ( package  r)

Definition at line 742 of file ipid.cc.

743 {
744  idhdl h=basePack->idroot;
745  while (h!=NULL)
746  {
747  if ((IDTYP(h)==PACKAGE_CMD)
748  && (IDPACKAGE(h)==r))
749  return h;
750  h=IDNEXT(h);
751  }
752  return NULL;
753 }
#define IDNEXT(a)
Definition: ipid.h:113
Definition: idrec.h:34
#define IDPACKAGE(a)
Definition: ipid.h:134
#define IDTYP(a)
Definition: ipid.h:114
#define NULL
Definition: omList.c:10
package basePack
Definition: ipid.cc:60
static Poly * h
Definition: janet.cc:972

◆ paCleanUp()

void paCleanUp ( package  pack)

Definition at line 694 of file ipid.cc.

695 {
696  (pack->ref)--;
697  if (pack->ref < 0)
698  {
699 #ifndef HAVE_STATIC
700  if( pack->language == LANG_C)
701  {
702  Print("//dlclose(%s)\n",pack->libname);
703 #ifdef HAVE_DYNAMIC_LOADING
704  dynl_close (pack->handle);
705 #endif /* HAVE_DYNAMIC_LOADING */
706  }
707 #endif /* HAVE_STATIC */
708  omFree((ADDRESS)pack->libname);
709  memset((void *) pack, 0, sizeof(sip_package));
710  pack->language=LANG_NONE;
711  }
712 }
#define Print
Definition: emacs.cc:80
void * ADDRESS
Definition: auxiliary.h:133
Definition: subexpr.h:22
#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 656 of file ipid.cc.

657 {
658  (pi->ref)--;
659  if (pi->ref == 0)
660  {
661  if (pi->language==LANG_SINGULAR)
662  {
664  while (p!=NULL)
665  {
666  if (p->pi==pi && pi->ref <= 1)
667  {
668  Warn("`%s` in use, can not be killed",pi->procname);
669  return TRUE;
670  }
671  p=p->next;
672  }
673  }
674  if (pi->libname != NULL) // OB: ????
675  omFree((ADDRESS)pi->libname);
676  if (pi->procname != NULL) // OB: ????
677  omFree((ADDRESS)pi->procname);
678 
679  if( pi->language == LANG_SINGULAR)
680  {
681  if (pi->data.s.body != NULL) // OB: ????
682  omFree((ADDRESS)pi->data.s.body);
683  }
684  if( pi->language == LANG_C)
685  {
686  }
687  memset((void *) pi, 0, sizeof(procinfo));
688  //pi->language=LANG_NONE;
690  }
691  return FALSE;
692 }
#define FALSE
Definition: auxiliary.h:94
language_defs language
Definition: subexpr.h:59
#define TRUE
Definition: auxiliary.h:98
void * ADDRESS
Definition: auxiliary.h:133
short ref
Definition: subexpr.h:60
Definition: fevoices.h:58
Voice * next
Definition: fevoices.h:61
omBin procinfo_bin
Definition: subexpr.cc:47
char * procname
Definition: subexpr.h:57
Definition: subexpr.h:22
char * libname
Definition: subexpr.h:56
procinfo * pi
Definition: fevoices.h:64
#define omFree(addr)
Definition: omAllocDecl.h:261
procinfodata data
Definition: subexpr.h:63
#define NULL
Definition: omList.c:10
Voice * currentVoice
Definition: fevoices.cc:48
int p
Definition: cfModGcd.cc:4019
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
#define Warn
Definition: emacs.cc:77

◆ piProcinfo()

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

Definition at line 632 of file ipid.cc.

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

Variable Documentation

◆ basePack

package basePack = NULL

Definition at line 60 of file ipid.cc.

◆ basePackHdl

idhdl basePackHdl = NULL

Definition at line 58 of file ipid.cc.

◆ coeffs_BIGINT

coeffs coeffs_BIGINT

Definition at line 52 of file ipid.cc.

◆ currPack

package currPack = NULL

Definition at line 59 of file ipid.cc.

◆ currPackHdl

idhdl currPackHdl = NULL

Definition at line 57 of file ipid.cc.

◆ currRingHdl

idhdl currRingHdl = NULL

Definition at line 61 of file ipid.cc.

◆ idrec_bin

omBin idrec_bin = omGetSpecBin(sizeof(idrec))

Definition at line 50 of file ipid.cc.

◆ procstack

proclevel* procstack =NULL

Definition at line 54 of file ipid.cc.

◆ sip_command_bin

omBin sip_command_bin = omGetSpecBin(sizeof(sip_command))

Definition at line 47 of file ipid.cc.

◆ sip_package_bin

omBin sip_package_bin = omGetSpecBin(sizeof(sip_package))

Definition at line 48 of file ipid.cc.