Changeset c4144bc in tol


Ignore:
Timestamp:
Nov 19, 2010, 11:52:50 AM (16 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
3191f9b
Parents:
7e78186
Message:

Refs #1014

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

Location:
tol/btol/bgrammar
Files:
2 edited

Legend:

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

    r7e78186 rc4144bc  
    835835
    836836//--------------------------------------------------------------------
    837   bool BNameBlock::Using(const BSyntaxObject* obj)
     837bool BNameBlock::add_using_symbol(
     838  const BText& name,
     839  BObjByNameHash::const_iterator iter,
     840  bool usingAlsoReadOnly,
     841  bool usingAlsoPrivate
     842)
     843//--------------------------------------------------------------------
     844{
     845  if((iter->first)[0]=='_')
     846  {
     847    if(!usingAlsoReadOnly && ((iter->first)[1]=='.')) { return(true); }
     848    if(!usingAlsoPrivate  && ((iter->first)[1]!='.')) { return(true); }
     849  }
     850  bool ok = true;
     851  BObjByNameHash::const_iterator found ;
     852  BObjByClassNameHash::iterator fc;
     853  found = usingSymbols_.find(iter->first);
     854  if(found==usingSymbols_.end())
     855  {
     856  //Std(BText("\nUsing member '")+name+"::"+iter->first+"'\n");
     857    usingSymbols_[iter->first]=iter->second;
     858    assert(usingSymbols_.find(iter->first)!=usingSymbols_.end());
     859    BObjClassify oc(iter->second);
     860    fc = usingSymbolsByClass_.find(oc);
     861    BObjByNameHash* x;
     862    if(fc!=usingSymbolsByClass_.end())
     863    {
     864      x = fc->second;
     865    }
     866    else
     867    {
     868      x = new BObjByNameHash;
     869      SetEmptyKey  ((*x), NULL);
     870      SetDeletedKey((*x), name_del_key());
     871      usingSymbolsByClass_[oc] = x;
     872    }
     873    (*x)[iter->first]=iter->second;
     874  }
     875  else
     876  {
     877    Warning(found->second->FullName()+
     878            I2(" is already in use as global. "
     879               "So cannot add ",
     880               " ya se está usando como global. "
     881               "Por lo tanto no se puede añadir ")+
     882               name+"::"+iter->second->Name());
     883    ok = false;
     884  }
     885  return(true);
     886}
     887//--------------------------------------------------------------------
     888  bool BNameBlock::Using(
     889    const BSyntaxObject* obj,
     890    bool usingAlsoReadOnly,
     891    bool usingAlsoPrivate)
    838892//--------------------------------------------------------------------
    839893{
    … …  
    856910  }
    857911  bool ok = true;
     912  BObjByNameHash::const_iterator iter;
    858913  BNameBlock& ns = uns->Contens();
    859914  BObjByNameHash& pbm = ns.Public();
    860   BObjByNameHash::const_iterator iter;
    861   BObjByNameHash::const_iterator found;
    862   BObjByClassNameHash::iterator fc;
    863915  for(iter=pbm.begin(); iter!=pbm.end(); iter++)
    864916  {
    865     found = usingSymbols_.find(iter->first);
    866     if(found==usingSymbols_.end())
    867     {
    868     //Std(BText("\nUsing member '")+name+"::"+iter->first+"'\n");
    869       usingSymbols_[iter->first]=iter->second;
    870       assert(usingSymbols_.find(iter->first)!=usingSymbols_.end());
    871       BObjClassify oc(iter->second);
    872       fc = usingSymbolsByClass_.find(oc);
    873       BObjByNameHash* x;
    874       if(fc!=usingSymbolsByClass_.end())
    875       {
    876         x = fc->second;
    877       }
    878       else
    879       {
    880         x = new BObjByNameHash;
    881         SetEmptyKey  ((*x), NULL);
    882         SetDeletedKey((*x), name_del_key());
    883         usingSymbolsByClass_[oc] = x;
    884       }
    885       (*x)[iter->first]=iter->second;
    886     }
    887     else
    888     {
    889       Warning(found->second->FullName()+
    890               I2(" is already in use as global. "
    891                  "So cannot add ",
    892                  " ya se está usando como global. "
    893                  "Por lo tanto no se puede añadir ")+
    894                  name+"::"+iter->second->Name());
    895       ok = false;
    896     }
     917    ok = add_using_symbol(name, iter, false, false);
     918  }
     919  BObjByNameHash& prm = ns.Private();
     920  for(iter=prm.begin(); iter!=prm.end(); iter++)
     921  {
     922    ok = add_using_symbol(name, iter, usingAlsoReadOnly, usingAlsoPrivate);
    897923  }
    898924  return(ok);
    … …  
    13881414  BDatUsingNameBlock(BList* arg) : BDatTemporary(arg)
    13891415  {
    1390     uns_ = UNameBlock(Arg(1));
     1416    BList* lst = arg;
     1417    uns_ = UNameBlock(lst->Car());
     1418    lst = lst->Cdr();
    13911419    if(CheckNonDeclarativeAction("UsingNameBlock"))
    1392     { contens_ = false; }
     1420    {
     1421      contens_ = false;
     1422    }
    13931423    else
    1394     { contens_ = BNameBlock::Using(uns_); }
     1424    {
     1425      bool usingAlsoReadOnly = false;
     1426      bool usingAlsoPrivate = false;
     1427      if(lst && lst->Car())
     1428      {
     1429        usingAlsoReadOnly = Real(lst->Car())!=0.0;
     1430        lst = lst->Cdr();
     1431      }
     1432      if(lst && lst->Car())
     1433      {
     1434        usingAlsoPrivate = Real(lst->Car())!=0.0;
     1435        lst = lst->Cdr();
     1436      }
     1437      contens_ = BNameBlock::Using(uns_,usingAlsoReadOnly,usingAlsoPrivate);
     1438    }
    13951439  }
    13961440 ~BDatUsingNameBlock()
    … …  
    14041448
    14051449//--------------------------------------------------------------------
    1406   DefExtOpr(1, BDatUsingNameBlock, "UsingNameBlock",1,1,"NameBlock",
    1407   "(NameBlock nameBlock)",
     1450  DefExtOpr(1, BDatUsingNameBlock, "UsingNameBlock",1,3,
     1451  "NameBlock Real Real",
     1452  "(NameBlock nameBlock [, "
     1453    "Real usingAlsoReadOnly = False,"
     1454    "Real usingAlsoPrivate = False])",
    14081455  I2("In certain circumstances the public members of a NameBlock can "
    14091456     "pass to the global scope, that is to say, it is possible to "
  • tol/btol/bgrammar/tol_bnameblock.h

    r7e78186 rc4144bc  
    9999  static BUserNameBlock* SetBuilding(BUserNameBlock* ns);
    100100  static BSyntaxObject* EvaluateTree(const List* tre);
    101   static bool Using  (const BSyntaxObject* uns);
     101  static bool Using  (
     102    const BSyntaxObject* uns,
     103    bool usingAlsoReadOnly,
     104    bool usingAlsoPrivate);
    102105  static void Unusing(const BSyntaxObject* uns);
    103106  static BSyntaxObject* LocalMember(const BText& memberName);
    … …  
    163166
    164167  DeclareClassNewDelete(BNameBlock);
     168
     169private:
     170  static bool add_using_symbol  (
     171    const BText& name,
     172    BObjByNameHash::const_iterator iter,
     173    bool usingAlsoReadOnly,
     174    bool usingAlsoPrivate
     175  );
    165176};
    166177
Note: See TracChangeset for help on using the changeset viewer.