Changeset 6e30ee1 in tol
- Timestamp:
- Jan 23, 2009, 11:35:13 AM (18 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 1f5af94
- Parents:
- 3ac3a3f
- Location:
- tol/btol/bgrammar
- Files:
-
- 2 edited
-
nameblock.cpp (modified) (3 diffs)
-
tol_bnameblock.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tol/btol/bgrammar/nameblock.cpp
r3ac3a3f r6e30ee1 107 107 //-------------------------------------------------------------------- 108 108 { 109 static BText currentFullName = ""; 109 110 const BText& name = BEqualOperator::CreatingName(); 110 111 //Std(BText("BNameBlock::EvaluateTree:\n")+BParser::treWrite((List*)tre," ")); 111 112 BBool hasName = name.HasName(); 112 113 BText fullName = name; 113 if(BNameBlock::current_ && hasName) 114 { 115 fullName = BNameBlock::current_->Name()+"::"+name; 116 } 114 BText oldFullName = currentFullName; 115 if(hasName) 116 { 117 if(currentFullName.HasName()) 118 { 119 fullName = currentFullName+"::"+name; 120 } 121 currentFullName = fullName; 122 } 123 BUserNameBlock* ns_result = NULL; 117 124 BSyntaxObject* result = NULL; 118 125 int level = BGrammar::Level(); … … 138 145 I2("Current NameBlock is ", 139 146 "El NameBlock en curso es ")+BNameBlock::current_->Name())); 140 return(NULL); 141 } 142 //const BNameBlock* oldNameBlock = BNameBlock::current_; 143 BUserNameBlock* ns_result = new BGraContensP<BNameBlock>(new BNameBlock); 144 BNameBlock& newNameBlock = ns_result->Contens(); 145 newNameBlock.PutName(fullName); 146 //BNameBlock::current_ = &newNameBlock; 147 int oldErr = (int)TOLErrorNumber().Value(); 148 BGrammar::IncLevel(); 149 int stackPos = BGrammar::StackSize(); 150 BSyntaxObject* set_result = GraSet()->EvaluateTree(tre); 151 BGrammar::DestroyStackUntil(stackPos, set_result); 152 BGrammar::DecLevel(); 153 int numErr = (int)TOLErrorNumber().Value()-oldErr; 154 if(!set_result || (set_result->Grammar()!=GraSet())) 155 { 156 DESTROY(set_result); 157 DESTROY(ns_result); 158 } 159 if(set_result) 160 { 161 BUserSet* uSet = USet(set_result); 162 if(!newNameBlock.Fill(uSet->Contens())) 147 } 148 else 149 { 150 //const BNameBlock* oldNameBlock = BNameBlock::current_; 151 ns_result = new BGraContensP<BNameBlock>(new BNameBlock); 152 BNameBlock& newNameBlock = ns_result->Contens(); 153 newNameBlock.PutName(fullName); 154 //BNameBlock::current_ = &newNameBlock; 155 int oldErr = (int)TOLErrorNumber().Value(); 156 BGrammar::IncLevel(); 157 int stackPos = BGrammar::StackSize(); 158 BSyntaxObject* set_result = GraSet()->EvaluateTree(tre); 159 BGrammar::DestroyStackUntil(stackPos, set_result); 160 BGrammar::DecLevel(); 161 int numErr = (int)TOLErrorNumber().Value()-oldErr; 162 if(!set_result || (set_result->Grammar()!=GraSet())) 163 163 { 164 164 DESTROY(set_result); 165 165 DESTROY(ns_result); 166 166 } 167 } 168 //BNameBlock::current_ = oldNameBlock; 169 if(!set_result) 170 { 171 Error(I2("Cannot build NameBlock ", 172 "No se puede contruir el NameBlock ")+name); 173 bool assigned = (ns_result && (ns_result->IsAssigned()==1)); 174 if(assigned) { DESTROY(ns_result); } 175 } 176 else 177 { 178 if(numErr) 179 { 180 Warning(BText("NameBlock ")+name+" "+ 181 I2("has been built with", 182 "se ha construido con") + " "+numErr+" "+ 183 I2("errors.","errores.")); 184 } 185 DESTROY(set_result); 186 } 167 if(set_result) 168 { 169 BUserSet* uSet = USet(set_result); 170 if(!newNameBlock.Fill(uSet->Contens())) 171 { 172 DESTROY(set_result); 173 DESTROY(ns_result); 174 } 175 } 176 //BNameBlock::current_ = oldNameBlock; 177 if(!set_result) 178 { 179 Error(I2("Cannot build NameBlock ", 180 "No se puede contruir el NameBlock ")+name); 181 bool assigned = (ns_result && (ns_result->IsAssigned()==1)); 182 if(assigned) { DESTROY(ns_result); } 183 } 184 else 185 { 186 if(numErr) 187 { 188 Warning(BText("NameBlock ")+name+" "+ 189 I2("has been built with", 190 "se ha construido con") + " "+numErr+" "+ 191 I2("errors.","errores.")); 192 } 193 DESTROY(set_result); 194 } 195 } 196 currentFullName = oldFullName; 187 197 return(ns_result); 188 198 } … … 444 454 } 445 455 } 456 457 //-------------------------------------------------------------------- 458 BList* BNameBlock::SelectMembers(BList* lst, const BObjClassify& oc) 459 //-------------------------------------------------------------------- 460 { 461 //Std(BText("\n")+"BNameBlock::SelectMembers Exploring NameBlock "+Name()); 462 BSyntaxObject* obj; 463 BObjByNameHash::const_iterator iter; 464 //Std(BText("\n")+" Seaching for "+GetModeName(oc.mode_)+" "+oc.grammar_->Name()); 465 for(iter=public_.begin(); iter!=public_.end(); iter++) 466 { 467 obj = iter->second; 468 if((oc.mode_==BUSERFUNMODE) && 469 (obj->Mode()==BOBJECTMODE) && 470 (obj->Grammar()==GraCode())) 471 { 472 BUserCode* uc = (BUserCode*)obj; 473 obj = uc->Contens().Operator(); 474 } 475 bool match = (obj->Grammar()==oc.grammar_) && (obj->Mode()==oc.mode_); 476 if(match) 477 { 478 //Std(BText("\n")+" "+GetModeName(obj->Mode())+" "+obj->Grammar()->Name()+" "+obj->Name()+" matches? "+int(match)); 479 lst = Cons(obj,lst); 480 } 481 } 482 return(lst); 483 } 484 485 //-------------------------------------------------------------------- 486 BList* BNameBlock::SelectMembersDeep(BList* lst, const BObjClassify& oc) 487 //-------------------------------------------------------------------- 488 { 489 //Std(BText("\n")+"BNameBlock::SelectMembersDeep Exploring NameBlock "+Name()); 490 lst = SelectMembers(lst, oc); 491 BSyntaxObject* obj; 492 BObjByNameHash::const_iterator iter; 493 for(iter=public_.begin(); iter!=public_.end(); iter++) 494 { 495 obj = iter->second; 496 if((obj->Grammar()==GraNameBlock()) && (obj->Mode()==BOBJECTMODE)) 497 { 498 BUserNameBlock* unb = (BUserNameBlock*)obj; 499 lst = unb->Contens().SelectMembersDeep(lst, oc); 500 } 501 } 502 return(lst); 503 } 504 446 505 447 506 //-------------------------------------------------------------------- -
tol/btol/bgrammar/tol_bnameblock.h
r3ac3a3f r6e30ee1 131 131 BSyntaxObject* PublicMember (const BText& memberName) const; 132 132 BSyntaxObject* PrivateMember(const BText& memberName) const; 133 BList* SelectMembers(BList* lst, const BObjClassify& oc); 134 BList* SelectMembersDeep(BList* lst, const BObjClassify& oc); 133 135 134 136 DeclareClassNewDelete(BNameBlock);
Note: See TracChangeset
for help on using the changeset viewer.
