From e7323517b096546b88f629f400860190767a77ce Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Wed, 6 Jan 2010 15:18:23 -0300 Subject: [PATCH] Merge DMD r320: refactor --- dmd/expression.c | 7 +++---- dmd/expression.h | 2 +- dmd/mtype.c | 34 ++++++++-------------------------- 3 files changed, 12 insertions(+), 31 deletions(-) --- dmd/expression.c | 7 +++---- dmd/expression.h | 2 +- dmd/mtype.c | 34 ++++++++-------------------------- 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/dmd/expression.c b/dmd/expression.c index a8fa267a..6648632e 100644 --- a/dmd/expression.c +++ b/dmd/expression.c @@ -868,9 +868,7 @@ void functionParameters(Loc loc, Scope *sc, TypeFunction *tf, Expressions *argum { TypeSArray *ts = (TypeSArray *)tb; Type *ta = ts->next->arrayOf(); if (ts->size(arg->loc) == 0) - { arg = new NullExp(arg->loc); - arg->type = ta; - } + arg = new NullExp(arg->loc, ta); else arg = arg->castTo(sc, ta); } @@ -2587,10 +2585,11 @@ void SuperExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) /******************************** NullExp **************************/ -NullExp::NullExp(Loc loc) +NullExp::NullExp(Loc loc, Type *type) : Expression(loc, TOKnull, sizeof(NullExp)) { committed = 0; + this->type = type; } Expression *NullExp::semantic(Scope *sc) diff --git a/dmd/expression.h b/dmd/expression.h index da0a77db..6539ff0b 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -349,7 +349,7 @@ struct NullExp : Expression { unsigned char committed; // !=0 if type is committed - NullExp(Loc loc); + NullExp(Loc loc, Type *t = NULL); Expression *semantic(Scope *sc); int isBool(int result); int isConst(); diff --git a/dmd/mtype.c b/dmd/mtype.c index 4de5e254..de42e833 100644 --- a/dmd/mtype.c +++ b/dmd/mtype.c @@ -2239,10 +2239,7 @@ Expression *TypeDArray::defaultInit(Loc loc) #if LOGDEFAULTINIT printf("TypeDArray::defaultInit() '%s'\n", toChars()); #endif - Expression *e; - e = new NullExp(loc); - e->type = this; - return e; + return new NullExp(loc, this); } int TypeDArray::isZeroInit(Loc loc) @@ -2512,10 +2509,7 @@ Expression *TypeAArray::defaultInit(Loc loc) #if LOGDEFAULTINIT printf("TypeAArray::defaultInit() '%s'\n", toChars()); #endif - Expression *e; - e = new NullExp(loc); - e->type = this; - return e; + return new NullExp(loc, this); } int TypeAArray::isZeroInit(Loc loc) @@ -2628,10 +2622,7 @@ Expression *TypePointer::defaultInit(Loc loc) #if LOGDEFAULTINIT printf("TypePointer::defaultInit() '%s'\n", toChars()); #endif - Expression *e; - e = new NullExp(loc); - e->type = this; - return e; + return new NullExp(loc, this); } int TypePointer::isZeroInit(Loc loc) @@ -2695,9 +2686,7 @@ Expression *TypeReference::defaultInit(Loc loc) #if LOGDEFAULTINIT printf("TypeReference::defaultInit() '%s'\n", toChars()); #endif - Expression *e = new NullExp(loc); - e->type = this; - return e; + return new NullExp(loc, this); } int TypeReference::isZeroInit(Loc loc) @@ -3288,10 +3277,7 @@ Expression *TypeDelegate::defaultInit(Loc loc) #if LOGDEFAULTINIT printf("TypeDelegate::defaultInit() '%s'\n", toChars()); #endif - Expression *e; - e = new NullExp(loc); - e->type = this; - return e; + return new NullExp(loc, this); } int TypeDelegate::isZeroInit(Loc loc) @@ -4711,12 +4697,11 @@ unsigned TypeStruct::memalign(unsigned salign) } Expression *TypeStruct::defaultInit(Loc loc) -{ Declaration *d; - +{ #if LOGDEFAULTINIT printf("TypeStruct::defaultInit() '%s'\n", toChars()); #endif - d = new StaticStructInitDeclaration(sym->loc, sym); + Declaration *d = new StaticStructInitDeclaration(sym->loc, sym); assert(d); d->type = this; return new VarExp(sym->loc, d); @@ -5180,10 +5165,7 @@ Expression *TypeClass::defaultInit(Loc loc) #if LOGDEFAULTINIT printf("TypeClass::defaultInit() '%s'\n", toChars()); #endif - Expression *e; - e = new NullExp(loc); - e->type = this; - return e; + return new NullExp(loc, this); } int TypeClass::isZeroInit(Loc loc)