diff gen/statements.cpp @ 353:a7a26f538d6e trunk

[svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
author ChristianK
date Mon, 14 Jul 2008 11:07:15 +0200
parents d920a244691b
children d8357f7004ca
line wrap: on
line diff
--- a/gen/statements.cpp	Mon Jul 14 10:01:09 2008 +0200
+++ b/gen/statements.cpp	Mon Jul 14 11:07:15 2008 +0200
@@ -1033,16 +1033,20 @@
     }
     else
     {
+        std::string labelname = ident->toChars();
+        llvm::BasicBlock*& labelBB = p->func()->labelToBB[labelname];
+
         llvm::BasicBlock* oldend = gIR->scopeend();
-        if (llvmBB)
-                llvmBB->moveBefore(oldend);
-        else
-                llvmBB = llvm::BasicBlock::Create("label", p->topfunc(), oldend);
+        if (labelBB != NULL) {
+                labelBB->moveBefore(oldend);
+        } else {
+                labelBB = llvm::BasicBlock::Create("label", p->topfunc(), oldend);
+        }
 
         if (!p->scopereturned())
-                llvm::BranchInst::Create(llvmBB, p->scopebb());
+                llvm::BranchInst::Create(labelBB, p->scopebb());
 
-        p->scope() = IRScope(llvmBB,oldend);
+        p->scope() = IRScope(labelBB,oldend);
     }
 
     if (statement)