source: git/Singular/ipid.cc @ 42f46c

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