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