Mercurial > projects > ldc
comparison dmd2/statement.h @ 758:f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 11 Nov 2008 01:38:48 +0100 |
parents | |
children | 356e65836fb5 |
comparison
equal
deleted
inserted
replaced
757:2c730d530c98 | 758:f04dde6e882c |
---|---|
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 // 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 | |
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(Scope *sc, 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(Scope *sc, 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(Scope *sc, 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 EnclosingHandler* enclosinghandler; | |
406 | |
407 VarDeclaration *key; | |
408 | |
409 ForeachRangeStatement(Loc loc, enum TOK op, Argument *arg, | |
410 Expression *lwr, Expression *upr, Statement *body); | |
411 Statement *syntaxCopy(); | |
412 Statement *semantic(Scope *sc); | |
413 int hasBreak(); | |
414 int hasContinue(); | |
415 int usesEH(); | |
416 int blockExit(); | |
417 int fallOffEnd(); | |
418 int comeFrom(); | |
419 Expression *interpret(InterState *istate); | |
420 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
421 | |
422 Statement *inlineScan(InlineScanState *iss); | |
423 | |
424 void toIR(IRState *irs); | |
425 }; | |
426 #endif | |
427 | |
428 struct IfStatement : Statement | |
429 { | |
430 Argument *arg; | |
431 Expression *condition; | |
432 Statement *ifbody; | |
433 Statement *elsebody; | |
434 | |
435 VarDeclaration *match; // for MatchExpression results | |
436 | |
437 IfStatement(Loc loc, Argument *arg, Expression *condition, Statement *ifbody, Statement *elsebody); | |
438 Statement *syntaxCopy(); | |
439 Statement *semantic(Scope *sc); | |
440 Expression *interpret(InterState *istate); | |
441 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
442 int usesEH(); | |
443 int blockExit(); | |
444 int fallOffEnd(); | |
445 IfStatement *isIfStatement() { return this; } | |
446 | |
447 int inlineCost(InlineCostState *ics); | |
448 Expression *doInline(InlineDoState *ids); | |
449 Statement *inlineScan(InlineScanState *iss); | |
450 | |
451 void toIR(IRState *irs); | |
452 }; | |
453 | |
454 struct ConditionalStatement : Statement | |
455 { | |
456 Condition *condition; | |
457 Statement *ifbody; | |
458 Statement *elsebody; | |
459 | |
460 ConditionalStatement(Loc loc, Condition *condition, Statement *ifbody, Statement *elsebody); | |
461 Statement *syntaxCopy(); | |
462 Statement *semantic(Scope *sc); | |
463 Statements *flatten(Scope *sc); | |
464 int usesEH(); | |
465 int blockExit(); | |
466 | |
467 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
468 }; | |
469 | |
470 struct PragmaStatement : Statement | |
471 { | |
472 Identifier *ident; | |
473 Expressions *args; // array of Expression's | |
474 Statement *body; | |
475 | |
476 PragmaStatement(Loc loc, Identifier *ident, Expressions *args, Statement *body); | |
477 Statement *syntaxCopy(); | |
478 Statement *semantic(Scope *sc); | |
479 int usesEH(); | |
480 int blockExit(); | |
481 int fallOffEnd(); | |
482 | |
483 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
484 | |
485 void toIR(IRState *irs); | |
486 }; | |
487 | |
488 struct StaticAssertStatement : Statement | |
489 { | |
490 StaticAssert *sa; | |
491 | |
492 StaticAssertStatement(StaticAssert *sa); | |
493 Statement *syntaxCopy(); | |
494 Statement *semantic(Scope *sc); | |
495 | |
496 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
497 }; | |
498 | |
499 struct SwitchStatement : Statement | |
500 { | |
501 Expression *condition; | |
502 Statement *body; | |
503 | |
504 DefaultStatement *sdefault; | |
505 TryFinallyStatement *tf; | |
506 EnclosingHandler* enclosinghandler; | |
507 | |
508 Array gotoCases; // array of unresolved GotoCaseStatement's | |
509 Array *cases; // array of CaseStatement's | |
510 int hasNoDefault; // !=0 if no default statement | |
511 int hasVars; // !=0 if has variable case values | |
512 | |
513 SwitchStatement(Loc loc, Expression *c, Statement *b); | |
514 Statement *syntaxCopy(); | |
515 Statement *semantic(Scope *sc); | |
516 int hasBreak(); | |
517 int usesEH(); | |
518 int blockExit(); | |
519 int fallOffEnd(); | |
520 Expression *interpret(InterState *istate); | |
521 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
522 | |
523 Statement *inlineScan(InlineScanState *iss); | |
524 | |
525 void toIR(IRState *irs); | |
526 }; | |
527 | |
528 struct CaseStatement : Statement | |
529 { | |
530 Expression *exp; | |
531 Statement *statement; | |
532 int index; // which case it is (since we sort this) | |
533 block *cblock; // back end: label for the block | |
534 | |
535 CaseStatement(Loc loc, Expression *exp, Statement *s); | |
536 Statement *syntaxCopy(); | |
537 Statement *semantic(Scope *sc); | |
538 int compare(Object *obj); | |
539 int usesEH(); | |
540 int blockExit(); | |
541 int fallOffEnd(); | |
542 int comeFrom(); | |
543 Expression *interpret(InterState *istate); | |
544 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
545 | |
546 Statement *inlineScan(InlineScanState *iss); | |
547 | |
548 void toIR(IRState *irs); | |
549 | |
550 CaseStatement* isCaseStatement() { return this; } | |
551 | |
552 // LDC | |
553 llvm::BasicBlock* bodyBB; | |
554 llvm::ConstantInt* llvmIdx; | |
555 }; | |
556 | |
557 struct DefaultStatement : Statement | |
558 { | |
559 Statement *statement; | |
560 #if IN_GCC | |
561 block *cblock; // back end: label for the block | |
562 #endif | |
563 | |
564 DefaultStatement(Loc loc, Statement *s); | |
565 Statement *syntaxCopy(); | |
566 Statement *semantic(Scope *sc); | |
567 int usesEH(); | |
568 int blockExit(); | |
569 int fallOffEnd(); | |
570 int comeFrom(); | |
571 Expression *interpret(InterState *istate); | |
572 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
573 | |
574 Statement *inlineScan(InlineScanState *iss); | |
575 | |
576 void toIR(IRState *irs); | |
577 | |
578 // LDC | |
579 llvm::BasicBlock* bodyBB; | |
580 }; | |
581 | |
582 struct GotoDefaultStatement : Statement | |
583 { | |
584 SwitchStatement *sw; | |
585 EnclosingHandler* enclosinghandler; | |
586 | |
587 GotoDefaultStatement(Loc loc); | |
588 Statement *syntaxCopy(); | |
589 Statement *semantic(Scope *sc); | |
590 Expression *interpret(InterState *istate); | |
591 int blockExit(); | |
592 int fallOffEnd(); | |
593 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
594 | |
595 void toIR(IRState *irs); | |
596 }; | |
597 | |
598 struct GotoCaseStatement : Statement | |
599 { | |
600 Expression *exp; // NULL, or which case to goto | |
601 CaseStatement *cs; // case statement it resolves to | |
602 EnclosingHandler* enclosinghandler; | |
603 SwitchStatement *sw; | |
604 | |
605 GotoCaseStatement(Loc loc, Expression *exp); | |
606 Statement *syntaxCopy(); | |
607 Statement *semantic(Scope *sc); | |
608 Expression *interpret(InterState *istate); | |
609 int blockExit(); | |
610 int fallOffEnd(); | |
611 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
612 | |
613 void toIR(IRState *irs); | |
614 }; | |
615 | |
616 struct SwitchErrorStatement : Statement | |
617 { | |
618 SwitchErrorStatement(Loc loc); | |
619 int blockExit(); | |
620 int fallOffEnd(); | |
621 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
622 | |
623 void toIR(IRState *irs); | |
624 }; | |
625 | |
626 struct ReturnStatement : Statement | |
627 { | |
628 Expression *exp; | |
629 EnclosingHandler* enclosinghandler; | |
630 | |
631 ReturnStatement(Loc loc, Expression *exp); | |
632 Statement *syntaxCopy(); | |
633 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
634 Statement *semantic(Scope *sc); | |
635 int blockExit(); | |
636 int fallOffEnd(); | |
637 Expression *interpret(InterState *istate); | |
638 | |
639 int inlineCost(InlineCostState *ics); | |
640 Expression *doInline(InlineDoState *ids); | |
641 Statement *inlineScan(InlineScanState *iss); | |
642 | |
643 void toIR(IRState *irs); | |
644 | |
645 ReturnStatement *isReturnStatement() { return this; } | |
646 }; | |
647 | |
648 struct BreakStatement : Statement | |
649 { | |
650 Identifier *ident; | |
651 EnclosingHandler* enclosinghandler; | |
652 | |
653 BreakStatement(Loc loc, Identifier *ident); | |
654 Statement *syntaxCopy(); | |
655 Statement *semantic(Scope *sc); | |
656 Expression *interpret(InterState *istate); | |
657 int blockExit(); | |
658 int fallOffEnd(); | |
659 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
660 | |
661 void toIR(IRState *irs); | |
662 | |
663 // LDC: only set if ident is set: label statement to jump to | |
664 LabelStatement *target; | |
665 }; | |
666 | |
667 struct ContinueStatement : Statement | |
668 { | |
669 Identifier *ident; | |
670 EnclosingHandler* enclosinghandler; | |
671 | |
672 ContinueStatement(Loc loc, Identifier *ident); | |
673 Statement *syntaxCopy(); | |
674 Statement *semantic(Scope *sc); | |
675 Expression *interpret(InterState *istate); | |
676 int blockExit(); | |
677 int fallOffEnd(); | |
678 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
679 | |
680 void toIR(IRState *irs); | |
681 | |
682 // LDC: only set if ident is set: label statement to jump to | |
683 LabelStatement *target; | |
684 }; | |
685 | |
686 struct SynchronizedStatement : Statement | |
687 { | |
688 Expression *exp; | |
689 Statement *body; | |
690 EnclosingHandler* enclosinghandler; | |
691 | |
692 SynchronizedStatement(Loc loc, Expression *exp, Statement *body); | |
693 Statement *syntaxCopy(); | |
694 Statement *semantic(Scope *sc); | |
695 int hasBreak(); | |
696 int hasContinue(); | |
697 int usesEH(); | |
698 int blockExit(); | |
699 int fallOffEnd(); | |
700 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
701 | |
702 Statement *inlineScan(InlineScanState *iss); | |
703 | |
704 // Back end | |
705 elem *esync; | |
706 SynchronizedStatement(Loc loc, elem *esync, Statement *body); | |
707 void toIR(IRState *irs); | |
708 llvm::Value* llsync; | |
709 }; | |
710 | |
711 struct WithStatement : Statement | |
712 { | |
713 Expression *exp; | |
714 Statement *body; | |
715 VarDeclaration *wthis; | |
716 | |
717 WithStatement(Loc loc, Expression *exp, Statement *body); | |
718 Statement *syntaxCopy(); | |
719 Statement *semantic(Scope *sc); | |
720 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
721 int usesEH(); | |
722 int blockExit(); | |
723 int fallOffEnd(); | |
724 | |
725 Statement *inlineScan(InlineScanState *iss); | |
726 | |
727 void toIR(IRState *irs); | |
728 }; | |
729 | |
730 struct TryCatchStatement : Statement | |
731 { | |
732 Statement *body; | |
733 Array *catches; | |
734 | |
735 TryCatchStatement(Loc loc, Statement *body, Array *catches); | |
736 Statement *syntaxCopy(); | |
737 Statement *semantic(Scope *sc); | |
738 int hasBreak(); | |
739 int usesEH(); | |
740 int blockExit(); | |
741 int fallOffEnd(); | |
742 | |
743 Statement *inlineScan(InlineScanState *iss); | |
744 | |
745 void toIR(IRState *irs); | |
746 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
747 TryCatchStatement *isTryCatchStatement() { return this; } | |
748 }; | |
749 | |
750 struct Catch : Object | |
751 { | |
752 Loc loc; | |
753 Type *type; | |
754 Identifier *ident; | |
755 VarDeclaration *var; | |
756 Statement *handler; | |
757 | |
758 Catch(Loc loc, Type *t, Identifier *id, Statement *handler); | |
759 Catch *syntaxCopy(); | |
760 void semantic(Scope *sc); | |
761 int blockExit(); | |
762 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
763 }; | |
764 | |
765 struct TryFinallyStatement : Statement | |
766 { | |
767 Statement *body; | |
768 Statement *finalbody; | |
769 EnclosingHandler* enclosinghandler; | |
770 | |
771 TryFinallyStatement(Loc loc, Statement *body, Statement *finalbody); | |
772 Statement *syntaxCopy(); | |
773 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
774 Statement *semantic(Scope *sc); | |
775 int hasBreak(); | |
776 int hasContinue(); | |
777 int usesEH(); | |
778 int blockExit(); | |
779 int fallOffEnd(); | |
780 | |
781 Statement *inlineScan(InlineScanState *iss); | |
782 | |
783 void toIR(IRState *irs); | |
784 }; | |
785 | |
786 struct OnScopeStatement : Statement | |
787 { | |
788 TOK tok; | |
789 Statement *statement; | |
790 | |
791 OnScopeStatement(Loc loc, TOK tok, Statement *statement); | |
792 Statement *syntaxCopy(); | |
793 int blockExit(); | |
794 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
795 Statement *semantic(Scope *sc); | |
796 int usesEH(); | |
797 void scopeCode(Scope *sc, Statement **sentry, Statement **sexit, Statement **sfinally); | |
798 | |
799 void toIR(IRState *irs); | |
800 }; | |
801 | |
802 struct ThrowStatement : Statement | |
803 { | |
804 Expression *exp; | |
805 | |
806 ThrowStatement(Loc loc, Expression *exp); | |
807 Statement *syntaxCopy(); | |
808 Statement *semantic(Scope *sc); | |
809 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
810 int blockExit(); | |
811 int fallOffEnd(); | |
812 | |
813 Statement *inlineScan(InlineScanState *iss); | |
814 | |
815 void toIR(IRState *irs); | |
816 }; | |
817 | |
818 struct VolatileStatement : Statement | |
819 { | |
820 Statement *statement; | |
821 EnclosingHandler* enclosinghandler; | |
822 | |
823 VolatileStatement(Loc loc, Statement *statement); | |
824 Statement *syntaxCopy(); | |
825 Statement *semantic(Scope *sc); | |
826 Statements *flatten(Scope *sc); | |
827 int blockExit(); | |
828 int fallOffEnd(); | |
829 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
830 | |
831 Statement *inlineScan(InlineScanState *iss); | |
832 | |
833 void toIR(IRState *irs); | |
834 }; | |
835 | |
836 struct GotoStatement : Statement | |
837 { | |
838 Identifier *ident; | |
839 LabelDsymbol *label; | |
840 TryFinallyStatement *tf; | |
841 EnclosingHandler* enclosinghandler; | |
842 | |
843 GotoStatement(Loc loc, Identifier *ident); | |
844 Statement *syntaxCopy(); | |
845 Statement *semantic(Scope *sc); | |
846 int blockExit(); | |
847 int fallOffEnd(); | |
848 Expression *interpret(InterState *istate); | |
849 | |
850 void toIR(IRState *irs); | |
851 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
852 GotoStatement *isGotoStatement() { return this; } | |
853 }; | |
854 | |
855 struct LabelStatement : Statement | |
856 { | |
857 Identifier *ident; | |
858 Statement *statement; | |
859 TryFinallyStatement *tf; | |
860 EnclosingHandler* enclosinghandler; | |
861 block *lblock; // back end | |
862 int isReturnLabel; | |
863 | |
864 LabelStatement(Loc loc, Identifier *ident, Statement *statement); | |
865 Statement *syntaxCopy(); | |
866 Statement *semantic(Scope *sc); | |
867 Statements *flatten(Scope *sc); | |
868 int usesEH(); | |
869 int blockExit(); | |
870 int fallOffEnd(); | |
871 int comeFrom(); | |
872 Expression *interpret(InterState *istate); | |
873 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
874 | |
875 Statement *inlineScan(InlineScanState *iss); | |
876 | |
877 void toIR(IRState *irs); | |
878 | |
879 // LDC | |
880 bool asmLabel; // for labels inside inline assembler | |
881 }; | |
882 | |
883 struct LabelDsymbol : Dsymbol | |
884 { | |
885 LabelStatement *statement; | |
886 | |
887 LabelDsymbol(Identifier *ident); | |
888 LabelDsymbol *isLabel(); | |
889 }; | |
890 | |
891 struct AsmStatement : Statement | |
892 { | |
893 Token *tokens; | |
894 code *asmcode; | |
895 unsigned asmalign; // alignment of this statement | |
896 unsigned refparam; // !=0 if function parameter is referenced | |
897 unsigned naked; // !=0 if function is to be naked | |
898 unsigned regs; // mask of registers modified | |
899 | |
900 AsmStatement(Loc loc, Token *tokens); | |
901 Statement *syntaxCopy(); | |
902 Statement *semantic(Scope *sc); | |
903 int blockExit(); | |
904 int comeFrom(); | |
905 | |
906 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
907 virtual AsmStatement *isAsmStatement() { return this; } | |
908 | |
909 void toIR(IRState *irs); | |
910 | |
911 // LDC | |
912 // non-zero if this is a branch, contains the target labels identifier | |
913 Identifier* isBranchToLabel; | |
914 }; | |
915 | |
916 struct AsmBlockStatement : CompoundStatement | |
917 { | |
918 EnclosingHandler* enclosinghandler; | |
919 TryFinallyStatement* tf; | |
920 | |
921 AsmBlockStatement(Loc loc, Statements *s); | |
922 Statements *flatten(Scope *sc); | |
923 Statement *syntaxCopy(); | |
924 Statement *semantic(Scope *sc); | |
925 | |
926 CompoundStatement *isCompoundStatement() { return NULL; } | |
927 AsmBlockStatement *isAsmBlockStatement() { return this; } | |
928 | |
929 void toIR(IRState *irs); | |
930 }; | |
931 | |
932 #endif /* DMD_STATEMENT_H */ |