Changeset ea1d4f6 in tol


Ignore:
Timestamp:
Jan 26, 2009, 3:58:42 PM (18 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
75f1ea4
Parents:
d0b30d4
Message:

Member bool createdWithNew_ to distingish objects created in scope from created in stack with new operator.
Method short EnsureIsAssigned() const returns true for objects created in scope and calls IsAssigned method for objects created in stack
Member BText localName_ to difference between full and local name
Metohd void RebuildFullNameDeep(BText parentFullName) that rebuilds recursively full names of members of a NameBlock

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

File:
1 edited

Legend:

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

    rd0b30d4 rea1d4f6  
    8484BNameBlock::BNameBlock()
    8585//--------------------------------------------------------------------
    86 : BObject(),
    87   public_(),
    88   private_(),
    89   evLevel_(BGrammar::Level()),
    90   level_(-999999999),
    91   father_(current_)
     86: BObject   (),
     87  public_   (),
     88  private_  (),
     89  set_      (),
     90  evLevel_  (BGrammar::Level()),
     91  level_    (-999999999),
     92  father_   (current_),
     93  localName_()
    9294{
    9395  SetEmptyKey(public_ ,NULL);
    … …  
    9698
    9799//--------------------------------------------------------------------
    98 BNameBlock::BNameBlock(const BText& fullName)
    99 //--------------------------------------------------------------------
    100 : BObject (fullName),
    101   public_ (),
    102   private_(),
    103   set_    (),
    104   father_ (current_)
     100BNameBlock::BNameBlock(const BText& fullName, const BText& localName)
     101//--------------------------------------------------------------------
     102: BObject   (fullName),
     103  public_   (),
     104  private_  (),
     105  set_      (),
     106  evLevel_  (BGrammar::Level()),
     107  level_    (-999999999),
     108  father_   (current_),
     109  localName_(localName)
    105110{
    106111  SetEmptyKey(public_ ,NULL);
    107112  SetEmptyKey(private_,NULL);
    108 }
    109 //--------------------------------------------------------------------
    110 BNameBlock::~BNameBlock()
    111 //--------------------------------------------------------------------
    112 {
     113  short isAssigned = BObject::IsAssigned();
     114  createdWithNew_ = isAssigned!=-1;
    113115}
    114116
    … …  
    116118BNameBlock::BNameBlock(const BNameBlock& ns)
    117119//--------------------------------------------------------------------
    118 : BObject (ns.Name    ()),
    119   public_ (ns.Public  ()),
    120   private_(ns.Private ()),
    121   set_    (ns.Set     ()),
    122   father_ (ns.Father  ())
    123 {
     120: BObject   (ns.Name    ()),
     121  public_   (ns.Public  ()),
     122  private_  (ns.Private ()),
     123  set_      (ns.Set     ()),
     124  father_   (ns.Father  ()),
     125  localName_(ns.LocalName())
     126{
     127  short isAssigned = BObject::IsAssigned();
     128  createdWithNew_ = isAssigned!=-1;
    124129  //VBR: La copia de NameBlock tiene un problema si los miembros
    125130  //referenciados en ambos son los mismos, ¿cuál es su padre?
    … …  
    127132
    128133//--------------------------------------------------------------------
     134BNameBlock::~BNameBlock()
     135//--------------------------------------------------------------------
     136{
     137}
     138
     139//--------------------------------------------------------------------
    129140BNameBlock& BNameBlock:: operator= (const BNameBlock& ns)
    130141//--------------------------------------------------------------------
    131142{
    132143  PutName(ns.Name());
    133   set_      = ns.Set();
    134   father_   = ns.Father();
    135   public_   = ns.Public();
    136   private_  = ns.Private();
     144  set_       = ns.Set();
     145  father_    = ns.Father();
     146  public_    = ns.Public();
     147  private_   = ns.Private();
     148  localName_ = ns.LocalName();
    137149  //VBR: La copia de NameBlock tiene un problema si los miembros
    138150  //referenciados en ambos son los mismos, ¿cuál es su padre?
    139151  return(*this);
     152}
     153
     154//--------------------------------------------------------------------
     155  short BNameBlock::EnsureIsAssigned() const
     156//--------------------------------------------------------------------
     157{
     158  if(createdWithNew_) { return(BObject::IsAssigned()); }
     159  else                { return(true); }
    140160}
    141161
    … …  
    211231    BNameBlock& newNameBlock  = ns_result->Contens();
    212232    newNameBlock.PutName(fullName);
     233    newNameBlock.PutLocalName(name);
    213234  //BNameBlock::current_ = &newNameBlock;
    214235    int oldErr = (int)TOLErrorNumber().Value();
    … …  
    312333          BUserCode* uCode = UCode(obj);
    313334          BOperator* opr   = GetOperator(uCode);
    314           opr->PutNameBlock(this);
     335          if(!opr->System() && !opr->NameBlock())
     336          {
     337            opr->PutNameBlock(this);
     338          }
    315339        }
    316340      }
    … …  
    564588
    565589//--------------------------------------------------------------------
     590  void BNameBlock::RebuildFullNameDeep(BText parentFullName)
     591//--------------------------------------------------------------------
     592{
     593//Std(BText("\n")+"BNameBlock::SelectMembersDeep Exploring NameBlock "+Name());
     594  BSyntaxObject* obj;
     595  BUserNameBlock* unb;
     596  BObjByNameHash::const_iterator iter;
     597  if(parentFullName.HasName())
     598  {
     599    parentFullName = parentFullName+"::"+LocalName();
     600  }
     601  else
     602  {
     603    parentFullName = LocalName();
     604  }
     605  PutName(parentFullName);
     606  for(iter=public_.begin(); iter!=public_.end(); iter++)
     607  {
     608    obj = iter->second;
     609    if((obj->Grammar()==GraNameBlock()) && (obj->Mode()==BOBJECTMODE))
     610    {
     611      unb = (BUserNameBlock*)obj;
     612      unb->Contens().RebuildFullNameDeep(parentFullName);
     613    }
     614  }
     615}
     616
     617
     618//--------------------------------------------------------------------
    566619  BList* BNameBlock::Select(BList* lst, const BObjClassify&  oc)
    567620//--------------------------------------------------------------------
    … …  
    674727  {
    675728    const BText& name = BEqualOperator::CreatingName();
    676     contens_.PutName(name);
     729    BText fullName = name;
     730    BText currentFullName = "";
     731    if(BNameBlock::Current())
     732    {
     733      currentFullName = BNameBlock::Current()->Name();
     734      fullName = currentFullName+"::"+name;
     735    }
     736    else
     737    {
     738      currentFullName = "";
     739      fullName = name;
     740    }
     741    contens_.PutName(fullName);
     742    contens_.PutLocalName(name);
    677743    contens_.Fill(set);
     744    contens_.RebuildFullNameDeep(currentFullName);
    678745  }
    679746}
Note: See TracChangeset for help on using the changeset viewer.