source: git/Singular/ipid.cc @ 9ae5a3

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