Mercurial > projects > ddmd
diff dmd/TypeEnum.d @ 156:0c8cc2a10f99
+ ArrayInitializer.toAssocArrayLiteral()
+ FuncDeclaration.isUnique()
+ TypeEnum.alignsize()
+ TypeEnum.toChars()
+ TypeEnum.getProperty()
+ VarExp.equals()
+ expression.Util.fpunique()
* fixed missing default in TypeBasic
author | trass3r |
---|---|
date | Wed, 15 Sep 2010 18:24:39 +0200 |
parents | af1bebfd96a4 |
children | e3afd1303184 |
line wrap: on
line diff
--- a/dmd/TypeEnum.d Wed Sep 15 17:31:22 2010 +0200 +++ b/dmd/TypeEnum.d Wed Sep 15 18:24:39 2010 +0200 @@ -16,6 +16,7 @@ import dmd.MATCH; import dmd.OutBuffer; import dmd.CppMangleState; +import dmd.StringExp; import dmd.TypeInfoDeclaration; import dmd.TypeInfoEnumDeclaration; import dmd.ArrayTypes; @@ -57,14 +58,23 @@ return sym.memtype.size(loc); } - override uint alignsize() + override uint alignsize() { - assert(false); + if (!sym.memtype) + { + debug writef("1: "); + + error(Loc(0), "enum %s is forward referenced", sym.toChars()); + return 4; + } + return sym.memtype.alignsize(); } - - override string toChars() + + override string toChars() { - assert(false); + if (mod) + return super.toChars(); + return sym.toChars(); } override Type semantic(Loc loc, Scope sc) @@ -123,9 +133,46 @@ return em; } - override Expression getProperty(Loc loc, Identifier ident) + override Expression getProperty(Loc loc, Identifier ident) { - assert(false); + Expression e; + + if (ident is Id.max) + { + if (!sym.maxval) + goto Lfwd; + e = sym.maxval; + } + else if (ident is Id.min) + { + if (!sym.minval) + goto Lfwd; + e = sym.minval; + } + else if (ident is Id.init_) + { + e = defaultInitLiteral(loc); + } + else if (ident is Id.stringof_) + { + string s = toChars(); + e = new StringExp(loc, s, 'c'); + Scope sc; + e = e.semantic(sc); + } + else if (ident is Id.mangleof_) + { + e = Type.getProperty(loc, ident); + } + else + { + e = toBasetype().getProperty(loc, ident); + } + return e; + + Lfwd: + error(loc, "forward reference of %s.%s", toChars(), ident.toChars()); + return new ErrorExp(); } override bool isintegral()