source: git/Singular/ipid.cc @ f6b8d2e

fieker-DuValspielwiese
Last change on this file since f6b8d2e was d2fc5c5, checked in by Hans Schoenemann <hannes@…>, 8 years ago
removed unused test for QRING_CMD
  • Property mode set to 100644
File size: 18.0 KB
Line 
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 <omalloc/omalloc.h>
16
17#include <misc/options.h>
18#include <misc/intvec.h>
19
20#include <coeffs/numbers.h>
21#include <coeffs/bigintmat.h>
22
23#include <polys/matpol.h>
24#include <polys/monomials/ring.h>
25
26#include <kernel/polys.h>
27#include <kernel/ideals.h>
28#include <kernel/GBEngine/syz.h>
29
30#include <Singular/tok.h>
31#include <Singular/ipshell.h>
32#include <Singular/fevoices.h>
33#include <Singular/lists.h>
34#include <Singular/attrib.h>
35#include <Singular/links/silink.h>
36#include <Singular/ipid.h>
37#include <Singular/blackbox.h>
38#include <Singular/number2.h>
39
40#ifdef SINGULAR_4_1
41#include <Singular/number2.h>
42#endif
43#ifdef HAVE_DYNAMIC_LOADING
44#include <polys/mod_raw.h>
45#endif /* HAVE_DYNAMIC_LOADING */
46
47#include <string.h>
48
49omBin sip_command_bin = omGetSpecBin(sizeof(sip_command));
50omBin sip_package_bin = omGetSpecBin(sizeof(sip_package));
51//omBin ip_package_bin = omGetSpecBin(sizeof(ip_package));
52omBin idrec_bin = omGetSpecBin(sizeof(idrec));
53
54coeffs coeffs_BIGINT;
55
56FILE   *feFilePending; /*temp. storage for grammar.y */
57
58proclevel *procstack=NULL;
59//idhdl idroot = NULL;
60
61idhdl currPackHdl = NULL;
62idhdl basePackHdl = NULL;
63package currPack =NULL;
64package basePack =NULL;
65idhdl currRingHdl = NULL;
66const char* iiNoName="_";
67
68void paCleanUp(package pack);
69
70/*0 implementation*/
71
72int iiS2I(const char *s)
73{
74  int i;
75  i=s[0];
76  if (s[1]!='\0')
77  {
78    i=(i<<8)+s[1];
79    if (s[2]!='\0')
80    {
81      i=(i<<8)+s[2];
82      if (s[3]!='\0')
83      {
84        i=(i<<8)+s[3];
85      }
86    }
87  }
88  return i;
89}
90
91idhdl idrec::get(const char * s, int level)
92{
93  assume(s!=NULL);
94  assume((level>=0) && (level<=1000)); //not really, but if it isnt in that bounds..
95  idhdl h = this;
96  idhdl found=NULL;
97  int l;
98  const char *id_;
99  int i=iiS2I(s);
100  int less4=(i < (1<<24));
101  while (h!=NULL)
102  {
103    omCheckAddr((ADDRESS)IDID(h));
104    l=IDLEV(h);
105    if ((l==0)||(l==level))
106    {
107      if (i==h->id_i)
108      {
109        id_=IDID(h);
110        if (less4 || (0 == strcmp(s+4,id_+4)))
111        {
112          if (l==level) return h;
113          found=h;
114        }
115      }
116    }
117    h = IDNEXT(h);
118  }
119  return found;
120}
121
122//idrec::~idrec()
123//{
124//  if (id!=NULL)
125//  {
126//    omFree((ADDRESS)id);
127//    id=NULL;
128//  }
129//  /* much more !! */
130//}
131
132void *idrecDataInit(int t)
133{
134  switch (t)
135  {
136    //the type with init routines:
137#ifdef SINGULAR_4_1
138    case CNUMBER_CMD:
139      return (void*)n2Init(0,NULL);
140    case CMATRIX_CMD:
141#endif
142    case BIGINTMAT_CMD:
143      return (void *)new bigintmat();
144    case INTVEC_CMD:
145    case INTMAT_CMD:
146      return (void *)new intvec();
147    case NUMBER_CMD:
148      return (void *) nInit(0);
149    case BIGINT_CMD:
150      return (void *) n_Init(0, coeffs_BIGINT);
151    case IDEAL_CMD:
152    case MODUL_CMD:
153    case MATRIX_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    {
165      lists l=(lists)omAllocBin(slists_bin);
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 RING_CMD:
173      return NULL;
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    {
183      procinfov pi=(procinfov)omAlloc0Bin(procinfo_bin);
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 init (int,script,poly,def,package)
191    #ifdef SINGULAR_4_1
192    case CRING_CMD:
193    #endif
194    case INT_CMD:
195    case DEF_CMD:
196    case POLY_CMD:
197    case VECTOR_CMD:
198    case QRING_CMD:
199       return (void*)0L;
200    default:
201      {
202        if (t>MAX_TOK)
203        {
204#ifdef BLACKBOX_DEVEL
205          Print("bb-type %d\n",t);
206#endif
207          blackbox *bb=getBlackboxStuff(t);
208          if (bb!=NULL)
209             return (void *)bb->blackbox_Init(bb);
210        }
211        else
212          Werror("unknown type in idrecDataInit:%d",t);
213        break;
214      }
215  }
216  return (void *)0L;
217}
218idhdl idrec::set(const char * s, int level, int t, BOOLEAN init)
219{
220  //printf("define %s, %x, level: %d, typ: %d\n", s,s,level,t);
221  idhdl h = (idrec *)omAlloc0Bin(idrec_bin);
222  IDID(h)   = s;
223  IDTYP(h)  = t;
224  IDLEV(h)  = level;
225  IDNEXT(h) = this;
226  BOOLEAN at_start=(this==IDROOT);
227  h->id_i=iiS2I(s);
228  if (init)
229  {
230    if ((t==IDEAL_CMD)||(t==MODUL_CMD))
231      IDFLAG(h) = Sy_bit(FLAG_STD);
232    IDSTRING(h)=(char *)idrecDataInit(t);
233    // additional settings:--------------------------------------
234#if 0
235    // this leads to a memory leak
236    if (t == QRING_CMD)
237    {
238      // IDRING(h)=rCopy(currRing);
239      /* QRING_CMD is ring dep => currRing !=NULL */
240    }
241#endif
242  }
243  // --------------------------------------------------------
244  if (at_start)
245    IDNEXT(h) = IDROOT;
246  return  h;
247}
248
249char * idrec::String(BOOLEAN typed)
250{
251  sleftv tmp;
252  memset(&tmp,0,sizeof(sleftv));
253  tmp.rtyp=IDTYP(this);
254  tmp.data=IDDATA(this);
255  tmp.name=IDID(this);
256  return tmp.String(NULL, typed);
257}
258
259idhdl enterid(const char * s, int lev, int t, idhdl* root, BOOLEAN init, BOOLEAN search)
260{
261  if (s==NULL) return NULL;
262  if (root==NULL) return NULL;
263  idhdl h;
264  s=omStrDup(s);
265  // idhdl *save_root=root;
266  if (t==PACKAGE_CMD)
267  {
268    if (root!=&(basePack->idroot))
269    {
270      root=&(basePack->idroot);
271    }
272  }
273  // is it already defined in root ?
274  if ((h=(*root)->get(s,lev))!=NULL)
275  {
276    if (IDLEV(h)==lev)
277    {
278      if ((IDTYP(h) == t)||(t==DEF_CMD))
279      {
280        if ((IDTYP(h)==PACKAGE_CMD)
281        && (strcmp(s,"Top")==0))
282        {
283          goto errlabel;
284        }
285        if (BVERBOSE(V_REDEFINE))
286          Warn("redefining %s (%s)",s,my_yylinebuf);
287        if (s==IDID(h)) IDID(h)=NULL;
288        killhdl2(h,root,currRing);
289      }
290      else
291        goto errlabel;
292    }
293  }
294  // is it already defined in currRing->idroot ?
295  else if (search && (currRing!=NULL)&&((*root) != currRing->idroot))
296  {
297    if ((h=currRing->idroot->get(s,lev))!=NULL)
298    {
299      if (IDLEV(h)==lev)
300      {
301        if ((IDTYP(h) == t)||(t==DEF_CMD))
302        {
303          if (BVERBOSE(V_REDEFINE))
304            Warn("redefining %s (%s)",s,my_yylinebuf);
305          if (s==IDID(h)) IDID(h)=NULL;
306          killhdl2(h,&currRing->idroot,currRing);
307        }
308        else
309          goto errlabel;
310      }
311    }
312  }
313  // is it already defined in idroot ?
314  else if (search && (*root != IDROOT))
315  {
316    if ((h=IDROOT->get(s,lev))!=NULL)
317    {
318      if (IDLEV(h)==lev)
319      {
320        if ((IDTYP(h) == t)||(t==DEF_CMD))
321        {
322          if (BVERBOSE(V_REDEFINE))
323            Warn("redefining %s (%s)",s,my_yylinebuf);
324          if (s==IDID(h)) IDID(h)=NULL;
325          killhdl2(h,&IDROOT,NULL);
326        }
327        else
328          goto errlabel;
329      }
330    }
331  }
332  *root = (*root)->set(s, lev, t, init);
333#ifndef SING_NDEBUG
334  checkall();
335#endif
336  return *root;
337
338  errlabel:
339    //Werror("identifier `%s` in use(lev h=%d,typ=%d,t=%d, curr=%d)",s,IDLEV(h),IDTYP(h),t,lev);
340    Werror("identifier `%s` in use",s);
341    //listall();
342    omFree((ADDRESS)s);
343    return NULL;
344}
345void killid(const char * id, idhdl * ih)
346{
347  if (id!=NULL)
348  {
349    idhdl h = (*ih)->get(id,myynest);
350
351    // id not found in global list, is it defined in current ring ?
352    if (h==NULL)
353    {
354      if ((currRing!=NULL) && (*ih != (currRing->idroot)))
355      {
356        h = currRing->idroot->get(id,myynest);
357        if (h!=NULL)
358        {
359          killhdl2(h,&(currRing->idroot),currRing);
360          return;
361        }
362      }
363      Werror("`%s` is not defined",id);
364      return;
365    }
366    killhdl2(h,ih,currRing);
367  }
368  else
369    WerrorS("kill what ?");
370}
371
372void killhdl(idhdl h, package proot)
373{
374  int t=IDTYP(h);
375  if (((BEGIN_RING<t) && (t<END_RING))
376  || ((t==LIST_CMD) && (lRingDependend((lists)IDDATA(h)))))
377    killhdl2(h,&currRing->idroot,currRing);
378  else
379  {
380    if(t==PACKAGE_CMD)
381    {
382      killhdl2(h,&(basePack->idroot),NULL);
383    }
384    else
385    {
386      idhdl s=proot->idroot;
387      while ((s!=h) && (s!=NULL)) s=s->next;
388      if (s!=NULL)
389        killhdl2(h,&(proot->idroot),NULL);
390      else if (basePack!=proot)
391      {
392        idhdl s=basePack->idroot;
393        while ((s!=h) && (s!=NULL)) s=s->next;
394        if (s!=NULL)
395          killhdl2(h,&(basePack->idroot),currRing);
396        else
397          killhdl2(h,&(currRing->idroot),currRing);
398       }
399    }
400  }
401}
402
403void killhdl2(idhdl h, idhdl * ih, ring r)
404{
405  //printf("kill %s, id %x, typ %d lev: %d\n",IDID(h),(int)IDID(h),IDTYP(h),IDLEV(h));
406  idhdl hh;
407
408  if (TEST_V_ALLWARN
409  && (IDLEV(h)!=myynest)
410  &&(IDLEV(h)==0))
411  {
412    if (((*ih)==basePack->idroot)
413    || ((currRing!=NULL)&&((*ih)==currRing->idroot)))
414      Warn("kill global `%s` at line >>%s<<\n",IDID(h),my_yylinebuf);
415  }
416  if (h->attribute!=NULL)
417  {
418    //h->attribute->killAll(r); MEMORY LEAK!
419    h->attribute=NULL;
420  }
421  if (IDTYP(h) == PACKAGE_CMD)
422  {
423    if (strcmp(IDID(h),"Top")==0)
424    {
425      WarnS("can not kill `Top`");
426      return;
427    }
428    // any objects defined for this package ?
429    if ((IDPACKAGE(h)->ref<=0)  &&  (IDPACKAGE(h)->idroot!=NULL))
430    {
431      if (currPack==IDPACKAGE(h))
432      {
433        currPack=basePack;
434        currPackHdl=NULL;
435      }
436      idhdl * hd = &IDRING(h)->idroot;
437      idhdl  hdh = IDNEXT(*hd);
438      idhdl  temp;
439      while (hdh!=NULL)
440      {
441        temp = IDNEXT(hdh);
442        killhdl2(hdh,&(IDPACKAGE(h)->idroot),NULL);
443        hdh = temp;
444      }
445      killhdl2(*hd,hd,NULL);
446      if (IDPACKAGE(h)->libname!=NULL) omFree((ADDRESS)(IDPACKAGE(h)->libname));
447    }
448    paKill(IDPACKAGE(h));
449    if (currPackHdl==h) currPackHdl=packFindHdl(currPack);
450    iiCheckPack(currPack);
451  }
452  else if (IDTYP(h)==RING_CMD)
453    rKill(h);
454  else if (IDDATA(h)!=NULL)
455    s_internalDelete(IDTYP(h),IDDATA(h),r);
456  //  general  -------------------------------------------------------------
457  // now dechain it and delete idrec
458  if (IDID(h)!=NULL) // OB: ?????
459    omFree((ADDRESS)IDID(h));
460  IDID(h)=NULL;
461  IDDATA(h)=NULL;
462  if (h == (*ih))
463  {
464    // h is at the beginning of the list
465    *ih = IDNEXT(h) /* ==*ih */;
466  }
467  else if (ih!=NULL)
468  {
469    // h is somethere in the list:
470    hh = *ih;
471    loop
472    {
473      if (hh==NULL)
474      {
475        PrintS(">>?<< not found for kill\n");
476        return;
477      }
478      idhdl hhh = IDNEXT(hh);
479      if (hhh == h)
480      {
481        IDNEXT(hh) = IDNEXT(hhh);
482        break;
483      }
484      hh = hhh;
485    }
486  }
487  omFreeBin((ADDRESS)h, idrec_bin);
488}
489
490idhdl ggetid(const char *n, BOOLEAN /*local*/, idhdl *packhdl)
491{
492  idhdl h = IDROOT->get(n,myynest);
493  idhdl h2=NULL;
494  *packhdl = NULL;
495  if ((currRing!=NULL) && ((h==NULL)||(IDLEV(h)!=myynest)))
496  {
497    h2 = currRing->idroot->get(n,myynest);
498  }
499  if (h2==NULL) return h;
500  return h2;
501}
502
503idhdl ggetid(const char *n)
504{
505  idhdl h = IDROOT->get(n,myynest);
506  if ((h!=NULL)&&(IDLEV(h)==myynest)) return h;
507  idhdl h2=NULL;
508  if (currRing!=NULL)
509  {
510    h2 = currRing->idroot->get(n,myynest);
511  }
512  if (h2!=NULL) return h2;
513  if (h!=NULL) return h;
514  if (basePack!=currPack)
515    return basePack->idroot->get(n,myynest);
516  return NULL;
517}
518
519void ipListFlag(idhdl h)
520{
521  if (hasFlag(h,FLAG_STD)) PrintS(" (SB)");
522#ifdef HAVE_PLURAL
523  if (hasFlag(h,FLAG_TWOSTD)) PrintS(" (2SB)");
524#endif
525}
526
527lists ipNameList(idhdl root)
528{
529  idhdl h=root;
530  /* compute the length */
531  int l=0;
532  while (h!=NULL) { l++; h=IDNEXT(h); }
533  /* allocate list */
534  lists L=(lists)omAllocBin(slists_bin);
535  L->Init(l);
536  /* copy names */
537  h=root;
538  l=0;
539  while (h!=NULL)
540  {
541    /* list is initialized with 0 => no need to clear anything */
542    L->m[l].rtyp=STRING_CMD;
543    L->m[l].data=omStrDup(IDID(h));
544    l++;
545    h=IDNEXT(h);
546  }
547  return L;
548}
549
550lists ipNameListLev(idhdl root, int lev)
551{
552  idhdl h=root;
553  /* compute the length */
554  int l=0;
555  while (h!=NULL) { if (IDLEV(h)==lev) l++; h=IDNEXT(h); }
556  /* allocate list */
557  lists L=(lists)omAllocBin(slists_bin);
558  L->Init(l);
559  /* copy names */
560  h=root;
561  l=0;
562  while (h!=NULL)
563  {
564    if (IDLEV(h)==lev)
565    {
566      /* list is initialized with 0 => no need to clear anything */
567      L->m[l].rtyp=STRING_CMD;
568      L->m[l].data=omStrDup(IDID(h));
569      l++;
570    }
571    h=IDNEXT(h);
572  }
573  return L;
574}
575
576/*
577* move 'tomove' from root1 list to root2 list
578*/
579static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
580{
581  idhdl h;
582  /* search 'tomove' in root2 : if found -> do nothing */
583  h=root2;
584  while ((h!=NULL) && (h!=tomove)) h=IDNEXT(h);
585  if (h!=NULL) return FALSE; /*okay */
586  /* search predecessor of h in root1, remove 'tomove' */
587  h=root1;
588  if (tomove==h)
589  {
590    root1=IDNEXT(h);
591  }
592  else
593  {
594    while ((h!=NULL) && (IDNEXT(h)!=tomove)) h=IDNEXT(h);
595    if (h==NULL) return TRUE; /* not in the list root1 -> do nothing */
596    IDNEXT(h)=IDNEXT(tomove);
597  }
598  /* add to root2 list */
599  IDNEXT(tomove)=root2;
600  root2=tomove;
601  return FALSE;
602}
603
604void  ipMoveId(idhdl tomove)
605{
606  if ((currRing!=NULL)&&(tomove!=NULL))
607  {
608    if (RingDependend(IDTYP(tomove))
609    || ((IDTYP(tomove)==LIST_CMD) && (lRingDependend(IDLIST(tomove)))))
610    {
611      /*move 'tomove' to ring id's*/
612      if (ipSwapId(tomove,IDROOT,currRing->idroot))
613      ipSwapId(tomove,basePack->idroot,currRing->idroot);
614    }
615    else
616    {
617      /*move 'tomove' to global id's*/
618      ipSwapId(tomove,currRing->idroot,IDROOT);
619    }
620  }
621}
622
623const char * piProcinfo(procinfov pi, const char *request)
624{
625  if((pi == NULL)||(pi->language==LANG_NONE)) return "empty proc";
626  else if (strcmp(request, "libname")  == 0) return pi->libname;
627  else if (strcmp(request, "procname") == 0) return pi->procname;
628  else if (strcmp(request, "type")     == 0)
629  {
630    switch (pi->language)
631    {
632      case LANG_SINGULAR: return "singular"; break;
633      case LANG_C:        return "object";   break;
634      case LANG_NONE:     return "none";     break;
635      default:            return "unknown language";
636    }
637  }
638  else if (strcmp(request, "ref")      == 0)
639  {
640    char p[8];
641    sprintf(p, "%d", pi->ref);
642    return omStrDup(p);  // MEMORY-LEAK
643  }
644  return "??";
645}
646
647BOOLEAN piKill(procinfov pi)
648{
649  Voice *p=currentVoice;
650  while (p!=NULL)
651  {
652    if (p->pi==pi && pi->ref <= 1)
653    {
654      Warn("`%s` in use, can not be killed",pi->procname);
655      return TRUE;
656    }
657    p=p->next;
658  }
659  (pi->ref)--;
660  if (pi->ref <= 0)
661  {
662    if (pi->libname != NULL) // OB: ????
663      omFree((ADDRESS)pi->libname);
664    if (pi->procname != NULL) // OB: ????
665      omFree((ADDRESS)pi->procname);
666
667    if( pi->language == LANG_SINGULAR)
668    {
669      if (pi->data.s.body != NULL) // OB: ????
670        omFree((ADDRESS)pi->data.s.body);
671    }
672    if( pi->language == LANG_C)
673    {
674    }
675    memset((void *) pi, 0, sizeof(procinfo));
676    pi->language=LANG_NONE;
677    omFreeBin((ADDRESS)pi,  procinfo_bin);
678  }
679  return FALSE;
680}
681
682void paCleanUp(package pack)
683{
684  (pack->ref)--;
685  if (pack->ref < 0)
686  {
687#ifndef HAVE_STATIC
688    if( pack->language == LANG_C)
689    {
690      Print("//dlclose(%s)\n",pack->libname);
691#ifdef HAVE_DYNAMIC_LOADING
692      dynl_close (pack->handle);
693#endif /* HAVE_DYNAMIC_LOADING */
694    }
695#endif /* HAVE_STATIC */
696    omFree((ADDRESS)pack->libname);
697    memset((void *) pack, 0, sizeof(sip_package));
698    pack->language=LANG_NONE;
699  }
700}
701
702void proclevel::push(char *n)
703{
704  //Print("push %s\n",n);
705  proclevel *p=(proclevel*)omAlloc0(sizeof(proclevel));
706  p->name=n;
707  p->cPackHdl=currPackHdl;
708  p->cPack=currPack;
709  p->next=this;
710  procstack=p;
711}
712void proclevel::pop()
713{
714  //Print("pop %s\n",name);
715  //if (currRing!=::currRing) PrintS("currRing wrong\n");;
716  //::currRing=this->currRing;
717  //if (r==NULL) Print("set ring to NULL at lev %d(%s)\n",myynest,name);
718  //::currRingHdl=this->currRingHdl;
719  //if((::currRingHdl==NULL)||(IDRING(::currRingHdl)!=(::currRing)))
720  //  ::currRingHdl=rFindHdl(::currRing,NULL,NULL);
721  //Print("restore pack=%s,1.obj=%s\n",IDID(currPackHdl),IDID(currPack->idroot));
722  currPackHdl=this->cPackHdl;
723  currPack=this->cPack;
724  iiCheckPack(currPack);
725  proclevel *p=this;
726  procstack=next;
727  omFreeSize(p,sizeof(proclevel));
728}
729
730idhdl packFindHdl(package r)
731{
732  idhdl h=basePack->idroot;
733  while (h!=NULL)
734  {
735    if ((IDTYP(h)==PACKAGE_CMD)
736        && (IDPACKAGE(h)==r))
737      return h;
738    h=IDNEXT(h);
739  }
740  return NULL;
741}
742
743BOOLEAN iiAlias(leftv p)
744{
745  if (iiCurrArgs==NULL)
746  {
747    Werror("not enough arguments for proc %s",VoiceName());
748    p->CleanUp();
749    return TRUE;
750  }
751  leftv h=iiCurrArgs;
752  iiCurrArgs=h->next;
753  h->next=NULL;
754  if (h->rtyp!=IDHDL)
755  {
756    BOOLEAN res=iiAssign(p,h);
757    h->CleanUp();
758    omFreeBin((ADDRESS)h, sleftv_bin);
759    return res;
760  }
761  if ((h->Typ()!=p->Typ()) &&(p->Typ()!=DEF_CMD))
762  {
763    WerrorS("type mismatch");
764    return TRUE;
765  }
766  idhdl pp=(idhdl)p->data;
767  switch(pp->typ)
768  {
769#ifdef SINGULAR_4_1
770      case CRING_CMD:
771        nKillChar((coeffs)pp);
772        break;
773#endif
774      case DEF_CMD:
775      case INT_CMD:
776        break;
777      case INTVEC_CMD:
778      case INTMAT_CMD:
779         delete IDINTVEC(pp);
780         break;
781      case NUMBER_CMD:
782         nDelete(&IDNUMBER(pp));
783         break;
784      case BIGINT_CMD:
785         n_Delete(&IDNUMBER(pp),coeffs_BIGINT);
786         break;
787      case MAP_CMD:
788         {
789           map im = IDMAP(pp);
790           omFree((ADDRESS)im->preimage);
791         }
792         // continue as ideal:
793      case IDEAL_CMD:
794      case MODUL_CMD:
795      case MATRIX_CMD:
796          idDelete(&IDIDEAL(pp));
797         break;
798      case PROC_CMD:
799      case RESOLUTION_CMD:
800      case STRING_CMD:
801         omFree((ADDRESS)IDSTRING(pp));
802         break;
803      case LIST_CMD:
804         IDLIST(pp)->Clean();
805         break;
806      case LINK_CMD:
807         omFreeBin(IDLINK(pp),sip_link_bin);
808         break;
809       // case ring: cannot happen
810       default:
811         Werror("unknown type %d",p->Typ());
812         return TRUE;
813  }
814  pp->typ=ALIAS_CMD;
815  IDDATA(pp)=(char*)h->data;
816  int eff_typ=h->Typ();
817  if ((RingDependend(eff_typ))
818  || ((eff_typ==LIST_CMD) && (lRingDependend((lists)h->Data()))))
819  {
820    ipSwapId(pp,IDROOT,currRing->idroot);
821  }
822  h->CleanUp();
823  omFreeBin((ADDRESS)h, sleftv_bin);
824  return FALSE;
825}
826
Note: See TracBrowser for help on using the repository browser.