comparison dmd/DotVarExp.d @ 96:acd69f84627e

further work
author Trass3r
date Tue, 31 Aug 2010 02:12:15 +0200
parents be2ab491772e
children 3482c73a991b
comparison
equal deleted inserted replaced
95:ae5b11064a9a 96:acd69f84627e
124 } 124 }
125 //printf("-DotVarExp.semantic('%s')\n", toChars()); 125 //printf("-DotVarExp.semantic('%s')\n", toChars());
126 return this; 126 return this;
127 } 127 }
128 128
129 override int isLvalue() 129 override bool isLvalue()
130 { 130 {
131 return 1; 131 return true;
132 } 132 }
133 133
134 override Expression toLvalue(Scope sc, Expression e) 134 override Expression toLvalue(Scope sc, Expression e)
135 { 135 {
136 //printf("DotVarExp::toLvalue(%s)\n", toChars()); 136 //printf("DotVarExp::toLvalue(%s)\n", toChars());
195 return this; 195 return this;
196 } 196 }
197 197
198 override Expression optimize(int result) 198 override Expression optimize(int result)
199 { 199 {
200 //printf("DotVarExp.optimize(result = x%x) %s\n", result, toChars()); 200 //writef("DotVarExp.optimize(result = x%x) %s\n", result, toChars());
201 e1 = e1.optimize(result); 201 e1 = e1.optimize(result);
202
203 Expression e = e1;
202 204
203 if (e1.op == TOK.TOKvar) 205 if (e1.op == TOK.TOKvar)
204 { 206 {
205 VarExp ve = cast(VarExp)e1; 207 VarExp ve = cast(VarExp)e1;
206 VarDeclaration v = ve.var.isVarDeclaration(); 208 VarDeclaration v = ve.var.isVarDeclaration();
207 Expression e = expandVar(result, v); 209 e = expandVar(result, v);
208 if (e && e.op == TOK.TOKstructliteral) 210 }
209 { 211 if (e && e.op == TOK.TOKstructliteral)
210 StructLiteralExp sle = cast(StructLiteralExp)e; 212 {
211 VarDeclaration vf = var.isVarDeclaration(); 213 StructLiteralExp sle = cast(StructLiteralExp) e;
212 if (vf)
213 {
214 e = sle.getField(type, vf.offset);
215 if (e && e !is EXP_CANT_INTERPRET)
216 return e;
217 }
218 }
219 }
220 else if (e1.op == TOK.TOKstructliteral)
221 {
222 StructLiteralExp sle = cast(StructLiteralExp)e1;
223 VarDeclaration vf = var.isVarDeclaration(); 214 VarDeclaration vf = var.isVarDeclaration();
224 if (vf) 215 if (vf)
225 { 216 {
226 Expression e = sle.getField(type, vf.offset); 217 e = sle.getField(type, vf.offset);
227 if (e && e !is EXP_CANT_INTERPRET) 218 if (e && e !is EXP_CANT_INTERPRET)
228 return e; 219 return e;
229 } 220 }
230 } 221 }
231 222