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"
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"
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
57VAR package currPack = NULL;
58VAR package basePack = NULL;
60
61void paCleanUp(package pack);
62
63/*0 implementation*/
64
65idhdl idrec::get(const char * s, int level)
66{
67 assume(s!=NULL);
68 assume((level>=0) && (level<=1000)); //not really, but if it isnt in that bounds..
69 idhdl h = this;
71 while (h!=NULL)
72 {
73 const char *id_=IDID(h);
74 omCheckAddr((ADDRESS)id_);
75 int l=IDLEV(h);
76 if ((l==0)||(l==level))
77 {
78 if (0 == strcmp(s, id_))
79 {
80 if(l==level) return h;
81 found=h;
82 }
83 }
84 h = IDNEXT(h);
85 }
86 return found;
87}
88
89idhdl idrec::get_level(const char * s, int level)
90{
91 assume(s!=NULL);
92 assume((level>=0) && (level<=1000)); //not really, but if it isnt in that bounds..
93 idhdl h = this;
94 while (h!=NULL)
95 {
96 const char *id_=IDID(h);
97 omCheckAddr((ADDRESS)id_);
98 int l=IDLEV(h);
99 if ((l==level)&&(0 == strcmp(s, id_)))
100 {
101 return h;
102 }
103 h = IDNEXT(h);
104 }
105 return NULL;
106}
107
108//idrec::~idrec()
109//{
110// if (id!=NULL)
111// {
112// omFree((ADDRESS)id);
113// id=NULL;
114// }
115// /* much more !! */
116//}
117
118void *idrecDataInit(int t)
119{
120 switch (t)
121 {
122 //the type with init routines:
123#ifdef SINGULAR_4_2
124 case CNUMBER_CMD:
125 return (void*)n2Init(0,NULL);
126 case CPOLY_CMD:
127 return (void*)p2Init(0,NULL);
128 case CMATRIX_CMD:
129#endif
130 case BIGINTMAT_CMD:
131 return (void *)new bigintmat();
132 case BUCKET_CMD:
133 if (currRing!=NULL)
134 return (void*)sBucketCreate(currRing);
135 else
136 {
137 WerrorS("need basering for polyBucket");
138 return NULL;
139 }
140 case INTVEC_CMD:
141 case INTMAT_CMD:
142 return (void *)new intvec();
143 case NUMBER_CMD:
144 {
145 if (currRing!=NULL) return (void *) nInit(0);
146 else return NULL;
147 }
148 case BIGINT_CMD:
149 return (void *) n_Init(0, coeffs_BIGINT);
150 case IDEAL_CMD:
151 case MODUL_CMD:
152 case MATRIX_CMD:
153 case SMATRIX_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 PACKAGE_CMD:
173 {
174 package pa=(package)omAlloc0Bin(sip_package_bin);
175 pa->language=LANG_NONE;
176 pa->loaded = FALSE;
177 return (void*)pa;
178 }
179 case PROC_CMD:
180 {
182 pi->ref=1;
183 pi->language=LANG_NONE;
184 return (void*)pi;
185 }
186 case RESOLUTION_CMD:
187 return (void *)omAlloc0(sizeof(ssyStrategy));
188 //other types: without alloc. (int,script,poly,def,package,..)
189 case INT_CMD:
190 case DEF_CMD:
191 case POLY_CMD:
192 case VECTOR_CMD:
193 case RING_CMD:
194 case CRING_CMD:
195 case QRING_CMD:
196 return NULL;
197 default:
198 {
199 if (t>MAX_TOK)
200 {
201#ifdef BLACKBOX_DEVEL
202 Print("bb-type %d\n",t);
203#endif
204 blackbox *bb=getBlackboxStuff(t);
205 if (bb!=NULL)
206 return (void *)bb->blackbox_Init(bb);
207 }
208 else
209 Werror("unknown type in idrecDataInit:%d",t);
210 break;
211 }
212 }
213 return (void *)0L;
214}
215idhdl idrec::set(const char * s, int level, int t, BOOLEAN init)
216{
217 //printf("define %s, %x, level: %d, typ: %d\n", s,s,level,t);
219 IDID(h) = s;
220 IDTYP(h) = t;
221 IDLEV(h) = level;
222 IDNEXT(h) = this;
223 BOOLEAN at_start=(this==IDROOT);
224 if (t==BUCKET_CMD) WarnS("defining polyBucket");
225 if (init)
226 {
227 if ((t==IDEAL_CMD)||(t==MODUL_CMD))
229 IDSTRING(h)=(char *)idrecDataInit(t);
230 // additional settings:--------------------------------------
231#if 0
232 // this leads to a memory leak
233 if (t == QRING_CMD)
234 {
235 // IDRING(h)=rCopy(currRing);
236 /* QRING_CMD is ring dep => currRing !=NULL */
237 }
238#endif
239 }
240 // --------------------------------------------------------
241 if (at_start)
242 IDNEXT(h) = IDROOT;
243 return h;
244}
245
247{
248 sleftv tmp;
249 tmp.Init();
250 tmp.rtyp=IDTYP(this);
251 tmp.data=IDDATA(this);
252 tmp.name=IDID(this);
253 return tmp.String(NULL, typed);
254}
255
256idhdl enterid(const char * s, int lev, int t, idhdl* root, BOOLEAN init, BOOLEAN search)
257{
258 if (s==NULL) return NULL;
259 if (root==NULL) return NULL;
260 idhdl h;
261 s=omStrDup(s);
262 // idhdl *save_root=root;
263 if (t==PACKAGE_CMD)
264 {
265 if (root!=&(basePack->idroot))
266 {
267 root=&(basePack->idroot);
268 }
269 }
270 // is it already defined in root ?
271 if ((h=(*root)->get_level(s,lev))!=NULL)
272 {
273 if ((IDTYP(h) == t)||(t==DEF_CMD))
274 {
275 if (IDTYP(h)==PACKAGE_CMD)
276 {
277 if (strcmp(s,"Top")==0)
278 {
279 goto errlabel;
280 }
281 else return h;
282 }
283 else
284 {
285 if (BVERBOSE(V_REDEFINE))
286 {
287 const char *f=VoiceName();
288 if (strcmp(f,"STDIN")==0)
289 Warn("redefining %s (%s)",s,my_yylinebuf);
290 else
291 Warn("redefining %s (%s) %s:%d",s,my_yylinebuf,f, yylineno);
292 }
293 if (s==IDID(h)) IDID(h)=NULL;
294 killhdl2(h,root,currRing);
295 }
296 }
297 else
298 goto errlabel;
299 }
300 // is it already defined in currRing->idroot ?
301 else if (search && (currRing!=NULL)&&((*root) != currRing->idroot))
302 {
303 if ((h=currRing->idroot->get_level(s,lev))!=NULL)
304 {
305 if ((IDTYP(h) == t)||(t==DEF_CMD))
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,&currRing->idroot,currRing);
317 }
318 else
319 goto errlabel;
320 }
321 }
322 // is it already defined in idroot ?
323 else if (search && (*root != IDROOT))
324 {
325 if ((h=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;
339 }
340 else
341 goto errlabel;
342 }
343 }
344 *root = (*root)->set(s, lev, t, init);
345#ifndef SING_NDEBUG
346 checkall();
347#endif
348 return *root;
349
350 errlabel:
351 //Werror("identifier `%s` in use(lev h=%d,typ=%d,t=%d, curr=%d)",s,IDLEV(h),IDTYP(h),t,lev);
352 Werror("identifier `%s` in use",s);
353 //listall();
354 omFree((ADDRESS)s);
355 return NULL;
356}
357void killid(const char * id, idhdl * ih)
358{
359 if (id!=NULL)
360 {
361 idhdl h = (*ih)->get(id,myynest);
362
363 // id not found in global list, is it defined in current ring ?
364 if (h==NULL)
365 {
366 if ((currRing!=NULL) && (*ih != (currRing->idroot)))
367 {
368 h = currRing->idroot->get(id,myynest);
369 if (h!=NULL)
370 {
371 killhdl2(h,&(currRing->idroot),currRing);
372 return;
373 }
374 }
375 Werror("`%s` is not defined",id);
376 return;
377 }
378 killhdl2(h,ih,currRing);
379 }
380 else
381 WerrorS("kill what ?");
382}
383
384void killhdl(idhdl h, package proot)
385{
386 int t=IDTYP(h);
387 if (((BEGIN_RING<t) && (t<END_RING))
388 || ((t==LIST_CMD) && (lRingDependend((lists)IDDATA(h)))))
389 killhdl2(h,&currRing->idroot,currRing);
390 else
391 {
392 if(t==PACKAGE_CMD)
393 {
394 killhdl2(h,&(basePack->idroot),NULL);
395 }
396 else
397 {
398 idhdl s=proot->idroot;
399 while ((s!=h) && (s!=NULL)) s=s->next;
400 if (s!=NULL)
401 killhdl2(h,&(proot->idroot),NULL);
402 else if (basePack!=proot)
403 {
404 idhdl s=basePack->idroot;
405 while ((s!=h) && (s!=NULL)) s=s->next;
406 if (s!=NULL)
407 killhdl2(h,&(basePack->idroot),currRing);
408 else
409 killhdl2(h,&(currRing->idroot),currRing);
410 }
411 }
412 }
413}
414
415void killhdl2(idhdl h, idhdl * ih, ring r)
416{
417 //printf("kill %s, id %x, typ %d lev: %d\n",IDID(h),(int)IDID(h),IDTYP(h),IDLEV(h));
418 idhdl hh;
419
421 && (IDLEV(h)!=myynest)
422 &&(IDLEV(h)==0))
423 {
424 if (((*ih)==basePack->idroot)
425 || ((currRing!=NULL)&&((*ih)==currRing->idroot)))
426 Warn("kill global `%s` at line >>%s<<\n",IDID(h),my_yylinebuf);
427 }
428 if (h->attribute!=NULL)
429 {
430 if ((IDTYP(h)==RING_CMD)&&(IDRING(h)!=r))
431 h->attribute->killAll(IDRING(h));
432 else
433 h->attribute->killAll(r);
434 h->attribute=NULL;
435 }
436 if (IDTYP(h) == PACKAGE_CMD)
437 {
438 if (((IDPACKAGE(h)->language==LANG_C)&&(IDPACKAGE(h)->idroot!=NULL))
439 || (strcmp(IDID(h),"Top")==0))
440 {
441 Warn("cannot kill `%s`",IDID(h));
442 return;
443 }
444 // any objects defined for this package ?
445 if ((IDPACKAGE(h)->ref<=0) && (IDPACKAGE(h)->idroot!=NULL))
446 {
447 if (currPack==IDPACKAGE(h))
448 {
451 }
452 idhdl * hd = &IDRING(h)->idroot;
453 idhdl hdh = IDNEXT(*hd);
454 idhdl temp;
455 while (hdh!=NULL)
456 {
457 temp = IDNEXT(hdh);
458 killhdl2(hdh,&(IDPACKAGE(h)->idroot),NULL);
459 hdh = temp;
460 }
461 killhdl2(*hd,hd,NULL);
462 if (IDPACKAGE(h)->libname!=NULL) omFree((ADDRESS)(IDPACKAGE(h)->libname));
463 }
467 }
468 else if (IDTYP(h)==RING_CMD)
469 rKill(h);
470 else if (IDDATA(h)!=NULL)
472 // general -------------------------------------------------------------
473 // now dechain it and delete idrec
474 if (IDID(h)!=NULL) // OB: ?????
475 omFree((ADDRESS)IDID(h));
476 IDID(h)=NULL;
477 IDDATA(h)=NULL;
478 if (h == (*ih))
479 {
480 // h is at the beginning of the list
481 *ih = IDNEXT(h) /* ==*ih */;
482 }
483 else if (ih!=NULL)
484 {
485 // h is somethere in the list:
486 hh = *ih;
487 loop
488 {
489 if (hh==NULL)
490 {
491 PrintS(">>?<< not found for kill\n");
492 return;
493 }
494 idhdl hhh = IDNEXT(hh);
495 if (hhh == h)
496 {
497 IDNEXT(hh) = IDNEXT(hhh);
498 break;
499 }
500 hh = hhh;
501 }
502 }
504}
505
506#if 0
507idhdl ggetid(const char *n, BOOLEAN /*local*/, idhdl *packhdl)
508{
509 idhdl h = IDROOT->get(n,myynest);
510 idhdl h2=NULL;
511 *packhdl = NULL;
512 if ((currRing!=NULL) && ((h==NULL)||(IDLEV(h)!=myynest)))
513 {
514 h2 = currRing->idroot->get(n,myynest);
515 }
516 if (h2==NULL) return h;
517 return h2;
518}
519#endif
520
521#if 0
522// debug version
523idhdl ggetid(const char *n)
524{
525 if (currRing!=NULL)
526 {
527 idhdl h2 = currRing->idroot->get(n,myynest);
528 idhdl h = IDROOT->get(n,myynest);
529 if ((h!=NULL)&&(h2!=NULL)&&(IDLEV(h)==IDLEV(h2)))
530 {
531 Warn("SHADOW %s(%s) vs %s(%s) in %s\n",IDID(h),Tok2Cmdname(IDTYP(h)),IDID(h2),Tok2Cmdname(IDTYP(h2)),my_yylinebuf);
532 }
533 if ((h2!=NULL)&&(IDLEV(h2)==myynest)) return h2;
534 if (h!=NULL) return h;
535 if (h2!=NULL) return h2;
536 }
537 else
538 {
539 idhdl h = IDROOT->get(n,myynest);
540 if (h!=NULL) return h;
541 }
542 if (basePack!=currPack)
543 return basePack->idroot->get(n,myynest);
544 return NULL;
545}
546#endif
547#if 1
548// try currRing before non-ring stuff
549idhdl ggetid(const char *n)
550{
551 if (currRing!=NULL)
552 {
553 idhdl h2 = currRing->idroot->get(n,myynest);
554 if ((h2!=NULL)&&(IDLEV(h2)==myynest)) return h2;
555 idhdl h = IDROOT->get(n,myynest);
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 0
570// try non-ring stuff before ring stuff
571idhdl ggetid(const char *n)
572{
573 idhdl h = IDROOT->get(n,myynest);
574 if ((h!=NULL)&&(IDLEV(h)==myynest)) return h;
575 if (currRing!=NULL)
576 {
577 idhdl h2 = currRing->idroot->get(n,myynest);
578 if (h2!=NULL) return h2;
579 }
580 if (h!=NULL) return h;
581 if (basePack!=currPack)
582 return basePack->idroot->get(n,myynest);
583 return NULL;
584}
585#endif
586
588{
589 if (hasFlag(h,FLAG_STD)) PrintS(" (SB)");
590#ifdef HAVE_PLURAL
591 if (hasFlag(h,FLAG_TWOSTD)) PrintS(" (2SB)");
592#endif
593}
594
596{
597 idhdl h=root;
598 /* compute the length */
599 int l=0;
600 while (h!=NULL) { l++; h=IDNEXT(h); }
601 /* allocate list */
603 L->Init(l);
604 /* copy names */
605 h=root;
606 l=0;
607 while (h!=NULL)
608 {
609 /* list is initialized with 0 => no need to clear anything */
610 L->m[l].rtyp=STRING_CMD;
611 L->m[l].data=omStrDup(IDID(h));
612 l++;
613 h=IDNEXT(h);
614 }
615 return L;
616}
617
619{
620 idhdl h=root;
621 /* compute the length */
622 int l=0;
623 while (h!=NULL) { if (IDLEV(h)==lev) l++; h=IDNEXT(h); }
624 /* allocate list */
626 L->Init(l);
627 /* copy names */
628 h=root;
629 l=0;
630 while (h!=NULL)
631 {
632 if (IDLEV(h)==lev)
633 {
634 /* list is initialized with 0 => no need to clear anything */
635 L->m[l].rtyp=STRING_CMD;
636 L->m[l].data=omStrDup(IDID(h));
637 l++;
638 }
639 h=IDNEXT(h);
640 }
641 return L;
642}
643
644/*
645* move 'tomove' from root1 list to root2 list
646*/
647static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
648{
649 idhdl h;
650 /* search 'tomove' in root2 : if found -> do nothing */
651 h=root2;
652 while ((h!=NULL) && (h!=tomove)) h=IDNEXT(h);
653 if (h!=NULL) return FALSE; /*okay */
654 /* search predecessor of h in root1, remove 'tomove' */
655 h=root1;
656 if (tomove==h)
657 {
658 root1=IDNEXT(h);
659 }
660 else
661 {
662 while ((h!=NULL) && (IDNEXT(h)!=tomove)) h=IDNEXT(h);
663 if (h==NULL) return TRUE; /* not in the list root1 -> do nothing */
664 IDNEXT(h)=IDNEXT(tomove);
665 }
666 /* add to root2 list */
667 IDNEXT(tomove)=root2;
668 root2=tomove;
669 return FALSE;
670}
671
672void ipMoveId(idhdl tomove)
673{
674 if ((currRing!=NULL)&&(tomove!=NULL))
675 {
676 if (RingDependend(IDTYP(tomove))
677 || ((IDTYP(tomove)==LIST_CMD) && (lRingDependend(IDLIST(tomove)))))
678 {
679 /*move 'tomove' to ring id's*/
680 if (ipSwapId(tomove,IDROOT,currRing->idroot))
681 ipSwapId(tomove,basePack->idroot,currRing->idroot);
682 }
683 else
684 {
685 /*move 'tomove' to global id's*/
686 ipSwapId(tomove,currRing->idroot,IDROOT);
687 }
688 }
689}
690
691const char * piProcinfo(procinfov pi, const char *request)
692{
693 if((pi == NULL)||(pi->language==LANG_NONE)) return "empty proc";
694 else if (strcmp(request, "libname") == 0) return pi->libname;
695 else if (strcmp(request, "procname") == 0) return pi->procname;
696 else if (strcmp(request, "type") == 0)
697 {
698 switch (pi->language)
699 {
700 case LANG_SINGULAR: return "singular"; break;
701 case LANG_C: return "object"; break;
702 case LANG_NONE: return "none"; break;
703 default: return "unknown language";
704 }
705 }
706 else if (strcmp(request, "ref") == 0)
707 {
708 char p[8];
709 sprintf(p, "%d", pi->ref);
710 return omStrDup(p); // MEMORY-LEAK
711 }
712 return "??";
713}
714
716{
717 (pi->ref)--;
718 if (pi->ref == 0)
719 {
720 if (pi->language==LANG_SINGULAR)
721 {
723 while (p!=NULL)
724 {
725 if (p->pi==pi && pi->ref <= 1)
726 {
727 Warn("`%s` in use, can not be killed",pi->procname);
728 return TRUE;
729 }
730 p=p->next;
731 }
732 }
733 if (pi->libname != NULL) // OB: ????
734 omFree((ADDRESS)pi->libname);
735 if (pi->procname != NULL) // OB: ????
736 omFree((ADDRESS)pi->procname);
737
738 if( pi->language == LANG_SINGULAR)
739 {
740 if (pi->data.s.body != NULL) // OB: ????
741 omFree((ADDRESS)pi->data.s.body);
742 }
743 if( pi->language == LANG_C)
744 {
745 }
746 memset((void *) pi, 0, sizeof(procinfo));
747 //pi->language=LANG_NONE;
749 }
750 return FALSE;
751}
752
754{
755 (pack->ref)--;
756 if (pack->ref < 0)
757 {
758 if( pack->language == LANG_C)
759 {
760 Print("//dlclose(%s)\n",pack->libname);
761#ifdef HAVE_DYNAMIC_LOADING
762 dynl_close (pack->handle);
763#endif /* HAVE_DYNAMIC_LOADING */
764 }
765 omFree((ADDRESS)pack->libname);
766 memset((void *) pack, 0, sizeof(sip_package));
767 pack->language=LANG_NONE;
768 }
769}
770
771void proclevel::push(char *n)
772{
773 //Print("push %s\n",n);
775 p->name=n;
776 p->cPackHdl=currPackHdl;
777 p->cPack=currPack;
778 p->next=this;
779 procstack=p;
780}
782{
783 //Print("pop %s\n",name);
784 //if (currRing!=::currRing) PrintS("currRing wrong\n");;
785 //::currRing=this->currRing;
786 //if (r==NULL) Print("set ring to NULL at lev %d(%s)\n",myynest,name);
787 //::currRingHdl=this->currRingHdl;
788 //if((::currRingHdl==NULL)||(IDRING(::currRingHdl)!=(::currRing)))
789 // ::currRingHdl=rFindHdl(::currRing,NULL,NULL);
790 //Print("restore pack=%s,1.obj=%s\n",IDID(currPackHdl),IDID(currPack->idroot));
791 currPackHdl=this->cPackHdl;
792 currPack=this->cPack;
794 proclevel *p=this;
796 omFreeSize(p,sizeof(proclevel));
797}
798
800{
801 idhdl h=basePack->idroot;
802 while (h!=NULL)
803 {
804 if ((IDTYP(h)==PACKAGE_CMD)
805 && (IDPACKAGE(h)==r))
806 return h;
807 h=IDNEXT(h);
808 }
809 return NULL;
810}
811
813{
814 if (iiCurrArgs==NULL)
815 {
816 Werror("not enough arguments for proc %s",VoiceName());
817 p->CleanUp();
818 return TRUE;
819 }
821 iiCurrArgs=h->next;
822 h->next=NULL;
823 if (h->rtyp!=IDHDL)
824 {
826 h->CleanUp();
828 return res;
829 }
830 if ((h->Typ()!=p->Typ()) &&(p->Typ()!=DEF_CMD))
831 {
832 WerrorS("type mismatch");
833 return TRUE;
834 }
835 idhdl pp=(idhdl)p->data;
836 switch(pp->typ)
837 {
838 case CRING_CMD:
840 break;
841 case DEF_CMD:
842 case INT_CMD:
843 break;
844 case INTVEC_CMD:
845 case INTMAT_CMD:
846 delete IDINTVEC(pp);
847 break;
848 case NUMBER_CMD:
850 break;
851 case BIGINT_CMD:
853 break;
854 case MAP_CMD:
855 {
856 map im = IDMAP(pp);
857 omFree((ADDRESS)im->preimage);
858 im->preimage=NULL;// and continue
859 }
860 // continue as ideal:
861 case IDEAL_CMD:
862 case MODUL_CMD:
863 case MATRIX_CMD:
865 break;
866 case PROC_CMD:
867 case RESOLUTION_CMD:
868 case STRING_CMD:
870 break;
871 case LIST_CMD:
872 IDLIST(pp)->Clean();
873 break;
874 case LINK_CMD:
876 break;
877 // case ring: cannot happen
878 default:
879 Werror("unknown type %d",p->Typ());
880 return TRUE;
881 }
882 pp->typ=ALIAS_CMD;
883 IDDATA(pp)=(char*)h->data;
884 int eff_typ=h->Typ();
885 if ((RingDependend(eff_typ))
886 || ((eff_typ==LIST_CMD) && (lRingDependend((lists)h->Data()))))
887 {
888 ipSwapId(pp,IDROOT,currRing->idroot);
889 }
890 h->CleanUp();
892 return FALSE;
893}
894
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 p
Definition: cfModGcd.cc:4077
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:65
idhdl get_level(const char *s, int lev)
Definition: ipid.cc:89
idhdl set(const char *s, int lev, int t, BOOLEAN init=TRUE)
Definition: ipid.cc:215
char * String(BOOLEAN typed=FALSE)
Definition: ipid.cc:246
Definition: intvec.h:23
Definition: ipid.h:56
void pop()
Definition: ipid.cc:781
void push(char *)
Definition: ipid.cc:771
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
lists ipNameListLev(idhdl root, int lev)
Definition: ipid.cc:618
VAR omBin sip_package_bin
Definition: ipid.cc:46
void paCleanUp(package pack)
Definition: ipid.cc:753
static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
Definition: ipid.cc:647
void killid(const char *id, idhdl *ih)
Definition: ipid.cc:357
idhdl ggetid(const char *n)
Definition: ipid.cc:549
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition: ipid.cc:415
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition: ipid.cc:256
VAR package basePack
Definition: ipid.cc:58
VAR omBin idrec_bin
Definition: ipid.cc:48
void ipListFlag(idhdl h)
Definition: ipid.cc:587
VAR proclevel * procstack
Definition: ipid.cc:52
VAR idhdl currRingHdl
Definition: ipid.cc:59
VAR package currPack
Definition: ipid.cc:57
BOOLEAN iiAlias(leftv p)
Definition: ipid.cc:812
void killhdl(idhdl h, package proot)
Definition: ipid.cc:384
void * idrecDataInit(int t)
Definition: ipid.cc:118
VAR idhdl currPackHdl
Definition: ipid.cc:55
idhdl packFindHdl(package r)
Definition: ipid.cc:799
VAR idhdl basePackHdl
Definition: ipid.cc:56
lists ipNameList(idhdl root)
Definition: ipid.cc:595
void ipMoveId(idhdl tomove)
Definition: ipid.cc:672
BOOLEAN piKill(procinfov pi)
Definition: ipid.cc:715
const char * piProcinfo(procinfov pi, const char *request)
Definition: ipid.cc:691
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:43
#define loop
Definition: structs.h:75
procinfo * procinfov
Definition: structs.h:60
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