Mercurial > projects > ddmd
annotate dmd/ScopeStatement.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.ScopeStatement; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.Statement; |
5 import dmd.Loc; | |
6 import dmd.Scope; | |
7 import dmd.OutBuffer; | |
8 import dmd.HdrGenState; | |
9 import dmd.Expression; | |
10 import dmd.InterState; | |
11 import dmd.InlineScanState; | |
12 import dmd.ScopeDsymbol; | |
13 import dmd.ArrayTypes; | |
14 import dmd.CompoundStatement; | |
15 import dmd.IRState; | |
16 import dmd.BE; | |
17 | |
18 import dmd.backend.Blockx; | |
19 import dmd.backend.BC; | |
20 import dmd.backend.Util; | |
21 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
22 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
|
23 |
0 | 24 class ScopeStatement : Statement |
25 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
26 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
|
27 |
0 | 28 Statement statement; |
29 | |
30 this(Loc loc, Statement s) | |
31 { | |
178 | 32 register(); |
0 | 33 super(loc); |
34 this.statement = s; | |
35 } | |
36 | |
72 | 37 override Statement syntaxCopy() |
0 | 38 { |
39 Statement s = statement ? statement.syntaxCopy() : null; | |
40 s = new ScopeStatement(loc, s); | |
41 return s; | |
42 } | |
43 | |
72 | 44 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 45 { |
46 buf.writeByte('{'); | |
47 buf.writenl(); | |
48 | |
49 if (statement) | |
50 statement.toCBuffer(buf, hgs); | |
51 | |
52 buf.writeByte('}'); | |
53 buf.writenl(); | |
54 } | |
55 | |
72 | 56 override ScopeStatement isScopeStatement() { return this; } |
0 | 57 |
72 | 58 override Statement semantic(Scope sc) |
0 | 59 { |
60 ScopeDsymbol sym; | |
61 | |
62 //printf("ScopeStatement.semantic(sc = %p)\n", sc); | |
63 if (statement) | |
64 { | |
65 Statements a; | |
66 | |
67 sym = new ScopeDsymbol(); | |
68 sym.parent = sc.scopesym; | |
69 sc = sc.push(sym); | |
70 | |
71 a = statement.flatten(sc); | |
72 if (a) | |
73 { | |
74 statement = new CompoundStatement(loc, a); | |
75 } | |
76 | |
77 statement = statement.semantic(sc); | |
78 if (statement) | |
79 { | |
80 Statement sentry; | |
81 Statement sexception; | |
82 Statement sfinally; | |
83 | |
84 statement.scopeCode(sc, &sentry, &sexception, &sfinally); | |
85 if (sfinally) | |
86 { | |
87 //printf("adding sfinally\n"); | |
88 statement = new CompoundStatement(loc, statement, sfinally); | |
89 } | |
90 } | |
91 | |
92 sc.pop(); | |
93 } | |
94 return this; | |
95 } | |
96 | |
72 | 97 override bool hasBreak() |
0 | 98 { |
99 //printf("ScopeStatement.hasBreak() %s\n", toChars()); | |
100 return statement ? statement.hasBreak() : false; | |
101 } | |
102 | |
72 | 103 override bool hasContinue() |
0 | 104 { |
105 return statement ? statement.hasContinue() : false; | |
106 } | |
107 | |
72 | 108 override bool usesEH() |
0 | 109 { |
110 return statement ? statement.usesEH() : false; | |
111 } | |
112 | |
72 | 113 override BE blockExit() |
0 | 114 { |
115 //printf("ScopeStatement::blockExit(%p)\n", statement); | |
116 return statement ? statement.blockExit() : BE.BEfallthru; | |
117 } | |
118 | |
72 | 119 override bool comeFrom() |
0 | 120 { |
121 //printf("ScopeStatement.comeFrom()\n"); | |
122 return statement ? statement.comeFrom() : false; | |
123 } | |
124 | |
72 | 125 override bool isEmpty() |
0 | 126 { |
127 //printf("ScopeStatement::isEmpty() %d\n", statement ? statement->isEmpty() : TRUE); | |
128 return statement ? statement.isEmpty() : true; | |
129 } | |
130 | |
72 | 131 override Expression interpret(InterState istate) |
0 | 132 { |
154
14feb7ae01a6
* changed the build system to build a release version if the debug one compiles
trass3r
parents:
114
diff
changeset
|
133 version(LOG) |
14feb7ae01a6
* changed the build system to build a release version if the debug one compiles
trass3r
parents:
114
diff
changeset
|
134 writef("ScopeStatement::interpret()\n"); |
14feb7ae01a6
* changed the build system to build a release version if the debug one compiles
trass3r
parents:
114
diff
changeset
|
135 |
14feb7ae01a6
* changed the build system to build a release version if the debug one compiles
trass3r
parents:
114
diff
changeset
|
136 if (istate.start is this) |
14feb7ae01a6
* changed the build system to build a release version if the debug one compiles
trass3r
parents:
114
diff
changeset
|
137 istate.start = null; |
14feb7ae01a6
* changed the build system to build a release version if the debug one compiles
trass3r
parents:
114
diff
changeset
|
138 return statement ? statement.interpret(istate) : null; |
0 | 139 } |
140 | |
72 | 141 override Statement inlineScan(InlineScanState* iss) |
0 | 142 { |
143 if (statement) | |
144 statement = statement.inlineScan(iss); | |
145 return this; | |
146 } | |
147 | |
72 | 148 override void toIR(IRState* irs) |
0 | 149 { |
150 if (statement) | |
151 { | |
152 Blockx* blx = irs.blx; | |
153 IRState mystate = IRState(irs,this); | |
154 | |
155 if (mystate.prev.ident) | |
156 mystate.ident = mystate.prev.ident; | |
157 | |
158 statement.toIR(&mystate); | |
159 | |
160 if (mystate.breakBlock) | |
161 block_goto(blx, BC.BCgoto, mystate.breakBlock); | |
162 } | |
163 } | |
72 | 164 } |