comparison dmd/interpret.c @ 1590:8aa756a00228

Replace DMD's isSymbolDeclaration with isStaticStructInitDeclaration. See also [913] and bug #198.
author Christian Kamm <kamm incasoftware de>
date Sat, 07 Nov 2009 11:14:37 +0100
parents def7a1d494fd
children 207a8a438dea
comparison
equal deleted inserted replaced
1589:27948fd2e7ef 1590:8aa756a00228
194 { cantInterpret = 1; 194 { cantInterpret = 1;
195 return NULL; 195 return NULL;
196 } 196 }
197 if (!v2->value || v2->value->op != TOKvar) 197 if (!v2->value || v2->value->op != TOKvar)
198 break; 198 break;
199 //TODO 199 if (((VarExp *)v2->value)->var->isStaticStructInitDeclaration())
200 #ifdef IN_DMD
201 if (((VarExp *)v2->value)->var->isSymbolDeclaration())
202 { // This can happen if v is a struct initialized to 200 { // This can happen if v is a struct initialized to
203 // 0 using an __initZ SymbolDeclaration from 201 // 0 using an __initZ SymbolDeclaration from
204 // TypeStruct::defaultInit() 202 // TypeStruct::defaultInit()
205 break; // eg default-initialized variable 203 break; // eg default-initialized variable
206 } 204 }
207 #endif
208 earg = v2->value; 205 earg = v2->value;
209 } 206 }
210 207
211 v->value = new VarExp(earg->loc, v2); 208 v->value = new VarExp(earg->loc, v2);
212 209
1606 VarExp *ve = (VarExp *)e1; 1603 VarExp *ve = (VarExp *)e1;
1607 VarDeclaration *v = ve->var->isVarDeclaration(); 1604 VarDeclaration *v = ve->var->isVarDeclaration();
1608 if (v && v->value && v->value->op == TOKvar) 1605 if (v && v->value && v->value->op == TOKvar)
1609 { 1606 {
1610 VarExp *ve2 = (VarExp *)v->value; 1607 VarExp *ve2 = (VarExp *)v->value;
1611 //TODO 1608 if (ve2->var->isStaticStructInitDeclaration())
1612 #ifdef IN_DMD
1613 if (ve2->var->isSymbolDeclaration())
1614 { // This can happen if v is a struct initialized to 1609 { // This can happen if v is a struct initialized to
1615 // 0 using an __initZ SymbolDeclaration from 1610 // 0 using an __initZ SymbolDeclaration from
1616 // TypeStruct::defaultInit() 1611 // TypeStruct::defaultInit()
1617 } 1612 }
1618 else 1613 else
1619 #endif
1620 e1 = v->value; 1614 e1 = v->value;
1621 } 1615 }
1622 else if (v && v->value && (v->value->op==TOKindex || v->value->op == TOKdotvar)) 1616 else if (v && v->value && (v->value->op==TOKindex || v->value->op == TOKdotvar))
1623 { 1617 {
1624 // It is no longer be a TOKvar, eg when a[4] is passed by ref. 1618 // It is no longer be a TOKvar, eg when a[4] is passed by ref.
1692 } else { 1686 } else {
1693 // Chase down rebinding of out and ref 1687 // Chase down rebinding of out and ref
1694 if (v->value && v->value->op == TOKvar) 1688 if (v->value && v->value->op == TOKvar)
1695 { 1689 {
1696 VarExp *ve2 = (VarExp *)v->value; 1690 VarExp *ve2 = (VarExp *)v->value;
1697 //TODO 1691 if (ve2->var->isStaticStructInitDeclaration())
1698 #ifdef IN_DMD
1699 if (ve2->var->isSymbolDeclaration())
1700 { // This can happen if v is a struct initialized to 1692 { // This can happen if v is a struct initialized to
1701 // 0 using an __initZ SymbolDeclaration from 1693 // 0 using an __initZ SymbolDeclaration from
1702 // TypeStruct::defaultInit() 1694 // TypeStruct::defaultInit()
1703 } 1695 }
1704 else 1696 else
1705 #endif
1706 v = ve2->var->isVarDeclaration(); 1697 v = ve2->var->isVarDeclaration();
1707 assert(v); 1698 assert(v);
1708 } 1699 }
1709 } 1700 }
1710 if (fp && !v->value) 1701 if (fp && !v->value)
1812 return EXP_CANT_INTERPRET; 1803 return EXP_CANT_INTERPRET;
1813 } 1804 }
1814 if (v->value && v->value->op == TOKvar) 1805 if (v->value && v->value->op == TOKvar)
1815 { 1806 {
1816 VarExp *ve2 = (VarExp *)v->value; 1807 VarExp *ve2 = (VarExp *)v->value;
1817 // TODO 1808 if (ve2->var->isStaticStructInitDeclaration())
1818 #ifdef IN_DMD
1819 if (ve2->var->isSymbolDeclaration())
1820 { // This can happen if v is a struct initialized to 1809 { // This can happen if v is a struct initialized to
1821 // 0 using an __initZ SymbolDeclaration from 1810 // 0 using an __initZ SymbolDeclaration from
1822 // TypeStruct::defaultInit() 1811 // TypeStruct::defaultInit()
1823 } 1812 }
1824 else 1813 else
1825 #endif
1826 v = ve2->var->isVarDeclaration(); 1814 v = ve2->var->isVarDeclaration();
1827 assert(v); 1815 assert(v);
1828 } 1816 }
1829 if (!v->value) 1817 if (!v->value)
1830 { 1818 {
2071 } 2059 }
2072 // Chase down rebinding of out and ref 2060 // Chase down rebinding of out and ref
2073 if (v->value && v->value->op == TOKvar) 2061 if (v->value && v->value->op == TOKvar)
2074 { 2062 {
2075 VarExp *ve2 = (VarExp *)v->value; 2063 VarExp *ve2 = (VarExp *)v->value;
2076 // TODO 2064 if (ve2->var->isStaticStructInitDeclaration())
2077 #ifdef IN_DMD
2078 if (ve2->var->isSymbolDeclaration())
2079 { // This can happen if v is a struct initialized to 2065 { // This can happen if v is a struct initialized to
2080 // 0 using an __initZ SymbolDeclaration from 2066 // 0 using an __initZ SymbolDeclaration from
2081 // TypeStruct::defaultInit() 2067 // TypeStruct::defaultInit()
2082 } 2068 }
2083 else 2069 else
2084 #endif
2085 v = ve2->var->isVarDeclaration(); 2070 v = ve2->var->isVarDeclaration();
2086 assert(v); 2071 assert(v);
2087 } 2072 }
2088 /* Set the $ variable 2073 /* Set the $ variable
2089 */ 2074 */