changeset 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 545f54041d91
children 0749c0757a43
files dmd2/declaration.c dmd2/declaration.h dmd2/dsymbol.h dmd2/interpret.c dmd2/mtype.c
diffstat 5 files changed, 24 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/dmd2/declaration.c	Tue Feb 03 08:54:57 2009 +0100
+++ b/dmd2/declaration.c	Tue Feb 03 18:00:17 2009 +0100
@@ -1647,4 +1647,13 @@
     return NULL;
 }
 
-
+ 
+/********************** StaticStructInitDeclaration ***************************/ 
+ 
+StaticStructInitDeclaration::StaticStructInitDeclaration(Loc loc, StructDeclaration *dsym) 
+    : Declaration(new Identifier("", TOKidentifier)) 
+{ 
+    this->loc = loc; 
+    this->dsym = dsym; 
+    storage_class |= STCconst; 
+} 
--- a/dmd2/declaration.h	Tue Feb 03 08:54:57 2009 +0100
+++ b/dmd2/declaration.h	Tue Feb 03 18:00:17 2009 +0100
@@ -284,19 +284,18 @@
 
 /**************************************************************/
 
-// This is a shell around a back end symbol
+// LDC uses this to denote static struct initializers
 
-struct SymbolDeclaration : Declaration
+struct StaticStructInitDeclaration : Declaration
 {
-    Symbol *sym;
     StructDeclaration *dsym;
 
-    SymbolDeclaration(Loc loc, Symbol *s, StructDeclaration *dsym);
+    StaticStructInitDeclaration(Loc loc, StructDeclaration *dsym);
 
     Symbol *toSymbol();
 
     // Eliminate need for dynamic_cast
-    SymbolDeclaration *isSymbolDeclaration() { return (SymbolDeclaration *)this; }
+    StaticStructInitDeclaration *isStaticStructInitDeclaration() { return (StaticStructInitDeclaration *)this; }
 };
 
 struct ClassInfoDeclaration : VarDeclaration
--- a/dmd2/dsymbol.h	Tue Feb 03 08:54:57 2009 +0100
+++ b/dmd2/dsymbol.h	Tue Feb 03 18:00:17 2009 +0100
@@ -65,7 +65,7 @@
 struct ScopeDsymbol;
 struct WithScopeSymbol;
 struct ArrayScopeSymbol;
-struct SymbolDeclaration;
+struct StaticStructInitDeclaration;
 struct Expression;
 struct DeleteDeclaration;
 struct HdrGenState;
@@ -219,7 +219,7 @@
 #ifdef _DH
     virtual DeleteDeclaration *isDeleteDeclaration() { return NULL; }
 #endif
-    virtual SymbolDeclaration *isSymbolDeclaration() { return NULL; }
+    virtual StaticStructInitDeclaration *isStaticStructInitDeclaration() { return NULL; }
     virtual AttribDeclaration *isAttribDeclaration() { return NULL; }
     virtual OverloadSet *isOverloadSet() { return NULL; }
     virtual TypeInfoDeclaration* isTypeInfoDeclaration() { return NULL; }
--- a/dmd2/interpret.c	Tue Feb 03 08:54:57 2009 +0100
+++ b/dmd2/interpret.c	Tue Feb 03 18:00:17 2009 +0100
@@ -987,7 +987,7 @@
 {
     Expression *e = EXP_CANT_INTERPRET;
     VarDeclaration *v = d->isVarDeclaration();
-    SymbolDeclaration *s = d->isSymbolDeclaration();
+    StaticStructInitDeclaration *s = d->isStaticStructInitDeclaration();
     if (v)
     {
 #if DMDV2
@@ -1011,11 +1011,9 @@
     }
     else if (s)
     {
-	if (s->dsym->toInitializer() == s->sym)
-	{   Expressions *exps = new Expressions();
-	    e = new StructLiteralExp(0, s->dsym, exps);
-	    e = e->semantic(NULL);
-	}
+	Expressions *exps = new Expressions();
+	e = new StructLiteralExp(0, s->dsym, exps);
+	e = e->semantic(NULL);
     }
     return e;
 }
@@ -1466,10 +1464,10 @@
 	    if (v->value && v->value->op == TOKvar)
 	    {
 		VarExp *ve2 = (VarExp *)v->value;
-		if (ve2->var->isSymbolDeclaration())
+		if (ve2->var->isStaticStructInitDeclaration())
 		{
 		    /* This can happen if v is a struct initialized to
-		     * 0 using an __initZ SymbolDeclaration from
+		     * 0 using an StaticStructInitDeclaration from
 		     * TypeStruct::defaultInit()
 		     */
 		}
--- a/dmd2/mtype.c	Tue Feb 03 08:54:57 2009 +0100
+++ b/dmd2/mtype.c	Tue Feb 03 18:00:17 2009 +0100
@@ -5249,14 +5249,12 @@
 }
 
 Expression *TypeStruct::defaultInit(Loc loc)
-{   Symbol *s;
-    Declaration *d;
+{   Declaration *d;
 
 #if LOGDEFAULTINIT
     printf("TypeStruct::defaultInit() '%s'\n", toChars());
 #endif
-    s = sym->toInitializer();
-    d = new SymbolDeclaration(sym->loc, s, sym);
+    d = new StaticStructInitDeclaration(sym->loc, sym);
     assert(d);
     d->type = this;
     return new VarExp(sym->loc, d);