Mercurial > projects > ddmd
annotate dmd/ConditionalStatement.d @ 192:eb38fdcb3e62 default tip
updated to compile with dmd2.062
author | korDen |
---|---|
date | Sat, 02 Mar 2013 01:25:52 -0800 |
parents | b0d41ff5e0df |
children |
rev | line source |
---|---|
0 | 1 module dmd.ConditionalStatement; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.Statement; |
5 import dmd.Condition; | |
6 import dmd.Loc; | |
7 import dmd.OutBuffer; | |
8 import dmd.Scope; | |
9 import dmd.HdrGenState; | |
10 import dmd.ArrayTypes; | |
11 import dmd.BE; | |
12 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
13 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
|
14 |
0 | 15 class ConditionalStatement : Statement |
16 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
17 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
|
18 |
0 | 19 Condition condition; |
20 Statement ifbody; | |
21 Statement elsebody; | |
22 | |
23 this(Loc loc, Condition condition, Statement ifbody, Statement elsebody) | |
24 { | |
178 | 25 register(); |
0 | 26 super(loc); |
27 this.condition = condition; | |
28 this.ifbody = ifbody; | |
29 this.elsebody = elsebody; | |
30 } | |
31 | |
72 | 32 override Statement syntaxCopy() |
0 | 33 { |
49 | 34 Statement e = null; |
35 if (elsebody) | |
36 e = elsebody.syntaxCopy(); | |
37 ConditionalStatement s = new ConditionalStatement(loc, condition.syntaxCopy(), ifbody.syntaxCopy(), e); | |
38 return s; | |
0 | 39 } |
40 | |
72 | 41 override Statement semantic(Scope sc) |
0 | 42 { |
64 | 43 //printf("ConditionalStatement.semantic()\n"); |
44 | |
45 // If we can short-circuit evaluate the if statement, don't do the | |
46 // semantic analysis of the skipped code. | |
47 // This feature allows a limited form of conditional compilation. | |
48 if (condition.include(sc, null)) | |
49 { | |
50 ifbody = ifbody.semantic(sc); | |
51 return ifbody; | |
52 } | |
53 else | |
54 { | |
55 if (elsebody) | |
56 elsebody = elsebody.semantic(sc); | |
57 return elsebody; | |
58 } | |
0 | 59 } |
60 | |
72 | 61 override Statements flatten(Scope sc) |
0 | 62 { |
63 Statement s; | |
64 | |
65 if (condition.include(sc, null)) | |
66 s = ifbody; | |
67 else | |
68 s = elsebody; | |
69 | |
122
c77e9f4f1793
Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
70 auto a = new Statements(); |
c77e9f4f1793
Statements -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
71 a.push(s); |
0 | 72 |
73 return a; | |
74 } | |
75 | |
72 | 76 override bool usesEH() |
0 | 77 { |
78 assert(false); | |
79 } | |
80 | |
72 | 81 override BE blockExit() |
0 | 82 { |
83 assert(false); | |
84 } | |
85 | |
72 | 86 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 87 { |
88 assert(false); | |
89 } | |
72 | 90 } |