source: git/Singular/ipid.cc @ ea947e

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