Changeset a32a175 in tol
- Timestamp:
- Dec 23, 2009, 10:58:33 AM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 4725fcb
- Parents:
- 6a80a46
- Location:
- tol/btol/bgrammar
- Files:
-
- 3 edited
-
class.cpp (modified) (7 diffs)
-
nameblock.cpp (modified) (3 diffs)
-
tol_bclass.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol/btol/bgrammar/class.cpp
r6a80a46 ra32a175 37 37 #include <tol/tol_bcodgra.h> 38 38 #include <tol/tol_btxtgra.h> 39 #include <tol/tol_bdatgra.h> 39 40 40 41 … … 291 292 //-------------------------------------------------------------------- 292 293 { 294 static BText __destroyDec = "Real __destroy(Real void)"; 293 295 if(!isStatic_ && !method_ && isMethod_ && definition_.HasName()) 294 296 { … … 304 306 method_->IncNRefs(); 305 307 method_->PutMethod(); 308 bool isDestroy = method_->Name()=="__destroy"; 309 if(isDestroy) 310 { 311 if(Compact(declaration_)==__destroyDec) 312 { 313 cls->PutDestroy(method_); 314 } 315 else 316 { 317 Error(I2("Wrong declaration of destroyer method of Class ", 318 "Declaración errónea del método destructor de Class ")+ 319 parent_->getName()+ 320 "\n"+declaration_+"\n"+ 321 I2(" should be ", " debería ser ")+__destroyDec+ 322 "\n"+__destroyDec+"\n"); 323 } 324 } 306 325 BUserCode* uCode = UCode(method_); 307 326 uCode->Contens().Operator()->PutMethod(); … … 314 333 "Sintaxis incorrecta en declaración de método ")+ 315 334 BParser::Unparse(branch_,"","\n")+ 316 I2(" of Class ", " de Class ")+parent_->getName());335 I2(" of Class ", " de Class ")+parent_->getName()); 317 336 return(0); 318 337 } … … 1000 1019 : BSyntaxObject(), 1001 1020 BMemberOwner(), 1002 isDefined_(false) 1021 isDefined_(false), 1022 __destroy(NULL) 1003 1023 { 1004 1024 CreateMemberHashes(); … … 1022 1042 //Remove symbol from language searchers 1023 1043 BGrammar::DelObject(this); 1044 } 1045 1046 //-------------------------------------------------------------------- 1047 void BClass::PutDestroy(BSyntaxObject* destroy) 1048 //-------------------------------------------------------------------- 1049 { 1050 if(!__destroy) { __destroy = destroy; } 1024 1051 } 1025 1052 … … 1438 1465 } 1439 1466 1467 //-------------------------------------------------------------------- 1468 bool BClass::DestroyInstance(BNameBlock* instance) 1469 //-------------------------------------------------------------------- 1470 { 1471 BClassByNameHash::const_iterator iterC; 1472 BClassByNameHash& par = *(parentHash_); 1473 bool ok = true; 1474 for(iterC=par.begin(); iterC!=par.end(); iterC++) 1475 { 1476 BClass* parent = iterC->second; 1477 ok &= parent->DestroyInstance(instance); 1478 } 1479 if(__destroy) 1480 { 1481 BUserFunCode* ufc= (BUserFunCode*)__destroy; 1482 BUserFunction* dstryr = (BUserFunction*)ufc->Contens().Operator(); 1483 BList* args = NCons(new BContensDat(0.0)); 1484 const BNameBlock* old = dstryr->NameBlock(); 1485 dstryr->PutNameBlock(instance); 1486 BSyntaxObject* result = dstryr->Evaluator(args); 1487 if(!result) { ok = false; } 1488 else { ok = (bool)Real(result); } 1489 dstryr->PutNameBlock(old); 1490 DESTROY(result); 1491 } 1492 return(ok); 1493 } -
tol/btol/bgrammar/nameblock.cpp
r6a80a46 ra32a175 168 168 { 169 169 int n; 170 if(class_) 171 { 172 class_->DestroyInstance(this); 173 class_->DecNRefs(); 174 DESTROY(class_); 175 } 170 176 owner_ = NULL; 171 177 for(n=1; n<=set_.Card(); n++) … … 177 183 set_.Delete(); 178 184 father_ = NULL; 179 if(class_)180 {181 class_->DecNRefs();182 DESTROY(class_);183 }184 185 if(requiredPackages_) 185 186 { … … 187 188 requiredPackages_ = NULL; 188 189 } 189 190 190 } 191 191 -
tol/btol/bgrammar/tol_bclass.h
r6a80a46 ra32a175 185 185 static const BClass* currentClassBuildingInstance_; 186 186 static const BClass* currentStatic_; 187 BSyntaxObject* __destroy; 187 188 // Constructors and destructors: bgrammar\class.cpp 188 189 BClass(const BText& name); … … 200 201 201 202 bool CheckAutoDoc(); 202 203 void PutDestroy(BSyntaxObject* destroy); 204 bool DestroyInstance(BNameBlock* instance); 203 205 //! Evaluates a parsed tree with a Class declaration 204 206 static BClass* PredeclareClass(const BText&name, BClass*&old, bool &ok);
Note: See TracChangeset
for help on using the changeset viewer.
