My Project
ipid.cc
Go to the documentation of this file.
1 /****************************************
2 * Computer Algebra System SINGULAR *
3 ****************************************/
4 
5 /*
6 * ABSTRACT: identfier handling
7 */
8 
9 
10 
11 
12 
13 #include "kernel/mod2.h"
14 
15 #include "misc/options.h"
16 #include "misc/intvec.h"
17 
18 #include "coeffs/numbers.h"
19 #include "coeffs/bigintmat.h"
20 
21 #include "polys/matpol.h"
22 #include "polys/monomials/ring.h"
23 
24 #include "kernel/polys.h"
25 #include "kernel/ideals.h"
26 #include "kernel/GBEngine/syz.h"
27 
28 #include "Singular/tok.h"
29 #include "Singular/ipshell.h"
30 #include "Singular/fevoices.h"
31 #include "Singular/lists.h"
32 #include "Singular/attrib.h"
33 #include "Singular/links/silink.h"
34 #include "Singular/ipid.h"
35 #include "Singular/blackbox.h"
36 #include "Singular/number2.h"
37 
38 #ifdef SINGULAR_4_2
39 #include "Singular/number2.h"
40 #endif
41 #ifdef HAVE_DYNAMIC_LOADING
42 #include "polys/mod_raw.h"
43 #endif /* HAVE_DYNAMIC_LOADING */
44 
47 //omBin ip_package_bin = omGetSpecBin(sizeof(ip_package));
49 
51 
53 //idhdl idroot = NULL;
54 
57 VAR package currPack = NULL;
58 VAR package basePack = NULL;
60 
61 void paCleanUp(package pack);
62 
63 /*0 implementation*/
64 
65 static inline long iiS2I(const char *s)
66 {
67  long l;
68  strncpy((char*)&l,s,SIZEOF_LONG);
69  return l;
70 }
71 
72 idhdl idrec::get(const char * s, int level)
73 {
74  assume(s!=NULL);
75  assume((level>=0) && (level<=1000)); //not really, but if it isnt in that bounds..
76  idhdl h = this;
78  int l;
79  const char *id_;
80  unsigned long i=iiS2I(s);
81  int less4=(i < (1L<<((SIZEOF_LONG-1)*8)));
82  while (h!=NULL)
83  {
85  l=IDLEV(h);
86  if ((l==0)||(l==level))
87  {
88  if (i==h->id_i)
89  {
90  id_=IDID(h);
91  if (less4 || (0 == strcmp(s+SIZEOF_LONG,id_+SIZEOF_LONG)))
92  {
93  if(l==level) return h;
94  found=h;
95  }
96  }
97  }
98  h = IDNEXT(h);
99  }
100  return found;
101 }
102 
103 idhdl idrec::get_level(const char * s, int level)
104 {
105  assume(s!=NULL);
106  assume((level>=0) && (level<=1000)); //not really, but if it isnt in that bounds..
107  idhdl h = this;
108  int l;
109  const char *id_;
110  unsigned long i=iiS2I(s);
111  int less4=(i < (1L<<((SIZEOF_LONG-1)*8)));
112  while (h!=NULL)
113  {
115  l=IDLEV(h);
116  if ((l==level)&&(i==h->id_i))
117  {
118  id_=IDID(h);
119  if (less4 || (0 == strcmp(s+SIZEOF_LONG,id_+SIZEOF_LONG)))
120  {
121  return h;
122  }
123  }
124  h = IDNEXT(h);
125  }
126  return NULL;
127 }
128 
129 //idrec::~idrec()
130 //{
131 // if (id!=NULL)
132 // {
133 // omFree((ADDRESS)id);
134 // id=NULL;
135 // }
136 // /* much more !! */
137 //}
138 
139 void *idrecDataInit(int t)
140 {
141  switch (t)
142  {
143  //the type with init routines:
144 #ifdef SINGULAR_4_2
145  case CNUMBER_CMD:
146  return (void*)n2Init(0,NULL);
147  case CPOLY_CMD:
148  return (void*)p2Init(0,NULL);
149  case CMATRIX_CMD:
150 #endif
151  case BIGINTMAT_CMD:
152  return (void *)new bigintmat();
153  case BUCKET_CMD:
154  if (currRing!=NULL)
155  return (void*)sBucketCreate(currRing);
156  else
157  {
158  WerrorS("need basering for polyBucket");
159  return NULL;
160  }
161  case INTVEC_CMD:
162  case INTMAT_CMD:
163  return (void *)new intvec();
164  case NUMBER_CMD:
165  {
166  if (currRing!=NULL) return (void *) nInit(0);
167  else return NULL;
168  }
169  case BIGINT_CMD:
170  return (void *) n_Init(0, coeffs_BIGINT);
171  case IDEAL_CMD:
172  case MODUL_CMD:
173  case MATRIX_CMD:
174  case SMATRIX_CMD:
175  return (void*) idInit(1,1);
176  case MAP_CMD:
177  {
178  map m = (map)idInit(1,1);
179  m->preimage = omStrDup(IDID(currRingHdl));
180  return (void *)m;
181  }
182  case STRING_CMD:
183  return (void *)omAlloc0(1);
184  case LIST_CMD:
185  {
187  l->Init();
188  return (void*)l;
189  }
190  //the types with the standard init: set the struct to zero
191  case LINK_CMD:
192  return (void*) omAlloc0Bin(sip_link_bin);
193  case PACKAGE_CMD:
194  {
195  package pa=(package)omAlloc0Bin(sip_package_bin);
196  pa->language=LANG_NONE;
197  pa->loaded = FALSE;
198  return (void*)pa;
199  }
200  case PROC_CMD:
201  {
203  pi->ref=1;
204  pi->language=LANG_NONE;
205  return (void*)pi;
206  }
207  case RESOLUTION_CMD:
208  return (void *)omAlloc0(sizeof(ssyStrategy));
209  //other types: without alloc. (int,script,poly,def,package,..)
210  case INT_CMD:
211  case DEF_CMD:
212  case POLY_CMD:
213  case VECTOR_CMD:
214  case RING_CMD:
215  case CRING_CMD:
216  case QRING_CMD:
217  return NULL;
218  default:
219  {
220  if (t>MAX_TOK)
221  {
222 #ifdef BLACKBOX_DEVEL
223  Print("bb-type %d\n",t);
224 #endif
225  blackbox *bb=getBlackboxStuff(t);
226  if (bb!=NULL)
227  return (void *)bb->blackbox_Init(bb);
228  }
229  else
230  Werror("unknown type in idrecDataInit:%d",t);
231  break;
232  }
233  }
234  return (void *)0L;
235 }
236 idhdl idrec::set(const char * s, int level, int t, BOOLEAN init)
237 {
238  //printf("define %s, %x, level: %d, typ: %d\n", s,s,level,t);
240  IDID(h) = s;
241  IDTYP(h) = t;
242  IDLEV(h) = level;
243  IDNEXT(h) = this;
244  BOOLEAN at_start=(this==IDROOT);
245  h->id_i=iiS2I(s);
246  if (t==BUCKET_CMD) WarnS("defining polyBucket");
247  if (init)
248  {
249  if ((t==IDEAL_CMD)||(t==MODUL_CMD))
250  IDFLAG(h) = Sy_bit(FLAG_STD);
251  IDSTRING(h)=(char *)idrecDataInit(t);
252  // additional settings:--------------------------------------
253 #if 0
254  // this leads to a memory leak
255  if (t == QRING_CMD)
256  {
257  // IDRING(h)=rCopy(currRing);
258  /* QRING_CMD is ring dep => currRing !=NULL */
259  }
260 #endif
261  }
262  // --------------------------------------------------------
263  if (at_start)
264  IDNEXT(h) = IDROOT;
265  return h;
266 }
267 
268 char * idrec::String(BOOLEAN typed)
269 {
270  sleftv tmp;
271  tmp.Init();
272  tmp.rtyp=IDTYP(this);
273  tmp.data=IDDATA(this);
274  tmp.name=IDID(this);
275  return tmp.String(NULL, typed);
276 }
277 
278 idhdl enterid(const char * s, int lev, int t, idhdl* root, BOOLEAN init, BOOLEAN search)
279 {
280  if (s==NULL) return NULL;
281  if (root==NULL) return NULL;
282  idhdl h;
283  s=omStrDup(s);
284  // idhdl *save_root=root;
285  if (t==PACKAGE_CMD)
286  {
287  if (root!=&(basePack->idroot))
288  {
289  root=&(basePack->idroot);
290  }
291  }
292  // is it already defined in root ?
293  if ((h=(*root)->get_level(s,lev))!=NULL)
294  {
295  if ((IDTYP(h) == t)||(t==DEF_CMD))
296  {
297  if (IDTYP(h)==PACKAGE_CMD)
298  {
299  if (strcmp(s,"Top")==0)
300  {
301  goto errlabel;
302  }
303  else return h;
304  }
305  else
306  {
307  if (BVERBOSE(V_REDEFINE))
308  {
309  const char *f=VoiceName();
310  if (strcmp(f,"STDIN")==0)
311  Warn("redefining %s (%s)",s,my_yylinebuf);
312  else
313  Warn("redefining %s (%s) %s:%d",s,my_yylinebuf,f, yylineno);
314  }
315  if (s==IDID(h)) IDID(h)=NULL;
316  killhdl2(h,root,currRing);
317  }
318  }
319  else
320  goto errlabel;
321  }
322  // is it already defined in currRing->idroot ?
323  else if (search && (currRing!=NULL)&&((*root) != currRing->idroot))
324  {
325  if ((h=currRing->idroot->get_level(s,lev))!=NULL)
326  {
327  if ((IDTYP(h) == t)||(t==DEF_CMD))
328  {
329  if (BVERBOSE(V_REDEFINE))
330  {
331  const char *f=VoiceName();
332  if (strcmp(f,"STDIN")==0)
333  Warn("redefining %s (%s)",s,my_yylinebuf);
334  else
335  Warn("redefining %s (%s) %s:%d",s,my_yylinebuf,f, yylineno);
336  }
337  if (s==IDID(h)) IDID(h)=NULL;
338  killhdl2(h,&currRing->idroot,currRing);
339  }
340  else
341  goto errlabel;
342  }
343  }
344  // is it already defined in idroot ?
345  else if (search && (*root != IDROOT))
346  {
347  if ((h=IDROOT->get_level(s,lev))!=NULL)
348  {
349  if ((IDTYP(h) == t)||(t==DEF_CMD))
350  {
351  if (BVERBOSE(V_REDEFINE))
352  {
353  const char *f=VoiceName();
354  if (strcmp(f,"STDIN")==0)
355  Warn("redefining %s (%s)",s,my_yylinebuf);
356  else
357  Warn("redefining %s (%s) %s:%d",s,my_yylinebuf,f, yylineno);
358  }
359  if (s==IDID(h)) IDID(h)=NULL;
360  killhdl2(h,&IDROOT,NULL);
361  }
362  else
363  goto errlabel;
364  }
365  }
366  *root = (*root)->set(s, lev, t, init);
367 #ifndef SING_NDEBUG
368  checkall();
369 #endif
370  return *root;
371 
372  errlabel:
373  //Werror("identifier `%s` in use(lev h=%d,typ=%d,t=%d, curr=%d)",s,IDLEV(h),IDTYP(h),t,lev);
374  Werror("identifier `%s` in use",s);
375  //listall();
376  omFree((ADDRESS)s);
377  return NULL;
378 }
379 void killid(const char * id, idhdl * ih)
380 {
381  if (id!=NULL)
382  {
383  idhdl h = (*ih)->get(id,myynest);
384 
385  // id not found in global list, is it defined in current ring ?
386  if (h==NULL)
387  {
388  if ((currRing!=NULL) && (*ih != (currRing->idroot)))
389  {
390  h = currRing->idroot->get(id,myynest);
391  if (h!=NULL)
392  {
393  killhdl2(h,&(currRing->idroot),currRing);
394  return;
395  }
396  }
397  Werror("`%s` is not defined",id);
398  return;
399  }
400  killhdl2(h,ih,currRing);
401  }
402  else
403  WerrorS("kill what ?");
404 }
405 
406 void killhdl(idhdl h, package proot)
407 {
408  int t=IDTYP(h);
409  if (((BEGIN_RING<t) && (t<END_RING))
410  || ((t==LIST_CMD) && (lRingDependend((lists)IDDATA(h)))))
411  killhdl2(h,&currRing->idroot,currRing);
412  else
413  {
414  if(t==PACKAGE_CMD)
415  {
416  killhdl2(h,&(basePack->idroot),NULL);
417  }
418  else
419  {
420  idhdl s=proot->idroot;
421  while ((s!=h) && (s!=NULL)) s=s->next;
422  if (s!=NULL)
423  killhdl2(h,&(proot->idroot),NULL);
424  else if (basePack!=proot)
425  {
426  idhdl s=basePack->idroot;
427  while ((s!=h) && (s!=NULL)) s=s->next;
428  if (s!=NULL)
429  killhdl2(h,&(basePack->idroot),currRing);
430  else
431  killhdl2(h,&(currRing->idroot),currRing);
432  }
433  }
434  }
435 }
436 
437 void killhdl2(idhdl h, idhdl * ih, ring r)
438 {
439  //printf("kill %s, id %x, typ %d lev: %d\n",IDID(h),(int)IDID(h),IDTYP(h),IDLEV(h));
440  idhdl hh;
441 
442  if (TEST_V_ALLWARN
443  && (IDLEV(h)!=myynest)
444  &&(IDLEV(h)==0))
445  {
446  if (((*ih)==basePack->idroot)
447  || ((currRing!=NULL)&&((*ih)==currRing->idroot)))
448  Warn("kill global `%s` at line >>%s<<\n",IDID(h),my_yylinebuf);
449  }
450  if (h->attribute!=NULL)
451  {
452  if ((IDTYP(h)==RING_CMD)&&(IDRING(h)!=r))
453  h->attribute->killAll(IDRING(h));
454  else
455  h->attribute->killAll(r);
456  h->attribute=NULL;
457  }
458  if (IDTYP(h) == PACKAGE_CMD)
459  {
460  if (((IDPACKAGE(h)->language==LANG_C)&&(IDPACKAGE(h)->idroot!=NULL))
461  || (strcmp(IDID(h),"Top")==0))
462  {
463  Warn("cannot kill `%s`",IDID(h));
464  return;
465  }
466  // any objects defined for this package ?
467  if ((IDPACKAGE(h)->ref<=0) && (IDPACKAGE(h)->idroot!=NULL))
468  {
469  if (currPack==IDPACKAGE(h))
470  {
473  }
474  idhdl * hd = &IDRING(h)->idroot;
475  idhdl hdh = IDNEXT(*hd);
476  idhdl temp;
477  while (hdh!=NULL)
478  {
479  temp = IDNEXT(hdh);
480  killhdl2(hdh,&(IDPACKAGE(h)->idroot),NULL);
481  hdh = temp;
482  }
483  killhdl2(*hd,hd,NULL);
484  if (IDPACKAGE(h)->libname!=NULL) omFree((ADDRESS)(IDPACKAGE(h)->libname));
485  }
486  paKill(IDPACKAGE(h));
489  }
490  else if (IDTYP(h)==RING_CMD)
491  rKill(h);
492  else if (IDDATA(h)!=NULL)
494  // general -------------------------------------------------------------
495  // now dechain it and delete idrec
496  if (IDID(h)!=NULL) // OB: ?????
497  omFree((ADDRESS)IDID(h));
498  IDID(h)=NULL;
499  IDDATA(h)=NULL;
500  if (h == (*ih))
501  {
502  // h is at the beginning of the list
503  *ih = IDNEXT(h) /* ==*ih */;
504  }
505  else if (ih!=NULL)
506  {
507  // h is somethere in the list:
508  hh = *ih;
509  loop
510  {
511  if (hh==NULL)
512  {
513  PrintS(">>?<< not found for kill\n");
514  return;
515  }
516  idhdl hhh = IDNEXT(hh);
517  if (hhh == h)
518  {
519  IDNEXT(hh) = IDNEXT(hhh);
520  break;
521  }
522  hh = hhh;
523  }
524  }
526 }
527 
528 #if 0
529 idhdl ggetid(const char *n, BOOLEAN /*local*/, idhdl *packhdl)
530 {
531  idhdl h = IDROOT->get(n,myynest);
532  idhdl h2=NULL;
533  *packhdl = NULL;
534  if ((currRing!=NULL) && ((h==NULL)||(IDLEV(h)!=myynest)))
535  {
536  h2 = currRing->idroot->get(n,myynest);
537  }
538  if (h2==NULL) return h;
539  return h2;
540 }
541 #endif
542 
543 #if 0
544 // debug version
545 idhdl ggetid(const char *n)
546 {
547  if (currRing!=NULL)
548  {
549  idhdl h2 = currRing->idroot->get(n,myynest);
550  idhdl h = IDROOT->get(n,myynest);
551  if ((h!=NULL)&&(h2!=NULL)&&(IDLEV(h)==IDLEV(h2)))
552  {
553  Warn("SHADOW %s(%s) vs %s(%s) in %s\n",IDID(h),Tok2Cmdname(IDTYP(h)),IDID(h2),Tok2Cmdname(IDTYP(h2)),my_yylinebuf);
554  }
555  if ((h2!=NULL)&&(IDLEV(h2)==myynest)) return h2;
556  if (h!=NULL) return h;
557  if (h2!=NULL) return h2;
558  }
559  else
560  {
561  idhdl h = IDROOT->get(n,myynest);
562  if (h!=NULL) return h;
563  }
564  if (basePack!=currPack)
565  return basePack->idroot->get(n,myynest);
566  return NULL;
567 }
568 #endif
569 #if 1
570 // try currRing before non-ring stuff
571 idhdl ggetid(const char *n)
572 {
573  if (currRing!=NULL)
574  {
575  idhdl h2 = currRing->idroot->get(n,myynest);
576  if ((h2!=NULL)&&(IDLEV(h2)==myynest)) return h2;
577  idhdl h = IDROOT->get(n,myynest);
578  if (h!=NULL) return h;
579  if (h2!=NULL) return h2;
580  }
581  else
582  {
583  idhdl h = IDROOT->get(n,myynest);
584  if (h!=NULL) return h;
585  }
586  if (basePack!=currPack)
587  return basePack->idroot->get(n,myynest);
588  return NULL;
589 }
590 #endif
591 #if 0
592 // try non-ring stuff before ring stuff
593 idhdl ggetid(const char *n)
594 {
595  idhdl h = IDROOT->get(n,myynest);
596  if ((h!=NULL)&&(IDLEV(h)==myynest)) return h;
597  if (currRing!=NULL)
598  {
599  idhdl h2 = currRing->idroot->get(n,myynest);
600  if (h2!=NULL) return h2;
601  }
602  if (h!=NULL) return h;
603  if (basePack!=currPack)
604  return basePack->idroot->get(n,myynest);
605  return NULL;
606 }
607 #endif
608 
610 {
611  if (hasFlag(h,FLAG_STD)) PrintS(" (SB)");
612 #ifdef HAVE_PLURAL
613  if (hasFlag(h,FLAG_TWOSTD)) PrintS(" (2SB)");
614 #endif
615 }
616 
618 {
619  idhdl h=root;
620  /* compute the length */
621  int l=0;
622  while (h!=NULL) { l++; h=IDNEXT(h); }
623  /* allocate list */
625  L->Init(l);
626  /* copy names */
627  h=root;
628  l=0;
629  while (h!=NULL)
630  {
631  /* list is initialized with 0 => no need to clear anything */
632  L->m[l].rtyp=STRING_CMD;
633  L->m[l].data=omStrDup(IDID(h));
634  l++;
635  h=IDNEXT(h);
636  }
637  return L;
638 }
639 
640 lists ipNameListLev(idhdl root, int lev)
641 {
642  idhdl h=root;
643  /* compute the length */
644  int l=0;
645  while (h!=NULL) { if (IDLEV(h)==lev) l++; h=IDNEXT(h); }
646  /* allocate list */
648  L->Init(l);
649  /* copy names */
650  h=root;
651  l=0;
652  while (h!=NULL)
653  {
654  if (IDLEV(h)==lev)
655  {
656  /* list is initialized with 0 => no need to clear anything */
657  L->m[l].rtyp=STRING_CMD;
658  L->m[l].data=omStrDup(IDID(h));
659  l++;
660  }
661  h=IDNEXT(h);
662  }
663  return L;
664 }
665 
666 /*
667 * move 'tomove' from root1 list to root2 list
668 */
669 static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
670 {
671  idhdl h;
672  /* search 'tomove' in root2 : if found -> do nothing */
673  h=root2;
674  while ((h!=NULL) && (h!=tomove)) h=IDNEXT(h);
675  if (h!=NULL) return FALSE; /*okay */
676  /* search predecessor of h in root1, remove 'tomove' */
677  h=root1;
678  if (tomove==h)
679  {
680  root1=IDNEXT(h);
681  }
682  else
683  {
684  while ((h!=NULL) && (IDNEXT(h)!=tomove)) h=IDNEXT(h);
685  if (h==NULL) return TRUE; /* not in the list root1 -> do nothing */
686  IDNEXT(h)=IDNEXT(tomove);
687  }
688  /* add to root2 list */
689  IDNEXT(tomove)=root2;
690  root2=tomove;
691  return FALSE;
692 }
693 
694 void ipMoveId(idhdl tomove)
695 {
696  if ((currRing!=NULL)&&(tomove!=NULL))
697  {
698  if (RingDependend(IDTYP(tomove))
699  || ((IDTYP(tomove)==LIST_CMD) && (lRingDependend(IDLIST(tomove)))))
700  {
701  /*move 'tomove' to ring id's*/
702  if (ipSwapId(tomove,IDROOT,currRing->idroot))
703  ipSwapId(tomove,basePack->idroot,currRing->idroot);
704  }
705  else
706  {
707  /*move 'tomove' to global id's*/
708  ipSwapId(tomove,currRing->idroot,IDROOT);
709  }
710  }
711 }
712 
713 const char * piProcinfo(procinfov pi, const char *request)
714 {
715  if((pi == NULL)||(pi->language==LANG_NONE)) return "empty proc";
716  else if (strcmp(request, "libname") == 0) return pi->libname;
717  else if (strcmp(request, "procname") == 0) return pi->procname;
718  else if (strcmp(request, "type") == 0)
719  {
720  switch (pi->language)
721  {
722  case LANG_SINGULAR: return "singular"; break;
723  case LANG_C: return "object"; break;
724  case LANG_NONE: return "none"; break;
725  default: return "unknown language";
726  }
727  }
728  else if (strcmp(request, "ref") == 0)
729  {
730  char p[8];
731  sprintf(p, "%d", pi->ref);
732  return omStrDup(p); // MEMORY-LEAK
733  }
734  return "??";
735 }
736 
738 {
739  (pi->ref)--;
740  if (pi->ref == 0)
741  {
742  if (pi->language==LANG_SINGULAR)
743  {
745  while (p!=NULL)
746  {
747  if (p->pi==pi && pi->ref <= 1)
748  {
749  Warn("`%s` in use, can not be killed",pi->procname);
750  return TRUE;
751  }
752  p=p->next;
753  }
754  }
755  if (pi->libname != NULL) // OB: ????
756  omFree((ADDRESS)pi->libname);
757  if (pi->procname != NULL) // OB: ????
758  omFree((ADDRESS)pi->procname);
759 
760  if( pi->language == LANG_SINGULAR)
761  {
762  if (pi->data.s.body != NULL) // OB: ????
763  omFree((ADDRESS)pi->data.s.body);
764  }
765  if( pi->language == LANG_C)
766  {
767  }
768  memset((void *) pi, 0, sizeof(procinfo));
769  //pi->language=LANG_NONE;
771  }
772  return FALSE;
773 }
774 
775 void paCleanUp(package pack)
776 {
777  (pack->ref)--;
778  if (pack->ref < 0)
779  {
780  if( pack->language == LANG_C)
781  {
782  Print("//dlclose(%s)\n",pack->libname);
783 #ifdef HAVE_DYNAMIC_LOADING
784  dynl_close (pack->handle);
785 #endif /* HAVE_DYNAMIC_LOADING */
786  }
787  omFree((ADDRESS)pack->libname);
788  memset((void *) pack, 0, sizeof(sip_package));
789  pack->language=LANG_NONE;
790  }
791 }
792 
793 void proclevel::push(char *n)
794 {
795  //Print("push %s\n",n);
796  proclevel *p=(proclevel*)omAlloc0(sizeof(proclevel));
797  p->name=n;
798  p->cPackHdl=currPackHdl;
799  p->cPack=currPack;
800  p->next=this;
801  procstack=p;
802 }
804 {
805  //Print("pop %s\n",name);
806  //if (currRing!=::currRing) PrintS("currRing wrong\n");;
807  //::currRing=this->currRing;
808  //if (r==NULL) Print("set ring to NULL at lev %d(%s)\n",myynest,name);
809  //::currRingHdl=this->currRingHdl;
810  //if((::currRingHdl==NULL)||(IDRING(::currRingHdl)!=(::currRing)))
811  // ::currRingHdl=rFindHdl(::currRing,NULL,NULL);
812  //Print("restore pack=%s,1.obj=%s\n",IDID(currPackHdl),IDID(currPack->idroot));
813  currPackHdl=this->cPackHdl;
814  currPack=this->cPack;
816  proclevel *p=this;
817  procstack=next;
818  omFreeSize(p,sizeof(proclevel));
819 }
820 
822 {
823  idhdl h=basePack->idroot;
824  while (h!=NULL)
825  {
826  if ((IDTYP(h)==PACKAGE_CMD)
827  && (IDPACKAGE(h)==r))
828  return h;
829  h=IDNEXT(h);
830  }
831  return NULL;
832 }
833 
835 {
836  if (iiCurrArgs==NULL)
837  {
838  Werror("not enough arguments for proc %s",VoiceName());
839  p->CleanUp();
840  return TRUE;
841  }
843  iiCurrArgs=h->next;
844  h->next=NULL;
845  if (h->rtyp!=IDHDL)
846  {
848  h->CleanUp();
850  return res;
851  }
852  if ((h->Typ()!=p->Typ()) &&(p->Typ()!=DEF_CMD))
853  {
854  WerrorS("type mismatch");
855  return TRUE;
856  }
857  idhdl pp=(idhdl)p->data;
858  switch(pp->typ)
859  {
860  case CRING_CMD:
861  nKillChar((coeffs)pp);
862  break;
863  case DEF_CMD:
864  case INT_CMD:
865  break;
866  case INTVEC_CMD:
867  case INTMAT_CMD:
868  delete IDINTVEC(pp);
869  break;
870  case NUMBER_CMD:
871  nDelete(&IDNUMBER(pp));
872  break;
873  case BIGINT_CMD:
875  break;
876  case MAP_CMD:
877  {
878  map im = IDMAP(pp);
879  omFree((ADDRESS)im->preimage);
880  im->preimage=NULL;// and continue
881  }
882  // continue as ideal:
883  case IDEAL_CMD:
884  case MODUL_CMD:
885  case MATRIX_CMD:
886  idDelete(&IDIDEAL(pp));
887  break;
888  case PROC_CMD:
889  case RESOLUTION_CMD:
890  case STRING_CMD:
892  break;
893  case LIST_CMD:
894  IDLIST(pp)->Clean();
895  break;
896  case LINK_CMD:
898  break;
899  // case ring: cannot happen
900  default:
901  Werror("unknown type %d",p->Typ());
902  return TRUE;
903  }
904  pp->typ=ALIAS_CMD;
905  IDDATA(pp)=(char*)h->data;
906  int eff_typ=h->Typ();
907  if ((RingDependend(eff_typ))
908  || ((eff_typ==LIST_CMD) && (lRingDependend((lists)h->Data()))))
909  {
910  ipSwapId(pp,IDROOT,currRing->idroot);
911  }
912  h->CleanUp();
914  return FALSE;
915 }
916 
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
void * ADDRESS
Definition: auxiliary.h:119
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
Definition: blackbox.cc:17
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:676
int level(const CanonicalForm &f)
int l
Definition: cfEzgcd.cc:100
int m
Definition: cfEzgcd.cc:128
int i
Definition: cfEzgcd.cc:132
int p
Definition: cfModGcd.cc:4078
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:504
FILE * f
Definition: checklibs.c:9
Definition: fevoices.h:59
Matrices of numbers.
Definition: bigintmat.h:51
Definition: idrec.h:35
idhdl get(const char *s, int lev)
Definition: ipid.cc:72
idhdl get_level(const char *s, int lev)
Definition: ipid.cc:103
idhdl set(const char *s, int lev, int t, BOOLEAN init=TRUE)
Definition: ipid.cc:236
char * String(BOOLEAN typed=FALSE)
Definition: ipid.cc:268
Definition: intvec.h:23
Definition: ipid.h:56
void pop()
Definition: ipid.cc:803
void push(char *)
Definition: ipid.cc:793
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
const char * name
Definition: subexpr.h:87
int rtyp
Definition: subexpr.h:91
void Init()
Definition: subexpr.h:107
char * String(void *d=NULL, BOOLEAN typed=FALSE, int dim=1)
Called for conversion to string (used by string(..), write(..),..)
Definition: subexpr.cc:761
void * data
Definition: subexpr.h:88
Definition: lists.h:24
sleftv * m
Definition: lists.h:46
INLINE_THIS void Init(int l=0)
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
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:538
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:522
BOOLEAN pa(leftv res, leftv args)
Definition: cohomo.cc:4344
#define Print
Definition: emacs.cc:80
#define Warn
Definition: emacs.cc:77
#define WarnS
Definition: emacs.cc:78
const CanonicalForm int s
Definition: facAbsFact.cc:51
CanonicalForm res
Definition: facAbsFact.cc:60
bool found
Definition: facFactorize.cc:55
int search(const CFArray &A, const CanonicalForm &F, int i, int j)
search for F in A between index i and j
void WerrorS(const char *s)
Definition: feFopen.cc:24
VAR int yylineno
Definition: febase.cc:40
VAR char my_yylinebuf[80]
Definition: febase.cc:44
VAR int myynest
Definition: febase.cc:41
VAR Voice * currentVoice
Definition: fevoices.cc:47
const char * VoiceName()
Definition: fevoices.cc:56
const char * Tok2Cmdname(int tok)
Definition: gentable.cc:140
#define VAR
Definition: globaldefs.h:5
@ END_RING
Definition: grammar.cc:310
@ IDEAL_CMD
Definition: grammar.cc:284
@ MATRIX_CMD
Definition: grammar.cc:286
@ BUCKET_CMD
Definition: grammar.cc:283
@ BIGINTMAT_CMD
Definition: grammar.cc:278
@ MAP_CMD
Definition: grammar.cc:285
@ PROC_CMD
Definition: grammar.cc:280
@ BEGIN_RING
Definition: grammar.cc:282
@ INTMAT_CMD
Definition: grammar.cc:279
@ MODUL_CMD
Definition: grammar.cc:287
@ SMATRIX_CMD
Definition: grammar.cc:291
@ VECTOR_CMD
Definition: grammar.cc:292
@ RESOLUTION_CMD
Definition: grammar.cc:290
@ NUMBER_CMD
Definition: grammar.cc:288
@ POLY_CMD
Definition: grammar.cc:289
@ RING_CMD
Definition: grammar.cc:281
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
Definition: ipassign.cc:1963
VAR omBin sip_command_bin
Definition: ipid.cc:45
const char * piProcinfo(procinfov pi, const char *request)
Definition: ipid.cc:713
lists ipNameListLev(idhdl root, int lev)
Definition: ipid.cc:640
VAR omBin sip_package_bin
Definition: ipid.cc:46
void paCleanUp(package pack)
Definition: ipid.cc:775
static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
Definition: ipid.cc:669
void killid(const char *id, idhdl *ih)
Definition: ipid.cc:379
idhdl ggetid(const char *n)
Definition: ipid.cc:571
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:437
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:278
VAR package basePack
Definition: ipid.cc:58
void * idrecDataInit(int t)
Definition: ipid.cc:139
VAR omBin idrec_bin
Definition: ipid.cc:48
void ipListFlag(idhdl h)
Definition: ipid.cc:609
VAR proclevel * procstack
Definition: ipid.cc:52
static long iiS2I(const char *s)
Definition: ipid.cc:65
VAR idhdl currRingHdl
Definition: ipid.cc:59
VAR package currPack
Definition: ipid.cc:57
BOOLEAN iiAlias(leftv p)
Definition: ipid.cc:834
void killhdl(idhdl h, package proot)
Definition: ipid.cc:406
VAR idhdl currPackHdl
Definition: ipid.cc:55
idhdl packFindHdl(package r)
Definition: ipid.cc:821
VAR idhdl basePackHdl
Definition: ipid.cc:56
lists ipNameList(idhdl root)
Definition: ipid.cc:617
void ipMoveId(idhdl tomove)
Definition: ipid.cc:694
BOOLEAN piKill(procinfov pi)
Definition: ipid.cc:737
VAR coeffs coeffs_BIGINT
Definition: ipid.cc:50
#define IDMAP(a)
Definition: ipid.h:135
#define IDSTRING(a)
Definition: ipid.h:136
#define IDNEXT(a)
Definition: ipid.h:118
EXTERN_VAR omBin sleftv_bin
Definition: ipid.h:145
#define IDDATA(a)
Definition: ipid.h:126
#define hasFlag(A, F)
Definition: ipid.h:112
#define IDINTVEC(a)
Definition: ipid.h:128
#define IDLINK(a)
Definition: ipid.h:138
#define IDIDEAL(a)
Definition: ipid.h:133
#define IDFLAG(a)
Definition: ipid.h:120
#define IDID(a)
Definition: ipid.h:122
#define IDROOT
Definition: ipid.h:19
#define FLAG_TWOSTD
Definition: ipid.h:107
#define IDNUMBER(a)
Definition: ipid.h:132
#define IDPACKAGE(a)
Definition: ipid.h:139
#define IDLEV(a)
Definition: ipid.h:121
void paKill(package pack)
Definition: ipid.h:50
#define IDRING(a)
Definition: ipid.h:127
#define IDTYP(a)
Definition: ipid.h:119
#define FLAG_STD
Definition: ipid.h:106
#define IDLIST(a)
Definition: ipid.h:137
void iiCheckPack(package &p)
Definition: ipshell.cc:1634
void rKill(ring r)
Definition: ipshell.cc:6174
VAR leftv iiCurrArgs
Definition: ipshell.cc:80
STATIC_VAR Poly * h
Definition: janet.cc:971
ListNode * next
Definition: janet.h:31
#define pi
Definition: libparse.cc:1145
VAR omBin slists_bin
Definition: lists.cc:23
BOOLEAN lRingDependend(lists L)
Definition: lists.cc:199
#define assume(x)
Definition: mod2.h:387
int dynl_close(void *handle)
Definition: mod_raw.cc:170
slists * lists
Definition: mpr_numeric.h:146
void init()
Definition: lintree.cc:864
The main handler for Singular numbers which are suitable for Singular polynomials.
#define nDelete(n)
Definition: numbers.h:16
#define nInit(i)
Definition: numbers.h:24
#define omStrDup(s)
Definition: omAllocDecl.h:263
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omCheckAddr(addr)
Definition: omAllocDecl.h:328
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
#define omFree(addr)
Definition: omAllocDecl.h:261
#define omAlloc0(size)
Definition: omAllocDecl.h:211
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259
#define omGetSpecBin(size)
Definition: omBin.h:11
#define NULL
Definition: omList.c:12
omBin_t * omBin
Definition: omStructs.h:12
#define BVERBOSE(a)
Definition: options.h:34
#define TEST_V_ALLWARN
Definition: options.h:143
#define Sy_bit(x)
Definition: options.h:31
#define V_REDEFINE
Definition: options.h:44
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
Compatiblity layer for legacy polynomial operations (over currRing)
void PrintS(const char *s)
Definition: reporter.cc:284
void Werror(const char *fmt,...)
Definition: reporter.cc:189
idrec * idhdl
Definition: ring.h:21
sBucket_pt sBucketCreate(const ring r)
Definition: sbuckets.cc:96
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
ip_package * package
Definition: structs.h:47
#define loop
Definition: structs.h:79
procinfo * procinfov
Definition: structs.h:64
VAR omBin procinfo_bin
Definition: subexpr.cc:42
void s_internalDelete(const int t, void *d, const ring r)
Definition: subexpr.cc:514
@ LANG_SINGULAR
Definition: subexpr.h:22
@ LANG_NONE
Definition: subexpr.h:22
@ LANG_C
Definition: subexpr.h:22
BOOLEAN RingDependend(int t)
Definition: subexpr.h:142
#define IDHDL
Definition: tok.h:31
@ ALIAS_CMD
Definition: tok.h:34
@ BIGINT_CMD
Definition: tok.h:38
@ CRING_CMD
Definition: tok.h:56
@ LIST_CMD
Definition: tok.h:118
@ INTVEC_CMD
Definition: tok.h:101
@ PACKAGE_CMD
Definition: tok.h:149
@ CMATRIX_CMD
Definition: tok.h:46
@ DEF_CMD
Definition: tok.h:58
@ CNUMBER_CMD
Definition: tok.h:47
@ LINK_CMD
Definition: tok.h:117
@ QRING_CMD
Definition: tok.h:158
@ STRING_CMD
Definition: tok.h:185
@ CPOLY_CMD
Definition: tok.h:48
@ INT_CMD
Definition: tok.h:96
@ MAX_TOK
Definition: tok.h:218