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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.ConditionalStatement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 72
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Statement;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Condition;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.ArrayTypes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.BE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
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
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 class ConditionalStatement : Statement
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
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
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 Condition condition;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 Statement ifbody;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 Statement elsebody;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 this(Loc loc, Condition condition, Statement ifbody, Statement elsebody)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 122
diff changeset
25 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 super(loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 this.condition = condition;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 this.ifbody = ifbody;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 this.elsebody = elsebody;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
32 override Statement syntaxCopy()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 {
49
0aa7d1437ada AttribDeclaration.oneMember
korDen
parents: 0
diff changeset
34 Statement e = null;
0aa7d1437ada AttribDeclaration.oneMember
korDen
parents: 0
diff changeset
35 if (elsebody)
0aa7d1437ada AttribDeclaration.oneMember
korDen
parents: 0
diff changeset
36 e = elsebody.syntaxCopy();
0aa7d1437ada AttribDeclaration.oneMember
korDen
parents: 0
diff changeset
37 ConditionalStatement s = new ConditionalStatement(loc, condition.syntaxCopy(), ifbody.syntaxCopy(), e);
0aa7d1437ada AttribDeclaration.oneMember
korDen
parents: 0
diff changeset
38 return s;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
41 override Statement semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 {
64
4290d870944a More fixes
korDen
parents: 49
diff changeset
43 //printf("ConditionalStatement.semantic()\n");
4290d870944a More fixes
korDen
parents: 49
diff changeset
44
4290d870944a More fixes
korDen
parents: 49
diff changeset
45 // If we can short-circuit evaluate the if statement, don't do the
4290d870944a More fixes
korDen
parents: 49
diff changeset
46 // semantic analysis of the skipped code.
4290d870944a More fixes
korDen
parents: 49
diff changeset
47 // This feature allows a limited form of conditional compilation.
4290d870944a More fixes
korDen
parents: 49
diff changeset
48 if (condition.include(sc, null))
4290d870944a More fixes
korDen
parents: 49
diff changeset
49 {
4290d870944a More fixes
korDen
parents: 49
diff changeset
50 ifbody = ifbody.semantic(sc);
4290d870944a More fixes
korDen
parents: 49
diff changeset
51 return ifbody;
4290d870944a More fixes
korDen
parents: 49
diff changeset
52 }
4290d870944a More fixes
korDen
parents: 49
diff changeset
53 else
4290d870944a More fixes
korDen
parents: 49
diff changeset
54 {
4290d870944a More fixes
korDen
parents: 49
diff changeset
55 if (elsebody)
4290d870944a More fixes
korDen
parents: 49
diff changeset
56 elsebody = elsebody.semantic(sc);
4290d870944a More fixes
korDen
parents: 49
diff changeset
57 return elsebody;
4290d870944a More fixes
korDen
parents: 49
diff changeset
58 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
61 override Statements flatten(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 Statement s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 if (condition.include(sc, null))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 s = ifbody;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 s = elsebody;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
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
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 return a;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
76 override bool usesEH()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
81 override BE blockExit()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
86 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
90 }