Mercurial > projects > ldc
comparison dmd/statement.h @ 1141:f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
implement the synchronized storage class for functions.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Tue, 24 Mar 2009 21:18:18 +0100 |
parents | b30fe7e1dbb9 |
children | c6d6a68bb5db |
comparison
equal
deleted
inserted
replaced
1137:45d73f0a9b43 | 1141:f99a3b393c03 |
---|---|
92 BEbreak = 0x20, | 92 BEbreak = 0x20, |
93 BEcontinue = 0x40, | 93 BEcontinue = 0x40, |
94 BEany = (BEfallthru | BEthrow | BEreturn | BEgoto | BEhalt), | 94 BEany = (BEfallthru | BEthrow | BEreturn | BEgoto | BEhalt), |
95 }; | 95 }; |
96 | 96 |
97 // LDC this is used for tracking try-finally, synchronized and volatile scopes | |
98 // definitions in gen/llvmhelpers.cpp | |
99 struct EnclosingHandler : Object | |
100 { | |
101 virtual void emitCode(IRState* p) = 0; | |
102 virtual EnclosingHandler* getEnclosing() = 0; | |
103 }; | |
104 struct EnclosingTryFinally : EnclosingHandler | |
105 { | |
106 TryFinallyStatement* tf; | |
107 void emitCode(IRState* p); | |
108 EnclosingHandler* getEnclosing(); | |
109 EnclosingTryFinally(TryFinallyStatement* _tf) : tf(_tf) {} | |
110 }; | |
111 struct EnclosingVolatile : EnclosingHandler | |
112 { | |
113 VolatileStatement* v; | |
114 void emitCode(IRState* p); | |
115 EnclosingHandler* getEnclosing(); | |
116 EnclosingVolatile(VolatileStatement* _tf) : v(_tf) {} | |
117 }; | |
118 struct EnclosingSynchro : EnclosingHandler | |
119 { | |
120 SynchronizedStatement* s; | |
121 void emitCode(IRState* p); | |
122 EnclosingHandler* getEnclosing(); | |
123 EnclosingSynchro(SynchronizedStatement* _tf) : s(_tf) {} | |
124 }; | |
125 | |
126 struct Statement : Object | 97 struct Statement : Object |
127 { | 98 { |
128 Loc loc; | 99 Loc loc; |
129 | 100 |
130 Statement(Loc loc); | 101 Statement(Loc loc); |
253 * of the statements, and break will go to the end of the statements. | 224 * of the statements, and break will go to the end of the statements. |
254 */ | 225 */ |
255 struct UnrolledLoopStatement : Statement | 226 struct UnrolledLoopStatement : Statement |
256 { | 227 { |
257 Statements *statements; | 228 Statements *statements; |
258 EnclosingHandler* enclosinghandler; | |
259 | 229 |
260 UnrolledLoopStatement(Loc loc, Statements *statements); | 230 UnrolledLoopStatement(Loc loc, Statements *statements); |
261 Statement *syntaxCopy(); | 231 Statement *syntaxCopy(); |
262 Statement *semantic(Scope *sc); | 232 Statement *semantic(Scope *sc); |
263 int hasBreak(); | 233 int hasBreak(); |
298 | 268 |
299 struct WhileStatement : Statement | 269 struct WhileStatement : Statement |
300 { | 270 { |
301 Expression *condition; | 271 Expression *condition; |
302 Statement *body; | 272 Statement *body; |
303 EnclosingHandler* enclosinghandler; | |
304 | 273 |
305 WhileStatement(Loc loc, Expression *c, Statement *b); | 274 WhileStatement(Loc loc, Expression *c, Statement *b); |
306 Statement *syntaxCopy(); | 275 Statement *syntaxCopy(); |
307 Statement *semantic(Scope *sc); | 276 Statement *semantic(Scope *sc); |
308 int hasBreak(); | 277 int hasBreak(); |
320 | 289 |
321 struct DoStatement : Statement | 290 struct DoStatement : Statement |
322 { | 291 { |
323 Statement *body; | 292 Statement *body; |
324 Expression *condition; | 293 Expression *condition; |
325 EnclosingHandler* enclosinghandler; | |
326 | 294 |
327 DoStatement(Loc loc, Statement *b, Expression *c); | 295 DoStatement(Loc loc, Statement *b, Expression *c); |
328 Statement *syntaxCopy(); | 296 Statement *syntaxCopy(); |
329 Statement *semantic(Scope *sc); | 297 Statement *semantic(Scope *sc); |
330 int hasBreak(); | 298 int hasBreak(); |
344 { | 312 { |
345 Statement *init; | 313 Statement *init; |
346 Expression *condition; | 314 Expression *condition; |
347 Expression *increment; | 315 Expression *increment; |
348 Statement *body; | 316 Statement *body; |
349 EnclosingHandler* enclosinghandler; | |
350 | 317 |
351 ForStatement(Loc loc, Statement *init, Expression *condition, Expression *increment, Statement *body); | 318 ForStatement(Loc loc, Statement *init, Expression *condition, Expression *increment, Statement *body); |
352 Statement *syntaxCopy(); | 319 Statement *syntaxCopy(); |
353 Statement *semantic(Scope *sc); | 320 Statement *semantic(Scope *sc); |
354 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | 321 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); |
369 { | 336 { |
370 enum TOK op; // TOKforeach or TOKforeach_reverse | 337 enum TOK op; // TOKforeach or TOKforeach_reverse |
371 Arguments *arguments; // array of Argument*'s | 338 Arguments *arguments; // array of Argument*'s |
372 Expression *aggr; | 339 Expression *aggr; |
373 Statement *body; | 340 Statement *body; |
374 EnclosingHandler* enclosinghandler; | |
375 | 341 |
376 VarDeclaration *key; | 342 VarDeclaration *key; |
377 VarDeclaration *value; | 343 VarDeclaration *value; |
378 | 344 |
379 FuncDeclaration *func; // function we're lexically in | 345 FuncDeclaration *func; // function we're lexically in |
497 { | 463 { |
498 Expression *condition; | 464 Expression *condition; |
499 Statement *body; | 465 Statement *body; |
500 | 466 |
501 DefaultStatement *sdefault; | 467 DefaultStatement *sdefault; |
502 EnclosingHandler* enclosinghandler; | |
503 | 468 |
504 Array gotoCases; // array of unresolved GotoCaseStatement's | 469 Array gotoCases; // array of unresolved GotoCaseStatement's |
505 Array *cases; // array of CaseStatement's | 470 Array *cases; // array of CaseStatement's |
506 int hasNoDefault; // !=0 if no default statement | 471 int hasNoDefault; // !=0 if no default statement |
507 | 472 |
572 }; | 537 }; |
573 | 538 |
574 struct GotoDefaultStatement : Statement | 539 struct GotoDefaultStatement : Statement |
575 { | 540 { |
576 SwitchStatement *sw; | 541 SwitchStatement *sw; |
577 EnclosingHandler* enclosinghandler; | |
578 | 542 |
579 GotoDefaultStatement(Loc loc); | 543 GotoDefaultStatement(Loc loc); |
580 Statement *syntaxCopy(); | 544 Statement *syntaxCopy(); |
581 Statement *semantic(Scope *sc); | 545 Statement *semantic(Scope *sc); |
582 Expression *interpret(InterState *istate); | 546 Expression *interpret(InterState *istate); |
588 | 552 |
589 struct GotoCaseStatement : Statement | 553 struct GotoCaseStatement : Statement |
590 { | 554 { |
591 Expression *exp; // NULL, or which case to goto | 555 Expression *exp; // NULL, or which case to goto |
592 CaseStatement *cs; // case statement it resolves to | 556 CaseStatement *cs; // case statement it resolves to |
593 EnclosingHandler* enclosinghandler; | |
594 SwitchStatement *sw; | 557 SwitchStatement *sw; |
595 | 558 |
596 GotoCaseStatement(Loc loc, Expression *exp); | 559 GotoCaseStatement(Loc loc, Expression *exp); |
597 Statement *syntaxCopy(); | 560 Statement *syntaxCopy(); |
598 Statement *semantic(Scope *sc); | 561 Statement *semantic(Scope *sc); |
613 }; | 576 }; |
614 | 577 |
615 struct ReturnStatement : Statement | 578 struct ReturnStatement : Statement |
616 { | 579 { |
617 Expression *exp; | 580 Expression *exp; |
618 EnclosingHandler* enclosinghandler; | |
619 | 581 |
620 ReturnStatement(Loc loc, Expression *exp); | 582 ReturnStatement(Loc loc, Expression *exp); |
621 Statement *syntaxCopy(); | 583 Statement *syntaxCopy(); |
622 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 584 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
623 Statement *semantic(Scope *sc); | 585 Statement *semantic(Scope *sc); |
634 }; | 596 }; |
635 | 597 |
636 struct BreakStatement : Statement | 598 struct BreakStatement : Statement |
637 { | 599 { |
638 Identifier *ident; | 600 Identifier *ident; |
639 EnclosingHandler* enclosinghandler; | |
640 | 601 |
641 BreakStatement(Loc loc, Identifier *ident); | 602 BreakStatement(Loc loc, Identifier *ident); |
642 Statement *syntaxCopy(); | 603 Statement *syntaxCopy(); |
643 Statement *semantic(Scope *sc); | 604 Statement *semantic(Scope *sc); |
644 Expression *interpret(InterState *istate); | 605 Expression *interpret(InterState *istate); |
652 }; | 613 }; |
653 | 614 |
654 struct ContinueStatement : Statement | 615 struct ContinueStatement : Statement |
655 { | 616 { |
656 Identifier *ident; | 617 Identifier *ident; |
657 EnclosingHandler* enclosinghandler; | |
658 | 618 |
659 ContinueStatement(Loc loc, Identifier *ident); | 619 ContinueStatement(Loc loc, Identifier *ident); |
660 Statement *syntaxCopy(); | 620 Statement *syntaxCopy(); |
661 Statement *semantic(Scope *sc); | 621 Statement *semantic(Scope *sc); |
662 Expression *interpret(InterState *istate); | 622 Expression *interpret(InterState *istate); |
671 | 631 |
672 struct SynchronizedStatement : Statement | 632 struct SynchronizedStatement : Statement |
673 { | 633 { |
674 Expression *exp; | 634 Expression *exp; |
675 Statement *body; | 635 Statement *body; |
676 EnclosingHandler* enclosinghandler; | |
677 | 636 |
678 SynchronizedStatement(Loc loc, Expression *exp, Statement *body); | 637 SynchronizedStatement(Loc loc, Expression *exp, Statement *body); |
679 Statement *syntaxCopy(); | 638 Statement *syntaxCopy(); |
680 Statement *semantic(Scope *sc); | 639 Statement *semantic(Scope *sc); |
681 int hasBreak(); | 640 int hasBreak(); |
747 | 706 |
748 struct TryFinallyStatement : Statement | 707 struct TryFinallyStatement : Statement |
749 { | 708 { |
750 Statement *body; | 709 Statement *body; |
751 Statement *finalbody; | 710 Statement *finalbody; |
752 EnclosingHandler* enclosinghandler; | |
753 | 711 |
754 TryFinallyStatement(Loc loc, Statement *body, Statement *finalbody); | 712 TryFinallyStatement(Loc loc, Statement *body, Statement *finalbody); |
755 Statement *syntaxCopy(); | 713 Statement *syntaxCopy(); |
756 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 714 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
757 Statement *semantic(Scope *sc); | 715 Statement *semantic(Scope *sc); |
797 }; | 755 }; |
798 | 756 |
799 struct VolatileStatement : Statement | 757 struct VolatileStatement : Statement |
800 { | 758 { |
801 Statement *statement; | 759 Statement *statement; |
802 EnclosingHandler* enclosinghandler; | |
803 | 760 |
804 VolatileStatement(Loc loc, Statement *statement); | 761 VolatileStatement(Loc loc, Statement *statement); |
805 Statement *syntaxCopy(); | 762 Statement *syntaxCopy(); |
806 Statement *semantic(Scope *sc); | 763 Statement *semantic(Scope *sc); |
807 Statements *flatten(Scope *sc); | 764 Statements *flatten(Scope *sc); |
815 | 772 |
816 struct GotoStatement : Statement | 773 struct GotoStatement : Statement |
817 { | 774 { |
818 Identifier *ident; | 775 Identifier *ident; |
819 LabelDsymbol *label; | 776 LabelDsymbol *label; |
820 TryFinallyStatement *tf; | 777 TryFinallyStatement *enclosingFinally; |
821 EnclosingHandler* enclosinghandler; | 778 Statement* enclosingScopeExit; |
822 | 779 |
823 GotoStatement(Loc loc, Identifier *ident); | 780 GotoStatement(Loc loc, Identifier *ident); |
824 Statement *syntaxCopy(); | 781 Statement *syntaxCopy(); |
825 Statement *semantic(Scope *sc); | 782 Statement *semantic(Scope *sc); |
826 int blockExit(); | 783 int blockExit(); |
833 | 790 |
834 struct LabelStatement : Statement | 791 struct LabelStatement : Statement |
835 { | 792 { |
836 Identifier *ident; | 793 Identifier *ident; |
837 Statement *statement; | 794 Statement *statement; |
838 TryFinallyStatement *tf; | 795 TryFinallyStatement *enclosingFinally; |
839 EnclosingHandler* enclosinghandler; | 796 Statement* enclosingScopeExit; |
840 block *lblock; // back end | 797 block *lblock; // back end |
841 int isReturnLabel; | 798 int isReturnLabel; |
842 | 799 |
843 LabelStatement(Loc loc, Identifier *ident, Statement *statement); | 800 LabelStatement(Loc loc, Identifier *ident, Statement *statement); |
844 Statement *syntaxCopy(); | 801 Statement *syntaxCopy(); |
893 void toNakedIR(IRState *irs); | 850 void toNakedIR(IRState *irs); |
894 }; | 851 }; |
895 | 852 |
896 struct AsmBlockStatement : CompoundStatement | 853 struct AsmBlockStatement : CompoundStatement |
897 { | 854 { |
898 EnclosingHandler* enclosinghandler; | 855 TryFinallyStatement* enclosingFinally; |
899 TryFinallyStatement* tf; | 856 Statement* enclosingScopeExit; |
900 | 857 |
901 AsmBlockStatement(Loc loc, Statements *s); | 858 AsmBlockStatement(Loc loc, Statements *s); |
902 Statements *flatten(Scope *sc); | 859 Statements *flatten(Scope *sc); |
903 Statement *syntaxCopy(); | 860 Statement *syntaxCopy(); |
904 Statement *semantic(Scope *sc); | 861 Statement *semantic(Scope *sc); |