Mercurial > projects > ldc
annotate dmd/statement.h @ 1651:cb960b882ca3 default tip
bindings were moved to dsource.org/projects/bindings/
author | Moritz Warning <moritzwarning@web.de> |
---|---|
date | Thu, 20 May 2010 20:05:03 +0200 |
parents | 40bd4a0d4870 |
children |
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; } | |
1650 | 144 virtual LabelStatement* isLabelStatement() { return NULL; } |
1587 | 145 |
1630
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1607
diff
changeset
|
146 #if IN_LLVM |
1587 | 147 virtual void toNakedIR(IRState *irs); |
148 virtual AsmBlockStatement* endsWithAsm(); | |
1630
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1607
diff
changeset
|
149 #endif |
1587 | 150 }; |
151 | |
152 struct PeelStatement : Statement | |
153 { | |
154 Statement *s; | |
155 | |
156 PeelStatement(Statement *s); | |
157 Statement *semantic(Scope *sc); | |
158 }; | |
159 | |
160 struct ExpStatement : Statement | |
161 { | |
162 Expression *exp; | |
163 | |
164 ExpStatement(Loc loc, Expression *exp); | |
165 Statement *syntaxCopy(); | |
166 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
167 Statement *semantic(Scope *sc); | |
168 Expression *interpret(InterState *istate); | |
169 int blockExit(); | |
170 int isEmpty(); | |
171 | |
172 int inlineCost(InlineCostState *ics); | |
173 Expression *doInline(InlineDoState *ids); | |
174 Statement *inlineScan(InlineScanState *iss); | |
175 | |
176 void toIR(IRState *irs); | |
177 | |
1630
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1607
diff
changeset
|
178 #if IN_LLVM |
1587 | 179 void toNakedIR(IRState *irs); |
1630
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1607
diff
changeset
|
180 #endif |
1587 | 181 }; |
182 | |
183 struct CompileStatement : Statement | |
184 { | |
185 Expression *exp; | |
186 | |
187 CompileStatement(Loc loc, Expression *exp); | |
188 Statement *syntaxCopy(); | |
189 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
190 Statements *flatten(Scope *sc); | |
191 Statement *semantic(Scope *sc); | |
192 }; | |
193 | |
194 struct DeclarationStatement : ExpStatement | |
195 { | |
196 // Doing declarations as an expression, rather than a statement, | |
197 // makes inlining functions much easier. | |
198 | |
199 DeclarationStatement(Loc loc, Dsymbol *s); | |
200 DeclarationStatement(Loc loc, Expression *exp); | |
201 Statement *syntaxCopy(); | |
202 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
203 void scopeCode(Scope *sc, Statement **sentry, Statement **sexit, Statement **sfinally); | |
204 | |
205 DeclarationStatement *isDeclarationStatement() { return this; } | |
206 }; | |
207 | |
208 struct CompoundStatement : Statement | |
209 { | |
210 Statements *statements; | |
211 | |
212 CompoundStatement(Loc loc, Statements *s); | |
213 CompoundStatement(Loc loc, Statement *s1, Statement *s2); | |
214 virtual Statement *syntaxCopy(); | |
215 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
216 virtual Statement *semantic(Scope *sc); | |
217 int usesEH(); | |
218 int blockExit(); | |
219 int comeFrom(); | |
220 int isEmpty(); | |
221 virtual Statements *flatten(Scope *sc); | |
222 ReturnStatement *isReturnStatement(); | |
223 Expression *interpret(InterState *istate); | |
224 | |
225 int inlineCost(InlineCostState *ics); | |
226 Expression *doInline(InlineDoState *ids); | |
227 Statement *inlineScan(InlineScanState *iss); | |
228 | |
229 virtual void toIR(IRState *irs); | |
230 | |
231 // LDC | |
232 virtual void toNakedIR(IRState *irs); | |
233 virtual AsmBlockStatement* endsWithAsm(); | |
234 | |
235 virtual CompoundStatement *isCompoundStatement() { return this; } | |
236 }; | |
237 | |
238 struct CompoundDeclarationStatement : CompoundStatement | |
239 { | |
240 CompoundDeclarationStatement(Loc loc, Statements *s); | |
241 Statement *syntaxCopy(); | |
242 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
243 }; | |
244 | |
245 /* The purpose of this is so that continue will go to the next | |
246 * of the statements, and break will go to the end of the statements. | |
247 */ | |
248 struct UnrolledLoopStatement : Statement | |
249 { | |
250 Statements *statements; | |
251 | |
252 UnrolledLoopStatement(Loc loc, Statements *statements); | |
253 Statement *syntaxCopy(); | |
254 Statement *semantic(Scope *sc); | |
255 int hasBreak(); | |
256 int hasContinue(); | |
257 int usesEH(); | |
258 int blockExit(); | |
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 comeFrom(); | |
284 int isEmpty(); | |
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 | |
297 WhileStatement(Loc loc, Expression *c, Statement *b); | |
298 Statement *syntaxCopy(); | |
299 Statement *semantic(Scope *sc); | |
300 int hasBreak(); | |
301 int hasContinue(); | |
302 int usesEH(); | |
303 int blockExit(); | |
304 int comeFrom(); | |
305 Expression *interpret(InterState *istate); | |
306 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
307 | |
308 Statement *inlineScan(InlineScanState *iss); | |
309 | |
310 void toIR(IRState *irs); | |
311 }; | |
312 | |
313 struct DoStatement : Statement | |
314 { | |
315 Statement *body; | |
316 Expression *condition; | |
317 | |
318 DoStatement(Loc loc, Statement *b, Expression *c); | |
319 Statement *syntaxCopy(); | |
320 Statement *semantic(Scope *sc); | |
321 int hasBreak(); | |
322 int hasContinue(); | |
323 int usesEH(); | |
324 int blockExit(); | |
325 int comeFrom(); | |
326 Expression *interpret(InterState *istate); | |
327 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
328 | |
329 Statement *inlineScan(InlineScanState *iss); | |
330 | |
331 void toIR(IRState *irs); | |
332 }; | |
333 | |
334 struct ForStatement : Statement | |
335 { | |
336 Statement *init; | |
337 Expression *condition; | |
338 Expression *increment; | |
339 Statement *body; | |
340 | |
341 ForStatement(Loc loc, Statement *init, Expression *condition, Expression *increment, Statement *body); | |
342 Statement *syntaxCopy(); | |
343 Statement *semantic(Scope *sc); | |
344 void scopeCode(Scope *sc, Statement **sentry, Statement **sexit, Statement **sfinally); | |
345 int hasBreak(); | |
346 int hasContinue(); | |
347 int usesEH(); | |
348 int blockExit(); | |
349 int comeFrom(); | |
350 Expression *interpret(InterState *istate); | |
351 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
352 | |
353 Statement *inlineScan(InlineScanState *iss); | |
354 | |
355 void toIR(IRState *irs); | |
356 }; | |
357 | |
358 struct ForeachStatement : Statement | |
359 { | |
360 enum TOK op; // TOKforeach or TOKforeach_reverse | |
1607
207a8a438dea
Merge DMD r253: refactor: Argument => Parameter
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
361 Parameters *arguments; // array of Parameter*'s |
1587 | 362 Expression *aggr; |
363 Statement *body; | |
364 | |
365 VarDeclaration *key; | |
366 VarDeclaration *value; | |
367 | |
368 FuncDeclaration *func; // function we're lexically in | |
369 | |
370 Array cases; // put breaks, continues, gotos and returns here | |
371 Array gotos; // forward referenced goto's go here | |
372 | |
1607
207a8a438dea
Merge DMD r253: refactor: Argument => Parameter
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
373 ForeachStatement(Loc loc, enum TOK op, Parameters *arguments, Expression *aggr, Statement *body); |
1587 | 374 Statement *syntaxCopy(); |
375 Statement *semantic(Scope *sc); | |
376 int hasBreak(); | |
377 int hasContinue(); | |
378 int usesEH(); | |
379 int blockExit(); | |
380 int comeFrom(); | |
381 Expression *interpret(InterState *istate); | |
382 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
383 | |
384 Statement *inlineScan(InlineScanState *iss); | |
385 | |
386 void toIR(IRState *irs); | |
387 }; | |
388 | |
389 #if DMDV2 | |
390 struct ForeachRangeStatement : Statement | |
391 { | |
392 enum TOK op; // TOKforeach or TOKforeach_reverse | |
1607
207a8a438dea
Merge DMD r253: refactor: Argument => Parameter
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
393 Parameter *arg; // loop index variable |
1587 | 394 Expression *lwr; |
395 Expression *upr; | |
396 Statement *body; | |
397 | |
398 VarDeclaration *key; | |
399 | |
1607
207a8a438dea
Merge DMD r253: refactor: Argument => Parameter
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
400 ForeachRangeStatement(Loc loc, enum TOK op, Parameter *arg, |
1587 | 401 Expression *lwr, Expression *upr, Statement *body); |
402 Statement *syntaxCopy(); | |
403 Statement *semantic(Scope *sc); | |
404 int hasBreak(); | |
405 int hasContinue(); | |
406 int usesEH(); | |
407 int blockExit(); | |
408 int comeFrom(); | |
409 Expression *interpret(InterState *istate); | |
410 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
411 | |
412 Statement *inlineScan(InlineScanState *iss); | |
413 | |
414 void toIR(IRState *irs); | |
415 }; | |
416 #endif | |
417 | |
418 struct IfStatement : Statement | |
419 { | |
1607
207a8a438dea
Merge DMD r253: refactor: Argument => Parameter
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
420 Parameter *arg; |
1587 | 421 Expression *condition; |
422 Statement *ifbody; | |
423 Statement *elsebody; | |
424 | |
425 VarDeclaration *match; // for MatchExpression results | |
426 | |
1607
207a8a438dea
Merge DMD r253: refactor: Argument => Parameter
Leandro Lucarella <llucax@gmail.com>
parents:
1587
diff
changeset
|
427 IfStatement(Loc loc, Parameter *arg, Expression *condition, Statement *ifbody, Statement *elsebody); |
1587 | 428 Statement *syntaxCopy(); |
429 Statement *semantic(Scope *sc); | |
430 Expression *interpret(InterState *istate); | |
431 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
432 int usesEH(); | |
433 int blockExit(); | |
434 IfStatement *isIfStatement() { return this; } | |
435 | |
436 int inlineCost(InlineCostState *ics); | |
437 Expression *doInline(InlineDoState *ids); | |
438 Statement *inlineScan(InlineScanState *iss); | |
439 | |
440 void toIR(IRState *irs); | |
441 }; | |
442 | |
443 struct ConditionalStatement : Statement | |
444 { | |
445 Condition *condition; | |
446 Statement *ifbody; | |
447 Statement *elsebody; | |
448 | |
449 ConditionalStatement(Loc loc, Condition *condition, Statement *ifbody, Statement *elsebody); | |
450 Statement *syntaxCopy(); | |
451 Statement *semantic(Scope *sc); | |
452 Statements *flatten(Scope *sc); | |
453 int usesEH(); | |
454 int blockExit(); | |
455 | |
456 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
457 }; | |
458 | |
459 struct PragmaStatement : Statement | |
460 { | |
461 Identifier *ident; | |
462 Expressions *args; // array of Expression's | |
463 Statement *body; | |
464 | |
465 PragmaStatement(Loc loc, Identifier *ident, Expressions *args, Statement *body); | |
466 Statement *syntaxCopy(); | |
467 Statement *semantic(Scope *sc); | |
468 int usesEH(); | |
469 int blockExit(); | |
470 | |
471 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
472 }; | |
473 | |
474 struct StaticAssertStatement : Statement | |
475 { | |
476 StaticAssert *sa; | |
477 | |
478 StaticAssertStatement(StaticAssert *sa); | |
479 Statement *syntaxCopy(); | |
480 Statement *semantic(Scope *sc); | |
481 int blockExit(); | |
482 | |
483 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
484 }; | |
485 | |
486 struct SwitchStatement : Statement | |
487 { | |
488 Expression *condition; | |
489 Statement *body; | |
490 | |
491 DefaultStatement *sdefault; | |
492 | |
493 Array gotoCases; // array of unresolved GotoCaseStatement's | |
494 Array *cases; // array of CaseStatement's | |
495 int hasNoDefault; // !=0 if no default statement | |
1650 | 496 |
1587 | 497 // LDC |
498 Statement *enclosingScopeExit; | |
499 | |
500 SwitchStatement(Loc loc, Expression *c, Statement *b); | |
501 Statement *syntaxCopy(); | |
502 Statement *semantic(Scope *sc); | |
503 int hasBreak(); | |
504 int usesEH(); | |
505 int blockExit(); | |
506 Expression *interpret(InterState *istate); | |
507 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
508 | |
509 Statement *inlineScan(InlineScanState *iss); | |
510 | |
511 void toIR(IRState *irs); | |
512 }; | |
513 | |
514 struct CaseStatement : Statement | |
515 { | |
516 Expression *exp; | |
517 Statement *statement; | |
518 | |
519 int index; // which case it is (since we sort this) | |
520 block *cblock; // back end: label for the block | |
521 | |
522 // LDC | |
523 Statement *enclosingScopeExit; | |
524 | |
525 CaseStatement(Loc loc, Expression *exp, Statement *s); | |
526 Statement *syntaxCopy(); | |
527 Statement *semantic(Scope *sc); | |
528 int compare(Object *obj); | |
529 int usesEH(); | |
530 int blockExit(); | |
531 int comeFrom(); | |
532 Expression *interpret(InterState *istate); | |
533 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
534 | |
535 Statement *inlineScan(InlineScanState *iss); | |
536 | |
537 void toIR(IRState *irs); | |
538 | |
539 CaseStatement* isCaseStatement() { return this; } | |
1650 | 540 |
1587 | 541 // LDC |
542 llvm::BasicBlock* bodyBB; | |
543 llvm::ConstantInt* llvmIdx; | |
544 }; | |
545 | |
546 #if DMDV2 | |
547 | |
548 struct CaseRangeStatement : Statement | |
549 { | |
550 Expression *first; | |
551 Expression *last; | |
552 Statement *statement; | |
553 | |
554 CaseRangeStatement(Loc loc, Expression *first, Expression *last, Statement *s); | |
555 Statement *syntaxCopy(); | |
556 Statement *semantic(Scope *sc); | |
557 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
558 }; | |
559 | |
560 #endif | |
561 | |
562 struct DefaultStatement : Statement | |
563 { | |
564 Statement *statement; | |
565 #if IN_GCC | |
566 block *cblock; // back end: label for the block | |
567 #endif | |
568 | |
569 // LDC | |
570 Statement *enclosingScopeExit; | |
571 | |
572 DefaultStatement(Loc loc, Statement *s); | |
573 Statement *syntaxCopy(); | |
574 Statement *semantic(Scope *sc); | |
575 int usesEH(); | |
576 int blockExit(); | |
577 int comeFrom(); | |
578 Expression *interpret(InterState *istate); | |
579 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
580 | |
581 Statement *inlineScan(InlineScanState *iss); | |
582 | |
583 void toIR(IRState *irs); | |
584 | |
585 // LDC | |
586 llvm::BasicBlock* bodyBB; | |
587 }; | |
588 | |
589 struct GotoDefaultStatement : Statement | |
590 { | |
591 SwitchStatement *sw; | |
592 | |
593 GotoDefaultStatement(Loc loc); | |
594 Statement *syntaxCopy(); | |
595 Statement *semantic(Scope *sc); | |
596 Expression *interpret(InterState *istate); | |
597 int blockExit(); | |
598 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
599 | |
600 void toIR(IRState *irs); | |
601 }; | |
602 | |
603 struct GotoCaseStatement : Statement | |
604 { | |
605 Expression *exp; // NULL, or which case to goto | |
606 CaseStatement *cs; // case statement it resolves to | |
607 SwitchStatement *sw; | |
608 | |
609 GotoCaseStatement(Loc loc, Expression *exp); | |
610 Statement *syntaxCopy(); | |
611 Statement *semantic(Scope *sc); | |
612 Expression *interpret(InterState *istate); | |
613 int blockExit(); | |
614 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
615 | |
616 void toIR(IRState *irs); | |
617 }; | |
618 | |
619 struct SwitchErrorStatement : Statement | |
620 { | |
621 SwitchErrorStatement(Loc loc); | |
622 int blockExit(); | |
623 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
624 | |
625 void toIR(IRState *irs); | |
626 }; | |
627 | |
628 struct ReturnStatement : Statement | |
629 { | |
630 Expression *exp; | |
631 | |
632 ReturnStatement(Loc loc, Expression *exp); | |
633 Statement *syntaxCopy(); | |
634 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
635 Statement *semantic(Scope *sc); | |
636 int blockExit(); | |
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 | |
652 BreakStatement(Loc loc, Identifier *ident); | |
653 Statement *syntaxCopy(); | |
654 Statement *semantic(Scope *sc); | |
655 Expression *interpret(InterState *istate); | |
656 int blockExit(); | |
657 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
658 | |
659 void toIR(IRState *irs); | |
660 | |
661 // LDC: only set if ident is set: label statement to jump to | |
662 LabelStatement *target; | |
663 }; | |
664 | |
665 struct ContinueStatement : Statement | |
666 { | |
667 Identifier *ident; | |
668 | |
669 ContinueStatement(Loc loc, Identifier *ident); | |
670 Statement *syntaxCopy(); | |
671 Statement *semantic(Scope *sc); | |
672 Expression *interpret(InterState *istate); | |
673 int blockExit(); | |
674 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
675 | |
676 void toIR(IRState *irs); | |
677 | |
678 // LDC: only set if ident is set: label statement to jump to | |
679 LabelStatement *target; | |
680 }; | |
681 | |
682 struct SynchronizedStatement : Statement | |
683 { | |
684 Expression *exp; | |
685 Statement *body; | |
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 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
695 | |
696 Statement *inlineScan(InlineScanState *iss); | |
697 | |
698 // Back end | |
699 elem *esync; | |
700 SynchronizedStatement(Loc loc, elem *esync, Statement *body); | |
701 void toIR(IRState *irs); | |
702 llvm::Value* llsync; | |
703 }; | |
704 | |
705 struct WithStatement : Statement | |
706 { | |
707 Expression *exp; | |
708 Statement *body; | |
709 VarDeclaration *wthis; | |
710 | |
711 WithStatement(Loc loc, Expression *exp, Statement *body); | |
712 Statement *syntaxCopy(); | |
713 Statement *semantic(Scope *sc); | |
714 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
715 int usesEH(); | |
716 int blockExit(); | |
717 | |
718 Statement *inlineScan(InlineScanState *iss); | |
719 | |
720 void toIR(IRState *irs); | |
721 }; | |
722 | |
723 struct TryCatchStatement : Statement | |
724 { | |
725 Statement *body; | |
726 Array *catches; | |
727 | |
728 TryCatchStatement(Loc loc, Statement *body, Array *catches); | |
729 Statement *syntaxCopy(); | |
730 Statement *semantic(Scope *sc); | |
731 int hasBreak(); | |
732 int usesEH(); | |
733 int blockExit(); | |
734 | |
735 Statement *inlineScan(InlineScanState *iss); | |
736 | |
737 void toIR(IRState *irs); | |
738 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
739 TryCatchStatement *isTryCatchStatement() { return this; } | |
740 }; | |
741 | |
742 struct Catch : Object | |
743 { | |
744 Loc loc; | |
745 Type *type; | |
746 Identifier *ident; | |
747 VarDeclaration *var; | |
748 Statement *handler; | |
749 | |
750 Catch(Loc loc, Type *t, Identifier *id, Statement *handler); | |
751 Catch *syntaxCopy(); | |
752 void semantic(Scope *sc); | |
753 int blockExit(); | |
754 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
755 }; | |
756 | |
757 struct TryFinallyStatement : Statement | |
758 { | |
759 Statement *body; | |
760 Statement *finalbody; | |
761 | |
762 TryFinallyStatement(Loc loc, Statement *body, Statement *finalbody); | |
763 Statement *syntaxCopy(); | |
764 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
765 Statement *semantic(Scope *sc); | |
766 int hasBreak(); | |
767 int hasContinue(); | |
768 int usesEH(); | |
769 int blockExit(); | |
770 | |
771 Statement *inlineScan(InlineScanState *iss); | |
772 | |
773 void toIR(IRState *irs); | |
774 }; | |
775 | |
776 struct OnScopeStatement : Statement | |
777 { | |
778 TOK tok; | |
779 Statement *statement; | |
780 | |
781 OnScopeStatement(Loc loc, TOK tok, Statement *statement); | |
782 Statement *syntaxCopy(); | |
783 int blockExit(); | |
784 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
785 Statement *semantic(Scope *sc); | |
786 int usesEH(); | |
787 void scopeCode(Scope *sc, Statement **sentry, Statement **sexit, Statement **sfinally); | |
788 | |
789 void toIR(IRState *irs); | |
790 }; | |
791 | |
792 struct ThrowStatement : Statement | |
793 { | |
794 Expression *exp; | |
795 | |
796 ThrowStatement(Loc loc, Expression *exp); | |
797 Statement *syntaxCopy(); | |
798 Statement *semantic(Scope *sc); | |
799 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
800 int blockExit(); | |
801 | |
802 Statement *inlineScan(InlineScanState *iss); | |
803 | |
804 void toIR(IRState *irs); | |
805 }; | |
806 | |
807 struct VolatileStatement : Statement | |
808 { | |
809 Statement *statement; | |
810 | |
811 VolatileStatement(Loc loc, Statement *statement); | |
812 Statement *syntaxCopy(); | |
813 Statement *semantic(Scope *sc); | |
814 Statements *flatten(Scope *sc); | |
815 int blockExit(); | |
816 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
817 | |
818 Statement *inlineScan(InlineScanState *iss); | |
819 | |
820 void toIR(IRState *irs); | |
821 }; | |
822 | |
823 struct GotoStatement : Statement | |
824 { | |
825 Identifier *ident; | |
826 LabelDsymbol *label; | |
827 TryFinallyStatement *enclosingFinally; | |
828 Statement* enclosingScopeExit; | |
829 | |
830 GotoStatement(Loc loc, Identifier *ident); | |
831 Statement *syntaxCopy(); | |
832 Statement *semantic(Scope *sc); | |
833 int blockExit(); | |
834 Expression *interpret(InterState *istate); | |
835 | |
836 void toIR(IRState *irs); | |
837 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
838 GotoStatement *isGotoStatement() { return this; } | |
839 }; | |
840 | |
841 struct LabelStatement : Statement | |
842 { | |
843 Identifier *ident; | |
844 Statement *statement; | |
845 TryFinallyStatement *enclosingFinally; | |
846 Statement* enclosingScopeExit; | |
847 block *lblock; // back end | |
848 int isReturnLabel; | |
849 | |
850 LabelStatement(Loc loc, Identifier *ident, Statement *statement); | |
851 Statement *syntaxCopy(); | |
852 Statement *semantic(Scope *sc); | |
853 Statements *flatten(Scope *sc); | |
854 int usesEH(); | |
855 int blockExit(); | |
856 int comeFrom(); | |
857 Expression *interpret(InterState *istate); | |
858 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
859 | |
860 Statement *inlineScan(InlineScanState *iss); | |
861 | |
862 void toIR(IRState *irs); | |
863 | |
864 // LDC | |
865 bool asmLabel; // for labels inside inline assembler | |
866 void toNakedIR(IRState *irs); | |
1650 | 867 |
868 LabelStatement* isLabelStatement() { return this; } | |
1587 | 869 }; |
870 | |
871 struct LabelDsymbol : Dsymbol | |
872 { | |
873 LabelStatement *statement; | |
874 | |
875 LabelDsymbol(Identifier *ident); | |
876 LabelDsymbol *isLabel(); | |
877 }; | |
878 | |
879 struct AsmStatement : Statement | |
880 { | |
881 Token *tokens; | |
882 code *asmcode; | |
883 unsigned asmalign; // alignment of this statement | |
884 unsigned refparam; // !=0 if function parameter is referenced | |
885 unsigned naked; // !=0 if function is to be naked | |
886 | |
887 AsmStatement(Loc loc, Token *tokens); | |
888 Statement *syntaxCopy(); | |
889 Statement *semantic(Scope *sc); | |
890 int blockExit(); | |
891 int comeFrom(); | |
892 | |
893 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
894 virtual AsmStatement *isAsmStatement() { return this; } | |
895 | |
896 void toIR(IRState *irs); | |
897 | |
898 // LDC | |
899 // non-zero if this is a branch, contains the target labels identifier | |
900 Identifier* isBranchToLabel; | |
901 | |
902 void toNakedIR(IRState *irs); | |
903 }; | |
904 | |
905 struct AsmBlockStatement : CompoundStatement | |
906 { | |
907 TryFinallyStatement* enclosingFinally; | |
908 Statement* enclosingScopeExit; | |
909 | |
910 AsmBlockStatement(Loc loc, Statements *s); | |
911 Statements *flatten(Scope *sc); | |
912 Statement *syntaxCopy(); | |
913 Statement *semantic(Scope *sc); | |
914 | |
915 CompoundStatement *isCompoundStatement() { return NULL; } | |
916 AsmBlockStatement *isAsmBlockStatement() { return this; } | |
917 | |
918 void toIR(IRState *irs); | |
919 void toNakedIR(IRState *irs); | |
920 AsmBlockStatement* endsWithAsm(); | |
921 | |
922 llvm::Value* abiret; | |
923 }; | |
924 | |
925 #endif /* DMD_STATEMENT_H */ |