source: git/Singular/ipid.cc @ 6d281ac

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