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