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