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