Mercurial > projects > ldc
comparison dmd2/statement.h @ 1452:638d16625da2
LDC 2 compiles again.
author | Robert Clipsham <robert@octarineparrot.com> |
---|---|
date | Sat, 30 May 2009 17:23:32 +0100 |
parents | 03d7c4aac654 |
children | 54b3c1394d62 |
comparison
equal
deleted
inserted
replaced
1423:42bd767ec5a4 | 1452:638d16625da2 |
---|---|
39 struct ReturnStatement; | 39 struct ReturnStatement; |
40 struct CompoundStatement; | 40 struct CompoundStatement; |
41 struct Argument; | 41 struct Argument; |
42 struct StaticAssert; | 42 struct StaticAssert; |
43 struct AsmStatement; | 43 struct AsmStatement; |
44 #if IN_LLVM | |
44 struct AsmBlockStatement; | 45 struct AsmBlockStatement; |
46 #endif | |
45 struct GotoStatement; | 47 struct GotoStatement; |
46 struct ScopeStatement; | 48 struct ScopeStatement; |
47 struct TryCatchStatement; | 49 struct TryCatchStatement; |
48 struct TryFinallyStatement; | 50 struct TryFinallyStatement; |
49 struct HdrGenState; | 51 struct HdrGenState; |
50 struct InterState; | 52 struct InterState; |
53 #if IN_LLVM | |
51 struct CaseStatement; | 54 struct CaseStatement; |
52 struct LabelStatement; | 55 struct LabelStatement; |
53 struct VolatileStatement; | 56 struct VolatileStatement; |
54 struct SynchronizedStatement; | 57 struct SynchronizedStatement; |
58 #endif | |
55 | 59 |
56 enum TOK; | 60 enum TOK; |
57 | 61 |
62 #if IN_LLVM | |
58 namespace llvm | 63 namespace llvm |
59 { | 64 { |
60 class Value; | 65 class Value; |
61 class BasicBlock; | 66 class BasicBlock; |
62 class ConstantInt; | 67 class ConstantInt; |
63 } | 68 } |
69 #endif | |
64 | 70 |
65 // Back end | 71 // Back end |
66 struct IRState; | 72 struct IRState; |
67 struct Blockx; | 73 struct Blockx; |
68 #if IN_LLVM | 74 #if IN_LLVM |
77 struct block; | 83 struct block; |
78 //struct elem; | 84 //struct elem; |
79 #endif | 85 #endif |
80 struct code; | 86 struct code; |
81 | 87 |
82 /* How a statement exits | 88 /* How a statement exits; this is returned by blockExit() |
83 */ | 89 */ |
84 enum BE | 90 enum BE |
85 { | 91 { |
86 BEnone = 0, | 92 BEnone = 0, |
87 BEfallthru = 1, | 93 BEfallthru = 1, |
92 BEbreak = 0x20, | 98 BEbreak = 0x20, |
93 BEcontinue = 0x40, | 99 BEcontinue = 0x40, |
94 BEany = (BEfallthru | BEthrow | BEreturn | BEgoto | BEhalt), | 100 BEany = (BEfallthru | BEthrow | BEreturn | BEgoto | BEhalt), |
95 }; | 101 }; |
96 | 102 |
97 // LDC this is used for tracking try-finally, synchronized and volatile scopes | |
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 | 103 struct Statement : Object |
127 { | 104 { |
128 Loc loc; | 105 Loc loc; |
129 | 106 |
130 Statement(Loc loc); | 107 Statement(Loc loc); |
131 virtual Statement *syntaxCopy(); | 108 virtual Statement *syntaxCopy(); |
132 | 109 |
133 void print(); | 110 void print(); |
134 char *toChars(); | 111 char *toChars(); |
135 | 112 |
136 void error(const char *format, ...); | 113 void error(const char *format, ...) IS_PRINTF(2); |
114 void warning(const char *format, ...) IS_PRINTF(2); | |
137 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 115 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
138 virtual TryCatchStatement *isTryCatchStatement() { return NULL; } | 116 virtual TryCatchStatement *isTryCatchStatement() { return NULL; } |
139 virtual GotoStatement *isGotoStatement() { return NULL; } | 117 virtual GotoStatement *isGotoStatement() { return NULL; } |
140 virtual AsmStatement *isAsmStatement() { return NULL; } | 118 virtual AsmStatement *isAsmStatement() { return NULL; } |
141 virtual AsmBlockStatement *isAsmBlockStatement() { return NULL; } | 119 virtual AsmBlockStatement *isAsmBlockStatement() { return NULL; } |
146 virtual Statement *semantic(Scope *sc); | 124 virtual Statement *semantic(Scope *sc); |
147 Statement *semanticScope(Scope *sc, Statement *sbreak, Statement *scontinue); | 125 Statement *semanticScope(Scope *sc, Statement *sbreak, Statement *scontinue); |
148 virtual int hasBreak(); | 126 virtual int hasBreak(); |
149 virtual int hasContinue(); | 127 virtual int hasContinue(); |
150 virtual int usesEH(); | 128 virtual int usesEH(); |
151 virtual int fallOffEnd(); | |
152 virtual int blockExit(); | 129 virtual int blockExit(); |
153 virtual int comeFrom(); | 130 virtual int comeFrom(); |
154 virtual void scopeCode(Scope *sc, Statement **sentry, Statement **sexit, Statement **sfinally); | 131 virtual void scopeCode(Scope *sc, Statement **sentry, Statement **sexit, Statement **sfinally); |
155 virtual Statements *flatten(Scope *sc); | 132 virtual Statements *flatten(Scope *sc); |
156 virtual Expression *interpret(InterState *istate); | 133 virtual Expression *interpret(InterState *istate); |
181 ExpStatement(Loc loc, Expression *exp); | 158 ExpStatement(Loc loc, Expression *exp); |
182 Statement *syntaxCopy(); | 159 Statement *syntaxCopy(); |
183 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 160 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
184 Statement *semantic(Scope *sc); | 161 Statement *semantic(Scope *sc); |
185 Expression *interpret(InterState *istate); | 162 Expression *interpret(InterState *istate); |
186 int fallOffEnd(); | |
187 int blockExit(); | 163 int blockExit(); |
188 | 164 |
189 int inlineCost(InlineCostState *ics); | 165 int inlineCost(InlineCostState *ics); |
190 Expression *doInline(InlineDoState *ids); | 166 Expression *doInline(InlineDoState *ids); |
191 Statement *inlineScan(InlineScanState *iss); | 167 Statement *inlineScan(InlineScanState *iss); |
192 | 168 |
193 void toIR(IRState *irs); | 169 void toIR(IRState *irs); |
194 | 170 |
195 // LDC | 171 // LDC |
196 virtual void toNakedIR(IRState *irs); | 172 void toNakedIR(IRState *irs); |
197 }; | 173 }; |
198 | 174 |
199 struct CompileStatement : Statement | 175 struct CompileStatement : Statement |
200 { | 176 { |
201 Expression *exp; | 177 Expression *exp; |
230 virtual Statement *syntaxCopy(); | 206 virtual Statement *syntaxCopy(); |
231 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 207 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
232 virtual Statement *semantic(Scope *sc); | 208 virtual Statement *semantic(Scope *sc); |
233 int usesEH(); | 209 int usesEH(); |
234 int blockExit(); | 210 int blockExit(); |
235 int fallOffEnd(); | |
236 int comeFrom(); | 211 int comeFrom(); |
237 virtual Statements *flatten(Scope *sc); | 212 virtual Statements *flatten(Scope *sc); |
238 ReturnStatement *isReturnStatement(); | 213 ReturnStatement *isReturnStatement(); |
239 Expression *interpret(InterState *istate); | 214 Expression *interpret(InterState *istate); |
240 | 215 |
247 // LDC | 222 // LDC |
248 virtual void toNakedIR(IRState *irs); | 223 virtual void toNakedIR(IRState *irs); |
249 virtual AsmBlockStatement* endsWithAsm(); | 224 virtual AsmBlockStatement* endsWithAsm(); |
250 | 225 |
251 virtual CompoundStatement *isCompoundStatement() { return this; } | 226 virtual CompoundStatement *isCompoundStatement() { return this; } |
227 }; | |
228 | |
229 struct CompoundDeclarationStatement : CompoundStatement | |
230 { | |
231 CompoundDeclarationStatement(Loc loc, Statements *s); | |
232 Statement *syntaxCopy(); | |
233 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
252 }; | 234 }; |
253 | 235 |
254 /* The purpose of this is so that continue will go to the next | 236 /* The purpose of this is so that continue will go to the next |
255 * of the statements, and break will go to the end of the statements. | 237 * of the statements, and break will go to the end of the statements. |
256 */ | 238 */ |
257 struct UnrolledLoopStatement : Statement | 239 struct UnrolledLoopStatement : Statement |
258 { | 240 { |
259 Statements *statements; | 241 Statements *statements; |
260 EnclosingHandler* enclosinghandler; | |
261 | 242 |
262 UnrolledLoopStatement(Loc loc, Statements *statements); | 243 UnrolledLoopStatement(Loc loc, Statements *statements); |
263 Statement *syntaxCopy(); | 244 Statement *syntaxCopy(); |
264 Statement *semantic(Scope *sc); | 245 Statement *semantic(Scope *sc); |
265 int hasBreak(); | 246 int hasBreak(); |
266 int hasContinue(); | 247 int hasContinue(); |
267 int usesEH(); | 248 int usesEH(); |
268 int blockExit(); | 249 int blockExit(); |
269 int fallOffEnd(); | |
270 int comeFrom(); | 250 int comeFrom(); |
271 Expression *interpret(InterState *istate); | 251 Expression *interpret(InterState *istate); |
272 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 252 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
273 | 253 |
274 int inlineCost(InlineCostState *ics); | 254 int inlineCost(InlineCostState *ics); |
289 Statement *semantic(Scope *sc); | 269 Statement *semantic(Scope *sc); |
290 int hasBreak(); | 270 int hasBreak(); |
291 int hasContinue(); | 271 int hasContinue(); |
292 int usesEH(); | 272 int usesEH(); |
293 int blockExit(); | 273 int blockExit(); |
294 int fallOffEnd(); | |
295 int comeFrom(); | 274 int comeFrom(); |
296 Expression *interpret(InterState *istate); | 275 Expression *interpret(InterState *istate); |
297 | 276 |
298 Statement *inlineScan(InlineScanState *iss); | 277 Statement *inlineScan(InlineScanState *iss); |
299 | 278 |
302 | 281 |
303 struct WhileStatement : Statement | 282 struct WhileStatement : Statement |
304 { | 283 { |
305 Expression *condition; | 284 Expression *condition; |
306 Statement *body; | 285 Statement *body; |
307 EnclosingHandler* enclosinghandler; | |
308 | 286 |
309 WhileStatement(Loc loc, Expression *c, Statement *b); | 287 WhileStatement(Loc loc, Expression *c, Statement *b); |
310 Statement *syntaxCopy(); | 288 Statement *syntaxCopy(); |
311 Statement *semantic(Scope *sc); | 289 Statement *semantic(Scope *sc); |
312 int hasBreak(); | 290 int hasBreak(); |
313 int hasContinue(); | 291 int hasContinue(); |
314 int usesEH(); | 292 int usesEH(); |
315 int blockExit(); | 293 int blockExit(); |
316 int fallOffEnd(); | |
317 int comeFrom(); | 294 int comeFrom(); |
318 Expression *interpret(InterState *istate); | 295 Expression *interpret(InterState *istate); |
319 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 296 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
320 | 297 |
321 Statement *inlineScan(InlineScanState *iss); | 298 Statement *inlineScan(InlineScanState *iss); |
325 | 302 |
326 struct DoStatement : Statement | 303 struct DoStatement : Statement |
327 { | 304 { |
328 Statement *body; | 305 Statement *body; |
329 Expression *condition; | 306 Expression *condition; |
330 EnclosingHandler* enclosinghandler; | |
331 | 307 |
332 DoStatement(Loc loc, Statement *b, Expression *c); | 308 DoStatement(Loc loc, Statement *b, Expression *c); |
333 Statement *syntaxCopy(); | 309 Statement *syntaxCopy(); |
334 Statement *semantic(Scope *sc); | 310 Statement *semantic(Scope *sc); |
335 int hasBreak(); | 311 int hasBreak(); |
336 int hasContinue(); | 312 int hasContinue(); |
337 int usesEH(); | 313 int usesEH(); |
338 int blockExit(); | 314 int blockExit(); |
339 int fallOffEnd(); | |
340 int comeFrom(); | 315 int comeFrom(); |
341 Expression *interpret(InterState *istate); | 316 Expression *interpret(InterState *istate); |
342 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 317 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
343 | 318 |
344 Statement *inlineScan(InlineScanState *iss); | 319 Statement *inlineScan(InlineScanState *iss); |
350 { | 325 { |
351 Statement *init; | 326 Statement *init; |
352 Expression *condition; | 327 Expression *condition; |
353 Expression *increment; | 328 Expression *increment; |
354 Statement *body; | 329 Statement *body; |
355 EnclosingHandler* enclosinghandler; | |
356 | 330 |
357 ForStatement(Loc loc, Statement *init, Expression *condition, Expression *increment, Statement *body); | 331 ForStatement(Loc loc, Statement *init, Expression *condition, Expression *increment, Statement *body); |
358 Statement *syntaxCopy(); | 332 Statement *syntaxCopy(); |
359 Statement *semantic(Scope *sc); | 333 Statement *semantic(Scope *sc); |
360 void scopeCode(Scope *sc, Statement **sentry, Statement **sexit, Statement **sfinally); | 334 void scopeCode(Scope *sc, Statement **sentry, Statement **sexit, Statement **sfinally); |
361 int hasBreak(); | 335 int hasBreak(); |
362 int hasContinue(); | 336 int hasContinue(); |
363 int usesEH(); | 337 int usesEH(); |
364 int blockExit(); | 338 int blockExit(); |
365 int fallOffEnd(); | |
366 int comeFrom(); | 339 int comeFrom(); |
367 Expression *interpret(InterState *istate); | 340 Expression *interpret(InterState *istate); |
368 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 341 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
369 | 342 |
370 Statement *inlineScan(InlineScanState *iss); | 343 Statement *inlineScan(InlineScanState *iss); |
376 { | 349 { |
377 enum TOK op; // TOKforeach or TOKforeach_reverse | 350 enum TOK op; // TOKforeach or TOKforeach_reverse |
378 Arguments *arguments; // array of Argument*'s | 351 Arguments *arguments; // array of Argument*'s |
379 Expression *aggr; | 352 Expression *aggr; |
380 Statement *body; | 353 Statement *body; |
381 EnclosingHandler* enclosinghandler; | |
382 | 354 |
383 VarDeclaration *key; | 355 VarDeclaration *key; |
384 VarDeclaration *value; | 356 VarDeclaration *value; |
385 | 357 |
386 FuncDeclaration *func; // function we're lexically in | 358 FuncDeclaration *func; // function we're lexically in |
394 bool checkForArgTypes(); | 366 bool checkForArgTypes(); |
395 int hasBreak(); | 367 int hasBreak(); |
396 int hasContinue(); | 368 int hasContinue(); |
397 int usesEH(); | 369 int usesEH(); |
398 int blockExit(); | 370 int blockExit(); |
399 int fallOffEnd(); | |
400 int comeFrom(); | 371 int comeFrom(); |
401 Expression *interpret(InterState *istate); | 372 Expression *interpret(InterState *istate); |
402 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 373 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
403 | 374 |
404 Statement *inlineScan(InlineScanState *iss); | 375 Statement *inlineScan(InlineScanState *iss); |
412 enum TOK op; // TOKforeach or TOKforeach_reverse | 383 enum TOK op; // TOKforeach or TOKforeach_reverse |
413 Argument *arg; // loop index variable | 384 Argument *arg; // loop index variable |
414 Expression *lwr; | 385 Expression *lwr; |
415 Expression *upr; | 386 Expression *upr; |
416 Statement *body; | 387 Statement *body; |
417 EnclosingHandler* enclosinghandler; | |
418 | 388 |
419 VarDeclaration *key; | 389 VarDeclaration *key; |
420 | 390 |
421 ForeachRangeStatement(Loc loc, enum TOK op, Argument *arg, | 391 ForeachRangeStatement(Loc loc, enum TOK op, Argument *arg, |
422 Expression *lwr, Expression *upr, Statement *body); | 392 Expression *lwr, Expression *upr, Statement *body); |
424 Statement *semantic(Scope *sc); | 394 Statement *semantic(Scope *sc); |
425 int hasBreak(); | 395 int hasBreak(); |
426 int hasContinue(); | 396 int hasContinue(); |
427 int usesEH(); | 397 int usesEH(); |
428 int blockExit(); | 398 int blockExit(); |
429 int fallOffEnd(); | |
430 int comeFrom(); | 399 int comeFrom(); |
431 Expression *interpret(InterState *istate); | 400 Expression *interpret(InterState *istate); |
432 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 401 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
433 | 402 |
434 Statement *inlineScan(InlineScanState *iss); | 403 Statement *inlineScan(InlineScanState *iss); |
451 Statement *semantic(Scope *sc); | 420 Statement *semantic(Scope *sc); |
452 Expression *interpret(InterState *istate); | 421 Expression *interpret(InterState *istate); |
453 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 422 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
454 int usesEH(); | 423 int usesEH(); |
455 int blockExit(); | 424 int blockExit(); |
456 int fallOffEnd(); | |
457 IfStatement *isIfStatement() { return this; } | 425 IfStatement *isIfStatement() { return this; } |
458 | 426 |
459 int inlineCost(InlineCostState *ics); | 427 int inlineCost(InlineCostState *ics); |
460 Expression *doInline(InlineDoState *ids); | 428 Expression *doInline(InlineDoState *ids); |
461 Statement *inlineScan(InlineScanState *iss); | 429 Statement *inlineScan(InlineScanState *iss); |
488 PragmaStatement(Loc loc, Identifier *ident, Expressions *args, Statement *body); | 456 PragmaStatement(Loc loc, Identifier *ident, Expressions *args, Statement *body); |
489 Statement *syntaxCopy(); | 457 Statement *syntaxCopy(); |
490 Statement *semantic(Scope *sc); | 458 Statement *semantic(Scope *sc); |
491 int usesEH(); | 459 int usesEH(); |
492 int blockExit(); | 460 int blockExit(); |
493 int fallOffEnd(); | |
494 | 461 |
495 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 462 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
496 | 463 |
497 void toIR(IRState *irs); | 464 void toIR(IRState *irs); |
498 }; | 465 }; |
512 { | 479 { |
513 Expression *condition; | 480 Expression *condition; |
514 Statement *body; | 481 Statement *body; |
515 | 482 |
516 DefaultStatement *sdefault; | 483 DefaultStatement *sdefault; |
517 TryFinallyStatement *tf; | |
518 EnclosingHandler* enclosinghandler; | |
519 | 484 |
520 Array gotoCases; // array of unresolved GotoCaseStatement's | 485 Array gotoCases; // array of unresolved GotoCaseStatement's |
521 Array *cases; // array of CaseStatement's | 486 Array *cases; // array of CaseStatement's |
522 int hasNoDefault; // !=0 if no default statement | 487 int hasNoDefault; // !=0 if no default statement |
523 int hasVars; // !=0 if has variable case values | 488 int hasVars; // !=0 if has variable case values |
524 | 489 |
490 // LDC | |
491 Statement *enclosingScopeExit; | |
492 | |
525 SwitchStatement(Loc loc, Expression *c, Statement *b); | 493 SwitchStatement(Loc loc, Expression *c, Statement *b); |
526 Statement *syntaxCopy(); | 494 Statement *syntaxCopy(); |
527 Statement *semantic(Scope *sc); | 495 Statement *semantic(Scope *sc); |
528 int hasBreak(); | 496 int hasBreak(); |
529 int usesEH(); | 497 int usesEH(); |
530 int blockExit(); | 498 int blockExit(); |
531 int fallOffEnd(); | |
532 Expression *interpret(InterState *istate); | 499 Expression *interpret(InterState *istate); |
533 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 500 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
534 | 501 |
535 Statement *inlineScan(InlineScanState *iss); | 502 Statement *inlineScan(InlineScanState *iss); |
536 | 503 |
542 Expression *exp; | 509 Expression *exp; |
543 Statement *statement; | 510 Statement *statement; |
544 int index; // which case it is (since we sort this) | 511 int index; // which case it is (since we sort this) |
545 block *cblock; // back end: label for the block | 512 block *cblock; // back end: label for the block |
546 | 513 |
514 // LDC | |
515 Statement *enclosingScopeExit; | |
516 | |
547 CaseStatement(Loc loc, Expression *exp, Statement *s); | 517 CaseStatement(Loc loc, Expression *exp, Statement *s); |
548 Statement *syntaxCopy(); | 518 Statement *syntaxCopy(); |
549 Statement *semantic(Scope *sc); | 519 Statement *semantic(Scope *sc); |
550 int compare(Object *obj); | 520 int compare(Object *obj); |
551 int usesEH(); | 521 int usesEH(); |
552 int blockExit(); | 522 int blockExit(); |
553 int fallOffEnd(); | |
554 int comeFrom(); | 523 int comeFrom(); |
555 Expression *interpret(InterState *istate); | 524 Expression *interpret(InterState *istate); |
556 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 525 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
557 | 526 |
558 Statement *inlineScan(InlineScanState *iss); | 527 Statement *inlineScan(InlineScanState *iss); |
571 Statement *statement; | 540 Statement *statement; |
572 #if IN_GCC | 541 #if IN_GCC |
573 block *cblock; // back end: label for the block | 542 block *cblock; // back end: label for the block |
574 #endif | 543 #endif |
575 | 544 |
545 // LDC | |
546 Statement *enclosingScopeExit; | |
547 | |
576 DefaultStatement(Loc loc, Statement *s); | 548 DefaultStatement(Loc loc, Statement *s); |
577 Statement *syntaxCopy(); | 549 Statement *syntaxCopy(); |
578 Statement *semantic(Scope *sc); | 550 Statement *semantic(Scope *sc); |
579 int usesEH(); | 551 int usesEH(); |
580 int blockExit(); | 552 int blockExit(); |
581 int fallOffEnd(); | |
582 int comeFrom(); | 553 int comeFrom(); |
583 Expression *interpret(InterState *istate); | 554 Expression *interpret(InterState *istate); |
584 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 555 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
585 | 556 |
586 Statement *inlineScan(InlineScanState *iss); | 557 Statement *inlineScan(InlineScanState *iss); |
592 }; | 563 }; |
593 | 564 |
594 struct GotoDefaultStatement : Statement | 565 struct GotoDefaultStatement : Statement |
595 { | 566 { |
596 SwitchStatement *sw; | 567 SwitchStatement *sw; |
597 EnclosingHandler* enclosinghandler; | |
598 | 568 |
599 GotoDefaultStatement(Loc loc); | 569 GotoDefaultStatement(Loc loc); |
600 Statement *syntaxCopy(); | 570 Statement *syntaxCopy(); |
601 Statement *semantic(Scope *sc); | 571 Statement *semantic(Scope *sc); |
602 Expression *interpret(InterState *istate); | 572 Expression *interpret(InterState *istate); |
603 int blockExit(); | 573 int blockExit(); |
604 int fallOffEnd(); | |
605 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 574 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
606 | 575 |
607 void toIR(IRState *irs); | 576 void toIR(IRState *irs); |
608 }; | 577 }; |
609 | 578 |
610 struct GotoCaseStatement : Statement | 579 struct GotoCaseStatement : Statement |
611 { | 580 { |
612 Expression *exp; // NULL, or which case to goto | 581 Expression *exp; // NULL, or which case to goto |
613 CaseStatement *cs; // case statement it resolves to | 582 CaseStatement *cs; // case statement it resolves to |
614 EnclosingHandler* enclosinghandler; | |
615 SwitchStatement *sw; | 583 SwitchStatement *sw; |
616 | 584 |
617 GotoCaseStatement(Loc loc, Expression *exp); | 585 GotoCaseStatement(Loc loc, Expression *exp); |
618 Statement *syntaxCopy(); | 586 Statement *syntaxCopy(); |
619 Statement *semantic(Scope *sc); | 587 Statement *semantic(Scope *sc); |
620 Expression *interpret(InterState *istate); | 588 Expression *interpret(InterState *istate); |
621 int blockExit(); | 589 int blockExit(); |
622 int fallOffEnd(); | |
623 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 590 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
624 | 591 |
625 void toIR(IRState *irs); | 592 void toIR(IRState *irs); |
626 }; | 593 }; |
627 | 594 |
628 struct SwitchErrorStatement : Statement | 595 struct SwitchErrorStatement : Statement |
629 { | 596 { |
630 SwitchErrorStatement(Loc loc); | 597 SwitchErrorStatement(Loc loc); |
631 int blockExit(); | 598 int blockExit(); |
632 int fallOffEnd(); | |
633 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 599 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
634 | 600 |
635 void toIR(IRState *irs); | 601 void toIR(IRState *irs); |
636 }; | 602 }; |
637 | 603 |
638 struct ReturnStatement : Statement | 604 struct ReturnStatement : Statement |
639 { | 605 { |
640 Expression *exp; | 606 Expression *exp; |
641 EnclosingHandler* enclosinghandler; | |
642 | 607 |
643 ReturnStatement(Loc loc, Expression *exp); | 608 ReturnStatement(Loc loc, Expression *exp); |
644 Statement *syntaxCopy(); | 609 Statement *syntaxCopy(); |
645 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 610 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
646 Statement *semantic(Scope *sc); | 611 Statement *semantic(Scope *sc); |
647 int blockExit(); | 612 int blockExit(); |
648 int fallOffEnd(); | |
649 Expression *interpret(InterState *istate); | 613 Expression *interpret(InterState *istate); |
650 | 614 |
651 int inlineCost(InlineCostState *ics); | 615 int inlineCost(InlineCostState *ics); |
652 Expression *doInline(InlineDoState *ids); | 616 Expression *doInline(InlineDoState *ids); |
653 Statement *inlineScan(InlineScanState *iss); | 617 Statement *inlineScan(InlineScanState *iss); |
658 }; | 622 }; |
659 | 623 |
660 struct BreakStatement : Statement | 624 struct BreakStatement : Statement |
661 { | 625 { |
662 Identifier *ident; | 626 Identifier *ident; |
663 EnclosingHandler* enclosinghandler; | |
664 | 627 |
665 BreakStatement(Loc loc, Identifier *ident); | 628 BreakStatement(Loc loc, Identifier *ident); |
666 Statement *syntaxCopy(); | 629 Statement *syntaxCopy(); |
667 Statement *semantic(Scope *sc); | 630 Statement *semantic(Scope *sc); |
668 Expression *interpret(InterState *istate); | 631 Expression *interpret(InterState *istate); |
669 int blockExit(); | 632 int blockExit(); |
670 int fallOffEnd(); | |
671 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 633 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
672 | 634 |
673 void toIR(IRState *irs); | 635 void toIR(IRState *irs); |
674 | 636 |
675 // LDC: only set if ident is set: label statement to jump to | 637 // LDC: only set if ident is set: label statement to jump to |
677 }; | 639 }; |
678 | 640 |
679 struct ContinueStatement : Statement | 641 struct ContinueStatement : Statement |
680 { | 642 { |
681 Identifier *ident; | 643 Identifier *ident; |
682 EnclosingHandler* enclosinghandler; | |
683 | 644 |
684 ContinueStatement(Loc loc, Identifier *ident); | 645 ContinueStatement(Loc loc, Identifier *ident); |
685 Statement *syntaxCopy(); | 646 Statement *syntaxCopy(); |
686 Statement *semantic(Scope *sc); | 647 Statement *semantic(Scope *sc); |
687 Expression *interpret(InterState *istate); | 648 Expression *interpret(InterState *istate); |
688 int blockExit(); | 649 int blockExit(); |
689 int fallOffEnd(); | |
690 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 650 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
691 | 651 |
692 void toIR(IRState *irs); | 652 void toIR(IRState *irs); |
693 | 653 |
694 // LDC: only set if ident is set: label statement to jump to | 654 // LDC: only set if ident is set: label statement to jump to |
697 | 657 |
698 struct SynchronizedStatement : Statement | 658 struct SynchronizedStatement : Statement |
699 { | 659 { |
700 Expression *exp; | 660 Expression *exp; |
701 Statement *body; | 661 Statement *body; |
702 EnclosingHandler* enclosinghandler; | |
703 | 662 |
704 SynchronizedStatement(Loc loc, Expression *exp, Statement *body); | 663 SynchronizedStatement(Loc loc, Expression *exp, Statement *body); |
705 Statement *syntaxCopy(); | 664 Statement *syntaxCopy(); |
706 Statement *semantic(Scope *sc); | 665 Statement *semantic(Scope *sc); |
707 int hasBreak(); | 666 int hasBreak(); |
708 int hasContinue(); | 667 int hasContinue(); |
709 int usesEH(); | 668 int usesEH(); |
710 int blockExit(); | 669 int blockExit(); |
711 int fallOffEnd(); | |
712 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 670 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
713 | 671 |
714 Statement *inlineScan(InlineScanState *iss); | 672 Statement *inlineScan(InlineScanState *iss); |
715 | 673 |
716 // Back end | 674 // Back end |
730 Statement *syntaxCopy(); | 688 Statement *syntaxCopy(); |
731 Statement *semantic(Scope *sc); | 689 Statement *semantic(Scope *sc); |
732 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 690 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
733 int usesEH(); | 691 int usesEH(); |
734 int blockExit(); | 692 int blockExit(); |
735 int fallOffEnd(); | |
736 | 693 |
737 Statement *inlineScan(InlineScanState *iss); | 694 Statement *inlineScan(InlineScanState *iss); |
738 | 695 |
739 void toIR(IRState *irs); | 696 void toIR(IRState *irs); |
740 }; | 697 }; |
748 Statement *syntaxCopy(); | 705 Statement *syntaxCopy(); |
749 Statement *semantic(Scope *sc); | 706 Statement *semantic(Scope *sc); |
750 int hasBreak(); | 707 int hasBreak(); |
751 int usesEH(); | 708 int usesEH(); |
752 int blockExit(); | 709 int blockExit(); |
753 int fallOffEnd(); | |
754 | 710 |
755 Statement *inlineScan(InlineScanState *iss); | 711 Statement *inlineScan(InlineScanState *iss); |
756 | 712 |
757 void toIR(IRState *irs); | 713 void toIR(IRState *irs); |
758 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 714 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
776 | 732 |
777 struct TryFinallyStatement : Statement | 733 struct TryFinallyStatement : Statement |
778 { | 734 { |
779 Statement *body; | 735 Statement *body; |
780 Statement *finalbody; | 736 Statement *finalbody; |
781 EnclosingHandler* enclosinghandler; | |
782 | 737 |
783 TryFinallyStatement(Loc loc, Statement *body, Statement *finalbody); | 738 TryFinallyStatement(Loc loc, Statement *body, Statement *finalbody); |
784 Statement *syntaxCopy(); | 739 Statement *syntaxCopy(); |
785 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 740 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
786 Statement *semantic(Scope *sc); | 741 Statement *semantic(Scope *sc); |
787 int hasBreak(); | 742 int hasBreak(); |
788 int hasContinue(); | 743 int hasContinue(); |
789 int usesEH(); | 744 int usesEH(); |
790 int blockExit(); | 745 int blockExit(); |
791 int fallOffEnd(); | |
792 | 746 |
793 Statement *inlineScan(InlineScanState *iss); | 747 Statement *inlineScan(InlineScanState *iss); |
794 | 748 |
795 void toIR(IRState *irs); | 749 void toIR(IRState *irs); |
796 }; | 750 }; |
818 ThrowStatement(Loc loc, Expression *exp); | 772 ThrowStatement(Loc loc, Expression *exp); |
819 Statement *syntaxCopy(); | 773 Statement *syntaxCopy(); |
820 Statement *semantic(Scope *sc); | 774 Statement *semantic(Scope *sc); |
821 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 775 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
822 int blockExit(); | 776 int blockExit(); |
823 int fallOffEnd(); | |
824 | 777 |
825 Statement *inlineScan(InlineScanState *iss); | 778 Statement *inlineScan(InlineScanState *iss); |
826 | 779 |
827 void toIR(IRState *irs); | 780 void toIR(IRState *irs); |
828 }; | 781 }; |
829 | 782 |
830 struct VolatileStatement : Statement | 783 struct VolatileStatement : Statement |
831 { | 784 { |
832 Statement *statement; | 785 Statement *statement; |
833 EnclosingHandler* enclosinghandler; | |
834 | 786 |
835 VolatileStatement(Loc loc, Statement *statement); | 787 VolatileStatement(Loc loc, Statement *statement); |
836 Statement *syntaxCopy(); | 788 Statement *syntaxCopy(); |
837 Statement *semantic(Scope *sc); | 789 Statement *semantic(Scope *sc); |
838 Statements *flatten(Scope *sc); | 790 Statements *flatten(Scope *sc); |
839 int blockExit(); | 791 int blockExit(); |
840 int fallOffEnd(); | |
841 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 792 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
842 | 793 |
843 Statement *inlineScan(InlineScanState *iss); | 794 Statement *inlineScan(InlineScanState *iss); |
844 | 795 |
845 void toIR(IRState *irs); | 796 void toIR(IRState *irs); |
847 | 798 |
848 struct GotoStatement : Statement | 799 struct GotoStatement : Statement |
849 { | 800 { |
850 Identifier *ident; | 801 Identifier *ident; |
851 LabelDsymbol *label; | 802 LabelDsymbol *label; |
852 TryFinallyStatement *tf; | 803 TryFinallyStatement *enclosingFinally; |
853 EnclosingHandler* enclosinghandler; | 804 Statement* enclosingScopeExit; |
854 | 805 |
855 GotoStatement(Loc loc, Identifier *ident); | 806 GotoStatement(Loc loc, Identifier *ident); |
856 Statement *syntaxCopy(); | 807 Statement *syntaxCopy(); |
857 Statement *semantic(Scope *sc); | 808 Statement *semantic(Scope *sc); |
858 int blockExit(); | 809 int blockExit(); |
859 int fallOffEnd(); | |
860 Expression *interpret(InterState *istate); | 810 Expression *interpret(InterState *istate); |
861 | 811 |
862 void toIR(IRState *irs); | 812 void toIR(IRState *irs); |
863 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 813 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
864 GotoStatement *isGotoStatement() { return this; } | 814 GotoStatement *isGotoStatement() { return this; } |
866 | 816 |
867 struct LabelStatement : Statement | 817 struct LabelStatement : Statement |
868 { | 818 { |
869 Identifier *ident; | 819 Identifier *ident; |
870 Statement *statement; | 820 Statement *statement; |
871 TryFinallyStatement *tf; | 821 TryFinallyStatement *enclosingFinally; |
872 EnclosingHandler* enclosinghandler; | 822 Statement* enclosingScopeExit; |
873 block *lblock; // back end | 823 block *lblock; // back end |
874 int isReturnLabel; | 824 int isReturnLabel; |
875 | 825 |
876 LabelStatement(Loc loc, Identifier *ident, Statement *statement); | 826 LabelStatement(Loc loc, Identifier *ident, Statement *statement); |
877 Statement *syntaxCopy(); | 827 Statement *syntaxCopy(); |
878 Statement *semantic(Scope *sc); | 828 Statement *semantic(Scope *sc); |
879 Statements *flatten(Scope *sc); | 829 Statements *flatten(Scope *sc); |
880 int usesEH(); | 830 int usesEH(); |
881 int blockExit(); | 831 int blockExit(); |
882 int fallOffEnd(); | |
883 int comeFrom(); | 832 int comeFrom(); |
884 Expression *interpret(InterState *istate); | 833 Expression *interpret(InterState *istate); |
885 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 834 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
886 | 835 |
887 Statement *inlineScan(InlineScanState *iss); | 836 Statement *inlineScan(InlineScanState *iss); |
888 | 837 |
889 void toIR(IRState *irs); | 838 void toIR(IRState *irs); |
890 | 839 |
891 // LDC | 840 // LDC |
892 bool asmLabel; // for labels inside inline assembler | 841 bool asmLabel; // for labels inside inline assembler |
893 virtual void toNakedIR(IRState *irs); | 842 void toNakedIR(IRState *irs); |
894 }; | 843 }; |
895 | 844 |
896 struct LabelDsymbol : Dsymbol | 845 struct LabelDsymbol : Dsymbol |
897 { | 846 { |
898 LabelStatement *statement; | 847 LabelStatement *statement; |
848 #if IN_GCC | |
849 unsigned asmLabelNum; // GCC-specific | |
850 #endif | |
899 | 851 |
900 LabelDsymbol(Identifier *ident); | 852 LabelDsymbol(Identifier *ident); |
901 LabelDsymbol *isLabel(); | 853 LabelDsymbol *isLabel(); |
902 }; | 854 }; |
903 | 855 |
923 | 875 |
924 // LDC | 876 // LDC |
925 // non-zero if this is a branch, contains the target labels identifier | 877 // non-zero if this is a branch, contains the target labels identifier |
926 Identifier* isBranchToLabel; | 878 Identifier* isBranchToLabel; |
927 | 879 |
928 virtual void toNakedIR(IRState *irs); | 880 void toNakedIR(IRState *irs); |
929 }; | 881 }; |
930 | 882 |
931 struct AsmBlockStatement : CompoundStatement | 883 struct AsmBlockStatement : CompoundStatement |
932 { | 884 { |
933 EnclosingHandler* enclosinghandler; | 885 TryFinallyStatement* enclosingFinally; |
934 TryFinallyStatement* tf; | 886 Statement* enclosingScopeExit; |
935 | 887 |
936 AsmBlockStatement(Loc loc, Statements *s); | 888 AsmBlockStatement(Loc loc, Statements *s); |
937 Statements *flatten(Scope *sc); | 889 Statements *flatten(Scope *sc); |
938 Statement *syntaxCopy(); | 890 Statement *syntaxCopy(); |
939 Statement *semantic(Scope *sc); | 891 Statement *semantic(Scope *sc); |
940 | 892 |
941 CompoundStatement *isCompoundStatement() { return NULL; } | 893 CompoundStatement *isCompoundStatement() { return NULL; } |
942 AsmBlockStatement *isAsmBlockStatement() { return this; } | 894 AsmBlockStatement *isAsmBlockStatement() { return this; } |
943 | 895 |
944 void toIR(IRState *irs); | 896 void toIR(IRState *irs); |
945 virtual void toNakedIR(IRState *irs); | 897 void toNakedIR(IRState *irs); |
946 AsmBlockStatement* endsWithAsm(); | 898 AsmBlockStatement* endsWithAsm(); |
947 | 899 |
948 llvm::Value* abiret; | 900 llvm::Value* abiret; |
949 }; | 901 }; |
950 | 902 |