comparison 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
comparison
equal deleted inserted replaced
36:c0967c4b2a74 37:77cdca8c210f
689 if (!p->scope().returned) 689 if (!p->scope().returned)
690 new llvm::BranchInst(nexbb, p->scopebb()); 690 new llvm::BranchInst(nexbb, p->scopebb());
691 691
692 // end 692 // end
693 p->scope() = IRScope(endbb,oldend); 693 p->scope() = IRScope(endbb,oldend);
694 }
695
696 //////////////////////////////////////////////////////////////////////////////
697
698 void LabelStatement::toIR(IRState* p)
699 {
700 Logger::println("LabelStatement::toIR(): %s", toChars());
701 LOG_SCOPE;
702
703 assert(tf == NULL);
704 assert(!isReturnLabel);
705
706 llvm::BasicBlock* oldend = gIR->scopeend();
707 if (llvmBB)
708 llvmBB->moveBefore(oldend);
709 else
710 llvmBB = new llvm::BasicBlock("label", p->topfunc(), oldend);
711
712 new llvm::BranchInst(llvmBB, p->scopebb());
713 p->scope() = IRScope(llvmBB,oldend);
714 statement->toIR(p);
715 }
716
717 //////////////////////////////////////////////////////////////////////////////
718
719 void GotoStatement::toIR(IRState* p)
720 {
721 Logger::println("GotoStatement::toIR(): %s", toChars());
722 LOG_SCOPE;
723
724 assert(tf == NULL);
725
726 llvm::BasicBlock* oldend = gIR->scopeend();
727 llvm::BasicBlock* bb = new llvm::BasicBlock("aftergoto", p->topfunc(), oldend);
728
729 if (label->statement->llvmBB == NULL)
730 label->statement->llvmBB = new llvm::BasicBlock("label", p->topfunc());
731 new llvm::BranchInst(label->statement->llvmBB, p->scopebb());
732 p->scope() = IRScope(bb,oldend);
694 } 733 }
695 734
696 ////////////////////////////////////////////////////////////////////////////// 735 //////////////////////////////////////////////////////////////////////////////
697 736
698 ////////////////////////////////////////////////////////////////////////////// 737 //////////////////////////////////////////////////////////////////////////////
718 //STUBST(ScopeStatement); 757 //STUBST(ScopeStatement);
719 STUBST(AsmStatement); 758 STUBST(AsmStatement);
720 //STUBST(TryCatchStatement); 759 //STUBST(TryCatchStatement);
721 //STUBST(TryFinallyStatement); 760 //STUBST(TryFinallyStatement);
722 STUBST(VolatileStatement); 761 STUBST(VolatileStatement);
723 STUBST(LabelStatement); 762 //STUBST(LabelStatement);
724 //STUBST(ThrowStatement); 763 //STUBST(ThrowStatement);
725 STUBST(GotoCaseStatement); 764 STUBST(GotoCaseStatement);
726 STUBST(GotoDefaultStatement); 765 STUBST(GotoDefaultStatement);
727 STUBST(GotoStatement); 766 //STUBST(GotoStatement);
728 //STUBST(UnrolledLoopStatement); 767 //STUBST(UnrolledLoopStatement);
729 //STUBST(OnScopeStatement); 768 //STUBST(OnScopeStatement);