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