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