Mercurial > projects > ldc
annotate dmd/statement.h @ 1141:f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
implement the synchronized storage class for functions.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Tue, 24 Mar 2009 21:18:18 +0100 |
parents | b30fe7e1dbb9 |
children | c6d6a68bb5db |
rev | line source |
---|---|
336 | 1 |
2 // Compiler implementation of the D programming language | |
3 // Copyright (c) 1999-2008 by Digital Mars | |
4 // All Rights Reserved | |
5 // written by Walter Bright | |
6 // http://www.digitalmars.com | |
7 // License for redistribution is by either the Artistic License | |
8 // in artistic.txt, or the GNU General Public License in gnu.txt. | |
9 // See the included readme.txt for details. | |
10 | |
11 #ifndef DMD_STATEMENT_H | |
12 #define DMD_STATEMENT_H | |
13 | |
14 #ifdef __DMC__ | |
15 #pragma once | |
16 #endif /* __DMC__ */ | |
17 | |
18 #include "root.h" | |
19 | |
20 #include "arraytypes.h" | |
21 #include "dsymbol.h" | |
22 #include "lexer.h" | |
23 | |
24 struct OutBuffer; | |
25 struct Scope; | |
26 struct Expression; | |
27 struct LabelDsymbol; | |
28 struct Identifier; | |
29 struct IfStatement; | |
30 struct DeclarationStatement; | |
31 struct DefaultStatement; | |
32 struct VarDeclaration; | |
33 struct Condition; | |
34 struct Module; | |
35 struct Token; | |
36 struct InlineCostState; | |
37 struct InlineDoState; | |
38 struct InlineScanState; | |
39 struct ReturnStatement; | |
40 struct CompoundStatement; | |
41 struct Argument; | |
42 struct StaticAssert; | |
43 struct AsmStatement; | |
44 struct AsmBlockStatement; | |
45 struct GotoStatement; | |
46 struct ScopeStatement; | |
47 struct TryCatchStatement; | |
48 struct TryFinallyStatement; | |
49 struct HdrGenState; | |
50 struct InterState; | |
51 struct CaseStatement; | |
52 struct LabelStatement; | |
53 struct VolatileStatement; | |
54 struct SynchronizedStatement; | |
55 | |
56 enum TOK; | |
57 | |
58 namespace llvm | |
59 { | |
60 class Value; | |
61 class BasicBlock; | |
62 class ConstantInt; | |
63 } | |
64 | |
65 // Back end | |
66 struct IRState; | |
67 struct Blockx; | |
68 #if IN_LLVM | |
69 struct DValue; | |
70 typedef DValue elem; | |
71 #endif | |
72 | |
73 #if IN_GCC | |
74 union tree_node; typedef union tree_node block; | |
75 //union tree_node; typedef union tree_node elem; | |
76 #else | |
77 struct block; | |
78 //struct elem; | |
79 #endif | |
80 struct code; | |
81 | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
945
diff
changeset
|
82 /* How a statement exits; this is returned by blockExit() |
336 | 83 */ |
84 enum BE | |
85 { | |
86 BEnone = 0, | |
87 BEfallthru = 1, | |
88 BEthrow = 2, | |
89 BEreturn = 4, | |
90 BEgoto = 8, | |
91 BEhalt = 0x10, | |
92 BEbreak = 0x20, | |
93 BEcontinue = 0x40, | |
94 BEany = (BEfallthru | BEthrow | BEreturn | BEgoto | BEhalt), | |
95 }; | |
96 | |
97 struct Statement : Object | |
98 { | |
99 Loc loc; | |
100 | |
101 Statement(Loc loc); | |
102 virtual Statement *syntaxCopy(); | |
103 | |
104 void print(); | |
105 char *toChars(); | |
106 | |
107 void error(const char *format, ...); | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
945
diff
changeset
|
108 void warning(const char *format, ...); |
336 | 109 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
110 virtual TryCatchStatement *isTryCatchStatement() { return NULL; } | |
111 virtual GotoStatement *isGotoStatement() { return NULL; } | |
112 virtual AsmStatement *isAsmStatement() { return NULL; } | |
113 virtual AsmBlockStatement *isAsmBlockStatement() { return NULL; } | |
114 #ifdef _DH | |
115 int incontract; | |
116 #endif | |
117 virtual ScopeStatement *isScopeStatement() { return NULL; } | |
118 virtual Statement *semantic(Scope *sc); | |
119 Statement *semanticScope(Scope *sc, Statement *sbreak, Statement *scontinue); | |
120 virtual int hasBreak(); | |
121 virtual int hasContinue(); | |
122 virtual int usesEH(); | |
123 virtual int blockExit(); | |
124 virtual int comeFrom(); | |
125 virtual void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
126 virtual Statements *flatten(Scope *sc); | |
127 virtual Expression *interpret(InterState *istate); | |
128 | |
129 virtual int inlineCost(InlineCostState *ics); | |
130 virtual Expression *doInline(InlineDoState *ids); | |
131 virtual Statement *inlineScan(InlineScanState *iss); | |
132 | |
133 // Back end | |
134 virtual void toIR(IRState *irs); | |
135 | |
136 // Avoid dynamic_cast | |
137 virtual DeclarationStatement *isDeclarationStatement() { return NULL; } | |
138 virtual CompoundStatement *isCompoundStatement() { return NULL; } | |
139 virtual ReturnStatement *isReturnStatement() { return NULL; } | |
140 virtual IfStatement *isIfStatement() { return NULL; } | |
141 virtual CaseStatement* isCaseStatement() { return NULL; } | |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
142 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
143 // LDC |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
144 virtual void toNakedIR(IRState *irs); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
145 virtual AsmBlockStatement* endsWithAsm(); |
336 | 146 }; |
147 | |
148 struct ExpStatement : Statement | |
149 { | |
150 Expression *exp; | |
151 | |
152 ExpStatement(Loc loc, Expression *exp); | |
153 Statement *syntaxCopy(); | |
154 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
155 Statement *semantic(Scope *sc); | |
156 Expression *interpret(InterState *istate); | |
157 int blockExit(); | |
158 | |
159 int inlineCost(InlineCostState *ics); | |
160 Expression *doInline(InlineDoState *ids); | |
161 Statement *inlineScan(InlineScanState *iss); | |
162 | |
163 void toIR(IRState *irs); | |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
164 |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
165 // LDC |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
166 void toNakedIR(IRState *irs); |
336 | 167 }; |
168 | |
169 struct CompileStatement : Statement | |
170 { | |
171 Expression *exp; | |
172 | |
173 CompileStatement(Loc loc, Expression *exp); | |
174 Statement *syntaxCopy(); | |
175 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
176 Statements *flatten(Scope *sc); | |
177 Statement *semantic(Scope *sc); | |
178 }; | |
179 | |
180 struct DeclarationStatement : ExpStatement | |
181 { | |
182 // Doing declarations as an expression, rather than a statement, | |
183 // makes inlining functions much easier. | |
184 | |
185 DeclarationStatement(Loc loc, Dsymbol *s); | |
186 DeclarationStatement(Loc loc, Expression *exp); | |
187 Statement *syntaxCopy(); | |
188 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
189 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
190 | |
191 DeclarationStatement *isDeclarationStatement() { return this; } | |
192 }; | |
193 | |
194 struct CompoundStatement : Statement | |
195 { | |
196 Statements *statements; | |
197 | |
198 CompoundStatement(Loc loc, Statements *s); | |
199 CompoundStatement(Loc loc, Statement *s1, Statement *s2); | |
200 virtual Statement *syntaxCopy(); | |
201 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
202 virtual Statement *semantic(Scope *sc); | |
203 int usesEH(); | |
204 int blockExit(); | |
205 int comeFrom(); | |
206 virtual Statements *flatten(Scope *sc); | |
207 ReturnStatement *isReturnStatement(); | |
208 Expression *interpret(InterState *istate); | |
209 | |
210 int inlineCost(InlineCostState *ics); | |
211 Expression *doInline(InlineDoState *ids); | |
212 Statement *inlineScan(InlineScanState *iss); | |
213 | |
214 virtual void toIR(IRState *irs); | |
215 | |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
216 // LDC |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
217 virtual void toNakedIR(IRState *irs); |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
218 virtual AsmBlockStatement* endsWithAsm(); |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
219 |
336 | 220 virtual CompoundStatement *isCompoundStatement() { return this; } |
221 }; | |
222 | |
223 /* The purpose of this is so that continue will go to the next | |
224 * of the statements, and break will go to the end of the statements. | |
225 */ | |
226 struct UnrolledLoopStatement : Statement | |
227 { | |
228 Statements *statements; | |
229 | |
230 UnrolledLoopStatement(Loc loc, Statements *statements); | |
231 Statement *syntaxCopy(); | |
232 Statement *semantic(Scope *sc); | |
233 int hasBreak(); | |
234 int hasContinue(); | |
235 int usesEH(); | |
236 int blockExit(); | |
237 int comeFrom(); | |
238 Expression *interpret(InterState *istate); | |
239 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
240 | |
241 int inlineCost(InlineCostState *ics); | |
242 Expression *doInline(InlineDoState *ids); | |
243 Statement *inlineScan(InlineScanState *iss); | |
244 | |
245 void toIR(IRState *irs); | |
246 }; | |
247 | |
248 struct ScopeStatement : Statement | |
249 { | |
250 Statement *statement; | |
251 | |
252 ScopeStatement(Loc loc, Statement *s); | |
253 Statement *syntaxCopy(); | |
254 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
255 ScopeStatement *isScopeStatement() { return this; } | |
256 Statement *semantic(Scope *sc); | |
257 int hasBreak(); | |
258 int hasContinue(); | |
259 int usesEH(); | |
260 int blockExit(); | |
261 int comeFrom(); | |
262 Expression *interpret(InterState *istate); | |
263 | |
264 Statement *inlineScan(InlineScanState *iss); | |
265 | |
266 void toIR(IRState *irs); | |
267 }; | |
268 | |
269 struct WhileStatement : Statement | |
270 { | |
271 Expression *condition; | |
272 Statement *body; | |
273 | |
274 WhileStatement(Loc loc, Expression *c, Statement *b); | |
275 Statement *syntaxCopy(); | |
276 Statement *semantic(Scope *sc); | |
277 int hasBreak(); | |
278 int hasContinue(); | |
279 int usesEH(); | |
280 int blockExit(); | |
281 int comeFrom(); | |
282 Expression *interpret(InterState *istate); | |
283 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
284 | |
285 Statement *inlineScan(InlineScanState *iss); | |
286 | |
287 void toIR(IRState *irs); | |
288 }; | |
289 | |
290 struct DoStatement : Statement | |
291 { | |
292 Statement *body; | |
293 Expression *condition; | |
294 | |
295 DoStatement(Loc loc, Statement *b, Expression *c); | |
296 Statement *syntaxCopy(); | |
297 Statement *semantic(Scope *sc); | |
298 int hasBreak(); | |
299 int hasContinue(); | |
300 int usesEH(); | |
301 int blockExit(); | |
302 int comeFrom(); | |
303 Expression *interpret(InterState *istate); | |
304 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
305 | |
306 Statement *inlineScan(InlineScanState *iss); | |
307 | |
308 void toIR(IRState *irs); | |
309 }; | |
310 | |
311 struct ForStatement : Statement | |
312 { | |
313 Statement *init; | |
314 Expression *condition; | |
315 Expression *increment; | |
316 Statement *body; | |
317 | |
318 ForStatement(Loc loc, Statement *init, Expression *condition, Expression *increment, Statement *body); | |
319 Statement *syntaxCopy(); | |
320 Statement *semantic(Scope *sc); | |
321 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
322 int hasBreak(); | |
323 int hasContinue(); | |
324 int usesEH(); | |
325 int blockExit(); | |
326 int comeFrom(); | |
327 Expression *interpret(InterState *istate); | |
328 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
329 | |
330 Statement *inlineScan(InlineScanState *iss); | |
331 | |
332 void toIR(IRState *irs); | |
333 }; | |
334 | |
335 struct ForeachStatement : Statement | |
336 { | |
337 enum TOK op; // TOKforeach or TOKforeach_reverse | |
338 Arguments *arguments; // array of Argument*'s | |
339 Expression *aggr; | |
340 Statement *body; | |
341 | |
342 VarDeclaration *key; | |
343 VarDeclaration *value; | |
344 | |
345 FuncDeclaration *func; // function we're lexically in | |
346 | |
347 Array cases; // put breaks, continues, gotos and returns here | |
348 Array gotos; // forward referenced goto's go here | |
349 | |
350 ForeachStatement(Loc loc, enum TOK op, Arguments *arguments, Expression *aggr, Statement *body); | |
351 Statement *syntaxCopy(); | |
352 Statement *semantic(Scope *sc); | |
353 int hasBreak(); | |
354 int hasContinue(); | |
355 int usesEH(); | |
356 int blockExit(); | |
357 int comeFrom(); | |
358 Expression *interpret(InterState *istate); | |
359 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
360 | |
361 Statement *inlineScan(InlineScanState *iss); | |
362 | |
363 void toIR(IRState *irs); | |
364 }; | |
365 | |
366 #if DMDV2 | |
367 struct ForeachRangeStatement : Statement | |
368 { | |
369 enum TOK op; // TOKforeach or TOKforeach_reverse | |
370 Argument *arg; // loop index variable | |
371 Expression *lwr; | |
372 Expression *upr; | |
373 Statement *body; | |
374 | |
375 VarDeclaration *key; | |
376 | |
377 ForeachRangeStatement(Loc loc, enum TOK op, Argument *arg, | |
378 Expression *lwr, Expression *upr, Statement *body); | |
379 Statement *syntaxCopy(); | |
380 Statement *semantic(Scope *sc); | |
381 int hasBreak(); | |
382 int hasContinue(); | |
383 int usesEH(); | |
384 int blockExit(); | |
385 int comeFrom(); | |
386 Expression *interpret(InterState *istate); | |
387 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
388 | |
389 Statement *inlineScan(InlineScanState *iss); | |
390 | |
391 void toIR(IRState *irs); | |
392 }; | |
393 #endif | |
394 | |
395 struct IfStatement : Statement | |
396 { | |
397 Argument *arg; | |
398 Expression *condition; | |
399 Statement *ifbody; | |
400 Statement *elsebody; | |
401 | |
402 VarDeclaration *match; // for MatchExpression results | |
403 | |
404 IfStatement(Loc loc, Argument *arg, Expression *condition, Statement *ifbody, Statement *elsebody); | |
405 Statement *syntaxCopy(); | |
406 Statement *semantic(Scope *sc); | |
407 Expression *interpret(InterState *istate); | |
408 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
409 int usesEH(); | |
410 int blockExit(); | |
411 IfStatement *isIfStatement() { return this; } | |
412 | |
413 int inlineCost(InlineCostState *ics); | |
414 Expression *doInline(InlineDoState *ids); | |
415 Statement *inlineScan(InlineScanState *iss); | |
416 | |
417 void toIR(IRState *irs); | |
418 }; | |
419 | |
420 struct ConditionalStatement : Statement | |
421 { | |
422 Condition *condition; | |
423 Statement *ifbody; | |
424 Statement *elsebody; | |
425 | |
426 ConditionalStatement(Loc loc, Condition *condition, Statement *ifbody, Statement *elsebody); | |
427 Statement *syntaxCopy(); | |
428 Statement *semantic(Scope *sc); | |
429 Statements *flatten(Scope *sc); | |
430 int usesEH(); | |
510
6aee82889553
Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
356
diff
changeset
|
431 int blockExit(); |
336 | 432 |
433 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
434 }; | |
435 | |
436 struct PragmaStatement : Statement | |
437 { | |
438 Identifier *ident; | |
439 Expressions *args; // array of Expression's | |
440 Statement *body; | |
441 | |
442 PragmaStatement(Loc loc, Identifier *ident, Expressions *args, Statement *body); | |
443 Statement *syntaxCopy(); | |
444 Statement *semantic(Scope *sc); | |
445 int usesEH(); | |
446 int blockExit(); | |
447 | |
448 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
449 }; | |
450 | |
451 struct StaticAssertStatement : Statement | |
452 { | |
453 StaticAssert *sa; | |
454 | |
455 StaticAssertStatement(StaticAssert *sa); | |
456 Statement *syntaxCopy(); | |
457 Statement *semantic(Scope *sc); | |
458 | |
459 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
460 }; | |
461 | |
462 struct SwitchStatement : Statement | |
463 { | |
464 Expression *condition; | |
465 Statement *body; | |
466 | |
467 DefaultStatement *sdefault; | |
468 | |
469 Array gotoCases; // array of unresolved GotoCaseStatement's | |
470 Array *cases; // array of CaseStatement's | |
471 int hasNoDefault; // !=0 if no default statement | |
472 | |
473 SwitchStatement(Loc loc, Expression *c, Statement *b); | |
474 Statement *syntaxCopy(); | |
475 Statement *semantic(Scope *sc); | |
476 int hasBreak(); | |
477 int usesEH(); | |
478 int blockExit(); | |
479 Expression *interpret(InterState *istate); | |
480 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
481 | |
482 Statement *inlineScan(InlineScanState *iss); | |
483 | |
484 void toIR(IRState *irs); | |
485 }; | |
486 | |
487 struct CaseStatement : Statement | |
488 { | |
489 Expression *exp; | |
490 Statement *statement; | |
491 int index; // which case it is (since we sort this) | |
492 block *cblock; // back end: label for the block | |
493 | |
494 CaseStatement(Loc loc, Expression *exp, Statement *s); | |
495 Statement *syntaxCopy(); | |
496 Statement *semantic(Scope *sc); | |
497 int compare(Object *obj); | |
498 int usesEH(); | |
499 int blockExit(); | |
500 int comeFrom(); | |
501 Expression *interpret(InterState *istate); | |
502 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
503 | |
504 Statement *inlineScan(InlineScanState *iss); | |
505 | |
506 void toIR(IRState *irs); | |
507 | |
508 CaseStatement* isCaseStatement() { return this; } | |
509 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
510 // LDC |
336 | 511 llvm::BasicBlock* bodyBB; |
512 llvm::ConstantInt* llvmIdx; | |
513 }; | |
514 | |
515 struct DefaultStatement : Statement | |
516 { | |
517 Statement *statement; | |
518 #if IN_GCC | |
519 block *cblock; // back end: label for the block | |
520 #endif | |
521 | |
522 DefaultStatement(Loc loc, Statement *s); | |
523 Statement *syntaxCopy(); | |
524 Statement *semantic(Scope *sc); | |
525 int usesEH(); | |
526 int blockExit(); | |
527 int comeFrom(); | |
528 Expression *interpret(InterState *istate); | |
529 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
530 | |
531 Statement *inlineScan(InlineScanState *iss); | |
532 | |
533 void toIR(IRState *irs); | |
534 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
535 // LDC |
336 | 536 llvm::BasicBlock* bodyBB; |
537 }; | |
538 | |
539 struct GotoDefaultStatement : Statement | |
540 { | |
541 SwitchStatement *sw; | |
542 | |
543 GotoDefaultStatement(Loc loc); | |
544 Statement *syntaxCopy(); | |
545 Statement *semantic(Scope *sc); | |
546 Expression *interpret(InterState *istate); | |
547 int blockExit(); | |
548 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
549 | |
550 void toIR(IRState *irs); | |
551 }; | |
552 | |
553 struct GotoCaseStatement : Statement | |
554 { | |
555 Expression *exp; // NULL, or which case to goto | |
556 CaseStatement *cs; // case statement it resolves to | |
557 SwitchStatement *sw; | |
558 | |
559 GotoCaseStatement(Loc loc, Expression *exp); | |
560 Statement *syntaxCopy(); | |
561 Statement *semantic(Scope *sc); | |
562 Expression *interpret(InterState *istate); | |
563 int blockExit(); | |
564 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
565 | |
566 void toIR(IRState *irs); | |
567 }; | |
568 | |
569 struct SwitchErrorStatement : Statement | |
570 { | |
571 SwitchErrorStatement(Loc loc); | |
572 int blockExit(); | |
573 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
574 | |
575 void toIR(IRState *irs); | |
576 }; | |
577 | |
578 struct ReturnStatement : Statement | |
579 { | |
580 Expression *exp; | |
581 | |
582 ReturnStatement(Loc loc, Expression *exp); | |
583 Statement *syntaxCopy(); | |
584 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
585 Statement *semantic(Scope *sc); | |
586 int blockExit(); | |
587 Expression *interpret(InterState *istate); | |
588 | |
589 int inlineCost(InlineCostState *ics); | |
590 Expression *doInline(InlineDoState *ids); | |
591 Statement *inlineScan(InlineScanState *iss); | |
592 | |
593 void toIR(IRState *irs); | |
594 | |
595 ReturnStatement *isReturnStatement() { return this; } | |
596 }; | |
597 | |
598 struct BreakStatement : Statement | |
599 { | |
600 Identifier *ident; | |
601 | |
602 BreakStatement(Loc loc, Identifier *ident); | |
603 Statement *syntaxCopy(); | |
604 Statement *semantic(Scope *sc); | |
605 Expression *interpret(InterState *istate); | |
606 int blockExit(); | |
607 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
608 | |
609 void toIR(IRState *irs); | |
610 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
611 // LDC: only set if ident is set: label statement to jump to |
336 | 612 LabelStatement *target; |
613 }; | |
614 | |
615 struct ContinueStatement : Statement | |
616 { | |
617 Identifier *ident; | |
618 | |
619 ContinueStatement(Loc loc, Identifier *ident); | |
620 Statement *syntaxCopy(); | |
621 Statement *semantic(Scope *sc); | |
622 Expression *interpret(InterState *istate); | |
623 int blockExit(); | |
624 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
625 | |
626 void toIR(IRState *irs); | |
627 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
628 // LDC: only set if ident is set: label statement to jump to |
336 | 629 LabelStatement *target; |
630 }; | |
631 | |
632 struct SynchronizedStatement : Statement | |
633 { | |
634 Expression *exp; | |
635 Statement *body; | |
636 | |
637 SynchronizedStatement(Loc loc, Expression *exp, Statement *body); | |
638 Statement *syntaxCopy(); | |
639 Statement *semantic(Scope *sc); | |
640 int hasBreak(); | |
641 int hasContinue(); | |
642 int usesEH(); | |
643 int blockExit(); | |
644 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
645 | |
646 Statement *inlineScan(InlineScanState *iss); | |
647 | |
648 // Back end | |
649 elem *esync; | |
650 SynchronizedStatement(Loc loc, elem *esync, Statement *body); | |
651 void toIR(IRState *irs); | |
652 llvm::Value* llsync; | |
653 }; | |
654 | |
655 struct WithStatement : Statement | |
656 { | |
657 Expression *exp; | |
658 Statement *body; | |
659 VarDeclaration *wthis; | |
660 | |
661 WithStatement(Loc loc, Expression *exp, Statement *body); | |
662 Statement *syntaxCopy(); | |
663 Statement *semantic(Scope *sc); | |
664 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
665 int usesEH(); | |
666 int blockExit(); | |
667 | |
668 Statement *inlineScan(InlineScanState *iss); | |
669 | |
670 void toIR(IRState *irs); | |
671 }; | |
672 | |
673 struct TryCatchStatement : Statement | |
674 { | |
675 Statement *body; | |
676 Array *catches; | |
677 | |
678 TryCatchStatement(Loc loc, Statement *body, Array *catches); | |
679 Statement *syntaxCopy(); | |
680 Statement *semantic(Scope *sc); | |
681 int hasBreak(); | |
682 int usesEH(); | |
683 int blockExit(); | |
684 | |
685 Statement *inlineScan(InlineScanState *iss); | |
686 | |
687 void toIR(IRState *irs); | |
688 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
689 TryCatchStatement *isTryCatchStatement() { return this; } | |
690 }; | |
691 | |
692 struct Catch : Object | |
693 { | |
694 Loc loc; | |
695 Type *type; | |
696 Identifier *ident; | |
697 VarDeclaration *var; | |
698 Statement *handler; | |
699 | |
700 Catch(Loc loc, Type *t, Identifier *id, Statement *handler); | |
701 Catch *syntaxCopy(); | |
702 void semantic(Scope *sc); | |
703 int blockExit(); | |
704 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
705 }; | |
706 | |
707 struct TryFinallyStatement : Statement | |
708 { | |
709 Statement *body; | |
710 Statement *finalbody; | |
711 | |
712 TryFinallyStatement(Loc loc, Statement *body, Statement *finalbody); | |
713 Statement *syntaxCopy(); | |
714 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
715 Statement *semantic(Scope *sc); | |
716 int hasBreak(); | |
717 int hasContinue(); | |
718 int usesEH(); | |
719 int blockExit(); | |
720 | |
721 Statement *inlineScan(InlineScanState *iss); | |
722 | |
723 void toIR(IRState *irs); | |
724 }; | |
725 | |
726 struct OnScopeStatement : Statement | |
727 { | |
728 TOK tok; | |
729 Statement *statement; | |
730 | |
731 OnScopeStatement(Loc loc, TOK tok, Statement *statement); | |
732 Statement *syntaxCopy(); | |
733 int blockExit(); | |
734 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
735 Statement *semantic(Scope *sc); | |
736 int usesEH(); | |
737 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
738 | |
739 void toIR(IRState *irs); | |
740 }; | |
741 | |
742 struct ThrowStatement : Statement | |
743 { | |
744 Expression *exp; | |
745 | |
746 ThrowStatement(Loc loc, Expression *exp); | |
747 Statement *syntaxCopy(); | |
748 Statement *semantic(Scope *sc); | |
749 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
750 int blockExit(); | |
751 | |
752 Statement *inlineScan(InlineScanState *iss); | |
753 | |
754 void toIR(IRState *irs); | |
755 }; | |
756 | |
757 struct VolatileStatement : Statement | |
758 { | |
759 Statement *statement; | |
760 | |
761 VolatileStatement(Loc loc, Statement *statement); | |
762 Statement *syntaxCopy(); | |
763 Statement *semantic(Scope *sc); | |
764 Statements *flatten(Scope *sc); | |
765 int blockExit(); | |
766 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
767 | |
768 Statement *inlineScan(InlineScanState *iss); | |
769 | |
770 void toIR(IRState *irs); | |
771 }; | |
772 | |
773 struct GotoStatement : Statement | |
774 { | |
775 Identifier *ident; | |
776 LabelDsymbol *label; | |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
777 TryFinallyStatement *enclosingFinally; |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
778 Statement* enclosingScopeExit; |
336 | 779 |
780 GotoStatement(Loc loc, Identifier *ident); | |
781 Statement *syntaxCopy(); | |
782 Statement *semantic(Scope *sc); | |
783 int blockExit(); | |
784 Expression *interpret(InterState *istate); | |
785 | |
786 void toIR(IRState *irs); | |
787 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
788 GotoStatement *isGotoStatement() { return this; } | |
789 }; | |
790 | |
791 struct LabelStatement : Statement | |
792 { | |
793 Identifier *ident; | |
794 Statement *statement; | |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
795 TryFinallyStatement *enclosingFinally; |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
796 Statement* enclosingScopeExit; |
336 | 797 block *lblock; // back end |
798 int isReturnLabel; | |
799 | |
800 LabelStatement(Loc loc, Identifier *ident, Statement *statement); | |
801 Statement *syntaxCopy(); | |
802 Statement *semantic(Scope *sc); | |
803 Statements *flatten(Scope *sc); | |
804 int usesEH(); | |
805 int blockExit(); | |
806 int comeFrom(); | |
807 Expression *interpret(InterState *istate); | |
808 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
809 | |
810 Statement *inlineScan(InlineScanState *iss); | |
811 | |
812 void toIR(IRState *irs); | |
813 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
814 // LDC |
336 | 815 bool asmLabel; // for labels inside inline assembler |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
816 void toNakedIR(IRState *irs); |
336 | 817 }; |
818 | |
819 struct LabelDsymbol : Dsymbol | |
820 { | |
821 LabelStatement *statement; | |
822 | |
823 LabelDsymbol(Identifier *ident); | |
824 LabelDsymbol *isLabel(); | |
825 }; | |
826 | |
827 struct AsmStatement : Statement | |
828 { | |
829 Token *tokens; | |
830 code *asmcode; | |
831 unsigned asmalign; // alignment of this statement | |
832 unsigned refparam; // !=0 if function parameter is referenced | |
833 unsigned naked; // !=0 if function is to be naked | |
834 | |
835 AsmStatement(Loc loc, Token *tokens); | |
836 Statement *syntaxCopy(); | |
837 Statement *semantic(Scope *sc); | |
838 int blockExit(); | |
839 int comeFrom(); | |
840 | |
841 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
842 virtual AsmStatement *isAsmStatement() { return this; } | |
843 | |
844 void toIR(IRState *irs); | |
845 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
846 // LDC |
336 | 847 // non-zero if this is a branch, contains the target labels identifier |
848 Identifier* isBranchToLabel; | |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
849 |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
850 void toNakedIR(IRState *irs); |
336 | 851 }; |
852 | |
853 struct AsmBlockStatement : CompoundStatement | |
854 { | |
1141
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
855 TryFinallyStatement* enclosingFinally; |
f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
Christian Kamm <kamm incasoftware de>
parents:
1103
diff
changeset
|
856 Statement* enclosingScopeExit; |
336 | 857 |
858 AsmBlockStatement(Loc loc, Statements *s); | |
859 Statements *flatten(Scope *sc); | |
860 Statement *syntaxCopy(); | |
861 Statement *semantic(Scope *sc); | |
862 | |
863 CompoundStatement *isCompoundStatement() { return NULL; } | |
864 AsmBlockStatement *isAsmBlockStatement() { return this; } | |
865 | |
866 void toIR(IRState *irs); | |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
875
diff
changeset
|
867 void toNakedIR(IRState *irs); |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
868 AsmBlockStatement* endsWithAsm(); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
869 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
870 llvm::Value* abiret; |
336 | 871 }; |
872 | |
873 #endif /* DMD_STATEMENT_H */ |