diff gen/statements.cpp @ 144:a27941d00351 trunk

[svn r149] fixed: a bunch of D-style variadics problems. fixed: GotoDefaultStatement implemented. fixed: some other minor bugs.
author lindquist
date Sat, 26 Jan 2008 17:13:22 +0100
parents ce7b81fb957f
children 8f704cb9969b
line wrap: on
line diff
--- a/gen/statements.cpp	Fri Jan 25 01:42:36 2008 +0100
+++ b/gen/statements.cpp	Sat Jan 26 17:13:22 2008 +0100
@@ -52,13 +52,7 @@
 
     if (exp)
     {
-        Logger::println("return type is: %s", exp->type->toChars());
-
-        Type* exptype = DtoDType(exp->type);
-        TY expty = exptype->ty;
         if (p->topfunc()->getReturnType() == llvm::Type::VoidTy) {
-            assert(DtoIsPassedByRef(exptype));
-
             IrFunction* f = p->func();
             assert(f->type->llvmRetInPtr);
             assert(f->decl->irFunc->retArg);
@@ -320,6 +314,7 @@
     init->toIR(p);
 
     // move into the for condition block, ie. start the loop
+    assert(!gIR->scopereturned());
     new llvm::BranchInst(forbb, gIR->scopebb());
 
     p->loopbbs.push_back(IRScope(forincbb,endbb));
@@ -333,7 +328,8 @@
     delete cond_e;
 
     // conditional branch
-    llvm::Value* ifbreak = new llvm::BranchInst(forbodybb, endbb, cond_val, forbb);
+    assert(!gIR->scopereturned());
+    new llvm::BranchInst(forbodybb, endbb, cond_val, gIR->scopebb());
 
     // rewrite scope
     gIR->scope() = IRScope(forbodybb,forincbb);
@@ -674,6 +670,7 @@
     llvm::BasicBlock* defbb = 0;
     if (!hasNoDefault) {
         defbb = new llvm::BasicBlock("default", p->topfunc(), oldend);
+        defaultBB = defbb;
     }
 
     // end (break point)
@@ -982,6 +979,22 @@
 
 //////////////////////////////////////////////////////////////////////////////
 
+void GotoDefaultStatement::toIR(IRState* p)
+{
+    Logger::println("GotoDefaultStatement::toIR(): %s", loc.toChars());
+    LOG_SCOPE;
+
+    llvm::BasicBlock* oldend = gIR->scopeend();
+    llvm::BasicBlock* bb = new llvm::BasicBlock("aftergotodefault", p->topfunc(), oldend);
+
+    assert(!p->scopereturned());
+    assert(sw->defaultBB);
+    new llvm::BranchInst(sw->defaultBB, p->scopebb());
+    p->scope() = IRScope(bb,oldend);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
 void WithStatement::toIR(IRState* p)
 {
     Logger::println("WithStatement::toIR(): %s", loc.toChars());
@@ -1085,7 +1098,7 @@
 //STUBST(LabelStatement);
 //STUBST(ThrowStatement);
 STUBST(GotoCaseStatement);
-STUBST(GotoDefaultStatement);
+//STUBST(GotoDefaultStatement);
 //STUBST(GotoStatement);
 //STUBST(UnrolledLoopStatement);
 //STUBST(OnScopeStatement);