changeset 148:86d3bb8ca33e trunk

[svn r154] renaming enclosingtry to enclosingtryfinally to distinguish it from enclosingtrycatch, which will probably need to be added for exception handling
author ChristianK
date Sat, 22 Mar 2008 12:20:32 +0100
parents 0636f6269dfd
children 4c577c2b7229
files dmd/statement.c dmd/statement.h gen/irstate.cpp gen/irstate.h gen/statements.cpp
diffstat 5 files changed, 70 insertions(+), 70 deletions(-) [+]
line wrap: on
line diff
--- a/dmd/statement.c	Thu Mar 13 18:37:52 2008 +0100
+++ b/dmd/statement.c	Sat Mar 22 12:20:32 2008 +0100
@@ -561,7 +561,7 @@
     : Statement(loc)
 {
     statements = s;
-    enclosingtry = NULL;
+    enclosingtryfinally = NULL;
 }
 
 Statement *UnrolledLoopStatement::syntaxCopy()
@@ -583,7 +583,7 @@
 {
     //printf("UnrolledLoopStatement::semantic(this = %p, sc = %p)\n", this, sc);
 
-    enclosingtry = sc->tfOfTry;
+    enclosingtryfinally = sc->tfOfTry;
 
     sc->noctor++;
     Scope *scd = sc->push();
@@ -774,7 +774,7 @@
 {
     condition = c;
     body = b;
-    enclosingtry = NULL;
+    enclosingtryfinally = NULL;
 }
 
 Statement *WhileStatement::syntaxCopy()
@@ -809,7 +809,7 @@
     }
 #endif
 
-    enclosingtry = sc->tfOfTry;
+    enclosingtryfinally = sc->tfOfTry;
 
     condition = condition->semantic(sc);
     condition = resolveProperties(sc, condition);
@@ -876,7 +876,7 @@
 {
     body = b;
     condition = c;
-    enclosingtry = NULL;
+    enclosingtryfinally = NULL;
 }
 
 Statement *DoStatement::syntaxCopy()
@@ -888,7 +888,7 @@
 
 Statement *DoStatement::semantic(Scope *sc)
 {
-    enclosingtry = sc->tfOfTry;
+    enclosingtryfinally = sc->tfOfTry;
 
     sc->noctor++;
     if (body)
@@ -952,7 +952,7 @@
     this->condition = condition;
     this->increment = increment;
     this->body = body;
-    this->enclosingtry = NULL;
+    this->enclosingtryfinally = NULL;
 }
 
 Statement *ForStatement::syntaxCopy()
@@ -972,7 +972,7 @@
 
 Statement *ForStatement::semantic(Scope *sc)
 {
-    enclosingtry = sc->tfOfTry;
+    enclosingtryfinally = sc->tfOfTry;
 
     ScopeDsymbol *sym = new ScopeDsymbol();
     sym->parent = sc->scopesym;
@@ -1086,7 +1086,7 @@
     this->arguments = arguments;
     this->aggr = aggr;
     this->body = body;
-    this->enclosingtry = NULL;
+    this->enclosingtryfinally = NULL;
 
     this->key = NULL;
     this->value = NULL;
@@ -1115,7 +1115,7 @@
     Type *tn = NULL;
     Type *tnv = NULL;
 
-    enclosingtry = sc->tfOfTry;
+    enclosingtryfinally = sc->tfOfTry;
 
     func = sc->func;
     if (func->fes)
@@ -1971,7 +1971,7 @@
     cases = NULL;
     hasNoDefault = 0;
     // LLVMDC
-    enclosingtry = NULL;
+    enclosingtryfinally = NULL;
 }
 
 Statement *SwitchStatement::syntaxCopy()
@@ -1986,7 +1986,7 @@
     //printf("SwitchStatement::semantic(%p)\n", this);
     assert(!cases);		// ensure semantic() is only run once
 
-    enclosingtry = sc->tfOfTry;
+    enclosingtryfinally = sc->tfOfTry;
 
     condition = condition->semantic(sc);
     condition = resolveProperties(sc, condition);
@@ -2274,7 +2274,7 @@
     : Statement(loc)
 {
     sw = NULL;
-    enclosingtry = NULL;
+    enclosingtryfinally = NULL;
 }
 
 Statement *GotoDefaultStatement::syntaxCopy()
@@ -2285,7 +2285,7 @@
 
 Statement *GotoDefaultStatement::semantic(Scope *sc)
 {
-    enclosingtry = sc->tfOfTry;
+    enclosingtryfinally = sc->tfOfTry;
     sw = sc->sw;
     if (!sw)
 	error("goto default not in switch statement");
@@ -2309,7 +2309,7 @@
 {
     cs = NULL;
     this->exp = exp;
-    enclosingtry = NULL;
+    enclosingtryfinally = NULL;
     sw = NULL;
 }
 
@@ -2322,7 +2322,7 @@
 
 Statement *GotoCaseStatement::semantic(Scope *sc)
 {
-    enclosingtry = sc->tfOfTry;
+    enclosingtryfinally = sc->tfOfTry;
     if (exp)
 	exp = exp->semantic(sc);
 
@@ -2381,7 +2381,7 @@
     : Statement(loc)
 {
     this->exp = exp;
-    this->enclosingtry = NULL;
+    this->enclosingtryfinally = NULL;
 }
 
 Statement *ReturnStatement::syntaxCopy()
@@ -2396,7 +2396,7 @@
 Statement *ReturnStatement::semantic(Scope *sc)
 {
     //printf("ReturnStatement::semantic() %s\n", toChars());
-    this->enclosingtry = sc->tfOfTry;
+    this->enclosingtryfinally = sc->tfOfTry;
 
     FuncDeclaration *fd = sc->parent->isFuncDeclaration();
     Scope *scx = sc;
@@ -2657,7 +2657,7 @@
     : Statement(loc)
 {
     this->ident = ident;
-    this->enclosingtry = NULL;
+    this->enclosingtryfinally = NULL;
 }
 
 Statement *BreakStatement::syntaxCopy()
@@ -2668,7 +2668,7 @@
 
 Statement *BreakStatement::semantic(Scope *sc)
 {
-    enclosingtry = sc->tfOfTry;
+    enclosingtryfinally = sc->tfOfTry;
     // If:
     //	break Identifier;
     if (ident)
@@ -2751,7 +2751,7 @@
     : Statement(loc)
 {
     this->ident = ident;
-    this->enclosingtry = NULL;
+    this->enclosingtryfinally = NULL;
 }
 
 Statement *ContinueStatement::syntaxCopy()
@@ -2762,7 +2762,7 @@
 
 Statement *ContinueStatement::semantic(Scope *sc)
 {
-    enclosingtry = sc->tfOfTry;
+    enclosingtryfinally = sc->tfOfTry;
     //printf("ContinueStatement::semantic() %p\n", this);
     if (ident)
     {
@@ -3195,7 +3195,7 @@
 {
     this->body = body;
     this->finalbody = finalbody;
-    this->enclosingtry = NULL;
+    this->enclosingtryfinally = NULL;
 }
 
 Statement *TryFinallyStatement::syntaxCopy()
@@ -3209,10 +3209,10 @@
 {
     //printf("TryFinallyStatement::semantic()\n");
 
-    enclosingtry = sc->tfOfTry;
+    enclosingtryfinally = sc->tfOfTry;
     sc->tfOfTry = this;
     body = body->semantic(sc);
-    sc->tfOfTry = enclosingtry;
+    sc->tfOfTry = enclosingtryfinally;
 
     sc = sc->push();
     sc->tf = this;
@@ -3447,7 +3447,7 @@
     this->ident = ident;
     this->label = NULL;
     this->tf = NULL;
-    this->enclosingtry = NULL;
+    this->enclosingtryfinally = NULL;
 }
 
 Statement *GotoStatement::syntaxCopy()
@@ -3461,7 +3461,7 @@
 
     //printf("GotoStatement::semantic()\n");
     tf = sc->tf;
-    enclosingtry = sc->tfOfTry;
+    enclosingtryfinally = sc->tfOfTry;
     label = fd->searchLabel(ident);
     if (!label->statement && sc->fes)
     {
@@ -3505,7 +3505,7 @@
     this->ident = ident;
     this->statement = statement;
     this->tf = NULL;
-    this->enclosingtry = NULL;
+    this->enclosingtryfinally = NULL;
     this->lblock = NULL;
     this->isReturnLabel = 0;
     this->llvmBB = NULL;
@@ -3528,7 +3528,7 @@
     else
 	ls->statement = this;
     tf = sc->tf;
-    enclosingtry = sc->tfOfTry;
+    enclosingtryfinally = sc->tfOfTry;
     sc = sc->push();
     sc->scopesym = sc->enclosing->scopesym;
     sc->callSuper |= CSXlabel;
--- a/dmd/statement.h	Thu Mar 13 18:37:52 2008 +0100
+++ b/dmd/statement.h	Sat Mar 22 12:20:32 2008 +0100
@@ -193,7 +193,7 @@
 struct UnrolledLoopStatement : Statement
 {
     Statements *statements;
-    TryFinallyStatement *enclosingtry;
+    TryFinallyStatement *enclosingtryfinally;
 
     UnrolledLoopStatement(Loc loc, Statements *statements);
     Statement *syntaxCopy();
@@ -238,7 +238,7 @@
 {
     Expression *condition;
     Statement *body;
-    TryFinallyStatement *enclosingtry;
+    TryFinallyStatement *enclosingtryfinally;
 
     WhileStatement(Loc loc, Expression *c, Statement *b);
     Statement *syntaxCopy();
@@ -260,7 +260,7 @@
 {
     Statement *body;
     Expression *condition;
-    TryFinallyStatement *enclosingtry;
+    TryFinallyStatement *enclosingtryfinally;
 
     DoStatement(Loc loc, Statement *b, Expression *c);
     Statement *syntaxCopy();
@@ -284,7 +284,7 @@
     Expression *condition;
     Expression *increment;
     Statement *body;
-    TryFinallyStatement *enclosingtry;
+    TryFinallyStatement *enclosingtryfinally;
 
     ForStatement(Loc loc, Statement *init, Expression *condition, Expression *increment, Statement *body);
     Statement *syntaxCopy();
@@ -309,7 +309,7 @@
     Arguments *arguments;	// array of Argument*'s
     Expression *aggr;
     Statement *body;
-    TryFinallyStatement *enclosingtry;
+    TryFinallyStatement *enclosingtryfinally;
 
     VarDeclaration *key;
     VarDeclaration *value;
@@ -406,7 +406,7 @@
     Expression *condition;
     Statement *body;
     DefaultStatement *sdefault;
-    TryFinallyStatement *enclosingtry;
+    TryFinallyStatement *enclosingtryfinally;
 
     Array gotoCases;		// array of unresolved GotoCaseStatement's
     Array *cases;		// array of CaseStatement's
@@ -480,7 +480,7 @@
 struct GotoDefaultStatement : Statement
 {
     SwitchStatement *sw;
-    TryFinallyStatement *enclosingtry;
+    TryFinallyStatement *enclosingtryfinally;
 
     GotoDefaultStatement(Loc loc);
     Statement *syntaxCopy();
@@ -496,7 +496,7 @@
 {
     Expression *exp;		// NULL, or which case to goto
     CaseStatement *cs;		// case statement it resolves to
-    TryFinallyStatement *enclosingtry;
+    TryFinallyStatement *enclosingtryfinally;
     SwitchStatement *sw;
 
     GotoCaseStatement(Loc loc, Expression *exp);
@@ -521,7 +521,7 @@
 struct ReturnStatement : Statement
 {
     Expression *exp;
-    TryFinallyStatement *enclosingtry;
+    TryFinallyStatement *enclosingtryfinally;
 
     ReturnStatement(Loc loc, Expression *exp);
     Statement *syntaxCopy();
@@ -542,7 +542,7 @@
 struct BreakStatement : Statement
 {
     Identifier *ident;
-    TryFinallyStatement *enclosingtry;
+    TryFinallyStatement *enclosingtryfinally;
 
     BreakStatement(Loc loc, Identifier *ident);
     Statement *syntaxCopy();
@@ -560,7 +560,7 @@
 struct ContinueStatement : Statement
 {
     Identifier *ident;
-    TryFinallyStatement *enclosingtry;
+    TryFinallyStatement *enclosingtryfinally;
 
     ContinueStatement(Loc loc, Identifier *ident);
     Statement *syntaxCopy();
@@ -652,7 +652,7 @@
 {
     Statement *body;
     Statement *finalbody;
-    TryFinallyStatement *enclosingtry;
+    TryFinallyStatement *enclosingtryfinally;
 
     TryFinallyStatement(Loc loc, Statement *body, Statement *finalbody);
     Statement *syntaxCopy();
@@ -719,7 +719,7 @@
     Identifier *ident;
     LabelDsymbol *label;
     TryFinallyStatement *tf;
-    TryFinallyStatement *enclosingtry;
+    TryFinallyStatement *enclosingtryfinally;
 
     GotoStatement(Loc loc, Identifier *ident);
     Statement *syntaxCopy();
@@ -737,7 +737,7 @@
     Identifier *ident;
     Statement *statement;
     TryFinallyStatement *tf;
-    TryFinallyStatement *enclosingtry;
+    TryFinallyStatement *enclosingtryfinally;
     block *lblock;		// back end
     int isReturnLabel;
 
--- a/gen/irstate.cpp	Thu Mar 13 18:37:52 2008 +0100
+++ b/gen/irstate.cpp	Sat Mar 22 12:20:32 2008 +0100
@@ -35,13 +35,13 @@
 {
 }
 
-IRLoopScope::IRLoopScope(Statement* s, TryFinallyStatement* enclosingtry, llvm::BasicBlock* b, llvm::BasicBlock* e)
+IRLoopScope::IRLoopScope(Statement* s, TryFinallyStatement* enclosingtryfinally, llvm::BasicBlock* b, llvm::BasicBlock* e)
 {
     begin = b;
     end = e;
     builder.SetInsertPoint(b);
     this->s = s;
-    this->enclosingtry = enclosingtry;
+    this->enclosingtryfinally = enclosingtryfinally;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
--- a/gen/irstate.h	Thu Mar 13 18:37:52 2008 +0100
+++ b/gen/irstate.h	Sat Mar 22 12:20:32 2008 +0100
@@ -42,10 +42,10 @@
     // generating statement
     Statement* s;
     // the try of a TryFinally that encloses the loop
-    TryFinallyStatement* enclosingtry;
+    TryFinallyStatement* enclosingtryfinally;
 
     IRLoopScope();
-    IRLoopScope(Statement* s, TryFinallyStatement* enclosingtry, llvm::BasicBlock* b, llvm::BasicBlock* e);
+    IRLoopScope(Statement* s, TryFinallyStatement* enclosingtryfinally, llvm::BasicBlock* b, llvm::BasicBlock* e);
 };
 
 struct IRBuilderHelper
--- a/gen/statements.cpp	Thu Mar 13 18:37:52 2008 +0100
+++ b/gen/statements.cpp	Sat Mar 22 12:20:32 2008 +0100
@@ -53,7 +53,7 @@
     // verify that end encloses start
     TryFinallyStatement* endfinally = start;
     while(endfinally != NULL && endfinally != end) {
-        endfinally = endfinally->enclosingtry;
+        endfinally = endfinally->enclosingtryfinally;
     }
     assert(endfinally == end);
 
@@ -61,7 +61,7 @@
     TryFinallyStatement* tf = start;
     while(tf != end) {
         tf->finalbody->toIR(p);
-        tf = tf->enclosingtry;
+        tf = tf->enclosingtryfinally;
     }
 }
 
@@ -90,7 +90,7 @@
             if (!e->inPlace())
                 DtoAssign(rvar, e);
 
-            emit_finallyblocks(p, enclosingtry, NULL);
+            emit_finallyblocks(p, enclosingtryfinally, NULL);
 
             if (global.params.symdebug) DtoDwarfFuncEnd(f->decl);
             new llvm::ReturnInst(p->scopebb());
@@ -103,7 +103,7 @@
             delete e;
             Logger::cout() << "return value is '" <<*v << "'\n";
 
-            emit_finallyblocks(p, enclosingtry, NULL);
+            emit_finallyblocks(p, enclosingtryfinally, NULL);
 
             if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl);
             new llvm::ReturnInst(v, p->scopebb());
@@ -112,7 +112,7 @@
     else
     {
         if (p->topfunc()->getReturnType() == llvm::Type::VoidTy) {
-            emit_finallyblocks(p, enclosingtry, NULL);
+            emit_finallyblocks(p, enclosingtryfinally, NULL);
 
             if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl);
             new llvm::ReturnInst(p->scopebb());
@@ -254,7 +254,7 @@
     gIR->scope() = IRScope(whilebodybb,endbb);
 
     // while body code
-    p->loopbbs.push_back(IRLoopScope(this,enclosingtry,whilebb,endbb));
+    p->loopbbs.push_back(IRLoopScope(this,enclosingtryfinally,whilebb,endbb));
     body->toIR(p);
     p->loopbbs.pop_back();
 
@@ -286,7 +286,7 @@
     gIR->scope() = IRScope(dowhilebb,endbb);
 
     // do-while body code
-    p->loopbbs.push_back(IRLoopScope(this,enclosingtry,dowhilebb,endbb));
+    p->loopbbs.push_back(IRLoopScope(this,enclosingtryfinally,dowhilebb,endbb));
     body->toIR(p);
     p->loopbbs.pop_back();
 
@@ -324,7 +324,7 @@
     assert(!gIR->scopereturned());
     new llvm::BranchInst(forbb, gIR->scopebb());
 
-    p->loopbbs.push_back(IRLoopScope(this,enclosingtry,forincbb,endbb));
+    p->loopbbs.push_back(IRLoopScope(this,enclosingtryfinally,forincbb,endbb));
 
     // replace current scope
     gIR->scope() = IRScope(forbb,forbodybb);
@@ -375,7 +375,7 @@
     if (ident != 0) {
         Logger::println("ident = %s", ident->toChars());
 
-        emit_finallyblocks(p, enclosingtry, target->enclosingtry);
+        emit_finallyblocks(p, enclosingtryfinally, target->enclosingtryfinally);
 
         // get the loop statement the label refers to
         Statement* targetLoopStatement = target->statement;
@@ -394,7 +394,7 @@
         assert(0);
     }
     else {
-        emit_finallyblocks(p, enclosingtry, gIR->loopbbs.back().enclosingtry);
+        emit_finallyblocks(p, enclosingtryfinally, gIR->loopbbs.back().enclosingtryfinally);
         new llvm::BranchInst(gIR->loopbbs.back().end, gIR->scopebb());
     }
 }
@@ -409,7 +409,7 @@
     if (ident != 0) {
         Logger::println("ident = %s", ident->toChars());
 
-        emit_finallyblocks(p, enclosingtry, target->enclosingtry);
+        emit_finallyblocks(p, enclosingtryfinally, target->enclosingtryfinally);
 
         // get the loop statement the label refers to
         Statement* targetLoopStatement = target->statement;
@@ -428,7 +428,7 @@
         assert(0);
     }
     else {
-        emit_finallyblocks(p, enclosingtry, gIR->loopbbs.back().enclosingtry);
+        emit_finallyblocks(p, enclosingtryfinally, gIR->loopbbs.back().enclosingtryfinally);
         new llvm::BranchInst(gIR->loopbbs.back().begin, gIR->scopebb());
     }
 }
@@ -713,7 +713,7 @@
     {
         llvm::BasicBlock* nextbb = (i == n-1) ? (defbb ? defbb : endbb) : vcases[i+1].first;
         p->scope() = IRScope(vcases[i].first,nextbb);
-        p->loopbbs.push_back(IRLoopScope(this,enclosingtry,p->scopebb(),endbb));
+        p->loopbbs.push_back(IRLoopScope(this,enclosingtryfinally,p->scopebb(),endbb));
         vbodies[i]->toIR(p);
         p->loopbbs.pop_back();
 
@@ -728,7 +728,7 @@
     if (defbb)
     {
         p->scope() = IRScope(defbb,endbb);
-        p->loopbbs.push_back(IRLoopScope(this,enclosingtry,p->scopebb(),endbb));
+        p->loopbbs.push_back(IRLoopScope(this,enclosingtryfinally,p->scopebb(),endbb));
         Logger::println("doing default statement");
         sdefault->statement->toIR(p);
         p->loopbbs.pop_back();
@@ -763,7 +763,7 @@
     llvm::BasicBlock* endbb = new llvm::BasicBlock("unrolledend", p->topfunc(), oldend);
 
     p->scope() = IRScope(p->scopebb(),endbb);
-    p->loopbbs.push_back(IRLoopScope(this,enclosingtry,p->scopebb(),endbb));
+    p->loopbbs.push_back(IRLoopScope(this,enclosingtryfinally,p->scopebb(),endbb));
 
     for (int i=0; i<statements->dim; ++i)
     {
@@ -921,7 +921,7 @@
     }
 
     // emit body
-    p->loopbbs.push_back(IRLoopScope(this,enclosingtry,nextbb,endbb));
+    p->loopbbs.push_back(IRLoopScope(this,enclosingtryfinally,nextbb,endbb));
     body->toIR(p);
     p->loopbbs.pop_back();
 
@@ -981,17 +981,17 @@
     assert(!p->scopereturned());
 
     // find finallys between goto and label
-    TryFinallyStatement* endfinally = enclosingtry;
-    while(endfinally != NULL && endfinally != label->statement->enclosingtry) {
-        endfinally = endfinally->enclosingtry;
+    TryFinallyStatement* endfinally = enclosingtryfinally;
+    while(endfinally != NULL && endfinally != label->statement->enclosingtryfinally) {
+        endfinally = endfinally->enclosingtryfinally;
     }
 
     // error if didn't find tf statement of label
-    if(endfinally != label->statement->enclosingtry)
+    if(endfinally != label->statement->enclosingtryfinally)
         error("cannot goto into try block", loc.toChars());
 
     // emit code for finallys between goto and label
-    emit_finallyblocks(p, enclosingtry, endfinally);
+    emit_finallyblocks(p, enclosingtryfinally, endfinally);
 
     new llvm::BranchInst(label->statement->llvmBB, p->scopebb());
     p->scope() = IRScope(bb,oldend);
@@ -1010,7 +1010,7 @@
     assert(!p->scopereturned());
     assert(sw->sdefault->bodyBB);
 
-    emit_finallyblocks(p, enclosingtry, sw->enclosingtry);
+    emit_finallyblocks(p, enclosingtryfinally, sw->enclosingtryfinally);
 
     new llvm::BranchInst(sw->sdefault->bodyBB, p->scopebb());
     p->scope() = IRScope(bb,oldend);
@@ -1029,7 +1029,7 @@
     assert(!p->scopereturned());
     assert(cs->bodyBB);
 
-    emit_finallyblocks(p, enclosingtry, sw->enclosingtry);
+    emit_finallyblocks(p, enclosingtryfinally, sw->enclosingtryfinally);
 
     new llvm::BranchInst(cs->bodyBB, p->scopebb());
     p->scope() = IRScope(bb,oldend);