Mercurial > projects > ldc
annotate dmd/statement.h @ 314:8d98e42ece93 trunk
[svn r335] The basics of exception handling are in place.
Still need to make sure calls are turned into invokes everywhere. (NewExpression for instance)
Still some rough edges and corner cases to figure out.
Needs testing!
author | ChristianK |
---|---|
date | Wed, 02 Jul 2008 22:20:18 +0200 |
parents | d59c363fccad |
children | aaade6ded589 |
rev | line source |
---|---|
1 | 1 |
2 // Compiler implementation of the D programming language | |
3 // Copyright (c) 1999-2007 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; | |
232
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
44 struct AsmBlockStatement; |
1 | 45 struct GotoStatement; |
46 struct ScopeStatement; | |
47 struct TryCatchStatement; | |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
48 struct TryFinallyStatement; |
1 | 49 struct HdrGenState; |
50 struct InterState; | |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
86
diff
changeset
|
51 struct CaseStatement; |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
52 struct LabelStatement; |
309 | 53 struct VolatileStatement; |
54 struct SynchronizedStatement; | |
1 | 55 |
56 enum TOK; | |
57 | |
58 namespace llvm | |
59 { | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
37
diff
changeset
|
60 class Value; |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
1
diff
changeset
|
61 class BasicBlock; |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
239
diff
changeset
|
62 class ConstantInt; |
1 | 63 } |
64 | |
65 // Back end | |
66 struct IRState; | |
67 struct Blockx; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
37
diff
changeset
|
68 #if IN_LLVM |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
37
diff
changeset
|
69 struct DValue; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
37
diff
changeset
|
70 typedef DValue elem; |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
37
diff
changeset
|
71 #endif |
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
37
diff
changeset
|
72 |
1 | 73 #if IN_GCC |
74 union tree_node; typedef union tree_node block; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
37
diff
changeset
|
75 //union tree_node; typedef union tree_node elem; |
1 | 76 #else |
77 struct block; | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
37
diff
changeset
|
78 //struct elem; |
1 | 79 #endif |
80 struct code; | |
81 | |
309 | 82 // LLVMDC this is used for tracking try-finally, synchronized and volatile scopes |
83 // definitions in gen/llvmhelpers.cpp | |
84 struct EnclosingHandler : Object | |
85 { | |
86 virtual void emitCode(IRState* p) = 0; | |
87 virtual EnclosingHandler* getEnclosing() = 0; | |
88 }; | |
89 struct EnclosingTryFinally : EnclosingHandler | |
90 { | |
91 TryFinallyStatement* tf; | |
92 void emitCode(IRState* p); | |
93 EnclosingHandler* getEnclosing(); | |
94 EnclosingTryFinally(TryFinallyStatement* _tf) : tf(_tf) {} | |
95 }; | |
96 struct EnclosingVolatile : EnclosingHandler | |
97 { | |
98 VolatileStatement* v; | |
99 void emitCode(IRState* p); | |
100 EnclosingHandler* getEnclosing(); | |
101 EnclosingVolatile(VolatileStatement* _tf) : v(_tf) {} | |
102 }; | |
103 struct EnclosingSynchro : EnclosingHandler | |
104 { | |
105 SynchronizedStatement* s; | |
106 void emitCode(IRState* p); | |
107 EnclosingHandler* getEnclosing(); | |
108 EnclosingSynchro(SynchronizedStatement* _tf) : s(_tf) {} | |
109 }; | |
110 | |
1 | 111 struct Statement : Object |
112 { | |
113 Loc loc; | |
114 | |
115 Statement(Loc loc); | |
116 virtual Statement *syntaxCopy(); | |
117 | |
118 void print(); | |
119 char *toChars(); | |
120 | |
121 void error(const char *format, ...); | |
122 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
123 virtual TryCatchStatement *isTryCatchStatement() { return NULL; } | |
124 virtual GotoStatement *isGotoStatement() { return NULL; } | |
125 virtual AsmStatement *isAsmStatement() { return NULL; } | |
232
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
126 virtual AsmBlockStatement *isAsmBlockStatement() { return NULL; } |
1 | 127 #ifdef _DH |
128 int incontract; | |
129 #endif | |
130 virtual ScopeStatement *isScopeStatement() { return NULL; } | |
131 virtual Statement *semantic(Scope *sc); | |
132 Statement *semanticScope(Scope *sc, Statement *sbreak, Statement *scontinue); | |
133 virtual int hasBreak(); | |
134 virtual int hasContinue(); | |
135 virtual int usesEH(); | |
136 virtual int fallOffEnd(); | |
137 virtual int comeFrom(); | |
138 virtual void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
139 virtual Statements *flatten(Scope *sc); | |
140 virtual Expression *interpret(InterState *istate); | |
141 | |
142 virtual int inlineCost(InlineCostState *ics); | |
143 virtual Expression *doInline(InlineDoState *ids); | |
144 virtual Statement *inlineScan(InlineScanState *iss); | |
145 | |
146 // Back end | |
147 virtual void toIR(IRState *irs); | |
148 | |
149 // Avoid dynamic_cast | |
150 virtual DeclarationStatement *isDeclarationStatement() { return NULL; } | |
151 virtual CompoundStatement *isCompoundStatement() { return NULL; } | |
152 virtual ReturnStatement *isReturnStatement() { return NULL; } | |
153 virtual IfStatement *isIfStatement() { return NULL; } | |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
86
diff
changeset
|
154 virtual CaseStatement* isCaseStatement() { return NULL; } |
1 | 155 }; |
156 | |
157 struct ExpStatement : Statement | |
158 { | |
159 Expression *exp; | |
160 | |
161 ExpStatement(Loc loc, Expression *exp); | |
162 Statement *syntaxCopy(); | |
163 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
164 Statement *semantic(Scope *sc); | |
165 Expression *interpret(InterState *istate); | |
166 int fallOffEnd(); | |
167 | |
168 int inlineCost(InlineCostState *ics); | |
169 Expression *doInline(InlineDoState *ids); | |
170 Statement *inlineScan(InlineScanState *iss); | |
171 | |
172 void toIR(IRState *irs); | |
173 }; | |
174 | |
175 struct CompileStatement : Statement | |
176 { | |
177 Expression *exp; | |
178 | |
179 CompileStatement(Loc loc, Expression *exp); | |
180 Statement *syntaxCopy(); | |
181 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
182 Statement *semantic(Scope *sc); | |
183 }; | |
184 | |
185 struct DeclarationStatement : ExpStatement | |
186 { | |
187 // Doing declarations as an expression, rather than a statement, | |
188 // makes inlining functions much easier. | |
189 | |
190 DeclarationStatement(Loc loc, Dsymbol *s); | |
191 DeclarationStatement(Loc loc, Expression *exp); | |
192 Statement *syntaxCopy(); | |
193 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
194 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
195 | |
196 DeclarationStatement *isDeclarationStatement() { return this; } | |
197 }; | |
198 | |
199 struct CompoundStatement : Statement | |
200 { | |
201 Statements *statements; | |
202 | |
203 CompoundStatement(Loc loc, Statements *s); | |
204 CompoundStatement(Loc loc, Statement *s1, Statement *s2); | |
239
fa691b1c0498
[svn r256] AsmBlockStatement was still being flattened in some cases.
lindquist
parents:
232
diff
changeset
|
205 virtual Statement *syntaxCopy(); |
1 | 206 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
207 Statement *semantic(Scope *sc); | |
208 int usesEH(); | |
209 int fallOffEnd(); | |
210 int comeFrom(); | |
239
fa691b1c0498
[svn r256] AsmBlockStatement was still being flattened in some cases.
lindquist
parents:
232
diff
changeset
|
211 virtual Statements *flatten(Scope *sc); |
1 | 212 ReturnStatement *isReturnStatement(); |
213 Expression *interpret(InterState *istate); | |
214 | |
215 int inlineCost(InlineCostState *ics); | |
216 Expression *doInline(InlineDoState *ids); | |
217 Statement *inlineScan(InlineScanState *iss); | |
218 | |
239
fa691b1c0498
[svn r256] AsmBlockStatement was still being flattened in some cases.
lindquist
parents:
232
diff
changeset
|
219 virtual void toIR(IRState *irs); |
1 | 220 |
239
fa691b1c0498
[svn r256] AsmBlockStatement was still being flattened in some cases.
lindquist
parents:
232
diff
changeset
|
221 virtual CompoundStatement *isCompoundStatement() { return this; } |
1 | 222 }; |
223 | |
224 /* The purpose of this is so that continue will go to the next | |
225 * of the statements, and break will go to the end of the statements. | |
226 */ | |
227 struct UnrolledLoopStatement : Statement | |
228 { | |
229 Statements *statements; | |
309 | 230 EnclosingHandler* enclosinghandler; |
1 | 231 |
232 UnrolledLoopStatement(Loc loc, Statements *statements); | |
233 Statement *syntaxCopy(); | |
234 Statement *semantic(Scope *sc); | |
235 int hasBreak(); | |
236 int hasContinue(); | |
237 int usesEH(); | |
238 int fallOffEnd(); | |
239 int comeFrom(); | |
240 Expression *interpret(InterState *istate); | |
241 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
242 | |
243 int inlineCost(InlineCostState *ics); | |
244 Expression *doInline(InlineDoState *ids); | |
245 Statement *inlineScan(InlineScanState *iss); | |
246 | |
247 void toIR(IRState *irs); | |
248 }; | |
249 | |
250 struct ScopeStatement : Statement | |
251 { | |
252 Statement *statement; | |
253 | |
254 ScopeStatement(Loc loc, Statement *s); | |
255 Statement *syntaxCopy(); | |
256 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
257 ScopeStatement *isScopeStatement() { return this; } | |
258 Statement *semantic(Scope *sc); | |
259 int hasBreak(); | |
260 int hasContinue(); | |
261 int usesEH(); | |
262 int fallOffEnd(); | |
263 int comeFrom(); | |
264 Expression *interpret(InterState *istate); | |
265 | |
266 Statement *inlineScan(InlineScanState *iss); | |
267 | |
268 void toIR(IRState *irs); | |
269 }; | |
270 | |
271 struct WhileStatement : Statement | |
272 { | |
273 Expression *condition; | |
274 Statement *body; | |
309 | 275 EnclosingHandler* enclosinghandler; |
1 | 276 |
277 WhileStatement(Loc loc, Expression *c, Statement *b); | |
278 Statement *syntaxCopy(); | |
279 Statement *semantic(Scope *sc); | |
280 int hasBreak(); | |
281 int hasContinue(); | |
282 int usesEH(); | |
283 int fallOffEnd(); | |
284 int comeFrom(); | |
285 Expression *interpret(InterState *istate); | |
286 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
287 | |
288 Statement *inlineScan(InlineScanState *iss); | |
289 | |
290 void toIR(IRState *irs); | |
291 }; | |
292 | |
293 struct DoStatement : Statement | |
294 { | |
295 Statement *body; | |
296 Expression *condition; | |
309 | 297 EnclosingHandler* enclosinghandler; |
1 | 298 |
299 DoStatement(Loc loc, Statement *b, Expression *c); | |
300 Statement *syntaxCopy(); | |
301 Statement *semantic(Scope *sc); | |
302 int hasBreak(); | |
303 int hasContinue(); | |
304 int usesEH(); | |
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 ForStatement : Statement | |
316 { | |
317 Statement *init; | |
318 Expression *condition; | |
319 Expression *increment; | |
320 Statement *body; | |
309 | 321 EnclosingHandler* enclosinghandler; |
1 | 322 |
323 ForStatement(Loc loc, Statement *init, Expression *condition, Expression *increment, Statement *body); | |
324 Statement *syntaxCopy(); | |
325 Statement *semantic(Scope *sc); | |
326 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
327 int hasBreak(); | |
328 int hasContinue(); | |
329 int usesEH(); | |
330 int fallOffEnd(); | |
331 int comeFrom(); | |
332 Expression *interpret(InterState *istate); | |
333 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
334 | |
335 Statement *inlineScan(InlineScanState *iss); | |
336 | |
337 void toIR(IRState *irs); | |
338 }; | |
339 | |
340 struct ForeachStatement : Statement | |
341 { | |
342 enum TOK op; // TOKforeach or TOKforeach_reverse | |
343 Arguments *arguments; // array of Argument*'s | |
344 Expression *aggr; | |
345 Statement *body; | |
309 | 346 EnclosingHandler* enclosinghandler; |
1 | 347 |
348 VarDeclaration *key; | |
349 VarDeclaration *value; | |
350 | |
351 FuncDeclaration *func; // function we're lexically in | |
352 | |
353 Array cases; // put breaks, continues, gotos and returns here | |
354 Array gotos; // forward referenced goto's go here | |
355 | |
356 ForeachStatement(Loc loc, enum TOK op, Arguments *arguments, Expression *aggr, Statement *body); | |
357 Statement *syntaxCopy(); | |
358 Statement *semantic(Scope *sc); | |
359 int hasBreak(); | |
360 int hasContinue(); | |
361 int usesEH(); | |
362 int fallOffEnd(); | |
363 int comeFrom(); | |
364 Expression *interpret(InterState *istate); | |
365 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
366 | |
367 Statement *inlineScan(InlineScanState *iss); | |
368 | |
369 void toIR(IRState *irs); | |
370 }; | |
371 | |
372 struct IfStatement : Statement | |
373 { | |
374 Argument *arg; | |
375 Expression *condition; | |
376 Statement *ifbody; | |
377 Statement *elsebody; | |
378 | |
379 VarDeclaration *match; // for MatchExpression results | |
380 | |
381 IfStatement(Loc loc, Argument *arg, Expression *condition, Statement *ifbody, Statement *elsebody); | |
382 Statement *syntaxCopy(); | |
383 Statement *semantic(Scope *sc); | |
384 Expression *interpret(InterState *istate); | |
385 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
386 int usesEH(); | |
387 int fallOffEnd(); | |
388 IfStatement *isIfStatement() { return this; } | |
389 | |
390 int inlineCost(InlineCostState *ics); | |
391 Expression *doInline(InlineDoState *ids); | |
392 Statement *inlineScan(InlineScanState *iss); | |
393 | |
394 void toIR(IRState *irs); | |
395 }; | |
396 | |
397 struct ConditionalStatement : Statement | |
398 { | |
399 Condition *condition; | |
400 Statement *ifbody; | |
401 Statement *elsebody; | |
402 | |
403 ConditionalStatement(Loc loc, Condition *condition, Statement *ifbody, Statement *elsebody); | |
404 Statement *syntaxCopy(); | |
405 Statement *semantic(Scope *sc); | |
406 Statements *flatten(Scope *sc); | |
407 int usesEH(); | |
408 | |
409 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
410 }; | |
411 | |
412 struct PragmaStatement : Statement | |
413 { | |
414 Identifier *ident; | |
415 Expressions *args; // array of Expression's | |
416 Statement *body; | |
417 | |
418 PragmaStatement(Loc loc, Identifier *ident, Expressions *args, Statement *body); | |
419 Statement *syntaxCopy(); | |
420 Statement *semantic(Scope *sc); | |
421 int usesEH(); | |
422 int fallOffEnd(); | |
423 | |
424 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
425 }; | |
426 | |
427 struct StaticAssertStatement : Statement | |
428 { | |
429 StaticAssert *sa; | |
430 | |
431 StaticAssertStatement(StaticAssert *sa); | |
432 Statement *syntaxCopy(); | |
433 Statement *semantic(Scope *sc); | |
434 | |
435 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
436 }; | |
437 | |
438 struct SwitchStatement : Statement | |
439 { | |
440 Expression *condition; | |
441 Statement *body; | |
442 DefaultStatement *sdefault; | |
309 | 443 EnclosingHandler* enclosinghandler; |
1 | 444 |
445 Array gotoCases; // array of unresolved GotoCaseStatement's | |
446 Array *cases; // array of CaseStatement's | |
447 int hasNoDefault; // !=0 if no default statement | |
448 | |
449 SwitchStatement(Loc loc, Expression *c, Statement *b); | |
450 Statement *syntaxCopy(); | |
451 Statement *semantic(Scope *sc); | |
452 int hasBreak(); | |
453 int usesEH(); | |
454 int fallOffEnd(); | |
455 Expression *interpret(InterState *istate); | |
456 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
457 | |
458 Statement *inlineScan(InlineScanState *iss); | |
459 | |
460 void toIR(IRState *irs); | |
461 }; | |
462 | |
463 struct CaseStatement : Statement | |
464 { | |
465 Expression *exp; | |
466 Statement *statement; | |
467 int index; // which case it is (since we sort this) | |
468 block *cblock; // back end: label for the block | |
469 | |
470 CaseStatement(Loc loc, Expression *exp, Statement *s); | |
471 Statement *syntaxCopy(); | |
472 Statement *semantic(Scope *sc); | |
473 int compare(Object *obj); | |
474 int usesEH(); | |
475 int fallOffEnd(); | |
476 int comeFrom(); | |
477 Expression *interpret(InterState *istate); | |
478 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
479 | |
480 Statement *inlineScan(InlineScanState *iss); | |
481 | |
482 void toIR(IRState *irs); | |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
86
diff
changeset
|
483 |
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
86
diff
changeset
|
484 CaseStatement* isCaseStatement() { return this; } |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
485 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
486 // LLVMDC |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
487 llvm::BasicBlock* bodyBB; |
262
88252a1af660
[svn r280] Fixed a bunch of issues with switch statements. Ended up a bit far reaching...
lindquist
parents:
239
diff
changeset
|
488 llvm::ConstantInt* llvmIdx; |
1 | 489 }; |
490 | |
491 struct DefaultStatement : Statement | |
492 { | |
493 Statement *statement; | |
494 #if IN_GCC | |
495 block *cblock; // back end: label for the block | |
496 #endif | |
497 | |
498 DefaultStatement(Loc loc, Statement *s); | |
499 Statement *syntaxCopy(); | |
500 Statement *semantic(Scope *sc); | |
501 int usesEH(); | |
502 int fallOffEnd(); | |
503 int comeFrom(); | |
504 Expression *interpret(InterState *istate); | |
505 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
506 | |
507 Statement *inlineScan(InlineScanState *iss); | |
508 | |
509 void toIR(IRState *irs); | |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
510 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
511 // LLVMDC |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
512 llvm::BasicBlock* bodyBB; |
1 | 513 }; |
514 | |
515 struct GotoDefaultStatement : Statement | |
516 { | |
517 SwitchStatement *sw; | |
309 | 518 EnclosingHandler* enclosinghandler; |
1 | 519 |
520 GotoDefaultStatement(Loc loc); | |
521 Statement *syntaxCopy(); | |
522 Statement *semantic(Scope *sc); | |
523 Expression *interpret(InterState *istate); | |
524 int fallOffEnd(); | |
525 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
526 | |
527 void toIR(IRState *irs); | |
528 }; | |
529 | |
530 struct GotoCaseStatement : Statement | |
531 { | |
532 Expression *exp; // NULL, or which case to goto | |
533 CaseStatement *cs; // case statement it resolves to | |
309 | 534 EnclosingHandler* enclosinghandler; |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
535 SwitchStatement *sw; |
1 | 536 |
537 GotoCaseStatement(Loc loc, Expression *exp); | |
538 Statement *syntaxCopy(); | |
539 Statement *semantic(Scope *sc); | |
540 Expression *interpret(InterState *istate); | |
541 int fallOffEnd(); | |
542 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
543 | |
544 void toIR(IRState *irs); | |
545 }; | |
546 | |
547 struct SwitchErrorStatement : Statement | |
548 { | |
549 SwitchErrorStatement(Loc loc); | |
550 int fallOffEnd(); | |
551 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
552 | |
553 void toIR(IRState *irs); | |
554 }; | |
555 | |
556 struct ReturnStatement : Statement | |
557 { | |
558 Expression *exp; | |
309 | 559 EnclosingHandler* enclosinghandler; |
1 | 560 |
561 ReturnStatement(Loc loc, Expression *exp); | |
562 Statement *syntaxCopy(); | |
563 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
564 Statement *semantic(Scope *sc); | |
565 int fallOffEnd(); | |
566 Expression *interpret(InterState *istate); | |
567 | |
568 int inlineCost(InlineCostState *ics); | |
569 Expression *doInline(InlineDoState *ids); | |
570 Statement *inlineScan(InlineScanState *iss); | |
571 | |
572 void toIR(IRState *irs); | |
573 | |
574 ReturnStatement *isReturnStatement() { return this; } | |
575 }; | |
576 | |
577 struct BreakStatement : Statement | |
578 { | |
579 Identifier *ident; | |
309 | 580 EnclosingHandler* enclosinghandler; |
1 | 581 |
582 BreakStatement(Loc loc, Identifier *ident); | |
583 Statement *syntaxCopy(); | |
584 Statement *semantic(Scope *sc); | |
585 Expression *interpret(InterState *istate); | |
586 int fallOffEnd(); | |
587 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
588 | |
589 void toIR(IRState *irs); | |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
590 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
591 // LLVMDC: only set if ident is set: label statement to jump to |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
592 LabelStatement *target; |
1 | 593 }; |
594 | |
595 struct ContinueStatement : Statement | |
596 { | |
597 Identifier *ident; | |
309 | 598 EnclosingHandler* enclosinghandler; |
1 | 599 |
600 ContinueStatement(Loc loc, Identifier *ident); | |
601 Statement *syntaxCopy(); | |
602 Statement *semantic(Scope *sc); | |
603 Expression *interpret(InterState *istate); | |
604 int fallOffEnd(); | |
605 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
606 | |
607 void toIR(IRState *irs); | |
145
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
608 |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
609 // LLVMDC: only set if ident is set: label statement to jump to |
8f704cb9969b
[svn r150] fixes #16 and #17, implements GotoCaseStatement
ChristianK
parents:
144
diff
changeset
|
610 LabelStatement *target; |
1 | 611 }; |
612 | |
613 struct SynchronizedStatement : Statement | |
614 { | |
615 Expression *exp; | |
616 Statement *body; | |
309 | 617 EnclosingHandler* enclosinghandler; |
1 | 618 |
619 SynchronizedStatement(Loc loc, Expression *exp, Statement *body); | |
620 Statement *syntaxCopy(); | |
621 Statement *semantic(Scope *sc); | |
622 int hasBreak(); | |
623 int hasContinue(); | |
624 int usesEH(); | |
625 int fallOffEnd(); | |
626 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
627 | |
628 Statement *inlineScan(InlineScanState *iss); | |
629 | |
630 // Back end | |
631 elem *esync; | |
632 SynchronizedStatement(Loc loc, elem *esync, Statement *body); | |
633 void toIR(IRState *irs); | |
309 | 634 llvm::Value* llsync; |
1 | 635 }; |
636 | |
637 struct WithStatement : Statement | |
638 { | |
639 Expression *exp; | |
640 Statement *body; | |
641 VarDeclaration *wthis; | |
642 | |
643 WithStatement(Loc loc, Expression *exp, Statement *body); | |
644 Statement *syntaxCopy(); | |
645 Statement *semantic(Scope *sc); | |
646 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
647 int usesEH(); | |
648 int fallOffEnd(); | |
649 | |
650 Statement *inlineScan(InlineScanState *iss); | |
651 | |
652 void toIR(IRState *irs); | |
653 }; | |
654 | |
655 struct TryCatchStatement : Statement | |
656 { | |
657 Statement *body; | |
658 Array *catches; | |
659 | |
660 TryCatchStatement(Loc loc, Statement *body, Array *catches); | |
661 Statement *syntaxCopy(); | |
662 Statement *semantic(Scope *sc); | |
663 int hasBreak(); | |
664 int usesEH(); | |
665 int fallOffEnd(); | |
666 | |
667 Statement *inlineScan(InlineScanState *iss); | |
668 | |
669 void toIR(IRState *irs); | |
670 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
671 TryCatchStatement *isTryCatchStatement() { return this; } | |
672 }; | |
673 | |
674 struct Catch : Object | |
675 { | |
676 Loc loc; | |
677 Type *type; | |
678 Identifier *ident; | |
679 VarDeclaration *var; | |
680 Statement *handler; | |
681 | |
682 Catch(Loc loc, Type *t, Identifier *id, Statement *handler); | |
683 Catch *syntaxCopy(); | |
684 void semantic(Scope *sc); | |
685 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
686 }; | |
687 | |
688 struct TryFinallyStatement : Statement | |
689 { | |
690 Statement *body; | |
691 Statement *finalbody; | |
309 | 692 EnclosingHandler* enclosinghandler; |
1 | 693 |
694 TryFinallyStatement(Loc loc, Statement *body, Statement *finalbody); | |
695 Statement *syntaxCopy(); | |
696 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
697 Statement *semantic(Scope *sc); | |
698 int hasBreak(); | |
699 int hasContinue(); | |
700 int usesEH(); | |
701 int fallOffEnd(); | |
702 | |
703 Statement *inlineScan(InlineScanState *iss); | |
704 | |
705 void toIR(IRState *irs); | |
706 }; | |
707 | |
708 struct OnScopeStatement : Statement | |
709 { | |
710 TOK tok; | |
711 Statement *statement; | |
712 | |
713 OnScopeStatement(Loc loc, TOK tok, Statement *statement); | |
714 Statement *syntaxCopy(); | |
715 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
716 Statement *semantic(Scope *sc); | |
717 int usesEH(); | |
718 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
719 | |
720 void toIR(IRState *irs); | |
721 }; | |
722 | |
723 struct ThrowStatement : Statement | |
724 { | |
725 Expression *exp; | |
726 | |
727 ThrowStatement(Loc loc, Expression *exp); | |
728 Statement *syntaxCopy(); | |
729 Statement *semantic(Scope *sc); | |
730 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
731 int fallOffEnd(); | |
732 | |
733 Statement *inlineScan(InlineScanState *iss); | |
734 | |
735 void toIR(IRState *irs); | |
736 }; | |
737 | |
738 struct VolatileStatement : Statement | |
739 { | |
740 Statement *statement; | |
309 | 741 EnclosingHandler* enclosinghandler; |
1 | 742 |
743 VolatileStatement(Loc loc, Statement *statement); | |
744 Statement *syntaxCopy(); | |
745 Statement *semantic(Scope *sc); | |
746 Statements *flatten(Scope *sc); | |
747 int fallOffEnd(); | |
748 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
749 | |
750 Statement *inlineScan(InlineScanState *iss); | |
751 | |
752 void toIR(IRState *irs); | |
753 }; | |
754 | |
755 struct GotoStatement : Statement | |
756 { | |
757 Identifier *ident; | |
758 LabelDsymbol *label; | |
759 TryFinallyStatement *tf; | |
309 | 760 EnclosingHandler* enclosinghandler; |
1 | 761 |
762 GotoStatement(Loc loc, Identifier *ident); | |
763 Statement *syntaxCopy(); | |
764 Statement *semantic(Scope *sc); | |
765 int fallOffEnd(); | |
766 Expression *interpret(InterState *istate); | |
767 | |
768 void toIR(IRState *irs); | |
769 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
770 GotoStatement *isGotoStatement() { return this; } | |
771 }; | |
772 | |
773 struct LabelStatement : Statement | |
774 { | |
775 Identifier *ident; | |
776 Statement *statement; | |
777 TryFinallyStatement *tf; | |
309 | 778 EnclosingHandler* enclosinghandler; |
1 | 779 block *lblock; // back end |
780 int isReturnLabel; | |
781 | |
782 LabelStatement(Loc loc, Identifier *ident, Statement *statement); | |
783 Statement *syntaxCopy(); | |
784 Statement *semantic(Scope *sc); | |
785 Statements *flatten(Scope *sc); | |
786 int usesEH(); | |
787 int fallOffEnd(); | |
788 int comeFrom(); | |
789 Expression *interpret(InterState *istate); | |
790 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
791 | |
792 Statement *inlineScan(InlineScanState *iss); | |
793 | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
37
diff
changeset
|
794 void toIR(IRState *irs); |
232
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
795 |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
796 // LLVMDC |
37
77cdca8c210f
[svn r41] new'd dynamic arrays are now initialized with the element type's default initializer.
lindquist
parents:
1
diff
changeset
|
797 llvm::BasicBlock* llvmBB; |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
798 bool asmLabel; // for labels inside inline assembler |
1 | 799 }; |
800 | |
801 struct LabelDsymbol : Dsymbol | |
802 { | |
803 LabelStatement *statement; | |
804 | |
805 LabelDsymbol(Identifier *ident); | |
806 LabelDsymbol *isLabel(); | |
807 }; | |
808 | |
809 struct AsmStatement : Statement | |
810 { | |
811 Token *tokens; | |
812 code *asmcode; | |
813 unsigned asmalign; // alignment of this statement | |
814 unsigned refparam; // !=0 if function parameter is referenced | |
815 unsigned naked; // !=0 if function is to be naked | |
816 unsigned regs; // mask of registers modified | |
817 | |
818 AsmStatement(Loc loc, Token *tokens); | |
819 Statement *syntaxCopy(); | |
820 Statement *semantic(Scope *sc); | |
821 int comeFrom(); | |
822 | |
823 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
824 virtual AsmStatement *isAsmStatement() { return this; } | |
825 | |
826 void toIR(IRState *irs); | |
299
df8a7b8d5929
[svn r320] Begun work on branches out of asm blocks. Unfinished.
ChristianK
parents:
262
diff
changeset
|
827 |
df8a7b8d5929
[svn r320] Begun work on branches out of asm blocks. Unfinished.
ChristianK
parents:
262
diff
changeset
|
828 // LLVMDC |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
829 // non-zero if this is a branch, contains the target labels identifier |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
304
diff
changeset
|
830 Identifier* isBranchToLabel; |
1 | 831 }; |
832 | |
232
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
833 struct AsmBlockStatement : CompoundStatement |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
834 { |
309 | 835 EnclosingHandler* enclosinghandler; |
302 | 836 |
232
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
837 AsmBlockStatement(Loc loc, Statements *s); |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
838 Statements *flatten(Scope *sc); |
239
fa691b1c0498
[svn r256] AsmBlockStatement was still being flattened in some cases.
lindquist
parents:
232
diff
changeset
|
839 Statement *syntaxCopy(); |
302 | 840 Statement *semantic(Scope *sc); |
239
fa691b1c0498
[svn r256] AsmBlockStatement was still being flattened in some cases.
lindquist
parents:
232
diff
changeset
|
841 |
fa691b1c0498
[svn r256] AsmBlockStatement was still being flattened in some cases.
lindquist
parents:
232
diff
changeset
|
842 CompoundStatement *isCompoundStatement() { return NULL; } |
232
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
843 AsmBlockStatement *isAsmBlockStatement() { return this; } |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
844 |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
845 void toIR(IRState *irs); |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
846 }; |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
219
diff
changeset
|
847 |
1 | 848 #endif /* DMD_STATEMENT_H */ |