Mercurial > projects > ldc
annotate dmd/statement.h @ 904:01d9ece9982a
Fix bug #177 by not attempting to define composite debug info for
forward-declared structs.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Fri, 23 Jan 2009 13:41:03 +0100 |
parents | 330f999ade44 |
children | 545f54041d91 |
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 | |
82 /* How a statement exits | |
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 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
97 // LDC this is used for tracking try-finally, synchronized and volatile scopes |
336 | 98 // definitions in gen/llvmhelpers.cpp |
99 struct EnclosingHandler : Object | |
100 { | |
101 virtual void emitCode(IRState* p) = 0; | |
102 virtual EnclosingHandler* getEnclosing() = 0; | |
103 }; | |
104 struct EnclosingTryFinally : EnclosingHandler | |
105 { | |
106 TryFinallyStatement* tf; | |
107 void emitCode(IRState* p); | |
108 EnclosingHandler* getEnclosing(); | |
109 EnclosingTryFinally(TryFinallyStatement* _tf) : tf(_tf) {} | |
110 }; | |
111 struct EnclosingVolatile : EnclosingHandler | |
112 { | |
113 VolatileStatement* v; | |
114 void emitCode(IRState* p); | |
115 EnclosingHandler* getEnclosing(); | |
116 EnclosingVolatile(VolatileStatement* _tf) : v(_tf) {} | |
117 }; | |
118 struct EnclosingSynchro : EnclosingHandler | |
119 { | |
120 SynchronizedStatement* s; | |
121 void emitCode(IRState* p); | |
122 EnclosingHandler* getEnclosing(); | |
123 EnclosingSynchro(SynchronizedStatement* _tf) : s(_tf) {} | |
124 }; | |
125 | |
126 struct Statement : Object | |
127 { | |
128 Loc loc; | |
129 | |
130 Statement(Loc loc); | |
131 virtual Statement *syntaxCopy(); | |
132 | |
133 void print(); | |
134 char *toChars(); | |
135 | |
136 void error(const char *format, ...); | |
137 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
138 virtual TryCatchStatement *isTryCatchStatement() { return NULL; } | |
139 virtual GotoStatement *isGotoStatement() { return NULL; } | |
140 virtual AsmStatement *isAsmStatement() { return NULL; } | |
141 virtual AsmBlockStatement *isAsmBlockStatement() { return NULL; } | |
142 #ifdef _DH | |
143 int incontract; | |
144 #endif | |
145 virtual ScopeStatement *isScopeStatement() { return NULL; } | |
146 virtual Statement *semantic(Scope *sc); | |
147 Statement *semanticScope(Scope *sc, Statement *sbreak, Statement *scontinue); | |
148 virtual int hasBreak(); | |
149 virtual int hasContinue(); | |
150 virtual int usesEH(); | |
151 virtual int blockExit(); | |
152 virtual int comeFrom(); | |
153 virtual void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
154 virtual Statements *flatten(Scope *sc); | |
155 virtual Expression *interpret(InterState *istate); | |
156 | |
157 virtual int inlineCost(InlineCostState *ics); | |
158 virtual Expression *doInline(InlineDoState *ids); | |
159 virtual Statement *inlineScan(InlineScanState *iss); | |
160 | |
161 // Back end | |
162 virtual void toIR(IRState *irs); | |
163 | |
164 // Avoid dynamic_cast | |
165 virtual DeclarationStatement *isDeclarationStatement() { return NULL; } | |
166 virtual CompoundStatement *isCompoundStatement() { return NULL; } | |
167 virtual ReturnStatement *isReturnStatement() { return NULL; } | |
168 virtual IfStatement *isIfStatement() { return NULL; } | |
169 virtual CaseStatement* isCaseStatement() { return NULL; } | |
170 }; | |
171 | |
172 struct ExpStatement : Statement | |
173 { | |
174 Expression *exp; | |
175 | |
176 ExpStatement(Loc loc, Expression *exp); | |
177 Statement *syntaxCopy(); | |
178 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
179 Statement *semantic(Scope *sc); | |
180 Expression *interpret(InterState *istate); | |
181 int blockExit(); | |
182 | |
183 int inlineCost(InlineCostState *ics); | |
184 Expression *doInline(InlineDoState *ids); | |
185 Statement *inlineScan(InlineScanState *iss); | |
186 | |
187 void toIR(IRState *irs); | |
188 }; | |
189 | |
190 struct CompileStatement : Statement | |
191 { | |
192 Expression *exp; | |
193 | |
194 CompileStatement(Loc loc, Expression *exp); | |
195 Statement *syntaxCopy(); | |
196 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
197 Statements *flatten(Scope *sc); | |
198 Statement *semantic(Scope *sc); | |
199 }; | |
200 | |
201 struct DeclarationStatement : ExpStatement | |
202 { | |
203 // Doing declarations as an expression, rather than a statement, | |
204 // makes inlining functions much easier. | |
205 | |
206 DeclarationStatement(Loc loc, Dsymbol *s); | |
207 DeclarationStatement(Loc loc, Expression *exp); | |
208 Statement *syntaxCopy(); | |
209 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
210 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
211 | |
212 DeclarationStatement *isDeclarationStatement() { return this; } | |
213 }; | |
214 | |
215 struct CompoundStatement : Statement | |
216 { | |
217 Statements *statements; | |
218 | |
219 CompoundStatement(Loc loc, Statements *s); | |
220 CompoundStatement(Loc loc, Statement *s1, Statement *s2); | |
221 virtual Statement *syntaxCopy(); | |
222 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
223 virtual Statement *semantic(Scope *sc); | |
224 int usesEH(); | |
225 int blockExit(); | |
226 int comeFrom(); | |
227 virtual Statements *flatten(Scope *sc); | |
228 ReturnStatement *isReturnStatement(); | |
229 Expression *interpret(InterState *istate); | |
230 | |
231 int inlineCost(InlineCostState *ics); | |
232 Expression *doInline(InlineDoState *ids); | |
233 Statement *inlineScan(InlineScanState *iss); | |
234 | |
235 virtual void toIR(IRState *irs); | |
236 | |
237 virtual CompoundStatement *isCompoundStatement() { return this; } | |
238 }; | |
239 | |
240 /* The purpose of this is so that continue will go to the next | |
241 * of the statements, and break will go to the end of the statements. | |
242 */ | |
243 struct UnrolledLoopStatement : Statement | |
244 { | |
245 Statements *statements; | |
246 EnclosingHandler* enclosinghandler; | |
247 | |
248 UnrolledLoopStatement(Loc loc, Statements *statements); | |
249 Statement *syntaxCopy(); | |
250 Statement *semantic(Scope *sc); | |
251 int hasBreak(); | |
252 int hasContinue(); | |
253 int usesEH(); | |
254 int blockExit(); | |
255 int comeFrom(); | |
256 Expression *interpret(InterState *istate); | |
257 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
258 | |
259 int inlineCost(InlineCostState *ics); | |
260 Expression *doInline(InlineDoState *ids); | |
261 Statement *inlineScan(InlineScanState *iss); | |
262 | |
263 void toIR(IRState *irs); | |
264 }; | |
265 | |
266 struct ScopeStatement : Statement | |
267 { | |
268 Statement *statement; | |
269 | |
270 ScopeStatement(Loc loc, Statement *s); | |
271 Statement *syntaxCopy(); | |
272 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
273 ScopeStatement *isScopeStatement() { return this; } | |
274 Statement *semantic(Scope *sc); | |
275 int hasBreak(); | |
276 int hasContinue(); | |
277 int usesEH(); | |
278 int blockExit(); | |
279 int comeFrom(); | |
280 Expression *interpret(InterState *istate); | |
281 | |
282 Statement *inlineScan(InlineScanState *iss); | |
283 | |
284 void toIR(IRState *irs); | |
285 }; | |
286 | |
287 struct WhileStatement : Statement | |
288 { | |
289 Expression *condition; | |
290 Statement *body; | |
291 EnclosingHandler* enclosinghandler; | |
292 | |
293 WhileStatement(Loc loc, Expression *c, Statement *b); | |
294 Statement *syntaxCopy(); | |
295 Statement *semantic(Scope *sc); | |
296 int hasBreak(); | |
297 int hasContinue(); | |
298 int usesEH(); | |
299 int blockExit(); | |
300 int comeFrom(); | |
301 Expression *interpret(InterState *istate); | |
302 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
303 | |
304 Statement *inlineScan(InlineScanState *iss); | |
305 | |
306 void toIR(IRState *irs); | |
307 }; | |
308 | |
309 struct DoStatement : Statement | |
310 { | |
311 Statement *body; | |
312 Expression *condition; | |
313 EnclosingHandler* enclosinghandler; | |
314 | |
315 DoStatement(Loc loc, Statement *b, Expression *c); | |
316 Statement *syntaxCopy(); | |
317 Statement *semantic(Scope *sc); | |
318 int hasBreak(); | |
319 int hasContinue(); | |
320 int usesEH(); | |
321 int blockExit(); | |
322 int comeFrom(); | |
323 Expression *interpret(InterState *istate); | |
324 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
325 | |
326 Statement *inlineScan(InlineScanState *iss); | |
327 | |
328 void toIR(IRState *irs); | |
329 }; | |
330 | |
331 struct ForStatement : Statement | |
332 { | |
333 Statement *init; | |
334 Expression *condition; | |
335 Expression *increment; | |
336 Statement *body; | |
337 EnclosingHandler* enclosinghandler; | |
338 | |
339 ForStatement(Loc loc, Statement *init, Expression *condition, Expression *increment, Statement *body); | |
340 Statement *syntaxCopy(); | |
341 Statement *semantic(Scope *sc); | |
342 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
343 int hasBreak(); | |
344 int hasContinue(); | |
345 int usesEH(); | |
346 int blockExit(); | |
347 int comeFrom(); | |
348 Expression *interpret(InterState *istate); | |
349 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
350 | |
351 Statement *inlineScan(InlineScanState *iss); | |
352 | |
353 void toIR(IRState *irs); | |
354 }; | |
355 | |
356 struct ForeachStatement : Statement | |
357 { | |
358 enum TOK op; // TOKforeach or TOKforeach_reverse | |
359 Arguments *arguments; // array of Argument*'s | |
360 Expression *aggr; | |
361 Statement *body; | |
362 EnclosingHandler* enclosinghandler; | |
363 | |
364 VarDeclaration *key; | |
365 VarDeclaration *value; | |
366 | |
367 FuncDeclaration *func; // function we're lexically in | |
368 | |
369 Array cases; // put breaks, continues, gotos and returns here | |
370 Array gotos; // forward referenced goto's go here | |
371 | |
372 ForeachStatement(Loc loc, enum TOK op, Arguments *arguments, Expression *aggr, Statement *body); | |
373 Statement *syntaxCopy(); | |
374 Statement *semantic(Scope *sc); | |
375 int hasBreak(); | |
376 int hasContinue(); | |
377 int usesEH(); | |
378 int blockExit(); | |
379 int comeFrom(); | |
380 Expression *interpret(InterState *istate); | |
381 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
382 | |
383 Statement *inlineScan(InlineScanState *iss); | |
384 | |
385 void toIR(IRState *irs); | |
386 }; | |
387 | |
388 #if DMDV2 | |
389 struct ForeachRangeStatement : Statement | |
390 { | |
391 enum TOK op; // TOKforeach or TOKforeach_reverse | |
392 Argument *arg; // loop index variable | |
393 Expression *lwr; | |
394 Expression *upr; | |
395 Statement *body; | |
396 | |
397 VarDeclaration *key; | |
398 | |
399 ForeachRangeStatement(Loc loc, enum TOK op, Argument *arg, | |
400 Expression *lwr, Expression *upr, Statement *body); | |
401 Statement *syntaxCopy(); | |
402 Statement *semantic(Scope *sc); | |
403 int hasBreak(); | |
404 int hasContinue(); | |
405 int usesEH(); | |
406 int blockExit(); | |
407 int comeFrom(); | |
408 Expression *interpret(InterState *istate); | |
409 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
410 | |
411 Statement *inlineScan(InlineScanState *iss); | |
412 | |
413 void toIR(IRState *irs); | |
414 }; | |
415 #endif | |
416 | |
417 struct IfStatement : Statement | |
418 { | |
419 Argument *arg; | |
420 Expression *condition; | |
421 Statement *ifbody; | |
422 Statement *elsebody; | |
423 | |
424 VarDeclaration *match; // for MatchExpression results | |
425 | |
426 IfStatement(Loc loc, Argument *arg, Expression *condition, Statement *ifbody, Statement *elsebody); | |
427 Statement *syntaxCopy(); | |
428 Statement *semantic(Scope *sc); | |
429 Expression *interpret(InterState *istate); | |
430 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
431 int usesEH(); | |
432 int blockExit(); | |
433 IfStatement *isIfStatement() { return this; } | |
434 | |
435 int inlineCost(InlineCostState *ics); | |
436 Expression *doInline(InlineDoState *ids); | |
437 Statement *inlineScan(InlineScanState *iss); | |
438 | |
439 void toIR(IRState *irs); | |
440 }; | |
441 | |
442 struct ConditionalStatement : Statement | |
443 { | |
444 Condition *condition; | |
445 Statement *ifbody; | |
446 Statement *elsebody; | |
447 | |
448 ConditionalStatement(Loc loc, Condition *condition, Statement *ifbody, Statement *elsebody); | |
449 Statement *syntaxCopy(); | |
450 Statement *semantic(Scope *sc); | |
451 Statements *flatten(Scope *sc); | |
452 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
|
453 int blockExit(); |
336 | 454 |
455 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
456 }; | |
457 | |
458 struct PragmaStatement : Statement | |
459 { | |
460 Identifier *ident; | |
461 Expressions *args; // array of Expression's | |
462 Statement *body; | |
463 | |
464 PragmaStatement(Loc loc, Identifier *ident, Expressions *args, Statement *body); | |
465 Statement *syntaxCopy(); | |
466 Statement *semantic(Scope *sc); | |
467 int usesEH(); | |
468 int blockExit(); | |
469 | |
470 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
471 }; | |
472 | |
473 struct StaticAssertStatement : Statement | |
474 { | |
475 StaticAssert *sa; | |
476 | |
477 StaticAssertStatement(StaticAssert *sa); | |
478 Statement *syntaxCopy(); | |
479 Statement *semantic(Scope *sc); | |
480 | |
481 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
482 }; | |
483 | |
484 struct SwitchStatement : Statement | |
485 { | |
486 Expression *condition; | |
487 Statement *body; | |
488 | |
489 DefaultStatement *sdefault; | |
490 EnclosingHandler* enclosinghandler; | |
491 | |
492 Array gotoCases; // array of unresolved GotoCaseStatement's | |
493 Array *cases; // array of CaseStatement's | |
494 int hasNoDefault; // !=0 if no default statement | |
495 | |
496 SwitchStatement(Loc loc, Expression *c, Statement *b); | |
497 Statement *syntaxCopy(); | |
498 Statement *semantic(Scope *sc); | |
499 int hasBreak(); | |
500 int usesEH(); | |
501 int blockExit(); | |
502 Expression *interpret(InterState *istate); | |
503 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
504 | |
505 Statement *inlineScan(InlineScanState *iss); | |
506 | |
507 void toIR(IRState *irs); | |
508 }; | |
509 | |
510 struct CaseStatement : Statement | |
511 { | |
512 Expression *exp; | |
513 Statement *statement; | |
514 int index; // which case it is (since we sort this) | |
515 block *cblock; // back end: label for the block | |
516 | |
517 CaseStatement(Loc loc, Expression *exp, Statement *s); | |
518 Statement *syntaxCopy(); | |
519 Statement *semantic(Scope *sc); | |
520 int compare(Object *obj); | |
521 int usesEH(); | |
522 int blockExit(); | |
523 int comeFrom(); | |
524 Expression *interpret(InterState *istate); | |
525 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
526 | |
527 Statement *inlineScan(InlineScanState *iss); | |
528 | |
529 void toIR(IRState *irs); | |
530 | |
531 CaseStatement* isCaseStatement() { return this; } | |
532 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
533 // LDC |
336 | 534 llvm::BasicBlock* bodyBB; |
535 llvm::ConstantInt* llvmIdx; | |
536 }; | |
537 | |
538 struct DefaultStatement : Statement | |
539 { | |
540 Statement *statement; | |
541 #if IN_GCC | |
542 block *cblock; // back end: label for the block | |
543 #endif | |
544 | |
545 DefaultStatement(Loc loc, Statement *s); | |
546 Statement *syntaxCopy(); | |
547 Statement *semantic(Scope *sc); | |
548 int usesEH(); | |
549 int blockExit(); | |
550 int comeFrom(); | |
551 Expression *interpret(InterState *istate); | |
552 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
553 | |
554 Statement *inlineScan(InlineScanState *iss); | |
555 | |
556 void toIR(IRState *irs); | |
557 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
558 // LDC |
336 | 559 llvm::BasicBlock* bodyBB; |
560 }; | |
561 | |
562 struct GotoDefaultStatement : Statement | |
563 { | |
564 SwitchStatement *sw; | |
565 EnclosingHandler* enclosinghandler; | |
566 | |
567 GotoDefaultStatement(Loc loc); | |
568 Statement *syntaxCopy(); | |
569 Statement *semantic(Scope *sc); | |
570 Expression *interpret(InterState *istate); | |
571 int blockExit(); | |
572 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
573 | |
574 void toIR(IRState *irs); | |
575 }; | |
576 | |
577 struct GotoCaseStatement : Statement | |
578 { | |
579 Expression *exp; // NULL, or which case to goto | |
580 CaseStatement *cs; // case statement it resolves to | |
581 EnclosingHandler* enclosinghandler; | |
582 SwitchStatement *sw; | |
583 | |
584 GotoCaseStatement(Loc loc, Expression *exp); | |
585 Statement *syntaxCopy(); | |
586 Statement *semantic(Scope *sc); | |
587 Expression *interpret(InterState *istate); | |
588 int blockExit(); | |
589 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
590 | |
591 void toIR(IRState *irs); | |
592 }; | |
593 | |
594 struct SwitchErrorStatement : Statement | |
595 { | |
596 SwitchErrorStatement(Loc loc); | |
597 int blockExit(); | |
598 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
599 | |
600 void toIR(IRState *irs); | |
601 }; | |
602 | |
603 struct ReturnStatement : Statement | |
604 { | |
605 Expression *exp; | |
606 EnclosingHandler* enclosinghandler; | |
607 | |
608 ReturnStatement(Loc loc, Expression *exp); | |
609 Statement *syntaxCopy(); | |
610 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
611 Statement *semantic(Scope *sc); | |
612 int blockExit(); | |
613 Expression *interpret(InterState *istate); | |
614 | |
615 int inlineCost(InlineCostState *ics); | |
616 Expression *doInline(InlineDoState *ids); | |
617 Statement *inlineScan(InlineScanState *iss); | |
618 | |
619 void toIR(IRState *irs); | |
620 | |
621 ReturnStatement *isReturnStatement() { return this; } | |
622 }; | |
623 | |
624 struct BreakStatement : Statement | |
625 { | |
626 Identifier *ident; | |
627 EnclosingHandler* enclosinghandler; | |
628 | |
629 BreakStatement(Loc loc, Identifier *ident); | |
630 Statement *syntaxCopy(); | |
631 Statement *semantic(Scope *sc); | |
632 Expression *interpret(InterState *istate); | |
633 int blockExit(); | |
634 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
635 | |
636 void toIR(IRState *irs); | |
637 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
638 // LDC: only set if ident is set: label statement to jump to |
336 | 639 LabelStatement *target; |
640 }; | |
641 | |
642 struct ContinueStatement : Statement | |
643 { | |
644 Identifier *ident; | |
645 EnclosingHandler* enclosinghandler; | |
646 | |
647 ContinueStatement(Loc loc, Identifier *ident); | |
648 Statement *syntaxCopy(); | |
649 Statement *semantic(Scope *sc); | |
650 Expression *interpret(InterState *istate); | |
651 int blockExit(); | |
652 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
653 | |
654 void toIR(IRState *irs); | |
655 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
656 // LDC: only set if ident is set: label statement to jump to |
336 | 657 LabelStatement *target; |
658 }; | |
659 | |
660 struct SynchronizedStatement : Statement | |
661 { | |
662 Expression *exp; | |
663 Statement *body; | |
664 EnclosingHandler* enclosinghandler; | |
665 | |
666 SynchronizedStatement(Loc loc, Expression *exp, Statement *body); | |
667 Statement *syntaxCopy(); | |
668 Statement *semantic(Scope *sc); | |
669 int hasBreak(); | |
670 int hasContinue(); | |
671 int usesEH(); | |
672 int blockExit(); | |
673 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
674 | |
675 Statement *inlineScan(InlineScanState *iss); | |
676 | |
677 // Back end | |
678 elem *esync; | |
679 SynchronizedStatement(Loc loc, elem *esync, Statement *body); | |
680 void toIR(IRState *irs); | |
681 llvm::Value* llsync; | |
682 }; | |
683 | |
684 struct WithStatement : Statement | |
685 { | |
686 Expression *exp; | |
687 Statement *body; | |
688 VarDeclaration *wthis; | |
689 | |
690 WithStatement(Loc loc, Expression *exp, Statement *body); | |
691 Statement *syntaxCopy(); | |
692 Statement *semantic(Scope *sc); | |
693 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
694 int usesEH(); | |
695 int blockExit(); | |
696 | |
697 Statement *inlineScan(InlineScanState *iss); | |
698 | |
699 void toIR(IRState *irs); | |
700 }; | |
701 | |
702 struct TryCatchStatement : Statement | |
703 { | |
704 Statement *body; | |
705 Array *catches; | |
706 | |
707 TryCatchStatement(Loc loc, Statement *body, Array *catches); | |
708 Statement *syntaxCopy(); | |
709 Statement *semantic(Scope *sc); | |
710 int hasBreak(); | |
711 int usesEH(); | |
712 int blockExit(); | |
713 | |
714 Statement *inlineScan(InlineScanState *iss); | |
715 | |
716 void toIR(IRState *irs); | |
717 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
718 TryCatchStatement *isTryCatchStatement() { return this; } | |
719 }; | |
720 | |
721 struct Catch : Object | |
722 { | |
723 Loc loc; | |
724 Type *type; | |
725 Identifier *ident; | |
726 VarDeclaration *var; | |
727 Statement *handler; | |
728 | |
729 Catch(Loc loc, Type *t, Identifier *id, Statement *handler); | |
730 Catch *syntaxCopy(); | |
731 void semantic(Scope *sc); | |
732 int blockExit(); | |
733 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
734 }; | |
735 | |
736 struct TryFinallyStatement : Statement | |
737 { | |
738 Statement *body; | |
739 Statement *finalbody; | |
740 EnclosingHandler* enclosinghandler; | |
741 | |
742 TryFinallyStatement(Loc loc, Statement *body, Statement *finalbody); | |
743 Statement *syntaxCopy(); | |
744 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
745 Statement *semantic(Scope *sc); | |
746 int hasBreak(); | |
747 int hasContinue(); | |
748 int usesEH(); | |
749 int blockExit(); | |
750 | |
751 Statement *inlineScan(InlineScanState *iss); | |
752 | |
753 void toIR(IRState *irs); | |
754 }; | |
755 | |
756 struct OnScopeStatement : Statement | |
757 { | |
758 TOK tok; | |
759 Statement *statement; | |
760 | |
761 OnScopeStatement(Loc loc, TOK tok, Statement *statement); | |
762 Statement *syntaxCopy(); | |
763 int blockExit(); | |
764 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
765 Statement *semantic(Scope *sc); | |
766 int usesEH(); | |
767 void scopeCode(Statement **sentry, Statement **sexit, Statement **sfinally); | |
768 | |
769 void toIR(IRState *irs); | |
770 }; | |
771 | |
772 struct ThrowStatement : Statement | |
773 { | |
774 Expression *exp; | |
775 | |
776 ThrowStatement(Loc loc, Expression *exp); | |
777 Statement *syntaxCopy(); | |
778 Statement *semantic(Scope *sc); | |
779 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
780 int blockExit(); | |
781 | |
782 Statement *inlineScan(InlineScanState *iss); | |
783 | |
784 void toIR(IRState *irs); | |
785 }; | |
786 | |
787 struct VolatileStatement : Statement | |
788 { | |
789 Statement *statement; | |
790 EnclosingHandler* enclosinghandler; | |
791 | |
792 VolatileStatement(Loc loc, Statement *statement); | |
793 Statement *syntaxCopy(); | |
794 Statement *semantic(Scope *sc); | |
795 Statements *flatten(Scope *sc); | |
796 int blockExit(); | |
797 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
798 | |
799 Statement *inlineScan(InlineScanState *iss); | |
800 | |
801 void toIR(IRState *irs); | |
802 }; | |
803 | |
804 struct GotoStatement : Statement | |
805 { | |
806 Identifier *ident; | |
807 LabelDsymbol *label; | |
808 TryFinallyStatement *tf; | |
809 EnclosingHandler* enclosinghandler; | |
810 | |
811 GotoStatement(Loc loc, Identifier *ident); | |
812 Statement *syntaxCopy(); | |
813 Statement *semantic(Scope *sc); | |
814 int blockExit(); | |
815 Expression *interpret(InterState *istate); | |
816 | |
817 void toIR(IRState *irs); | |
818 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
819 GotoStatement *isGotoStatement() { return this; } | |
820 }; | |
821 | |
822 struct LabelStatement : Statement | |
823 { | |
824 Identifier *ident; | |
825 Statement *statement; | |
826 TryFinallyStatement *tf; | |
827 EnclosingHandler* enclosinghandler; | |
828 block *lblock; // back end | |
829 int isReturnLabel; | |
830 | |
831 LabelStatement(Loc loc, Identifier *ident, Statement *statement); | |
832 Statement *syntaxCopy(); | |
833 Statement *semantic(Scope *sc); | |
834 Statements *flatten(Scope *sc); | |
835 int usesEH(); | |
836 int blockExit(); | |
837 int comeFrom(); | |
838 Expression *interpret(InterState *istate); | |
839 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
840 | |
841 Statement *inlineScan(InlineScanState *iss); | |
842 | |
843 void toIR(IRState *irs); | |
844 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
845 // LDC |
336 | 846 bool asmLabel; // for labels inside inline assembler |
847 }; | |
848 | |
849 struct LabelDsymbol : Dsymbol | |
850 { | |
851 LabelStatement *statement; | |
852 | |
853 LabelDsymbol(Identifier *ident); | |
854 LabelDsymbol *isLabel(); | |
855 }; | |
856 | |
857 struct AsmStatement : Statement | |
858 { | |
859 Token *tokens; | |
860 code *asmcode; | |
861 unsigned asmalign; // alignment of this statement | |
862 unsigned refparam; // !=0 if function parameter is referenced | |
863 unsigned naked; // !=0 if function is to be naked | |
864 | |
865 AsmStatement(Loc loc, Token *tokens); | |
866 Statement *syntaxCopy(); | |
867 Statement *semantic(Scope *sc); | |
868 int blockExit(); | |
869 int comeFrom(); | |
870 | |
871 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
872 virtual AsmStatement *isAsmStatement() { return this; } | |
873 | |
874 void toIR(IRState *irs); | |
875 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
510
diff
changeset
|
876 // LDC |
336 | 877 // non-zero if this is a branch, contains the target labels identifier |
878 Identifier* isBranchToLabel; | |
879 }; | |
880 | |
881 struct AsmBlockStatement : CompoundStatement | |
882 { | |
883 EnclosingHandler* enclosinghandler; | |
356
44daf304421c
[svn r377] The previous check was too strict, it completely disallowed gotos within finally blocks. This reenables them as long as they don't cross a finally boundary.
ChristianK
parents:
353
diff
changeset
|
884 TryFinallyStatement* tf; |
336 | 885 |
886 AsmBlockStatement(Loc loc, Statements *s); | |
887 Statements *flatten(Scope *sc); | |
888 Statement *syntaxCopy(); | |
889 Statement *semantic(Scope *sc); | |
890 | |
891 CompoundStatement *isCompoundStatement() { return NULL; } | |
892 AsmBlockStatement *isAsmBlockStatement() { return this; } | |
893 | |
894 void toIR(IRState *irs); | |
895 }; | |
896 | |
897 #endif /* DMD_STATEMENT_H */ |