Mercurial > projects > ldc
comparison gen/statements.cpp @ 1412:3f5ea912149d
Fix #308 by giving finally code emitted by EnclosingTryFinally a different landing pad.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 23 May 2009 00:23:39 +0200 |
parents | 15e9762bb620 |
children | 303e6422f785 |
comparison
equal
deleted
inserted
replaced
1411:e57859ca8f1e | 1412:3f5ea912149d |
---|---|
590 // set up the landing pad | 590 // set up the landing pad |
591 // | 591 // |
592 p->scope() = IRScope(landingpadbb, endbb); | 592 p->scope() = IRScope(landingpadbb, endbb); |
593 | 593 |
594 assert(finalbody); | 594 assert(finalbody); |
595 gIR->func()->landingPad.addFinally(finalbody); | 595 gIR->func()->targetScopes.push_back(IRTargetScope(this,new EnclosingTryFinally(this,gIR->func()->landingPad),NULL,NULL)); |
596 gIR->func()->landingPad.push(landingpadbb); | 596 gIR->func()->landingPadInfo.addFinally(finalbody); |
597 gIR->func()->landingPadInfo.push(landingpadbb); | |
598 gIR->func()->landingPad = gIR->func()->landingPadInfo.get(); | |
597 | 599 |
598 // | 600 // |
599 // do the try block | 601 // do the try block |
600 // | 602 // |
601 p->scope() = IRScope(trybb,finallybb); | 603 p->scope() = IRScope(trybb,finallybb); |
602 | 604 |
603 assert(body); | 605 assert(body); |
604 p->func()->targetScopes.push_back(IRTargetScope(this,new EnclosingTryFinally(this),NULL,NULL)); | |
605 body->toIR(p); | 606 body->toIR(p); |
606 p->func()->targetScopes.pop_back(); | |
607 | 607 |
608 // terminate try BB | 608 // terminate try BB |
609 if (!p->scopereturned()) | 609 if (!p->scopereturned()) |
610 llvm::BranchInst::Create(finallybb, p->scopebb()); | 610 llvm::BranchInst::Create(finallybb, p->scopebb()); |
611 | 611 |
612 gIR->func()->landingPad.pop(); | 612 gIR->func()->landingPadInfo.pop(); |
613 gIR->func()->landingPad = gIR->func()->landingPadInfo.get(); | |
614 gIR->func()->targetScopes.pop_back(); | |
613 | 615 |
614 // | 616 // |
615 // do finally block | 617 // do finally block |
616 // | 618 // |
617 p->scope() = IRScope(finallybb,landingpadbb); | 619 p->scope() = IRScope(finallybb,landingpadbb); |
656 gIR->scope() = IRScope(landingpadbb, endbb); | 658 gIR->scope() = IRScope(landingpadbb, endbb); |
657 | 659 |
658 for (int i = 0; i < catches->dim; i++) | 660 for (int i = 0; i < catches->dim; i++) |
659 { | 661 { |
660 Catch *c = (Catch *)catches->data[i]; | 662 Catch *c = (Catch *)catches->data[i]; |
661 gIR->func()->landingPad.addCatch(c, endbb); | 663 gIR->func()->landingPadInfo.addCatch(c, endbb); |
662 } | 664 } |
663 | 665 |
664 gIR->func()->landingPad.push(landingpadbb); | 666 gIR->func()->landingPadInfo.push(landingpadbb); |
667 gIR->func()->landingPad = gIR->func()->landingPadInfo.get(); | |
665 | 668 |
666 // | 669 // |
667 // do the try block | 670 // do the try block |
668 // | 671 // |
669 p->scope() = IRScope(trybb,landingpadbb); | 672 p->scope() = IRScope(trybb,landingpadbb); |
672 body->toIR(p); | 675 body->toIR(p); |
673 | 676 |
674 if (!gIR->scopereturned()) | 677 if (!gIR->scopereturned()) |
675 llvm::BranchInst::Create(endbb, p->scopebb()); | 678 llvm::BranchInst::Create(endbb, p->scopebb()); |
676 | 679 |
677 gIR->func()->landingPad.pop(); | 680 gIR->func()->landingPadInfo.pop(); |
681 gIR->func()->landingPad = gIR->func()->landingPadInfo.get(); | |
678 | 682 |
679 // rewrite the scope | 683 // rewrite the scope |
680 p->scope() = IRScope(endbb,oldend); | 684 p->scope() = IRScope(endbb,oldend); |
681 } | 685 } |
682 | 686 |