source: git/Singular/ipid.cc @ 19fcc66

spielwiese
Last change on this file since 19fcc66 was 19fcc66, checked in by Hans Schönemann <hannes@…>, 14 years ago
code clean up git-svn-id: file:///usr/local/Singular/svn/trunk@12504 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, idtyp 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        IDSTRING(h) = omStrDup("");
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, idtyp 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)&&(IDTYP(h)!=DEF_CMD) && (IDTYP(h)!=NONE))
468    Warn("unknown type to kill: %s(%d)",Tok2Cmdname(IDTYP(h)),IDTYP(h));
469#endif
470
471  //  general  -------------------------------------------------------------
472  // now dechain it and delete idrec
473#ifdef KAI
474  if(h->next != NULL)
475    Print("=======>%s(%x) -> %s<====\n", IDID(h), IDID(h), IDID(h->next));
476  else
477    Print("=======>%s(%x)<====\n", IDID(h), IDID(h));
478#endif
479
480  if (IDID(h)!=NULL) // OB: ?????
481    omFree((ADDRESS)IDID(h));
482  IDID(h)=NULL;
483  IDDATA(h)=NULL;
484  if (h == (*ih))
485  {
486    // h is at the beginning of the list
487    *ih = IDNEXT(h) /* ==*ih */;
488  }
489  else if (ih!=NULL)
490  {
491    // h is somethere in the list:
492    hh = *ih;
493    loop
494    {
495      if (hh==NULL)
496      {
497        PrintS(">>?<< not found for kill\n");
498        return;
499      }
500      idhdl hhh = IDNEXT(hh);
501      if (hhh == h)
502      {
503        IDNEXT(hh) = IDNEXT(hhh);
504        break;
505      }
506      hh = hhh;
507    }
508  }
509  omFreeBin((ADDRESS)h, idrec_bin);
510}
511
512idhdl ggetid(const char *n, BOOLEAN local, idhdl *packhdl)
513{
514  idhdl h = IDROOT->get(n,myynest);
515  idhdl h2=NULL;
516  *packhdl = NULL;
517  if ((currRing!=NULL) && ((h==NULL)||(IDLEV(h)!=myynest)))
518  {
519    h2 = currRing->idroot->get(n,myynest);
520  }
521  if (h2==NULL) return h;
522  return h2;
523}
524
525idhdl ggetid(const char *n, BOOLEAN local)
526{
527  idhdl h = IDROOT->get(n,myynest);
528  if ((h!=NULL)&&(IDLEV(h)==myynest)) return h;
529  idhdl h2=NULL;
530  if (currRing!=NULL)
531  {
532    h2 = currRing->idroot->get(n,myynest);
533  }
534  if (h2!=NULL) return h2;
535  if (h!=NULL) return h;
536  if (basePack!=currPack)
537    return basePack->idroot->get(n,myynest);
538  return NULL;
539}
540
541void ipListFlag(idhdl h)
542{
543  if (hasFlag(h,FLAG_STD)) PrintS(" (SB)");
544#ifdef HAVE_PLURAL
545  if (hasFlag(h,FLAG_TWOSTD)) PrintS(" (2SB)");
546#endif
547}
548
549lists ipNameList(idhdl root)
550{
551  idhdl h=root;
552  /* compute the length */
553  int l=0;
554  while (h!=NULL) { l++; h=IDNEXT(h); }
555  /* allocate list */
556  lists L=(lists)omAllocBin(slists_bin);
557  L->Init(l);
558  /* copy names */
559  h=root;
560  l=0;
561  while (h!=NULL)
562  {
563    /* list is initialized with 0 => no need to clear anything */
564    L->m[l].rtyp=STRING_CMD;
565    L->m[l].data=omStrDup(IDID(h));
566    l++;
567    h=IDNEXT(h);
568  }
569  return L;
570}
571
572/*
573* move 'tomove' from root1 list to root2 list
574*/
575static int ipSwapId(idhdl tomove, idhdl &root1, idhdl &root2)
576{
577  idhdl h;
578  /* search 'tomove' in root2 : if found -> do nothing */
579  h=root2;
580  while ((h!=NULL) && (h!=tomove)) h=IDNEXT(h);
581  if (h!=NULL) return FALSE; /*okay */
582  /* search predecessor of h in root1, remove 'tomove' */
583  h=root1;
584  if (tomove==h)
585  {
586    root1=IDNEXT(h);
587  }
588  else
589  {
590    while ((h!=NULL) && (IDNEXT(h)!=tomove)) h=IDNEXT(h);
591    if (h==NULL) return TRUE; /* not in the list root1 -> do nothing */
592    IDNEXT(h)=IDNEXT(tomove);
593  }
594  /* add to root2 list */
595  IDNEXT(tomove)=root2;
596  root2=tomove;
597  return FALSE;
598}
599
600void  ipMoveId(idhdl tomove)
601{
602  if ((currRing!=NULL)&&(tomove!=NULL))
603  {
604    if (((QRING_CMD!=IDTYP(tomove)) && RingDependend(IDTYP(tomove)))
605    || ((IDTYP(tomove)==LIST_CMD) && (lRingDependend(IDLIST(tomove)))))
606    {
607      /*move 'tomove' to ring id's*/
608      if (ipSwapId(tomove,IDROOT,currRing->idroot))
609      ipSwapId(tomove,basePack->idroot,currRing->idroot);
610    }
611    else
612    {
613      /*move 'tomove' to global id's*/
614      ipSwapId(tomove,currRing->idroot,IDROOT);
615    }
616  }
617}
618
619const char * piProcinfo(procinfov pi, const char *request)
620{
621  if(pi == NULL) return "empty proc";
622  else if (strcmp(request, "libname")  == 0) return pi->libname;
623  else if (strcmp(request, "procname") == 0) return pi->procname;
624  else if (strcmp(request, "type")     == 0)
625  {
626    switch (pi->language)
627    {
628      case LANG_SINGULAR: return "singular"; break;
629      case LANG_C:        return "object";   break;
630      case LANG_NONE:     return "none";     break;
631      default:            return "unknow language";
632    }
633  }
634  else if (strcmp(request, "ref")      == 0)
635  {
636    char p[8];
637    sprintf(p, "%d", pi->ref);
638    return omStrDup(p);  // MEMORY-LEAK
639  }
640  return "??";
641}
642
643void piCleanUp(procinfov pi)
644{
645  (pi->ref)--;
646  if (pi->ref <= 0)
647  {
648    if (pi->libname != NULL) // OB: ????
649      omFree((ADDRESS)pi->libname);
650    if (pi->procname != NULL) // OB: ????
651      omFree((ADDRESS)pi->procname);
652
653    if( pi->language == LANG_SINGULAR)
654    {
655      if (pi->data.s.body != NULL) // OB: ????
656        omFree((ADDRESS)pi->data.s.body);
657    }
658    if( pi->language == LANG_C)
659    {
660    }
661    memset((void *) pi, 0, sizeof(procinfo));
662    pi->language=LANG_NONE;
663  }
664}
665
666BOOLEAN piKill(procinfov pi)
667{
668  Voice *p=currentVoice;
669  while (p!=NULL)
670  {
671    if (p->pi==pi && pi->ref <= 1)
672    {
673      Warn("`%s` in use, can not be killed",pi->procname);
674      return TRUE;
675    }
676    p=p->next;
677  }
678  piCleanUp(pi);
679  if (pi->ref <= 0)
680    omFreeBin((ADDRESS)pi,  procinfo_bin);
681  return FALSE;
682}
683
684void paCleanUp(package pack)
685{
686  (pack->ref)--;
687  if (pack->ref < 0)
688  {
689#ifndef HAVE_STATIC
690    if( pack->language == LANG_C)
691    {
692      Print("//dlclose(%s)\n",pack->libname);
693#ifdef HAVE_DYNAMIC_LOADING
694      dynl_close (pack->handle);
695#endif /* HAVE_DYNAMIC_LOADING */
696    }
697#endif /* HAVE_STATIC */
698    omfree((ADDRESS)pack->libname);
699    memset((void *) pack, 0, sizeof(sip_package));
700    pack->language=LANG_NONE;
701  }
702}
703
704char *idhdl2id(idhdl pck, idhdl h)
705{
706  char *name = (char *)omAlloc(strlen(pck->id) + strlen(h->id) + 3);
707  sprintf(name, "%s::%s", pck->id, h->id);
708  return(name);
709}
710
711void iiname2hdl(const char *name, idhdl *pck, idhdl *h)
712{
713  const char *q = strchr(name, ':');
714  char *p, *i;
715
716  if(q==NULL)
717  {
718    p = omStrDup("");
719    i = (char *)omAlloc(strlen(name)+1);
720    *i = '\0';
721    sscanf(name, "%s", i);
722  }
723  else {
724    if( *(q+1) != ':') return;
725    i = (char *)omAlloc(strlen(name)+1);
726    *i = '\0';
727    if(name == q)
728    {
729      p = omStrDup("");
730      sscanf(name, "::%s", i);
731    }
732    else
733    {
734      p = (char *)omAlloc(strlen(name)+1);
735      sscanf(name, "%[^:]::%s", p, i);
736    }
737  }
738  //printf("Package: '%s'\n", p);
739  //printf("Id Rec : '%s'\n", i);
740  omFree(p);
741  omFree(i);
742}
743
744#if 0
745char *getnamelev()
746{
747  char buf[256];
748  sprintf(buf, "(%s:%d)", namespaceroot->name,namespaceroot->lev);
749  return(buf);
750}
751// warning: address of local variable `buf' returned
752#endif
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.