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

fieker-DuValspielwiese
Last change on this file since 42a7cb4 was 951177, checked in by Hans Schoenemann <hannes@…>, 8 years ago
fix: crash at defining proc in .lib and .so twice (LIB"gfan.lib";LIB"gfan.lib";)
  • 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_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_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    #ifdef SINGULAR_4_1
194    case CRING_CMD:
195    #endif
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
498idhdl ggetid(const char *n, BOOLEAN /*local*/, idhdl *packhdl)
499{
500  idhdl h = IDROOT->get(n,myynest);
501  idhdl h2=NULL;
502  *packhdl = NULL;
503  if ((currRing!=NULL) && ((h==NULL)||(IDLEV(h)!=myynest)))
504  {
505    h2 = currRing->idroot->get(n,myynest);
506  }
507  if (h2==NULL) return h;
508  return h2;
509}
510
511idhdl ggetid(const char *n)
512{
513  idhdl h = IDROOT->get(n,myynest);
514  if ((h!=NULL)&&(IDLEV(h)==myynest)) return h;
515  idhdl h2=NULL;
516  if (currRing!=NULL)
517  {
518    h2 = currRing->idroot->get(n,myynest);
519  }
520  if (h2!=NULL) return h2;
521  if (h!=NULL) return h;
522  if (basePack!=currPack)
523    return basePack->idroot->get(n,myynest);
524  return NULL;
525}
526
527void ipListFlag(idhdl h)
528{
529  if (hasFlag(h,FLAG_STD)) PrintS(" (SB)");
530#ifdef HAVE_PLURAL
531  if (hasFlag(h,FLAG_TWOSTD)) PrintS(" (2SB)");
532#endif
533}
534
535lists ipNameList(idhdl root)
536{
537  idhdl h=root;
538  /* compute the length */
539  int l=0;
540  while (h!=NULL) { l++; h=IDNEXT(h); }
541  /* allocate list */
542  lists L=(lists)omAllocBin(slists_bin);
543  L->Init(l);
544  /* copy names */
545  h=root;
546  l=0;
547  while (h!=NULL)
548  {
549    /* list is initialized with 0 => no need to clear anything */
550    L->m[l].rtyp=STRING_CMD;
551    L->m[l].data=omStrDup(IDID(h));
552    l++;
553    h=IDNEXT(h);
554  }
555  return L;
556}
557
558lists ipNameListLev(idhdl root, int lev)
559{
560  idhdl h=root;
561  /* compute the length */
562  int l=0;
563  while (h!=NULL) { if (IDLEV(h)==lev) l++; h=IDNEXT(h); }
564  /* allocate list */
565  lists L=(lists)omAllocBin(slists_bin);
566  L->Init(l);
567  /* copy names */
568  h=root;
569  l=0;
570  while (h!=NULL)
571  {
572    if (IDLEV(h)==lev)
573    {
574      /* list is initialized with 0 => no need to clear anything */
575      L->m[l].rtyp=STRING_CMD;
576      L->m[l].data=omStrDup(IDID(h));
577      l++;
578    }
579    h=IDNEXT(h);
580  }
581  return L;
582}
583
584/*
585* move 'tomove' from root1 list to root2 list
586*/
587static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
588{
589  idhdl h;
590  /* search 'tomove' in root2 : if found -> do nothing */
591  h=root2;
592  while ((h!=NULL) && (h!=tomove)) h=IDNEXT(h);
593  if (h!=NULL) return FALSE; /*okay */
594  /* search predecessor of h in root1, remove 'tomove' */
595  h=root1;
596  if (tomove==h)
597  {
598    root1=IDNEXT(h);
599  }
600  else
601  {
602    while ((h!=NULL) && (IDNEXT(h)!=tomove)) h=IDNEXT(h);
603    if (h==NULL) return TRUE; /* not in the list root1 -> do nothing */
604    IDNEXT(h)=IDNEXT(tomove);
605  }
606  /* add to root2 list */
607  IDNEXT(tomove)=root2;
608  root2=tomove;
609  return FALSE;
610}
611
612void  ipMoveId(idhdl tomove)
613{
614  if ((currRing!=NULL)&&(tomove!=NULL))
615  {
616    if (RingDependend(IDTYP(tomove))
617    || ((IDTYP(tomove)==LIST_CMD) && (lRingDependend(IDLIST(tomove)))))
618    {
619      /*move 'tomove' to ring id's*/
620      if (ipSwapId(tomove,IDROOT,currRing->idroot))
621      ipSwapId(tomove,basePack->idroot,currRing->idroot);
622    }
623    else
624    {
625      /*move 'tomove' to global id's*/
626      ipSwapId(tomove,currRing->idroot,IDROOT);
627    }
628  }
629}
630
631const char * piProcinfo(procinfov pi, const char *request)
632{
633  if((pi == NULL)||(pi->language==LANG_NONE)) return "empty proc";
634  else if (strcmp(request, "libname")  == 0) return pi->libname;
635  else if (strcmp(request, "procname") == 0) return pi->procname;
636  else if (strcmp(request, "type")     == 0)
637  {
638    switch (pi->language)
639    {
640      case LANG_SINGULAR: return "singular"; break;
641      case LANG_C:        return "object";   break;
642      case LANG_NONE:     return "none";     break;
643      default:            return "unknown language";
644    }
645  }
646  else if (strcmp(request, "ref")      == 0)
647  {
648    char p[8];
649    sprintf(p, "%d", pi->ref);
650    return omStrDup(p);  // MEMORY-LEAK
651  }
652  return "??";
653}
654
655BOOLEAN piKill(procinfov pi)
656{
657  (pi->ref)--;
658  if (pi->ref == 0)
659  {
660    if (pi->language==LANG_SINGULAR)
661    {
662      Voice *p=currentVoice;
663      while (p!=NULL)
664      {
665        if (p->pi==pi && pi->ref <= 1)
666        {
667          Warn("`%s` in use, can not be killed",pi->procname);
668          return TRUE;
669        }
670        p=p->next;
671      }
672    }
673    if (pi->libname != NULL) // OB: ????
674      omFree((ADDRESS)pi->libname);
675    if (pi->procname != NULL) // OB: ????
676      omFree((ADDRESS)pi->procname);
677
678    if( pi->language == LANG_SINGULAR)
679    {
680      if (pi->data.s.body != NULL) // OB: ????
681        omFree((ADDRESS)pi->data.s.body);
682    }
683    if( pi->language == LANG_C)
684    {
685    }
686    memset((void *) pi, 0, sizeof(procinfo));
687    //pi->language=LANG_NONE;
688    omFreeBin((ADDRESS)pi,  procinfo_bin);
689  }
690  return FALSE;
691}
692
693void paCleanUp(package pack)
694{
695  (pack->ref)--;
696  if (pack->ref < 0)
697  {
698#ifndef HAVE_STATIC
699    if( pack->language == LANG_C)
700    {
701      Print("//dlclose(%s)\n",pack->libname);
702#ifdef HAVE_DYNAMIC_LOADING
703      dynl_close (pack->handle);
704#endif /* HAVE_DYNAMIC_LOADING */
705    }
706#endif /* HAVE_STATIC */
707    omFree((ADDRESS)pack->libname);
708    memset((void *) pack, 0, sizeof(sip_package));
709    pack->language=LANG_NONE;
710  }
711}
712
713void proclevel::push(char *n)
714{
715  //Print("push %s\n",n);
716  proclevel *p=(proclevel*)omAlloc0(sizeof(proclevel));
717  p->name=n;
718  p->cPackHdl=currPackHdl;
719  p->cPack=currPack;
720  p->next=this;
721  procstack=p;
722}
723void proclevel::pop()
724{
725  //Print("pop %s\n",name);
726  //if (currRing!=::currRing) PrintS("currRing wrong\n");;
727  //::currRing=this->currRing;
728  //if (r==NULL) Print("set ring to NULL at lev %d(%s)\n",myynest,name);
729  //::currRingHdl=this->currRingHdl;
730  //if((::currRingHdl==NULL)||(IDRING(::currRingHdl)!=(::currRing)))
731  //  ::currRingHdl=rFindHdl(::currRing,NULL,NULL);
732  //Print("restore pack=%s,1.obj=%s\n",IDID(currPackHdl),IDID(currPack->idroot));
733  currPackHdl=this->cPackHdl;
734  currPack=this->cPack;
735  iiCheckPack(currPack);
736  proclevel *p=this;
737  procstack=next;
738  omFreeSize(p,sizeof(proclevel));
739}
740
741idhdl packFindHdl(package r)
742{
743  idhdl h=basePack->idroot;
744  while (h!=NULL)
745  {
746    if ((IDTYP(h)==PACKAGE_CMD)
747        && (IDPACKAGE(h)==r))
748      return h;
749    h=IDNEXT(h);
750  }
751  return NULL;
752}
753
754BOOLEAN iiAlias(leftv p)
755{
756  if (iiCurrArgs==NULL)
757  {
758    Werror("not enough arguments for proc %s",VoiceName());
759    p->CleanUp();
760    return TRUE;
761  }
762  leftv h=iiCurrArgs;
763  iiCurrArgs=h->next;
764  h->next=NULL;
765  if (h->rtyp!=IDHDL)
766  {
767    BOOLEAN res=iiAssign(p,h);
768    h->CleanUp();
769    omFreeBin((ADDRESS)h, sleftv_bin);
770    return res;
771  }
772  if ((h->Typ()!=p->Typ()) &&(p->Typ()!=DEF_CMD))
773  {
774    WerrorS("type mismatch");
775    return TRUE;
776  }
777  idhdl pp=(idhdl)p->data;
778  switch(pp->typ)
779  {
780#ifdef SINGULAR_4_1
781      case CRING_CMD:
782        nKillChar((coeffs)pp);
783        break;
784#endif
785      case DEF_CMD:
786      case INT_CMD:
787        break;
788      case INTVEC_CMD:
789      case INTMAT_CMD:
790         delete IDINTVEC(pp);
791         break;
792      case NUMBER_CMD:
793         nDelete(&IDNUMBER(pp));
794         break;
795      case BIGINT_CMD:
796         n_Delete(&IDNUMBER(pp),coeffs_BIGINT);
797         break;
798      case MAP_CMD:
799         {
800           map im = IDMAP(pp);
801           omFree((ADDRESS)im->preimage);
802         }
803         // continue as ideal:
804      case IDEAL_CMD:
805      case MODUL_CMD:
806      case MATRIX_CMD:
807          idDelete(&IDIDEAL(pp));
808         break;
809      case PROC_CMD:
810      case RESOLUTION_CMD:
811      case STRING_CMD:
812         omFree((ADDRESS)IDSTRING(pp));
813         break;
814      case LIST_CMD:
815         IDLIST(pp)->Clean();
816         break;
817      case LINK_CMD:
818         omFreeBin(IDLINK(pp),sip_link_bin);
819         break;
820       // case ring: cannot happen
821       default:
822         Werror("unknown type %d",p->Typ());
823         return TRUE;
824  }
825  pp->typ=ALIAS_CMD;
826  IDDATA(pp)=(char*)h->data;
827  int eff_typ=h->Typ();
828  if ((RingDependend(eff_typ))
829  || ((eff_typ==LIST_CMD) && (lRingDependend((lists)h->Data()))))
830  {
831    ipSwapId(pp,IDROOT,currRing->idroot);
832  }
833  h->CleanUp();
834  omFreeBin((ADDRESS)h, sleftv_bin);
835  return FALSE;
836}
837
Note: See TracBrowser for help on using the repository browser.