My Project
Loading...
Searching...
No Matches
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 BIGINTVEC_CMD:
133 return (void *)new bigintmat(1,0,coeffs_BIGINT);
134 case BUCKET_CMD:
135 if (currRing!=NULL)
136 return (void*)sBucketCreate(currRing);
137 else
138 {
139 WerrorS("need basering for polyBucket");
140 return NULL;
141 }
142 case INTVEC_CMD:
143 case INTMAT_CMD:
144 return (void *)new intvec();
145 case NUMBER_CMD:
146 {
147 if (currRing!=NULL) return (void *) nInit(0);
148 else return NULL;
149 }
150 case BIGINT_CMD:
151 return (void *) n_Init(0, coeffs_BIGINT);
152 case IDEAL_CMD:
153 case MODUL_CMD:
154 case MATRIX_CMD:
155 case SMATRIX_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 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 alloc. (int,script,poly,def,package,..)
191 case INT_CMD:
192 case DEF_CMD:
193 case POLY_CMD:
194 case VECTOR_CMD:
195 case RING_CMD:
196 case CRING_CMD:
197 case QRING_CMD:
198 return NULL;
199 default:
200 {
201 if (t>MAX_TOK)
202 {
203#ifdef BLACKBOX_DEVEL
204 Print("bb-type %d\n",t);
205#endif
206 blackbox *bb=getBlackboxStuff(t);
207 if (bb!=NULL)
208 return (void *)bb->blackbox_Init(bb);
209 }
210 else
211 Werror("unknown type in idrecDataInit:%d",t);
212 break;
213 }
214 }
215 return (void *)0L;
216}
217idhdl idrec::set(const char * s, int level, int t, BOOLEAN init)
218{
219 //printf("define %s, %x, level: %d, typ: %d\n", s,s,level,t);
221 IDID(h) = s;
222 IDTYP(h) = t;
223 IDLEV(h) = level;
224 IDNEXT(h) = this;
225 BOOLEAN at_start=(this==IDROOT);
226 if (t==BUCKET_CMD) WarnS("defining polyBucket");
227 if (init)
228 {
229 if ((t==IDEAL_CMD)||(t==MODUL_CMD))
231 IDSTRING(h)=(char *)idrecDataInit(t);
232 // additional settings:--------------------------------------
233#if 0
234 // this leads to a memory leak
235 if (t == QRING_CMD)
236 {
237 // IDRING(h)=rCopy(currRing);
238 /* QRING_CMD is ring dep => currRing !=NULL */
239 }
240#endif
241 }
242 // --------------------------------------------------------
243 if (at_start)
244 IDNEXT(h) = IDROOT;
245 return h;
246}
247
249{
250 sleftv tmp;
251 tmp.Init();
252 tmp.rtyp=IDTYP(this);
253 tmp.data=IDDATA(this);
254 tmp.name=IDID(this);
255 return tmp.String(NULL, typed);
256}
257
258idhdl enterid(const char * s, int lev, int t, idhdl* root, BOOLEAN init, BOOLEAN search)
259{
260 if (s==NULL) return NULL;
261 if (root==NULL) return NULL;
262 idhdl h;
263 s=omStrDup(s);
264 // idhdl *save_root=root;
265 if (t==PACKAGE_CMD)
266 {
267 if (root!=&(basePack->idroot))
268 {
269 root=&(basePack->idroot);
270 }
271 }
272 // is it already defined in root ?
273 if ((h=(*root)->get_level(s,lev))!=NULL)
274 {
275 if ((IDTYP(h) == t)||(t==DEF_CMD))
276 {
277 if (IDTYP(h)==PACKAGE_CMD)
278 {
279 if (strcmp(s,"Top")==0)
280 {
281 goto errlabel;
282 }
283 else return h;
284 }
285 else
286 {
287 if (BVERBOSE(V_REDEFINE))
288 {
289 const char *f=VoiceName();
290 if (strcmp(f,"STDIN")==0)
291 Warn("redefining %s (%s)",s,my_yylinebuf);
292 else
293 Warn("redefining %s (%s) %s:%d",s,my_yylinebuf,f, yylineno);
294 }
295 if (s==IDID(h)) IDID(h)=NULL;
296 if((t!=PROC_CMD)||(IDPROC(h)->language!=LANG_C))
297 {
298 killhdl2(h,root,currRing);
299 }
300 }
301 }
302 else
303 goto errlabel;
304 }
305 // is it already defined in currRing->idroot ?
306 else if (search && (currRing!=NULL)&&((*root) != currRing->idroot))
307 {
308 if ((h=currRing->idroot->get_level(s,lev))!=NULL)
309 {
310 if ((IDTYP(h) == t)||(t==DEF_CMD))
311 {
312 if (BVERBOSE(V_REDEFINE))
313 {
314 const char *f=VoiceName();
315 if (strcmp(f,"STDIN")==0)
316 Warn("redefining %s (%s)",s,my_yylinebuf);
317 else
318 Warn("redefining %s (%s) %s:%d",s,my_yylinebuf,f, yylineno);
319 }
320 if (s==IDID(h)) IDID(h)=NULL;
321 // proc is not ring-dep, no need to check for type "proc":
322 killhdl2(h,&currRing->idroot,currRing);
323 }
324 else
325 goto errlabel;
326 }
327 }
328 // is it already defined in idroot ?
329 else if (search && (*root != IDROOT))
330 {
331 if ((h=IDROOT->get_level(s,lev))!=NULL)
332 {
333 if ((IDTYP(h) == t)||(t==DEF_CMD))
334 {
335 if (BVERBOSE(V_REDEFINE))
336 {
337 const char *f=VoiceName();
338 if (strcmp(f,"STDIN")==0)
339 Warn("redefining %s (%s)",s,my_yylinebuf);
340 else
341 Warn("redefining %s (%s) %s:%d",s,my_yylinebuf,f, yylineno);
342 }
343 if (s==IDID(h)) IDID(h)=NULL;
344 if((t!=PROC_CMD)||(IDPROC(h)->language!=LANG_C))
345 {
347 }
348 }
349 else
350 goto errlabel;
351 }
352 }
353 *root = (*root)->set(s, lev, t, init);
354#ifndef SING_NDEBUG
355 checkall();
356#endif
357 return *root;
358
359 errlabel:
360 //Werror("identifier `%s` in use(lev h=%d,typ=%d,t=%d, curr=%d)",s,IDLEV(h),IDTYP(h),t,lev);
361 Werror("identifier `%s` in use",s);
362 //listall();
364 return NULL;
365}
366void killid(const char * id, idhdl * ih)
367{
368 if (id!=NULL)
369 {
370 idhdl h = (*ih)->get(id,myynest);
371
372 // id not found in global list, is it defined in current ring ?
373 if (h==NULL)
374 {
375 if ((currRing!=NULL) && (*ih != (currRing->idroot)))
376 {
377 h = currRing->idroot->get(id,myynest);
378 if (h!=NULL)
379 {
380 killhdl2(h,&(currRing->idroot),currRing);
381 return;
382 }
383 }
384 Werror("`%s` is not defined",id);
385 return;
386 }
387 killhdl2(h,ih,currRing);
388 }
389 else
390 WerrorS("kill what ?");
391}
392
393void killhdl(idhdl h, package proot)
394{
395 int t=IDTYP(h);
396 if (((BEGIN_RING<t) && (t<END_RING))
397 || ((t==LIST_CMD) && (lRingDependend((lists)IDDATA(h)))))
398 killhdl2(h,&currRing->idroot,currRing);
399 else
400 {
401 if(t==PACKAGE_CMD)
402 {
403 killhdl2(h,&(basePack->idroot),NULL);
404 }
405 else
406 {
407 idhdl s=proot->idroot;
408 while ((s!=h) && (s!=NULL)) s=s->next;
409 if (s!=NULL)
410 killhdl2(h,&(proot->idroot),NULL);
411 else if (basePack!=proot)
412 {
413 idhdl s=basePack->idroot;
414 while ((s!=h) && (s!=NULL)) s=s->next;
415 if (s!=NULL)
416 killhdl2(h,&(basePack->idroot),currRing);
417 else
418 killhdl2(h,&(currRing->idroot),currRing);
419 }
420 }
421 }
422}
423
424void killhdl2(idhdl h, idhdl * ih, ring r)
425{
426 //printf("kill %s, id %x, typ %d lev: %d\n",IDID(h),(int)IDID(h),IDTYP(h),IDLEV(h));
427 idhdl hh;
428
430 && (IDLEV(h)!=myynest)
431 &&(IDLEV(h)==0))
432 {
433 if (((*ih)==basePack->idroot)
434 || ((currRing!=NULL)&&((*ih)==currRing->idroot)))
435 Warn("kill global `%s` at line >>%s<<\n",IDID(h),my_yylinebuf);
436 }
437 if (h->attribute!=NULL)
438 {
439 if ((IDTYP(h)==RING_CMD)&&(IDRING(h)!=r))
440 h->attribute->killAll(IDRING(h));
441 else
442 h->attribute->killAll(r);
443 h->attribute=NULL;
444 }
445 if (IDTYP(h) == PACKAGE_CMD)
446 {
447 if ((((IDPACKAGE(h)->language==LANG_C) ||(IDPACKAGE(h)->language==LANG_MIX))
448 &&(IDPACKAGE(h)->idroot!=NULL))
449 || (strcmp(IDID(h),"Top")==0))
450 {
451 Warn("cannot kill `%s`",IDID(h));
452 return;
453 }
454 // any objects defined for this package ?
455 if ((IDPACKAGE(h)->ref<=0) && (IDPACKAGE(h)->idroot!=NULL))
456 {
457 if (currPack==IDPACKAGE(h))
458 {
461 }
462 idhdl * hd = &IDRING(h)->idroot;
463 idhdl hdh = IDNEXT(*hd);
464 idhdl temp;
465 while (hdh!=NULL)
466 {
467 temp = IDNEXT(hdh);
468 killhdl2(hdh,&(IDPACKAGE(h)->idroot),NULL);
469 hdh = temp;
470 }
471 killhdl2(*hd,hd,NULL);
472 if (IDPACKAGE(h)->libname!=NULL) omFreeBinAddr((ADDRESS)(IDPACKAGE(h)->libname));
473 }
477 }
478 else if (IDTYP(h)==RING_CMD)
479 rKill(h);
480 else if (IDDATA(h)!=NULL)
482 IDDATA(h)=NULL;
483 // general -------------------------------------------------------------
484 // now dechain it and delete idrec
485 if (IDID(h)!=NULL) // OB: ?????
487 IDID(h)=NULL;
488 IDDATA(h)=NULL;
489 if (h == (*ih))
490 {
491 // h is at the beginning of the list
492 *ih = IDNEXT(h) /* ==*ih */;
493 }
494 else if (ih!=NULL)
495 {
496 // h is somethere in the list:
497 hh = *ih;
498 loop
499 {
500 if (hh==NULL)
501 {
502 PrintS(">>?<< not found for kill\n");
503 return;
504 }
505 idhdl hhh = IDNEXT(hh);
506 if (hhh == h)
507 {
508 IDNEXT(hh) = IDNEXT(hhh);
509 break;
510 }
511 hh = hhh;
512 }
513 }
515}
516
517#if 0
518idhdl ggetid(const char *n, BOOLEAN /*local*/, idhdl *packhdl)
519{
520 idhdl h = IDROOT->get(n,myynest);
521 idhdl h2=NULL;
522 *packhdl = NULL;
523 if ((currRing!=NULL) && ((h==NULL)||(IDLEV(h)!=myynest)))
524 {
525 h2 = currRing->idroot->get(n,myynest);
526 }
527 if (h2==NULL) return h;
528 return h2;
529}
530#endif
531
532#if 0
533// debug version
534idhdl ggetid(const char *n)
535{
536 if (currRing!=NULL)
537 {
538 idhdl h2 = currRing->idroot->get(n,myynest);
539 idhdl h = IDROOT->get(n,myynest);
540 if ((h!=NULL)&&(h2!=NULL)&&(IDLEV(h)==IDLEV(h2)))
541 {
542 Warn("SHADOW %s(%s) vs %s(%s) in %s\n",IDID(h),Tok2Cmdname(IDTYP(h)),IDID(h2),Tok2Cmdname(IDTYP(h2)),my_yylinebuf);
543 }
544 if ((h2!=NULL)&&(IDLEV(h2)==myynest)) return h2;
545 if (h!=NULL) return h;
546 if (h2!=NULL) return h2;
547 }
548 else
549 {
550 idhdl h = IDROOT->get(n,myynest);
551 if (h!=NULL) return h;
552 }
553 if (basePack!=currPack)
554 return basePack->idroot->get(n,myynest);
555 return NULL;
556}
557#endif
558#if 1
559// try currRing before non-ring stuff
560idhdl ggetid(const char *n)
561{
562 if (currRing!=NULL)
563 {
564 idhdl h2 = currRing->idroot->get(n,myynest);
565 if ((h2!=NULL)&&(IDLEV(h2)==myynest)) return h2;
566 idhdl h = IDROOT->get(n,myynest);
567 if (h!=NULL) return h;
568 if (h2!=NULL) return h2;
569 }
570 else
571 {
572 idhdl h = IDROOT->get(n,myynest);
573 if (h!=NULL) return h;
574 }
575 if (basePack!=currPack)
576 return basePack->idroot->get(n,myynest);
577 return NULL;
578}
579#endif
580#if 0
581// try non-ring stuff before ring stuff
582idhdl ggetid(const char *n)
583{
584 idhdl h = IDROOT->get(n,myynest);
585 if ((h!=NULL)&&(IDLEV(h)==myynest)) return h;
586 if (currRing!=NULL)
587 {
588 idhdl h2 = currRing->idroot->get(n,myynest);
589 if (h2!=NULL) return h2;
590 }
591 if (h!=NULL) return h;
592 if (basePack!=currPack)
593 return basePack->idroot->get(n,myynest);
594 return NULL;
595}
596#endif
597
599{
600 if (hasFlag(h,FLAG_STD)) PrintS(" (SB)");
601#ifdef HAVE_PLURAL
602 if (hasFlag(h,FLAG_TWOSTD)) PrintS(" (2SB)");
603#endif
604}
605
607{
608 idhdl h=root;
609 /* compute the length */
610 int l=0;
611 while (h!=NULL) { l++; h=IDNEXT(h); }
612 /* allocate list */
614 L->Init(l);
615 /* copy names */
616 h=root;
617 l=0;
618 while (h!=NULL)
619 {
620 /* list is initialized with 0 => no need to clear anything */
621 L->m[l].rtyp=STRING_CMD;
622 L->m[l].data=omStrDup(IDID(h));
623 l++;
624 h=IDNEXT(h);
625 }
626 return L;
627}
628
630{
631 idhdl h=root;
632 /* compute the length */
633 int l=0;
634 while (h!=NULL) { if (IDLEV(h)==lev) l++; h=IDNEXT(h); }
635 /* allocate list */
637 L->Init(l);
638 /* copy names */
639 h=root;
640 l=0;
641 while (h!=NULL)
642 {
643 if (IDLEV(h)==lev)
644 {
645 /* list is initialized with 0 => no need to clear anything */
646 L->m[l].rtyp=STRING_CMD;
647 L->m[l].data=omStrDup(IDID(h));
648 l++;
649 }
650 h=IDNEXT(h);
651 }
652 return L;
653}
654
655/*
656* move 'tomove' from root1 list to root2 list
657*/
658static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
659{
660 idhdl h;
661 /* search 'tomove' in root2 : if found -> do nothing */
662 h=root2;
663 while ((h!=NULL) && (h!=tomove)) h=IDNEXT(h);
664 if (h!=NULL) return FALSE; /*okay */
665 /* search predecessor of h in root1, remove 'tomove' */
666 h=root1;
667 if (tomove==h)
668 {
669 root1=IDNEXT(h);
670 }
671 else
672 {
673 while ((h!=NULL) && (IDNEXT(h)!=tomove)) h=IDNEXT(h);
674 if (h==NULL) return TRUE; /* not in the list root1 -> do nothing */
675 IDNEXT(h)=IDNEXT(tomove);
676 }
677 /* add to root2 list */
678 IDNEXT(tomove)=root2;
679 root2=tomove;
680 return FALSE;
681}
682
683void ipMoveId(idhdl tomove)
684{
685 if ((currRing!=NULL)&&(tomove!=NULL))
686 {
687 if (RingDependend(IDTYP(tomove))
688 || ((IDTYP(tomove)==LIST_CMD) && (lRingDependend(IDLIST(tomove)))))
689 {
690 /*move 'tomove' to ring id's*/
691 if (ipSwapId(tomove,IDROOT,currRing->idroot))
692 ipSwapId(tomove,basePack->idroot,currRing->idroot);
693 }
694 else
695 {
696 /*move 'tomove' to global id's*/
697 ipSwapId(tomove,currRing->idroot,IDROOT);
698 }
699 }
700}
701
702const char * piProcinfo(procinfov pi, const char *request)
703{
704 if((pi == NULL)||(pi->language==LANG_NONE)) return "empty proc";
705 else if (strcmp(request, "libname") == 0) return pi->libname;
706 else if (strcmp(request, "procname") == 0) return pi->procname;
707 else if (strcmp(request, "type") == 0)
708 {
709 switch (pi->language)
710 {
711 case LANG_SINGULAR: return "singular"; break;
712 case LANG_C: return "object"; break;
713 case LANG_NONE: return "none"; break;
714 default: return "unknown language";
715 }
716 }
717 else if (strcmp(request, "ref") == 0)
718 {
719 char p[8];
720 snprintf(p,8, "%d", pi->ref);
721 return omStrDup(p); // MEMORY-LEAK
722 }
723 return "??";
724}
725
727{
728 (pi->ref)--;
729 if (pi->ref == 0)
730 {
731 if (pi->language==LANG_SINGULAR)
732 {
734 while (p!=NULL)
735 {
736 if (p->pi==pi && pi->ref <= 1)
737 {
738 Warn("`%s` in use, can not be killed",pi->procname);
739 return TRUE;
740 }
741 p=p->next;
742 }
743 }
744 if (pi->libname != NULL) // OB: ????
745 omFreeBinAddr((ADDRESS)pi->libname);
746 if (pi->procname != NULL) // OB: ????
747 omFreeBinAddr((ADDRESS)pi->procname);
748
749 if( pi->language == LANG_SINGULAR)
750 {
751 if (pi->data.s.body != NULL) // OB: ????
752 omFree((ADDRESS)pi->data.s.body);
753 }
754 if( pi->language == LANG_C)
755 {
756 }
757 memset((void *) pi, 0, sizeof(procinfo));
758 //pi->language=LANG_NONE;
760 }
761 return FALSE;
762}
763
765{
766 (pack->ref)--;
767 if (pack->ref < 0)
768 {
769 if( pack->language == LANG_C)
770 {
771 Print("//dlclose(%s)\n",pack->libname);
772#ifdef HAVE_DYNAMIC_LOADING
773 dynl_close (pack->handle);
774#endif /* HAVE_DYNAMIC_LOADING */
775 }
776 omFreeBinAddr((ADDRESS)pack->libname);
777 memset((void *) pack, 0, sizeof(sip_package));
778 pack->language=LANG_NONE;
779 }
780}
781
782void proclevel::push(char *n)
783{
784 //Print("push %s\n",n);
786 p->name=n;
787 p->cPackHdl=currPackHdl;
788 p->cPack=currPack;
789 p->next=this;
790 procstack=p;
791}
793{
794 //Print("pop %s\n",name);
795 //if (currRing!=::currRing) PrintS("currRing wrong\n");;
796 //::currRing=this->currRing;
797 //if (r==NULL) Print("set ring to NULL at lev %d(%s)\n",myynest,name);
798 //::currRingHdl=this->currRingHdl;
799 //if((::currRingHdl==NULL)||(IDRING(::currRingHdl)!=(::currRing)))
800 // ::currRingHdl=rFindHdl(::currRing,NULL,NULL);
801 //Print("restore pack=%s,1.obj=%s\n",IDID(currPackHdl),IDID(currPack->idroot));
802 currPackHdl=this->cPackHdl;
803 currPack=this->cPack;
805 proclevel *p=this;
807 omFreeSize(p,sizeof(proclevel));
808}
809
811{
812 idhdl h=basePack->idroot;
813 while (h!=NULL)
814 {
815 if ((IDTYP(h)==PACKAGE_CMD)
816 && (IDPACKAGE(h)==r))
817 return h;
818 h=IDNEXT(h);
819 }
820 return NULL;
821}
822
824{
825 if (iiCurrArgs==NULL)
826 {
827 Werror("not enough arguments for proc %s",VoiceName());
828 p->CleanUp();
829 return TRUE;
830 }
832 iiCurrArgs=h->next;
833 h->next=NULL;
834 if (h->rtyp!=IDHDL)
835 {
837 h->CleanUp();
839 return res;
840 }
841 if ((h->Typ()!=p->Typ()) &&(p->Typ()!=DEF_CMD))
842 {
843 WerrorS("type mismatch");
844 return TRUE;
845 }
846 idhdl pp=(idhdl)p->data;
847 switch(pp->typ)
848 {
849 case CRING_CMD:
851 break;
852 case DEF_CMD:
853 case INT_CMD:
854 break;
855 case INTVEC_CMD:
856 case INTMAT_CMD:
857 delete IDINTVEC(pp);
858 break;
859 case NUMBER_CMD:
861 break;
862 case BIGINT_CMD:
864 break;
865 case MAP_CMD:
866 {
867 map im = IDMAP(pp);
868 omFreeBinAddr((ADDRESS)im->preimage);
869 im->preimage=NULL;// and continue
870 }
871 // continue as ideal:
872 case IDEAL_CMD:
873 case MODUL_CMD:
874 case MATRIX_CMD:
876 break;
877 case PROC_CMD:
878 case RESOLUTION_CMD:
879 case STRING_CMD:
881 break;
882 case LIST_CMD:
883 IDLIST(pp)->Clean();
884 break;
885 case LINK_CMD:
887 break;
888 // case ring: cannot happen
889 default:
890 {
891 int t=p->Typ();
892 if (t<MAX_TOK)
893 {
894 Werror("unknown type %d(%s)",t,Tok2Cmdname(t));
895 return TRUE;
896 }
897 /*else: blackbox type, not yet set*/
898 break;
899 }
900 }
901 pp->typ=ALIAS_CMD;
902 IDDATA(pp)=(char*)h->data;
903 int eff_typ=h->Typ();
904 if ((RingDependend(eff_typ))
905 || ((eff_typ==LIST_CMD) && (lRingDependend((lists)h->Data()))))
906 {
907 ipSwapId(pp,IDROOT,currRing->idroot);
908 }
909 h->CleanUp();
911 return FALSE;
912}
913
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:4086
CanonicalForm map(const CanonicalForm &primElem, const Variable &alpha, const CanonicalForm &F, const Variable &beta)
map from to such that is mapped onto
FILE * f
Definition checklibs.c:9
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:217
char * String(BOOLEAN typed=FALSE)
Definition ipid.cc:248
idrec()
Definition idrec.h:48
void pop()
Definition ipid.cc:792
void push(char *)
Definition ipid.cc:782
proclevel * next
Definition ipid.h:58
package cPack
Definition ipid.h:60
idhdl cPackHdl
Definition ipid.h:59
proclevel()
Definition ipid.h:62
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:765
void * data
Definition subexpr.h:88
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:459
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
void nKillChar(coeffs r)
undo all initialisations
Definition numbers.cc:556
static BOOLEAN pa(leftv res, leftv args)
Definition cohomo.cc:3770
#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
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:49
const char * VoiceName()
Definition fevoices.cc:58
const char * Tok2Cmdname(int tok)
Definition gentable.cc:137
static int RingDependend(int t)
Definition gentable.cc:23
#define VAR
Definition globaldefs.h:5
@ END_RING
Definition grammar.cc:311
@ IDEAL_CMD
Definition grammar.cc:285
@ MATRIX_CMD
Definition grammar.cc:287
@ BUCKET_CMD
Definition grammar.cc:284
@ BIGINTMAT_CMD
Definition grammar.cc:278
@ MAP_CMD
Definition grammar.cc:286
@ PROC_CMD
Definition grammar.cc:281
@ BEGIN_RING
Definition grammar.cc:283
@ INTMAT_CMD
Definition grammar.cc:280
@ MODUL_CMD
Definition grammar.cc:288
@ SMATRIX_CMD
Definition grammar.cc:292
@ VECTOR_CMD
Definition grammar.cc:293
@ RESOLUTION_CMD
Definition grammar.cc:291
@ BIGINTVEC_CMD
Definition grammar.cc:279
@ NUMBER_CMD
Definition grammar.cc:289
@ POLY_CMD
Definition grammar.cc:290
@ RING_CMD
Definition grammar.cc:282
#define idDelete(H)
delete an ideal
Definition ideals.h:29
BOOLEAN iiAssign(leftv l, leftv r, BOOLEAN toplevel)
Definition ipassign.cc:2097
VAR omBin sip_command_bin
Definition ipid.cc:45
lists ipNameListLev(idhdl root, int lev)
Definition ipid.cc:629
VAR omBin sip_package_bin
Definition ipid.cc:46
void paCleanUp(package pack)
Definition ipid.cc:764
static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
Definition ipid.cc:658
void killid(const char *id, idhdl *ih)
Definition ipid.cc:366
idhdl ggetid(const char *n)
Definition ipid.cc:560
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition ipid.cc:424
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
Definition ipid.cc:258
VAR package basePack
Definition ipid.cc:58
VAR omBin idrec_bin
Definition ipid.cc:48
void ipListFlag(idhdl h)
Definition ipid.cc:598
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:823
void killhdl(idhdl h, package proot)
Definition ipid.cc:393
void * idrecDataInit(int t)
Definition ipid.cc:118
VAR idhdl currPackHdl
Definition ipid.cc:55
idhdl packFindHdl(package r)
Definition ipid.cc:810
VAR idhdl basePackHdl
Definition ipid.cc:56
lists ipNameList(idhdl root)
Definition ipid.cc:606
void ipMoveId(idhdl tomove)
Definition ipid.cc:683
BOOLEAN piKill(procinfov pi)
Definition ipid.cc:726
const char * piProcinfo(procinfov pi, const char *request)
Definition ipid.cc:702
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
EXTERN_VAR proclevel * procstack
Definition ipid.h:66
#define IDDATA(a)
Definition ipid.h:126
#define IDPROC(a)
Definition ipid.h:140
EXTERN_VAR package currPack
Definition ipid.h:17
#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
EXTERN_VAR idhdl currPackHdl
Definition ipid.h:15
#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:1620
void rKill(ring r)
Definition ipshell.cc:6162
VAR leftv iiCurrArgs
Definition ipshell.cc:80
STATIC_VAR Poly * h
Definition janet.cc:971
#define pi
Definition libparse.cc:1145
VAR omBin slists_bin
Definition lists.cc:23
BOOLEAN lRingDependend(lists L)
Definition lists.cc:222
#define assume(x)
Definition mod2.h:387
int dynl_close(void *handle)
Definition mod_raw.cc:170
slists * lists
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)
#define omFreeSize(addr, size)
#define omCheckAddr(addr)
#define omAllocBin(bin)
#define omAlloc0Bin(bin)
#define omFree(addr)
#define omAlloc0(size)
#define omFreeBin(addr, bin)
#define omFreeBinAddr(addr)
#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:35
#define TEST_V_ALLWARN
Definition options.h:145
#define Sy_bit(x)
Definition options.h:31
#define V_REDEFINE
Definition options.h:45
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
Compatibility 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
ip_package * package
Definition structs.h:43
sleftv * leftv
Definition structs.h:57
#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:518
@ LANG_SINGULAR
Definition subexpr.h:22
@ LANG_NONE
Definition subexpr.h:22
@ LANG_MIX
Definition subexpr.h:22
@ LANG_C
Definition subexpr.h:22
#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:150
@ 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:160
@ STRING_CMD
Definition tok.h:187
@ CPOLY_CMD
Definition tok.h:48
@ INT_CMD
Definition tok.h:96
@ MAX_TOK
Definition tok.h:220