Changeset c4144bc in tol
- Timestamp:
- Nov 19, 2010, 11:52:50 AM (16 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 3191f9b
- Parents:
- 7e78186
- Location:
- tol/btol/bgrammar
- Files:
-
- 2 edited
-
nameblock.cpp (modified) (4 diffs)
-
tol_bnameblock.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol/btol/bgrammar/nameblock.cpp
r7e78186 rc4144bc 835 835 836 836 //-------------------------------------------------------------------- 837 bool BNameBlock::Using(const BSyntaxObject* obj) 837 bool 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) 838 892 //-------------------------------------------------------------------- 839 893 { … … 856 910 } 857 911 bool ok = true; 912 BObjByNameHash::const_iterator iter; 858 913 BNameBlock& ns = uns->Contens(); 859 914 BObjByNameHash& pbm = ns.Public(); 860 BObjByNameHash::const_iterator iter;861 BObjByNameHash::const_iterator found;862 BObjByClassNameHash::iterator fc;863 915 for(iter=pbm.begin(); iter!=pbm.end(); iter++) 864 916 { 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); 897 923 } 898 924 return(ok); … … 1388 1414 BDatUsingNameBlock(BList* arg) : BDatTemporary(arg) 1389 1415 { 1390 uns_ = UNameBlock(Arg(1)); 1416 BList* lst = arg; 1417 uns_ = UNameBlock(lst->Car()); 1418 lst = lst->Cdr(); 1391 1419 if(CheckNonDeclarativeAction("UsingNameBlock")) 1392 { contens_ = false; } 1420 { 1421 contens_ = false; 1422 } 1393 1423 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 } 1395 1439 } 1396 1440 ~BDatUsingNameBlock() … … 1404 1448 1405 1449 //-------------------------------------------------------------------- 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])", 1408 1455 I2("In certain circumstances the public members of a NameBlock can " 1409 1456 "pass to the global scope, that is to say, it is possible to " -
tol/btol/bgrammar/tol_bnameblock.h
r7e78186 rc4144bc 99 99 static BUserNameBlock* SetBuilding(BUserNameBlock* ns); 100 100 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); 102 105 static void Unusing(const BSyntaxObject* uns); 103 106 static BSyntaxObject* LocalMember(const BText& memberName); … … 163 166 164 167 DeclareClassNewDelete(BNameBlock); 168 169 private: 170 static bool add_using_symbol ( 171 const BText& name, 172 BObjByNameHash::const_iterator iter, 173 bool usingAlsoReadOnly, 174 bool usingAlsoPrivate 175 ); 165 176 }; 166 177
Note: See TracChangeset
for help on using the changeset viewer.
