Mercurial > projects > ldc
comparison dmd2/interpret.c @ 921:75c53f8f67a4
Apply StaticStructInit changes from [913] to dmd2/
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Tue, 03 Feb 2009 18:00:17 +0100 |
parents | f04dde6e882c |
children | 638d16625da2 |
comparison
equal
deleted
inserted
replaced
920:545f54041d91 | 921:75c53f8f67a4 |
---|---|
985 | 985 |
986 Expression *getVarExp(Loc loc, InterState *istate, Declaration *d) | 986 Expression *getVarExp(Loc loc, InterState *istate, Declaration *d) |
987 { | 987 { |
988 Expression *e = EXP_CANT_INTERPRET; | 988 Expression *e = EXP_CANT_INTERPRET; |
989 VarDeclaration *v = d->isVarDeclaration(); | 989 VarDeclaration *v = d->isVarDeclaration(); |
990 SymbolDeclaration *s = d->isSymbolDeclaration(); | 990 StaticStructInitDeclaration *s = d->isStaticStructInitDeclaration(); |
991 if (v) | 991 if (v) |
992 { | 992 { |
993 #if DMDV2 | 993 #if DMDV2 |
994 if ((v->isConst() || v->isInvariant()) && v->init && !v->value) | 994 if ((v->isConst() || v->isInvariant()) && v->init && !v->value) |
995 #else | 995 #else |
1009 if (!e) | 1009 if (!e) |
1010 e = EXP_CANT_INTERPRET; | 1010 e = EXP_CANT_INTERPRET; |
1011 } | 1011 } |
1012 else if (s) | 1012 else if (s) |
1013 { | 1013 { |
1014 if (s->dsym->toInitializer() == s->sym) | 1014 Expressions *exps = new Expressions(); |
1015 { Expressions *exps = new Expressions(); | 1015 e = new StructLiteralExp(0, s->dsym, exps); |
1016 e = new StructLiteralExp(0, s->dsym, exps); | 1016 e = e->semantic(NULL); |
1017 e = e->semantic(NULL); | |
1018 } | |
1019 } | 1017 } |
1020 return e; | 1018 return e; |
1021 } | 1019 } |
1022 | 1020 |
1023 Expression *VarExp::interpret(InterState *istate) | 1021 Expression *VarExp::interpret(InterState *istate) |
1464 /* Chase down rebinding of out and ref | 1462 /* Chase down rebinding of out and ref |
1465 */ | 1463 */ |
1466 if (v->value && v->value->op == TOKvar) | 1464 if (v->value && v->value->op == TOKvar) |
1467 { | 1465 { |
1468 VarExp *ve2 = (VarExp *)v->value; | 1466 VarExp *ve2 = (VarExp *)v->value; |
1469 if (ve2->var->isSymbolDeclaration()) | 1467 if (ve2->var->isStaticStructInitDeclaration()) |
1470 { | 1468 { |
1471 /* This can happen if v is a struct initialized to | 1469 /* This can happen if v is a struct initialized to |
1472 * 0 using an __initZ SymbolDeclaration from | 1470 * 0 using an StaticStructInitDeclaration from |
1473 * TypeStruct::defaultInit() | 1471 * TypeStruct::defaultInit() |
1474 */ | 1472 */ |
1475 } | 1473 } |
1476 else | 1474 else |
1477 v = ve2->var->isVarDeclaration(); | 1475 v = ve2->var->isVarDeclaration(); |