Changeset 7e2783d in tol


Ignore:
Timestamp:
Feb 4, 2009, 9:22:26 AM (18 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
7c62e8b
Parents:
5278fc8
Message:

New member owner_ and related methods to get access to current syntax object that owns the NameBlock

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@584 be4846ae-f051-483a-831f-b64e7d08527f

Location:
tol/btol/bgrammar
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/bgrammar/nameblock.cpp

    r5278fc8 r7e2783d  
    3030#include <tol/tol_bdatgra.h>
    3131#include <tol/tol_btxtgra.h>
    32 
    3332
    3433#include <tol/tol_list.h>
    … …  
    9190  level_    (-999999999),
    9291  father_   (current_),
    93   localName_()
     92  localName_(),
     93  owner_    (NULL)
    9494{
    9595  SetEmptyKey(public_ ,NULL);
    … …  
    109109  level_    (-999999999),
    110110  father_   (current_),
    111   localName_(localName)
     111  localName_(localName),
     112  owner_    (NULL)
    112113{
    113114  SetEmptyKey(public_ ,NULL);
    … …  
    125126  set_      (ns.Set     ()),
    126127  father_   (ns.Father  ()),
    127   localName_(ns.LocalName())
     128  localName_(ns.LocalName()),
     129  owner_    (NULL)
    128130{
    129131  short isAssigned = BObject::IsAssigned();
    … …  
    144146{
    145147  PutName(ns.Name());
     148  owner_     = NULL;
    146149  set_       = ns.Set();
    147150  father_    = ns.Father();
    … …  
    153156  return(*this);
    154157}
     158
     159//--------------------------------------------------------------------
     160BUserNameBlock* BNameBlock::Owner() const
     161//--------------------------------------------------------------------
     162{
     163  return(owner_);
     164}
     165
     166//--------------------------------------------------------------------
     167void BNameBlock::PutOwner(BUserNameBlock* owner)
     168//--------------------------------------------------------------------
     169{
     170  owner_ = owner;
     171}
     172
     173//--------------------------------------------------------------------
     174const BText& BNameBlock::Name() const
     175//--------------------------------------------------------------------
     176{
     177  return(BObject::Name());
     178}
     179
     180//--------------------------------------------------------------------
     181const BText& BNameBlock::LocalName() const
     182//--------------------------------------------------------------------
     183{
     184  return(localName_);
     185};
    155186
    156187//--------------------------------------------------------------------
    … …  
    565596    }
    566597  }
     598  for(iter=private_.begin(); iter!=private_.end(); iter++)
     599  {
     600    obj = iter->second;
     601    if((obj->Name()[2]=='.')&&
     602       (oc.mode_==BUSERFUNMODE) &&
     603       (obj->Mode()==BOBJECTMODE) &&
     604       (obj->Grammar()==GraCode()))
     605    {
     606      BUserCode* uc = (BUserCode*)obj;
     607      obj = uc->Contens().Operator();
     608    }
     609    bool match = (obj->Grammar()==oc.grammar_) && (obj->Mode()==oc.mode_);
     610    if(match)
     611    {
     612    //Std(BText("\n")+"  "+GetModeName(obj->Mode())+" "+obj->Grammar()->Name()+" "+obj->Name()+" matches? "+int(match));
     613      lst = Cons(obj,lst);
     614    }
     615  }
    567616  return(lst);
    568617}
    … …  
    580629    obj = iter->second;
    581630    if((obj->Grammar()==GraNameBlock()) && (obj->Mode()==BOBJECTMODE))
     631    {
     632      BUserNameBlock* unb = (BUserNameBlock*)obj;
     633      lst = unb->Contens().SelectMembersDeep(lst, oc);
     634    }
     635  }
     636  for(iter=private_.begin(); iter!=private_.end(); iter++)
     637  {
     638    obj = iter->second;
     639    if((obj->Name()[2]=='.')&&
     640       (obj->Grammar()==GraNameBlock()) && (obj->Mode()==BOBJECTMODE))
    582641    {
    583642      BUserNameBlock* unb = (BUserNameBlock*)obj;
    … …  
    607666  PutName(parentFullName);
    608667  for(iter=public_.begin(); iter!=public_.end(); iter++)
     668  {
     669    obj = iter->second;
     670    if((obj->Grammar()==GraNameBlock()) && (obj->Mode()==BOBJECTMODE))
     671    {
     672      unb = (BUserNameBlock*)obj;
     673      unb->Contens().RebuildFullNameDeep(parentFullName);
     674    }
     675  }
     676  for(iter=private_.begin(); iter!=private_.end(); iter++)
    609677  {
    610678    obj = iter->second;
  • tol/btol/bgrammar/tol_bnameblock.h

    r5278fc8 r7e2783d  
    3737// forward references
    3838//--------------------------------------------------------------------
    39 class BUserNameBlock;
     39template<class Any> class BGraContensBase;
    4040
    4141//--------------------------------------------------------------------
    … …  
    5757  BText localName_;
    5858  bool createdWithNew_;
     59  BGraContensBase<BNameBlock>* owner_;
    5960public:
    6061  static bool Initialize();
    … …  
    8182
    8283  int Level() const;
    83   const BText& LocalName() const { return(localName_); };
     84  BGraContensBase<BNameBlock>* Owner() const;
     85  void PutOwner(BGraContensBase<BNameBlock>* owner);
     86  const BText& Name() const;
     87  const BText& LocalName() const;
    8488  void PutLocalName(const BText& localName) { localName_ = localName; };
    8589  const BObjByNameHash& Public () const { return(public_ ); }
Note: See TracChangeset for help on using the changeset viewer.