Mercurial > projects > ldc
annotate dmd/statement.h @ 533:2fe2d4518618
Reverted some changes in the Tango patch, splitting asm block is simply not supported by llvm.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sun, 24 Aug 2008 16:51:17 +0200 |
parents | 6aee82889553 |
children | eef8ac26c66c |
rev | line source |
---|---|
336 | 1 |
2 // Compiler implementation of the D programming language | |
3 // Copyright (c) 1999-2008 by Digital Mars | |
4 // All Rights Reserved | |
5 // written by Walter Bright | |
6 // http://www.digitalmars.com | |
7 // License for redistribution is by either the Artistic License | |
8 // in artistic.txt, or the GNU General Public License in gnu.txt. | |
9 // See the included readme.txt for details. | |
10 | |
11 #ifndef DMD_STATEMENT_H | |
12 #define DMD_STATEMENT_H | |
13 | |
14 #ifdef __DMC__ | |
15 #pragma once | |
16 #endif /* __DMC__ */ | |
17 | |
18 #include "root.h" | |
19 | |
20 #include "arraytypes.h" | |
21 #include "dsymbol.h" | |
22 #include "lexer.h" | |
23 | |
24 struct OutBuffer; | |
25 struct Scope; | |
26 struct Expression; | |
27 struct LabelDsymbol; | |
28 struct Identifier; | |
29 struct IfStatement; | |
30 struct DeclarationStatement; | |
31 struct DefaultStatement; | |
32 struct VarDeclaration; | |
33 struct Condition; | |
34 struct Module; | |
35 struct Token; | |
36 struct InlineCostState; | |
37 struct InlineDoState; | |
38 struct InlineScanState; | |
39 struct ReturnStatement; | |
40 struct CompoundStatement; | |
41 struct Argument; | |
42 struct StaticAssert; | |
43 struct AsmStatement; | |
44 struct AsmBlockStatement; | |
45 struct GotoStatement; | |
46 struct ScopeStatement; | |
47 struct TryCatchStatement; | |
48 struct TryFinallyStatement; | |
49 struct HdrGenState; | |
50 struct InterState; | |
51 struct CaseStatement; | |
52 struct LabelStatement; | |
53 struct VolatileStatement; | |
54 struct SynchronizedStatement; | |
55 | |
56 enum TOK; | |
57 | |
58 namespace llvm | |
59 { | |
60 class Value; | |
61 class BasicBlock; | |
62 class ConstantInt; | |
63 } | |
64 | |
65 // Back end | |
66 struct IRState; | |
67 struct Blockx; | |
68 #if IN_LLVM | |
69 struct DValue; | |
70 typedef DValue elem; | |
71 #endif | |
72 | |
73 #if IN_GCC | |
74 union tree_node; typedef union tree_node block; | |
75 //union tree_node; typedef union tree_node elem; | |
76 #else | |
77 struct block; | |
78 //struct elem; | |
79 #endif | |
80 struct code; | |
81 | |
82 /* How a statement exits | |
83 */ | |
84 enum BE | |
85 { | |
86 BEnone = 0, | |
87 BEfallthru = 1, | |
88 BEthrow = 2, | |
89 BEreturn = 4, | |
90 BEgoto = 8, | |
91 BEhalt = 0x10, | |
92 BEbreak = 0x20, | |
93 BEcontinue = 0x40, | |
94 BEany = (BEfallthru | BEthrow | BEreturn | BEgoto | BEhalt), | |
95 }; | |
96 | |
97 // LLVMDC 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 | |
127 { | |
128 Loc loc; | |
129 | |
130 Statement(Loc loc); | |
131 virtual Statement *syntaxCopy(); | |
132 | |
133 void print(); | |
134 char *toChars(); | |
135 | |
136 void error(const char *format, ...); | |
137 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
138 virtual TryCatchStatement *isTryCatchStatement() { return NULL; } | |
139 virtual GotoStatement *isGotoStatement() { return NULL; } | |
140 virtual AsmStatement *isAsmStatement() { return NULL; } | |
141 virtual AsmBlockStatement *isAsmBlockStatement() { return NULL; } | |
142 #ifdef _DH | |
143 int incontract; | |
144 #endif | |
145 virtual ScopeStatement *isScopeStatement() { return NULL; } | |
146 virtual Statement *semantic(Scope *sc); | |
147 Statement *semanticScope(Scope *sc, Statement *sbreak, Statement *scontinue); | |
148 virtual int hasBreak(); | |
149 virtual int hasContinue(); | |
150 virtual int usesEH(); | |
151 virtual int fallOffEnd(); | |
152 virtual int blockExit(); | |
153 virtual int comeFrom(); | |
154 virtual void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
155 virtual Statements *flatten(Scope *sc); | |
156 virtual Expression *interpret(InterState *istate); | |
157 | |
158 virtual int inlineCost(InlineCostState *ics); | |
159 virtual Expression *doInline(InlineDoState *ids); | |
160 virtual Statement *inlineScan(InlineScanState *iss); | |
161 | |
162 // Back end | |
163 virtual void toIR(IRState *irs); | |
164 | |
165 // Avoid dynamic_cast | |
166 virtual DeclarationStatement *isDeclarationStatement() { return NULL; } | |
167 virtual CompoundStatement *isCompoundStatement() { return NULL; } | |
168 virtual ReturnStatement *isReturnStatement() { return NULL; } | |
169 virtual IfStatement *isIfStatement() { return NULL; } | |
170 virtual CaseStatement* isCaseStatement() { return NULL; } | |
171 }; | |
172 | |
173 struct ExpStatement : Statement | |
174 { | |
175 Expression *exp; | |
176 | |
177 ExpStatement(Loc loc, Expression *exp); | |
178 Statement *syntaxCopy(); | |
179 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
180 Statement *semantic(Scope *sc); | |
181 Expression *interpret(InterState *istate); | |
182 int fallOffEnd(); | |
183 int blockExit(); | |
184 | |
185 int inlineCost(InlineCostState *ics); | |
186 Expression *doInline(InlineDoState *ids); | |
187 Statement *inlineScan(InlineScanState *iss); | |
188 | |
189 void toIR(IRState *irs); | |
190 }; | |
191 | |
192 struct CompileStatement : Statement | |
193 { | |
194 Expression *exp; | |
195 | |
196 CompileStatement(Loc loc, Expression *exp); | |
197 Statement *syntaxCopy(); | |
198 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
199 Statements *flatten(Scope *sc); | |
200 Statement *semantic(Scope *sc); | |
201 }; | |
202 | |
203 struct DeclarationStatement : ExpStatement | |
204 { | |
205 // Doing declarations as an expression, rather than a statement, | |
206 // makes inlining functions much easier. | |
207 | |
208 DeclarationStatement(Loc loc, Dsymbol *s); | |
209 DeclarationStatement(Loc loc, Expression *exp); | |
210 Statement *syntaxCopy(); | |
211 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
212 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
213 | |
214 DeclarationStatement *isDeclarationStatement() { return this; } | |
215 }; | |
216 | |
217 struct CompoundStatement : Statement | |
218 { | |
219 Statements *statements; | |
220 | |
221 CompoundStatement(Loc loc, Statements *s); | |
222 CompoundStatement(Loc loc, Statement *s1, Statement *s2); | |
223 virtual Statement *syntaxCopy(); | |
224 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
225 virtual Statement *semantic(Scope *sc); | |
226 int usesEH(); | |
227 int blockExit(); | |
228 int fallOffEnd(); | |
229 int comeFrom(); | |
230 virtual Statements *flatten(Scope *sc); | |
231 ReturnStatement *isReturnStatement(); | |
232 Expression *interpret(InterState *istate); | |
233 | |
234 int inlineCost(InlineCostState *ics); | |
235 Expression *doInline(InlineDoState *ids); | |
236 Statement *inlineScan(InlineScanState *iss); | |
237 | |
238 virtual void toIR(IRState *irs); | |
239 | |
240 virtual CompoundStatement *isCompoundStatement() { return this; } | |
241 }; | |
242 | |
243 /* The purpose of this is so that continue will go to the next | |
244 * of the statements, and break will go to the end of the statements. | |
245 */ | |
246 struct UnrolledLoopStatement : Statement | |
247 { | |
248 Statements *statements; | |
249 EnclosingHandler* enclosinghandler; | |
250 | |
251 UnrolledLoopStatement(Loc loc, Statements *statements); | |
252 Statement *syntaxCopy(); | |
253 Statement *semantic(Scope *sc); | |
254 int hasBreak(); | |
255 int hasContinue(); | |
256 int usesEH(); | |
257 int blockExit(); | |
258 int fallOffEnd(); | |
259 int comeFrom(); | |
260 Expression *interpret(InterState *istate); | |
261 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
262 | |
263 int inlineCost(InlineCostState *ics); | |
264 Expression *doInline(InlineDoState *ids); | |
265 Statement *inlineScan(InlineScanState *iss); | |
266 | |
267 void toIR(IRState *irs); | |
268 }; | |
269 | |
270 struct ScopeStatement : Statement | |
271 { | |
272 Statement *statement; | |
273 | |
274 ScopeStatement(Loc loc, Statement *s); | |
275 Statement *syntaxCopy(); | |
276 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
277 ScopeStatement *isScopeStatement() { return this; } | |
278 Statement *semantic(Scope *sc); | |
279 int hasBreak(); | |
280 int hasContinue(); | |
281 int usesEH(); | |
282 int blockExit(); | |
283 int fallOffEnd(); | |
284 int comeFrom(); | |
285 Expression *interpret(InterState *istate); | |
286 | |
287 Statement *inlineScan(InlineScanState *iss); | |
288 | |
289 void toIR(IRState *irs); | |
290 }; | |
291 | |
292 struct WhileStatement : Statement | |
293 { | |
294 Expression *condition; | |
295 Statement *body; | |
296 EnclosingHandler* enclosinghandler; | |
297 | |
298 WhileStatement(Loc loc, Expression *c, Statement *b); | |
299 Statement *syntaxCopy(); | |
300 Statement *semantic(Scope *sc); | |
301 int hasBreak(); | |
302 int hasContinue(); | |
303 int usesEH(); | |
304 int blockExit(); | |
305 int fallOffEnd(); | |
306 int comeFrom(); | |
307 Expression *interpret(InterState *istate); | |
308 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
309 | |
310 Statement *inlineScan(InlineScanState *iss); | |
311 | |
312 void toIR(IRState *irs); | |
313 }; | |
314 | |
315 struct DoStatement : Statement | |
316 { | |
317 Statement *body; | |
318 Expression *condition; | |
319 EnclosingHandler* enclosinghandler; | |
320 | |
321 DoStatement(Loc loc, Statement *b, Expression *c); | |
322 Statement *syntaxCopy(); | |
323 Statement *semantic(Scope *sc); | |
324 int hasBreak(); | |
325 int hasContinue(); | |
326 int usesEH(); | |
327 int blockExit(); | |
328 int fallOffEnd(); | |
329 int comeFrom(); | |
330 Expression *interpret(InterState *istate); | |
331 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
332 | |
333 Statement *inlineScan(InlineScanState *iss); | |
334 | |
335 void toIR(IRState *irs); | |
336 }; | |
337 | |
338 struct ForStatement : Statement | |
339 { | |
340 Statement *init; | |
341 Expression *condition; | |
342 Expression *increment; | |
343 Statement *body; | |
344 EnclosingHandler* enclosinghandler; | |
345 | |
346 ForStatement(Loc loc, Statement *init, Expression *condition, Expression *increment, Statement *body); | |
347 Statement *syntaxCopy(); | |
348 Statement *semantic(Scope *sc); | |
349 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
350 int hasBreak(); | |
351 int hasContinue(); | |
352 int usesEH(); | |
353 int blockExit(); | |
354 int fallOffEnd(); | |
355 int comeFrom(); | |
356 Expression *interpret(InterState *istate); | |
357 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
358 | |
359 Statement *inlineScan(InlineScanState *iss); | |
360 | |
361 void toIR(IRState *irs); | |
362 }; | |
363 | |
364 struct ForeachStatement : Statement | |
365 { | |
366 enum TOK op; // TOKforeach or TOKforeach_reverse | |
367 Arguments *arguments; // array of Argument*'s | |
368 Expression *aggr; | |
369 Statement *body; | |
370 EnclosingHandler* enclosinghandler; | |
371 | |
372 VarDeclaration *key; | |
373 VarDeclaration *value; | |
374 | |
375 FuncDeclaration *func; // function we're lexically in | |
376 | |
377 Array cases; // put breaks, continues, gotos and returns here | |
378 Array gotos; // forward referenced goto's go here | |
379 | |
380 ForeachStatement(Loc loc, enum TOK op, Arguments *arguments, Expression *aggr, Statement *body); | |
381 Statement *syntaxCopy(); | |
382 Statement *semantic(Scope *sc); | |
383 int hasBreak(); | |
384 int hasContinue(); | |
385 int usesEH(); | |
386 int blockExit(); | |
387 int fallOffEnd(); | |
388 int comeFrom(); | |
389 Expression *interpret(InterState *istate); | |
390 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
391 | |
392 Statement *inlineScan(InlineScanState *iss); | |
393 | |
394 void toIR(IRState *irs); | |
395 }; | |
396 | |
397 #if DMDV2 | |
398 struct ForeachRangeStatement : Statement | |
399 { | |
400 enum TOK op; // TOKforeach or TOKforeach_reverse | |
401 Argument *arg; // loop index variable | |
402 Expression *lwr; | |
403 Expression *upr; | |
404 Statement *body; | |
405 | |
406 VarDeclaration *key; | |
407 | |
408 ForeachRangeStatement(Loc loc, enum TOK op, Argument *arg, | |
409 Expression *lwr, Expression *upr, Statement *body); | |
410 Statement *syntaxCopy(); | |
411 Statement *semantic(Scope *sc); | |
412 int hasBreak(); | |
413 int hasContinue(); | |
414 int usesEH(); | |
415 int blockExit(); | |
416 int fallOffEnd(); | |
417 int comeFrom(); | |
418 Expression *interpret(InterState *istate); | |
419 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
420 | |
421 Statement *inlineScan(InlineScanState *iss); | |
422 | |
423 void toIR(IRState *irs); | |
424 }; | |
425 #endif | |
426 | |
427 struct IfStatement : Statement | |
428 { | |
429 Argument *arg; | |
430 Expression *condition; | |
431 Statement *ifbody; | |
432 Statement *elsebody; | |
433 | |
434 VarDeclaration *match; // for MatchExpression results | |
435 | |
436 IfStatement(Loc loc, Argument *arg, Expression *condition, Statement *ifbody, Statement *elsebody); | |
437 Statement *syntaxCopy(); | |
438 Statement *semantic(Scope *sc); | |
439 Expression *interpret(InterState *istate); | |
440 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
441 int usesEH(); | |
442 int blockExit(); | |
443 int fallOffEnd(); | |
444 IfStatement *isIfStatement() { return this; } | |
445 | |
446 int inlineCost(InlineCostState *ics); | |
447 Expression *doInline(InlineDoState *ids); | |
448 Statement *inlineScan(InlineScanState *iss); | |
449 | |
450 void toIR(IRState *irs); | |
451 }; | |
452 | |
453 struct ConditionalStatement : Statement | |
454 { | |
455 Condition *condition; | |
456 Statement *ifbody; | |
457 Statement *elsebody; | |
458 | |
459 ConditionalStatement(Loc loc, Condition *condition, Statement *ifbody, Statement *elsebody); | |
460 Statement *syntaxCopy(); | |
461 Statement *semantic(Scope *sc); | |
462 Statements *flatten(Scope *sc); | |
463 int usesEH(); | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
356
diff
changeset
|
464 int blockExit(); |
336 | 465 |
466 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
467 }; | |
468 | |
469 struct PragmaStatement : Statement | |
470 { | |
471 Identifier *ident; | |
472 Expressions *args; // array of Expression's | |
473 Statement *body; | |
474 | |
475 PragmaStatement(Loc loc, Identifier *ident, Expressions *args, Statement *body); | |
476 Statement *syntaxCopy(); | |
477 Statement *semantic(Scope *sc); | |
478 int usesEH(); | |
479 int blockExit(); | |
480 int fallOffEnd(); | |
481 | |
482 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
483 }; | |
484 | |
485 struct StaticAssertStatement : Statement | |
486 { | |
487 StaticAssert *sa; | |
488 | |
489 StaticAssertStatement(StaticAssert *sa); | |
490 Statement *syntaxCopy(); | |
491 Statement *semantic(Scope *sc); | |
492 | |
493 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
494 }; | |
495 | |
496 struct SwitchStatement : Statement | |
497 { | |
498 Expression *condition; | |
499 Statement *body; | |
500 | |
501 DefaultStatement *sdefault; | |
502 EnclosingHandler* enclosinghandler; | |
503 | |
504 Array gotoCases; // array of unresolved GotoCaseStatement's | |
505 Array *cases; // array of CaseStatement's | |
506 int hasNoDefault; // !=0 if no default statement | |
507 | |
508 SwitchStatement(Loc loc, Expression *c, Statement *b); | |
509 Statement *syntaxCopy(); | |
510 Statement *semantic(Scope *sc); | |
511 int hasBreak(); | |
512 int usesEH(); | |
513 int blockExit(); | |
514 int fallOffEnd(); | |
515 Expression *interpret(InterState *istate); | |
516 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
517 | |
518 Statement *inlineScan(InlineScanState *iss); | |
519 | |
520 void toIR(IRState *irs); | |
521 }; | |
522 | |
523 struct CaseStatement : Statement | |
524 { | |
525 Expression *exp; | |
526 Statement *statement; | |
527 int index; // which case it is (since we sort this) | |
528 block *cblock; // back end: label for the block | |
529 | |
530 CaseStatement(Loc loc, Expression *exp, Statement *s); | |
531 Statement *syntaxCopy(); | |
532 Statement *semantic(Scope *sc); | |
533 int compare(Object *obj); | |
534 int usesEH(); | |
535 int blockExit(); | |
536 int fallOffEnd(); | |
537 int comeFrom(); | |
538 Expression *interpret(InterState *istate); | |
539 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
540 | |
541 Statement *inlineScan(InlineScanState *iss); | |
542 | |
543 void toIR(IRState *irs); | |
544 | |
545 CaseStatement* isCaseStatement() { return this; } | |
546 | |
547 // LLVMDC | |
548 llvm::BasicBlock* bodyBB; | |
549 llvm::ConstantInt* llvmIdx; | |
550 }; | |
551 | |
552 struct DefaultStatement : Statement | |
553 { | |
554 Statement *statement; | |
555 #if IN_GCC | |
556 block *cblock; // back end: label for the block | |
557 #endif | |
558 | |
559 DefaultStatement(Loc loc, Statement *s); | |
560 Statement *syntaxCopy(); | |
561 Statement *semantic(Scope *sc); | |
562 int usesEH(); | |
563 int blockExit(); | |
564 int fallOffEnd(); | |
565 int comeFrom(); | |
566 Expression *interpret(InterState *istate); | |
567 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
568 | |
569 Statement *inlineScan(InlineScanState *iss); | |
570 | |
571 void toIR(IRState *irs); | |
572 | |
573 // LLVMDC | |
574 llvm::BasicBlock* bodyBB; | |
575 }; | |
576 | |
577 struct GotoDefaultStatement : Statement | |
578 { | |
579 SwitchStatement *sw; | |
580 EnclosingHandler* enclosinghandler; | |
581 | |
582 GotoDefaultStatement(Loc loc); | |
583 Statement *syntaxCopy(); | |
584 Statement *semantic(Scope *sc); | |
585 Expression *interpret(InterState *istate); | |
586 int blockExit(); | |
587 int fallOffEnd(); | |
588 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
589 | |
590 void toIR(IRState *irs); | |
591 }; | |
592 | |
593 struct GotoCaseStatement : Statement | |
594 { | |
595 Expression *exp; // NULL, or which case to goto | |
596 CaseStatement *cs; // case statement it resolves to | |
597 EnclosingHandler* enclosinghandler; | |
598 SwitchStatement *sw; | |
599 | |
600 GotoCaseStatement(Loc loc, Expression *exp); | |
601 Statement *syntaxCopy(); | |
602 Statement *semantic(Scope *sc); | |
603 Expression *interpret(InterState *istate); | |
604 int blockExit(); | |
605 int fallOffEnd(); | |
606 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
607 | |
608 void toIR(IRState *irs); | |
609 }; | |
610 | |
611 struct SwitchErrorStatement : Statement | |
612 { | |
613 SwitchErrorStatement(Loc loc); | |
614 int blockExit(); | |
615 int fallOffEnd(); | |
616 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
617 | |
618 void toIR(IRState *irs); | |
619 }; | |
620 | |
621 struct ReturnStatement : Statement | |
622 { | |
623 Expression *exp; | |
624 EnclosingHandler* enclosinghandler; | |
625 | |
626 ReturnStatement(Loc loc, Expression *exp); | |
627 Statement *syntaxCopy(); | |
628 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
629 Statement *semantic(Scope *sc); | |
630 int blockExit(); | |
631 int fallOffEnd(); | |
632 Expression *interpret(InterState *istate); | |
633 | |
634 int inlineCost(InlineCostState *ics); | |
635 Expression *doInline(InlineDoState *ids); | |
636 Statement *inlineScan(InlineScanState *iss); | |
637 | |
638 void toIR(IRState *irs); | |
639 | |
640 ReturnStatement *isReturnStatement() { return this; } | |
641 }; | |
642 | |
643 struct BreakStatement : Statement | |
644 { | |
645 Identifier *ident; | |
646 EnclosingHandler* enclosinghandler; | |
647 | |
648 BreakStatement(Loc loc, Identifier *ident); | |
649 Statement *syntaxCopy(); | |
650 Statement *semantic(Scope *sc); | |
651 Expression *interpret(InterState *istate); | |
652 int blockExit(); | |
653 int fallOffEnd(); | |
654 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
655 | |
656 void toIR(IRState *irs); | |
657 | |
658 // LLVMDC: only set if ident is set: label statement to jump to | |
659 LabelStatement *target; | |
660 }; | |
661 | |
662 struct ContinueStatement : Statement | |
663 { | |
664 Identifier *ident; | |
665 EnclosingHandler* enclosinghandler; | |
666 | |
667 ContinueStatement(Loc loc, Identifier *ident); | |
668 Statement *syntaxCopy(); | |
669 Statement *semantic(Scope *sc); | |
670 Expression *interpret(InterState *istate); | |
671 int blockExit(); | |
672 int fallOffEnd(); | |
673 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
674 | |
675 void toIR(IRState *irs); | |
676 | |
677 // LLVMDC: only set if ident is set: label statement to jump to | |
678 LabelStatement *target; | |
679 }; | |
680 | |
681 struct SynchronizedStatement : Statement | |
682 { | |
683 Expression *exp; | |
684 Statement *body; | |
685 EnclosingHandler* enclosinghandler; | |
686 | |
687 SynchronizedStatement(Loc loc, Expression *exp, Statement *body); | |
688 Statement *syntaxCopy(); | |
689 Statement *semantic(Scope *sc); | |
690 int hasBreak(); | |
691 int hasContinue(); | |
692 int usesEH(); | |
693 int blockExit(); | |
694 int fallOffEnd(); | |
695 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
696 | |
697 Statement *inlineScan(InlineScanState *iss); | |
698 | |
699 // Back end | |
700 elem *esync; | |
701 SynchronizedStatement(Loc loc, elem *esync, Statement *body); | |
702 void toIR(IRState *irs); | |
703 llvm::Value* llsync; | |
704 }; | |
705 | |
706 struct WithStatement : Statement | |
707 { | |
708 Expression *exp; | |
709 Statement *body; | |
710 VarDeclaration *wthis; | |
711 | |
712 WithStatement(Loc loc, Expression *exp, Statement *body); | |
713 Statement *syntaxCopy(); | |
714 Statement *semantic(Scope *sc); | |
715 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
716 int usesEH(); | |
717 int blockExit(); | |
718 int fallOffEnd(); | |
719 | |
720 Statement *inlineScan(InlineScanState *iss); | |
721 | |
722 void toIR(IRState *irs); | |
723 }; | |
724 | |
725 struct TryCatchStatement : Statement | |
726 { | |
727 Statement *body; | |
728 Array *catches; | |
729 | |
730 TryCatchStatement(Loc loc, Statement *body, Array *catches); | |
731 Statement *syntaxCopy(); | |
732 Statement *semantic(Scope *sc); | |
733 int hasBreak(); | |
734 int usesEH(); | |
735 int blockExit(); | |
736 int fallOffEnd(); | |
737 | |
738 Statement *inlineScan(InlineScanState *iss); | |
739 | |
740 void toIR(IRState *irs); | |
741 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
742 TryCatchStatement *isTryCatchStatement() { return this; } | |
743 }; | |
744 | |
745 struct Catch : Object | |
746 { | |
747 Loc loc; | |
748 Type *type; | |
749 Identifier *ident; | |
750 VarDeclaration *var; | |
751 Statement *handler; | |
752 | |
753 Catch(Loc loc, Type *t, Identifier *id, Statement *handler); | |
754 Catch *syntaxCopy(); | |
755 void semantic(Scope *sc); | |
756 int blockExit(); | |
757 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
758 }; | |
759 | |
760 struct TryFinallyStatement : Statement | |
761 { | |
762 Statement *body; | |
763 Statement *finalbody; | |
764 EnclosingHandler* enclosinghandler; | |
765 | |
766 TryFinallyStatement(Loc loc, Statement *body, Statement *finalbody); | |
767 Statement *syntaxCopy(); | |
768 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
769 Statement *semantic(Scope *sc); | |
770 int hasBreak(); | |
771 int hasContinue(); | |
772 int usesEH(); | |
773 int blockExit(); | |
774 int fallOffEnd(); | |
775 | |
776 Statement *inlineScan(InlineScanState *iss); | |
777 | |
778 void toIR(IRState *irs); | |
779 }; | |
780 | |
781 struct OnScopeStatement : Statement | |
782 { | |
783 TOK tok; | |
784 Statement *statement; | |
785 | |
786 OnScopeStatement(Loc loc, TOK tok, Statement *statement); | |
787 Statement *syntaxCopy(); | |
788 int blockExit(); | |
789 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
790 Statement *semantic(Scope *sc); | |
791 int usesEH(); | |
792 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
793 | |
794 void toIR(IRState *irs); | |
795 }; | |
796 | |
797 struct ThrowStatement : Statement | |
798 { | |
799 Expression *exp; | |
800 | |
801 ThrowStatement(Loc loc, Expression *exp); | |
802 Statement *syntaxCopy(); | |
803 Statement *semantic(Scope *sc); | |
804 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
805 int blockExit(); | |
806 int fallOffEnd(); | |
807 | |
808 Statement *inlineScan(InlineScanState *iss); | |
809 | |
810 void toIR(IRState *irs); | |
811 }; | |
812 | |
813 struct VolatileStatement : Statement | |
814 { | |
815 Statement *statement; | |
816 EnclosingHandler* enclosinghandler; | |
817 | |
818 VolatileStatement(Loc loc, Statement *statement); | |
819 Statement *syntaxCopy(); | |
820 Statement *semantic(Scope *sc); | |
821 Statements *flatten(Scope *sc); | |
822 int blockExit(); | |
823 int fallOffEnd(); | |
824 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
825 | |
826 Statement *inlineScan(InlineScanState *iss); | |
827 | |
828 void toIR(IRState *irs); | |
829 }; | |
830 | |
831 struct GotoStatement : Statement | |
832 { | |
833 Identifier *ident; | |
834 LabelDsymbol *label; | |
835 TryFinallyStatement *tf; | |
836 EnclosingHandler* enclosinghandler; | |
837 | |
838 GotoStatement(Loc loc, Identifier *ident); | |
839 Statement *syntaxCopy(); | |
840 Statement *semantic(Scope *sc); | |
841 int blockExit(); | |
842 int fallOffEnd(); | |
843 Expression *interpret(InterState *istate); | |
844 | |
845 void toIR(IRState *irs); | |
846 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
847 GotoStatement *isGotoStatement() { return this; } | |
848 }; | |
849 | |
850 struct LabelStatement : Statement | |
851 { | |
852 Identifier *ident; | |
853 Statement *statement; | |
854 TryFinallyStatement *tf; | |
855 EnclosingHandler* enclosinghandler; | |
856 block *lblock; // back end | |
857 int isReturnLabel; | |
858 | |
859 LabelStatement(Loc loc, Identifier *ident, Statement *statement); | |
860 Statement *syntaxCopy(); | |
861 Statement *semantic(Scope *sc); | |
862 Statements *flatten(Scope *sc); | |
863 int usesEH(); | |
864 int blockExit(); | |
865 int fallOffEnd(); | |
866 int comeFrom(); | |
867 Expression *interpret(InterState *istate); | |
868 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
869 | |
870 Statement *inlineScan(InlineScanState *iss); | |
871 | |
872 void toIR(IRState *irs); | |
873 | |
874 // LLVMDC | |
875 bool asmLabel; // for labels inside inline assembler | |
876 }; | |
877 | |
878 struct LabelDsymbol : Dsymbol | |
879 { | |
880 LabelStatement *statement; | |
881 | |
882 LabelDsymbol(Identifier *ident); | |
883 LabelDsymbol *isLabel(); | |
884 }; | |
885 | |
886 struct AsmStatement : Statement | |
887 { | |
888 Token *tokens; | |
889 code *asmcode; | |
890 unsigned asmalign; // alignment of this statement | |
891 unsigned refparam; // !=0 if function parameter is referenced | |
892 unsigned naked; // !=0 if function is to be naked | |
893 unsigned regs; // mask of registers modified | |
894 | |
895 AsmStatement(Loc loc, Token *tokens); | |
896 Statement *syntaxCopy(); | |
897 Statement *semantic(Scope *sc); | |
898 int blockExit(); | |
899 int comeFrom(); | |
900 | |
901 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
902 virtual AsmStatement *isAsmStatement() { return this; } | |
903 | |
904 void toIR(IRState *irs); | |
905 | |
906 // LLVMDC | |
907 // non-zero if this is a branch, contains the target labels identifier | |
908 Identifier* isBranchToLabel; | |
909 }; | |
910 | |
911 struct AsmBlockStatement : CompoundStatement | |
912 { | |
913 EnclosingHandler* enclosinghandler; | |
356
44daf304421c
[svn r377] The previous check was too strict, it completely disallowed gotos within finally blocks. This reenables them as long as they don't cross a finally boundary.
ChristianK
parents:
353
diff
changeset
|
914 TryFinallyStatement* tf; |
336 | 915 |
916 AsmBlockStatement(Loc loc, Statements *s); | |
917 Statements *flatten(Scope *sc); | |
918 Statement *syntaxCopy(); | |
919 Statement *semantic(Scope *sc); | |
920 | |
921 CompoundStatement *isCompoundStatement() { return NULL; } | |
922 AsmBlockStatement *isAsmBlockStatement() { return this; } | |
923 | |
924 void toIR(IRState *irs); | |
925 }; | |
926 | |
927 #endif /* DMD_STATEMENT_H */ |