Mercurial > projects > ddmd
annotate dmd/WhileStatement.d @ 187:b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
author | Abscissa |
---|---|
date | Tue, 07 Jun 2011 23:37:34 -0400 |
parents | e3afd1303184 |
children |
rev | line source |
---|---|
0 | 1 module dmd.WhileStatement; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.Statement; |
5 import dmd.Expression; | |
6 import dmd.Scope; | |
7 import dmd.InterState; | |
8 import dmd.HdrGenState; | |
9 import dmd.OutBuffer; | |
10 import dmd.InlineScanState; | |
11 import dmd.IRState; | |
12 import dmd.Loc; | |
13 import dmd.BE; | |
14 import dmd.ForStatement; | |
15 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
16 import dmd.DDMDExtensions; |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
17 |
0 | 18 class WhileStatement : Statement |
19 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
20 mixin insertMemberExtension!(typeof(this)); |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
21 |
0 | 22 Expression condition; |
23 Statement body_; | |
24 | |
25 this(Loc loc, Expression c, Statement b) | |
26 { | |
178 | 27 register(); |
0 | 28 super(loc); |
29 condition = c; | |
30 body_ = b; | |
31 } | |
32 | |
72 | 33 override Statement syntaxCopy() |
0 | 34 { |
62 | 35 WhileStatement s = new WhileStatement(loc, condition.syntaxCopy(), body_ ? body_.syntaxCopy() : null); |
36 return s; | |
0 | 37 } |
38 | |
72 | 39 override Statement semantic(Scope sc) |
0 | 40 { |
41 /* Rewrite as a for(;condition;) loop | |
42 */ | |
43 | |
44 Statement s = new ForStatement(loc, null, condition, null, body_); | |
45 s = s.semantic(sc); | |
46 return s; | |
47 } | |
48 | |
72 | 49 override bool hasBreak() |
0 | 50 { |
56 | 51 return true; |
0 | 52 } |
53 | |
72 | 54 override bool hasContinue() |
0 | 55 { |
123 | 56 return true; |
0 | 57 } |
58 | |
72 | 59 override bool usesEH() |
0 | 60 { |
61 assert(false); | |
62 } | |
63 | |
72 | 64 override BE blockExit() |
0 | 65 { |
66 assert(false); | |
67 } | |
68 | |
72 | 69 override bool comeFrom() |
0 | 70 { |
71 assert(false); | |
72 } | |
73 | |
72 | 74 override Expression interpret(InterState istate) |
0 | 75 { |
135 | 76 version(LOG) { |
77 printf("WhileStatement::interpret()\n"); | |
78 } | |
79 assert(false); // rewritten to ForStatement | |
80 return null; | |
0 | 81 } |
82 | |
72 | 83 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 84 { |
85 assert(false); | |
86 } | |
87 | |
72 | 88 override Statement inlineScan(InlineScanState* iss) |
0 | 89 { |
90 assert(false); | |
91 } | |
92 | |
72 | 93 override void toIR(IRState* irs) |
0 | 94 { |
95 assert(false); | |
96 } | |
72 | 97 } |