diff gen/statements.c @ 37:77cdca8c210f trunk

[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer. initial label/goto support.
author lindquist
date Wed, 10 Oct 2007 03:38:24 +0200
parents 4648206ca213
children 8b0e809563df
line wrap: on
line diff
--- a/gen/statements.c	Tue Oct 09 07:51:13 2007 +0200
+++ b/gen/statements.c	Wed Oct 10 03:38:24 2007 +0200
@@ -695,6 +695,45 @@
 
 //////////////////////////////////////////////////////////////////////////////
 
+void LabelStatement::toIR(IRState* p)
+{
+    Logger::println("LabelStatement::toIR(): %s", toChars());
+    LOG_SCOPE;
+
+    assert(tf == NULL);
+    assert(!isReturnLabel);
+
+    llvm::BasicBlock* oldend = gIR->scopeend();
+    if (llvmBB)
+        llvmBB->moveBefore(oldend);
+    else
+        llvmBB = new llvm::BasicBlock("label", p->topfunc(), oldend);
+
+    new llvm::BranchInst(llvmBB, p->scopebb());
+    p->scope() = IRScope(llvmBB,oldend);
+    statement->toIR(p);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+void GotoStatement::toIR(IRState* p)
+{
+    Logger::println("GotoStatement::toIR(): %s", toChars());
+    LOG_SCOPE;
+
+    assert(tf == NULL);
+
+    llvm::BasicBlock* oldend = gIR->scopeend();
+    llvm::BasicBlock* bb = new llvm::BasicBlock("aftergoto", p->topfunc(), oldend);
+
+    if (label->statement->llvmBB == NULL)
+        label->statement->llvmBB = new llvm::BasicBlock("label", p->topfunc());
+    new llvm::BranchInst(label->statement->llvmBB, p->scopebb());
+    p->scope() = IRScope(bb,oldend);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
 //////////////////////////////////////////////////////////////////////////////
 
 #define STUBST(x) void x::toIR(IRState * p) {error("Statement type "#x" not implemented: %s", toChars());fatal();}
@@ -720,10 +759,10 @@
 //STUBST(TryCatchStatement);
 //STUBST(TryFinallyStatement);
 STUBST(VolatileStatement);
-STUBST(LabelStatement);
+//STUBST(LabelStatement);
 //STUBST(ThrowStatement);
 STUBST(GotoCaseStatement);
 STUBST(GotoDefaultStatement);
-STUBST(GotoStatement);
+//STUBST(GotoStatement);
 //STUBST(UnrolledLoopStatement);
 //STUBST(OnScopeStatement);