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//idhdl idroot = NULL;
52
55VAR package currPack = NULL;
56VAR package basePack = NULL;
58
59void paCleanUp(package pack);
60
61/*0 implementation*/
62
63idhdl idrec::get(const char * s, int level)
64{
65 assume(s!=NULL);
66 assume((level>=0) && (level<=1000)); //not really, but if it isnt in that bounds..
67 idhdl h = this;
69 while (h!=NULL)
70 {
71 const char *id_=IDID(h);
72 omCheckAddr((ADDRESS)id_);
73 int l=IDLEV(h);
74 if ((l==0)||(l==level))
75 {
76 if (0 == strcmp(s, id_))
77 {
78 if(l==level) return h;
79 found=h;
80 }
81 }
82 h = IDNEXT(h);
83 }
84 return found;
85}
86
87idhdl idrec::get_level(const char * s, int level)
88{
89 assume(s!=NULL);
90 assume((level>=0) && (level<=1000)); //not really, but if it isnt in that bounds..
91 idhdl h = this;
92 while (h!=NULL)
93 {
94 const char *id_=IDID(h);
95 omCheckAddr((ADDRESS)id_);
96 int l=IDLEV(h);
97 if ((l==level)&&(0 == strcmp(s, id_)))
98 {
99 return h;
100 }
101 h = IDNEXT(h);
102 }
103 return NULL;
104}
105
106//idrec::~idrec()
107//{
108// if (id!=NULL)
109// {
110// omFree((ADDRESS)id);
111// id=NULL;
112// }
113// /* much more !! */
114//}
115
116void *idrecDataInit(int t)
117{
118 switch (t)
119 {
120 //the type with init routines:
121#ifdef SINGULAR_4_2
122 case CNUMBER_CMD:
123 return (void*)n2Init(0,NULL);
124 case CPOLY_CMD:
125 return (void*)p2Init(0,NULL);
126 case CMATRIX_CMD:
127#endif
128 case BIGINTMAT_CMD:
129 return (void *)new bigintmat();
130 case BIGINTVEC_CMD:
131 return (void *)new bigintmat(1,0,coeffs_BIGINT);
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 if((t!=PROC_CMD)||(IDPROC(h)->language!=LANG_C))
295 {
296 killhdl2(h,root,currRing);
297 }
298 }
299 }
300 else
301 goto errlabel;
302 }
303 // is it already defined in currRing->idroot ?
304 else if (search && (currRing!=NULL)&&((*root) != currRing->idroot))
305 {
306 if ((h=currRing->idroot->get_level(s,lev))!=NULL)
307 {
308 if ((IDTYP(h) == t)||(t==DEF_CMD))
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 // proc is not ring-dep, no need to check for type "proc":
320 killhdl2(h,&currRing->idroot,currRing);
321 }
322 else
323 goto errlabel;
324 }
325 }
326 // is it already defined in idroot ?
327 else if (search && (*root != IDROOT))
328 {
329 if ((h=IDROOT->get_level(s,lev))!=NULL)
330 {
331 if ((IDTYP(h) == t)||(t==DEF_CMD))
332 {
333 if (BVERBOSE(V_REDEFINE))
334 {
335 const char *f=VoiceName();
336 if (strcmp(f,"STDIN")==0)
337 Warn("redefining %s (%s)",s,my_yylinebuf);
338 else
339 Warn("redefining %s (%s) %s:%d",s,my_yylinebuf,f, yylineno);
340 }
341 if (s==IDID(h)) IDID(h)=NULL;
342 if((t!=PROC_CMD)||(IDPROC(h)->language!=LANG_C))
343 {
345 }
346 }
347 else
348 goto errlabel;
349 }
350 }
351 *root = (*root)->set(s, lev, t, init);
352#ifndef SING_NDEBUG
353 checkall();
354#endif
355 return *root;
356
357 errlabel:
358 //Werror("identifier `%s` in use(lev h=%d,typ=%d,t=%d, curr=%d)",s,IDLEV(h),IDTYP(h),t,lev);
359 Werror("identifier `%s` in use",s);
360 //listall();
362 return NULL;
363}
364void killid(const char * id, idhdl * ih)
365{
366 if (id!=NULL)
367 {
368 idhdl h = (*ih)->get(id,myynest);
369
370 // id not found in global list, is it defined in current ring ?
371 if (h==NULL)
372 {
373 if ((currRing!=NULL) && (*ih != (currRing->idroot)))
374 {
375 h = currRing->idroot->get(id,myynest);
376 if (h!=NULL)
377 {
378 killhdl2(h,&(currRing->idroot),currRing);
379 return;
380 }
381 }
382 Werror("`%s` is not defined",id);
383 return;
384 }
385 killhdl2(h,ih,currRing);
386 }
387 else
388 WerrorS("kill what ?");
389}
390
391void killhdl(idhdl h, package proot)
392{
393 int t=IDTYP(h);
394 if (((BEGIN_RING<t) && (t<END_RING))
395 || ((t==LIST_CMD) && (lRingDependend((lists)IDDATA(h)))))
396 killhdl2(h,&currRing->idroot,currRing);
397 else
398 {
399 if(t==PACKAGE_CMD)
400 {
401 killhdl2(h,&(basePack->idroot),NULL);
402 }
403 else
404 {
405 idhdl s=proot->idroot;
406 while ((s!=h) && (s!=NULL)) s=s->next;
407 if (s!=NULL)
408 killhdl2(h,&(proot->idroot),NULL);
409 else if (basePack!=proot)
410 {
411 idhdl s=basePack->idroot;
412 while ((s!=h) && (s!=NULL)) s=s->next;
413 if (s!=NULL)
414 killhdl2(h,&(basePack->idroot),currRing);
415 else
416 killhdl2(h,&(currRing->idroot),currRing);
417 }
418 }
419 }
420}
421
422void killhdl2(idhdl h, idhdl * ih, ring r)
423{
424 //printf("kill %s, id %x, typ %d lev: %d\n",IDID(h),(int)IDID(h),IDTYP(h),IDLEV(h));
425 idhdl hh;
426
428 && (IDLEV(h)!=myynest)
429 &&(IDLEV(h)==0))
430 {
431 if (((*ih)==basePack->idroot)
432 || ((currRing!=NULL)&&((*ih)==currRing->idroot)))
433 Warn("kill global `%s` at line >>%s<<\n",IDID(h),my_yylinebuf);
434 }
435 if (h->attribute!=NULL)
436 {
437 if ((IDTYP(h)==RING_CMD)&&(IDRING(h)!=r))
438 h->attribute->killAll(IDRING(h));
439 else
440 h->attribute->killAll(r);
441 h->attribute=NULL;
442 }
443 if (IDTYP(h) == PACKAGE_CMD)
444 {
445 if ((((IDPACKAGE(h)->language==LANG_C) ||(IDPACKAGE(h)->language==LANG_MIX))
446 &&(IDPACKAGE(h)->idroot!=NULL))
447 || (strcmp(IDID(h),"Top")==0))
448 {
449 Warn("cannot kill `%s`",IDID(h));
450 return;
451 }
452 // any objects defined for this package ?
453 if ((IDPACKAGE(h)->ref<=0) && (IDPACKAGE(h)->idroot!=NULL))
454 {
455 if (currPack==IDPACKAGE(h))
456 {
459 }
460 idhdl * hd = &IDRING(h)->idroot;
461 idhdl hdh = IDNEXT(*hd);
462 idhdl temp;
463 while (hdh!=NULL)
464 {
465 temp = IDNEXT(hdh);
466 killhdl2(hdh,&(IDPACKAGE(h)->idroot),NULL);
467 hdh = temp;
468 }
469 killhdl2(*hd,hd,NULL);
470 if (IDPACKAGE(h)->libname!=NULL) omFreeBinAddr((ADDRESS)(IDPACKAGE(h)->libname));
471 }
475 }
476 else if (IDTYP(h)==RING_CMD)
477 rKill(h);
478 else if (IDDATA(h)!=NULL)
480 IDDATA(h)=NULL;
481 // general -------------------------------------------------------------
482 // now dechain it and delete idrec
483 if (IDID(h)!=NULL) // OB: ?????
485 IDID(h)=NULL;
486 IDDATA(h)=NULL;
487 if (h == (*ih))
488 {
489 // h is at the beginning of the list
490 *ih = IDNEXT(h) /* ==*ih */;
491 }
492 else if (ih!=NULL)
493 {
494 // h is somethere in the list:
495 hh = *ih;
496 loop
497 {
498 if (hh==NULL)
499 {
500 PrintS(">>?<< not found for kill\n");
501 return;
502 }
503 idhdl hhh = IDNEXT(hh);
504 if (hhh == h)
505 {
506 IDNEXT(hh) = IDNEXT(hhh);
507 break;
508 }
509 hh = hhh;
510 }
511 }
513}
514
515#if 0
516idhdl ggetid(const char *n, BOOLEAN /*local*/, idhdl *packhdl)
517{
518 idhdl h = IDROOT->get(n,myynest);
519 idhdl h2=NULL;
520 *packhdl = NULL;
521 if ((currRing!=NULL) && ((h==NULL)||(IDLEV(h)!=myynest)))
522 {
523 h2 = currRing->idroot->get(n,myynest);
524 }
525 if (h2==NULL) return h;
526 return h2;
527}
528#endif
529
530#if 0
531// debug version
532idhdl ggetid(const char *n)
533{
534 if (currRing!=NULL)
535 {
536 idhdl h2 = currRing->idroot->get(n,myynest);
537 idhdl h = IDROOT->get(n,myynest);
538 if ((h!=NULL)&&(h2!=NULL)&&(IDLEV(h)==IDLEV(h2)))
539 {
540 Warn("SHADOW %s(%s) vs %s(%s) in %s\n",IDID(h),Tok2Cmdname(IDTYP(h)),IDID(h2),Tok2Cmdname(IDTYP(h2)),my_yylinebuf);
541 }
542 if ((h2!=NULL)&&(IDLEV(h2)==myynest)) return h2;
543 if (h!=NULL) return h;
544 if (h2!=NULL) return h2;
545 }
546 else
547 {
548 idhdl h = IDROOT->get(n,myynest);
549 if (h!=NULL) return h;
550 }
551 if (basePack!=currPack)
552 return basePack->idroot->get(n,myynest);
553 return NULL;
554}
555#endif
556#if 1
557// try currRing before non-ring stuff
558idhdl ggetid(const char *n)
559{
560 if (currRing!=NULL)
561 {
562 idhdl h2 = currRing->idroot->get(n,myynest);
563 if ((h2!=NULL)&&(IDLEV(h2)==myynest)) return h2;
564 idhdl h = IDROOT->get(n,myynest);
565 if (h!=NULL) return h;
566 if (h2!=NULL) return h2;
567 }
568 else
569 {
570 idhdl h = IDROOT->get(n,myynest);
571 if (h!=NULL) return h;
572 }
573 if (basePack!=currPack)
574 return basePack->idroot->get(n,myynest);
575 return NULL;
576}
577#endif
578#if 0
579// try non-ring stuff before ring stuff
580idhdl ggetid(const char *n)
581{
582 idhdl h = IDROOT->get(n,myynest);
583 if ((h!=NULL)&&(IDLEV(h)==myynest)) return h;
584 if (currRing!=NULL)
585 {
586 idhdl h2 = currRing->idroot->get(n,myynest);
587 if (h2!=NULL) return h2;
588 }
589 if (h!=NULL) return h;
590 if (basePack!=currPack)
591 return basePack->idroot->get(n,myynest);
592 return NULL;
593}
594#endif
595
597{
598 if (hasFlag(h,FLAG_STD)) PrintS(" (SB)");
599#ifdef HAVE_PLURAL
600 if (hasFlag(h,FLAG_TWOSTD)) PrintS(" (2SB)");
601#endif
602}
603
605{
606 idhdl h=root;
607 /* compute the length */
608 int l=0;
609 while (h!=NULL) { l++; h=IDNEXT(h); }
610 /* allocate list */
612 L->Init(l);
613 /* copy names */
614 h=root;
615 l=0;
616 while (h!=NULL)
617 {
618 /* list is initialized with 0 => no need to clear anything */
619 L->m[l].rtyp=STRING_CMD;
620 L->m[l].data=omStrDup(IDID(h));
621 l++;
622 h=IDNEXT(h);
623 }
624 return L;
625}
626
628{
629 idhdl h=root;
630 /* compute the length */
631 int l=0;
632 while (h!=NULL) { if (IDLEV(h)==lev) l++; h=IDNEXT(h); }
633 /* allocate list */
635 L->Init(l);
636 /* copy names */
637 h=root;
638 l=0;
639 while (h!=NULL)
640 {
641 if (IDLEV(h)==lev)
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 }
648 h=IDNEXT(h);
649 }
650 return L;
651}
652
653/*
654* move 'tomove' from root1 list to root2 list
655*/
656static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
657{
658 idhdl h;
659 /* search 'tomove' in root2 : if found -> do nothing */
660 h=root2;
661 while ((h!=NULL) && (h!=tomove)) h=IDNEXT(h);
662 if (h!=NULL) return FALSE; /*okay */
663 /* search predecessor of h in root1, remove 'tomove' */
664 h=root1;
665 if (tomove==h)
666 {
667 root1=IDNEXT(h);
668 }
669 else
670 {
671 while ((h!=NULL) && (IDNEXT(h)!=tomove)) h=IDNEXT(h);
672 if (h==NULL) return TRUE; /* not in the list root1 -> do nothing */
673 IDNEXT(h)=IDNEXT(tomove);
674 }
675 /* add to root2 list */
676 IDNEXT(tomove)=root2;
677 root2=tomove;
678 return FALSE;
679}
680
681void ipMoveId(idhdl tomove)
682{
683 if ((currRing!=NULL)&&(tomove!=NULL))
684 {
685 if (RingDependend(IDTYP(tomove))
686 || ((IDTYP(tomove)==LIST_CMD) && (lRingDependend(IDLIST(tomove)))))
687 {
688 /*move 'tomove' to ring id's*/
689 if (ipSwapId(tomove,IDROOT,currRing->idroot))
690 ipSwapId(tomove,basePack->idroot,currRing->idroot);
691 }
692 else
693 {
694 /*move 'tomove' to global id's*/
695 ipSwapId(tomove,currRing->idroot,IDROOT);
696 }
697 }
698}
699
700const char * piProcinfo(procinfov pi, const char *request)
701{
702 if((pi == NULL)||(pi->language==LANG_NONE)) return "empty proc";
703 else if (strcmp(request, "libname") == 0) return pi->libname;
704 else if (strcmp(request, "procname") == 0) return pi->procname;
705 else if (strcmp(request, "type") == 0)
706 {
707 switch (pi->language)
708 {
709 case LANG_SINGULAR: return "singular"; break;
710 case LANG_C: return "object"; break;
711 case LANG_NONE: return "none"; break;
712 default: return "unknown language";
713 }
714 }
715 else if (strcmp(request, "ref") == 0)
716 {
717 char p[8];
718 snprintf(p,8, "%d", pi->ref);
719 return omStrDup(p); // MEMORY-LEAK
720 }
721 return "??";
722}
723
725{
726 (pi->ref)--;
727 if (pi->ref == 0)
728 {
729 if (pi->language==LANG_SINGULAR)
730 {
732 while (p!=NULL)
733 {
734 if (p->pi==pi && pi->ref <= 1)
735 {
736 Warn("`%s` in use, can not be killed",pi->procname);
737 return TRUE;
738 }
739 p=p->next;
740 }
741 }
742 if (pi->libname != NULL) // OB: ????
743 omFreeBinAddr((ADDRESS)pi->libname);
744 if (pi->procname != NULL) // OB: ????
745 omFreeBinAddr((ADDRESS)pi->procname);
746
747 if( pi->language == LANG_SINGULAR)
748 {
749 if (pi->data.s.body != NULL) // OB: ????
750 omFree((ADDRESS)pi->data.s.body);
751 }
752 if( pi->language == LANG_C)
753 {
754 }
755 memset((void *) pi, 0, sizeof(procinfo));
756 //pi->language=LANG_NONE;
758 }
759 return FALSE;
760}
761
763{
764 (pack->ref)--;
765 if (pack->ref < 0)
766 {
767 if( pack->language == LANG_C)
768 {
769 Print("//dlclose(%s)\n",pack->libname);
770#ifdef HAVE_DYNAMIC_LOADING
771 dynl_close (pack->handle);
772#endif /* HAVE_DYNAMIC_LOADING */
773 }
774 omFreeBinAddr((ADDRESS)pack->libname);
775 memset((void *) pack, 0, sizeof(sip_package));
776 pack->language=LANG_NONE;
777 }
778}
779
780void proclevel::push(char *n)
781{
782 //Print("push %s\n",n);
784 p->name=n;
785 p->cPackHdl=currPackHdl;
786 p->cPack=currPack;
787 p->next=this;
788 procstack=p;
789}
791{
792 //Print("pop %s\n",name);
793 //if (currRing!=::currRing) PrintS("currRing wrong\n");;
794 //::currRing=this->currRing;
795 //if (r==NULL) Print("set ring to NULL at lev %d(%s)\n",myynest,name);
796 //::currRingHdl=this->currRingHdl;
797 //if((::currRingHdl==NULL)||(IDRING(::currRingHdl)!=(::currRing)))
798 // ::currRingHdl=rFindHdl(::currRing,NULL,NULL);
799 //Print("restore pack=%s,1.obj=%s\n",IDID(currPackHdl),IDID(currPack->idroot));
800 currPackHdl=this->cPackHdl;
801 currPack=this->cPack;
803 proclevel *p=this;
805 omFreeSize(p,sizeof(proclevel));
806}
807
809{
810 idhdl h=basePack->idroot;
811 while (h!=NULL)
812 {
813 if ((IDTYP(h)==PACKAGE_CMD)
814 && (IDPACKAGE(h)==r))
815 return h;
816 h=IDNEXT(h);
817 }
818 return NULL;
819}
820
822{
823 if (iiCurrArgs==NULL)
824 {
825 Werror("not enough arguments for proc %s",VoiceName());
826 p->CleanUp();
827 return TRUE;
828 }
830 iiCurrArgs=h->next;
831 h->next=NULL;
832 if (h->rtyp!=IDHDL)
833 {
835 h->CleanUp();
837 return res;
838 }
839 if ((h->Typ()!=p->Typ()) &&(p->Typ()!=DEF_CMD))
840 {
841 WerrorS("type mismatch");
842 return TRUE;
843 }
844 idhdl pp=(idhdl)p->data;
845 switch(pp->typ)
846 {
847 case CRING_CMD:
849 break;
850 case DEF_CMD:
851 case INT_CMD:
852 break;
853 case INTVEC_CMD:
854 case INTMAT_CMD:
855 delete IDINTVEC(pp);
856 break;
857 case NUMBER_CMD:
859 break;
860 case BIGINT_CMD:
862 break;
863 case MAP_CMD:
864 {
865 map im = IDMAP(pp);
866 omFreeBinAddr((ADDRESS)im->preimage);
867 im->preimage=NULL;// and continue
868 }
869 // continue as ideal:
870 case IDEAL_CMD:
871 case MODUL_CMD:
872 case MATRIX_CMD:
874 break;
875 case PROC_CMD:
876 case RESOLUTION_CMD:
877 case STRING_CMD:
879 break;
880 case LIST_CMD:
881 IDLIST(pp)->Clean();
882 break;
883 case LINK_CMD:
885 break;
886 // case ring: cannot happen
887 default:
888 {
889 int t=p->Typ();
890 if (t<MAX_TOK)
891 {
892 Werror("unknown type %d(%s)",t,Tok2Cmdname(t));
893 return TRUE;
894 }
895 /*else: blackbox type, not yet set*/
896 break;
897 }
898 }
899 pp->typ=ALIAS_CMD;
900 IDDATA(pp)=(char*)h->data;
901 int eff_typ=h->Typ();
902 if ((RingDependend(eff_typ))
903 || ((eff_typ==LIST_CMD) && (lRingDependend((lists)h->Data()))))
904 {
905 ipSwapId(pp,IDROOT,currRing->idroot);
906 }
907 h->CleanUp();
909 return FALSE;
910}
911
int BOOLEAN
Definition auxiliary.h:88
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
void * ADDRESS
Definition auxiliary.h:120
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:63
idhdl get_level(const char *s, int lev)
Definition ipid.cc:87
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
idrec()
Definition idrec.h:48
void pop()
Definition ipid.cc:790
void push(char *)
Definition ipid.cc:780
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:627
VAR omBin sip_package_bin
Definition ipid.cc:46
void paCleanUp(package pack)
Definition ipid.cc:762
static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
Definition ipid.cc:656
void killid(const char *id, idhdl *ih)
Definition ipid.cc:364
idhdl ggetid(const char *n)
Definition ipid.cc:558
void killhdl2(idhdl h, idhdl *ih, ring r)
Definition ipid.cc:422
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:56
VAR omBin idrec_bin
Definition ipid.cc:48
void ipListFlag(idhdl h)
Definition ipid.cc:596
VAR proclevel * procstack
Definition ipid.cc:50
VAR idhdl currRingHdl
Definition ipid.cc:57
VAR package currPack
Definition ipid.cc:55
BOOLEAN iiAlias(leftv p)
Definition ipid.cc:821
void killhdl(idhdl h, package proot)
Definition ipid.cc:391
void * idrecDataInit(int t)
Definition ipid.cc:116
VAR idhdl currPackHdl
Definition ipid.cc:53
idhdl packFindHdl(package r)
Definition ipid.cc:808
VAR idhdl basePackHdl
Definition ipid.cc:54
lists ipNameList(idhdl root)
Definition ipid.cc:604
void ipMoveId(idhdl tomove)
Definition ipid.cc:681
BOOLEAN piKill(procinfov pi)
Definition ipid.cc:724
const char * piProcinfo(procinfov pi, const char *request)
Definition ipid.cc:700
#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:1625
void rKill(ring r)
Definition ipshell.cc:6174
VAR leftv iiCurrArgs
Definition ipshell.cc:81
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: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 coeffs coeffs_BIGINT
Definition polys.cc:14
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:22
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:39
sleftv * leftv
Definition structs.h:53
#define loop
Definition structs.h:71
procinfo * procinfov
Definition structs.h:56
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