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