source: git/Singular/ipid.cc @ f59519

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