source: git/Singular/ipid.cc @ 086492f

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