changeset 103:e6090d1aea7c

fixed dmd.Id + some small fixups
author Trass3r
date Tue, 31 Aug 2010 16:22:22 +0200
parents 903b95002d4e
children e414dd80ebfa d8f19d85fadb
files dmd/Id.d dmd/StaticDtorDeclaration.d dmd/StructDeclaration.d dmd/TypeAArray.d dmd/VarDeclaration.d
diffstat 5 files changed, 279 insertions(+), 282 deletions(-) [+]
line wrap: on
line diff
--- a/dmd/Id.d	Tue Aug 31 04:04:33 2010 +0200
+++ b/dmd/Id.d	Tue Aug 31 16:22:22 2010 +0200
@@ -3,288 +3,16 @@
 import dmd.Identifier;
 import dmd.Lexer;
 
-struct Msgtable
+private string idgen(T...)(T ts)
 {
-	string ident;		// name to use in DMD source
-	string name_;	// name in D executable
-}
-
-	immutable Msgtable[100] msgtable =
-	[
-		{ "IUnknown" },
-		{ "Object_", "Object" },
-		{ "object" },
-		{ "max" },
-		{ "min" },
-		{ "This", "this" },
-		{ "ctor", "__ctor" },
-		{ "dtor", "__dtor" },
-		{ "cpctor", "__cpctor" },
-		{ "_postblit", "__postblit" },
-		{ "classInvariant", "__invariant" },
-		{ "unitTest", "__unitTest" },
-		{ "require", "__require" },
-		{ "ensure", "__ensure" },
-		{ "init_", "init" },
-		{ "size" },
-		{ "__sizeof", "sizeof" },
-		{ "alignof_", "alignof" },
-		{ "mangleof_", "mangleof" },
-		{ "stringof_", "stringof" },
-		{ "tupleof_", "tupleof" },
-		{ "length" },
-		{ "remove" },
-		{ "ptr" },
-		{ "funcptr" },
-		{ "dollar", "__dollar" },
-		{ "offset" },
-		{ "offsetof" },
-		{ "ModuleInfo" },
-		{ "ClassInfo" },
-		{ "classinfo_", "classinfo" },
-		{ "typeinfo_", "typeinfo" },
-		{ "outer" },
-		{ "Exception" },
-		{ "AssociativeArray" },
-		{ "Throwable" },
-		{ "withSym", "__withSym" },
-		{ "result", "__result" },
-		{ "returnLabel", "__returnLabel" },
-		{ "delegate_", "delegate" },
-		{ "line" },
-		{ "empty", "" },
-		{ "p" },
-		{ "coverage", "__coverage" },
-		{ "__vptr" },
-		{ "__monitor" },
-		{ "system" },
-
-		{ "TypeInfo" },
-		{ "TypeInfo_Class" },
-		{ "TypeInfo_Interface" },
-		{ "TypeInfo_Struct" },
-		{ "TypeInfo_Enum" },
-		{ "TypeInfo_Typedef" },
-		{ "TypeInfo_Pointer" },
-		{ "TypeInfo_Array" },
-		{ "TypeInfo_StaticArray" },
-		{ "TypeInfo_AssociativeArray" },
-		{ "TypeInfo_Function" },
-		{ "TypeInfo_Delegate" },
-		{ "TypeInfo_Tuple" },
-		{ "TypeInfo_Const" },
-		{ "TypeInfo_Invariant" },
-		{ "TypeInfo_Shared" },
-		{ "elements" },
-		{ "_arguments_typeinfo" },
-		{ "_arguments" },
-		{ "_argptr" },
-		{ "_match" },
-		{ "destroy" },
-		{ "_postblit", "__postblit" },
-
-		{ "LINE", "__LINE__" },
-		{ "FILE", "__FILE__" },
-		{ "DATE", "__DATE__" },
-		{ "TIME", "__TIME__" },
-		{ "TIMESTAMP", "__TIMESTAMP__" },
-		{ "VENDOR", "__VENDOR__" },
-		{ "VERSIONX", "__VERSION__" },
-		{ "EOFX", "__EOF__" },
-
-		{ "nan" },
-		{ "infinity" },
-		{ "dig" },
-		{ "epsilon" },
-		{ "mant_dig" },
-		{ "max_10_exp" },
-		{ "max_exp" },
-		{ "min_10_exp" },
-		{ "min_exp" },
-		{ "min_normal" },
-		{ "re" },
-		{ "im" },
-
-		{ "C" },
-		{ "D" },
-		{ "Windows" },
-		{ "Pascal" },
-		{ "System" },
-
-		{ "exit" },
-		{ "success" },
-		{ "failure" },
-
-		{ "keys" },
-		{ "values" },
-		{ "rehash" },
-
-		{ "sort" },
-		{ "reverse" },
-		{ "dup" },
-		{ "idup" },
-
-		{ "property" },
-
-		// For inline assembler
-		{ "___out", "out" },
-		{ "___in", "in" },
-		{ "__int", "int" },
-		{ "__dollar", "$" },
-		{ "__LOCAL_SIZE" },
+	string res = "struct Id\n{\n";
 
-		// For operator overloads
-		{ "uadd",	 "opPos" },
-		{ "neg",	 "opNeg" },
-		{ "com",	 "opCom" },
-		{ "add",	 "opAdd" },
-		{ "add_r",   "opAdd_r" },
-		{ "sub",	 "opSub" },
-		{ "sub_r",   "opSub_r" },
-		{ "mul",	 "opMul" },
-		{ "mul_r",   "opMul_r" },
-		{ "div",	 "opDiv" },
-		{ "div_r",   "opDiv_r" },
-		{ "mod",	 "opMod" },
-		{ "mod_r",   "opMod_r" },
-		{ "eq",	  "opEquals" },
-		{ "cmp",	 "opCmp" },
-		{ "iand",	"opAnd" },
-		{ "iand_r",  "opAnd_r" },
-		{ "ior",	 "opOr" },
-		{ "ior_r",   "opOr_r" },
-		{ "ixor",	"opXor" },
-		{ "ixor_r",  "opXor_r" },
-		{ "shl",	 "opShl" },
-		{ "shl_r",   "opShl_r" },
-		{ "shr",	 "opShr" },
-		{ "shr_r",   "opShr_r" },
-		{ "ushr",	"opUShr" },
-		{ "ushr_r",  "opUShr_r" },
-		{ "cat",	 "opCat" },
-		{ "cat_r",   "opCat_r" },
-		{ "assign",  "opAssign" },
-		{ "addass",  "opAddAssign" },
-		{ "subass",  "opSubAssign" },
-		{ "mulass",  "opMulAssign" },
-		{ "divass",  "opDivAssign" },
-		{ "modass",  "opModAssign" },
-		{ "andass",  "opAndAssign" },
-		{ "orass",   "opOrAssign" },
-		{ "xorass",  "opXorAssign" },
-		{ "shlass",  "opShlAssign" },
-		{ "shrass",  "opShrAssign" },
-		{ "ushrass", "opUShrAssign" },
-		{ "catass",  "opCatAssign" },
-		{ "postinc", "opPostInc" },
-		{ "postdec", "opPostDec" },
-		{ "index",	 "opIndex" },
-		{ "indexass", "opIndexAssign" },
-		{ "slice",	 "opSlice" },
-		{ "sliceass", "opSliceAssign" },
-		{ "call",	 "opCall" },
-		{ "cast",	 "opCast" },
-		{ "match",	 "opMatch" },
-		{ "next",	 "opNext" },
-		{ "opIn" },
-		{ "opIn_r" },
-		{ "opStar" },
-		{ "opDot" },
-		{ "opImplicitCast" },
-
-		{ "classNew", "new" },
-		{ "classDelete", "delete" },
-
-		// For foreach
-		{ "apply", "opApply" },
-		{ "applyReverse", "opApplyReverse" },
-
-//		#if 1
-		{ "Fempty", "empty" },
-		{ "Fhead", "front" },
-		{ "Ftoe", "back" },
-		{ "Fnext", "popFront" },
-		{ "Fretreat", "popBack" },
-	/*#else
-		{ "Fempty", "empty" },
-		{ "Fhead", "head" },
-		{ "Ftoe", "toe" },
-		{ "Fnext", "next" },
-		{ "Fretreat", "retreat" },
-	#endif*/
-
-		{ "adDup", "_adDupT" },
-		{ "adReverse", "_adReverse" },
-
-		// For internal functions
-		{ "aaLen", "_aaLen" },
-		{ "aaKeys", "_aaKeys" },
-		{ "aaValues", "_aaValues" },
-		{ "aaRehash", "_aaRehash" },
-		{ "monitorenter", "_d_monitorenter" },
-		{ "monitorexit", "_d_monitorexit" },
-		{ "criticalenter", "_d_criticalenter" },
-		{ "criticalexit", "_d_criticalexit" },
-
-		// For pragma's
-		{ "GNU_asm" },
-		{ "lib" },
-		{ "msg" },
-		{ "startaddress" },
-
-		// For special functions
-		{ "tohash", "toHash" },
-		{ "tostring", "toString" },
-		{ "getmembers", "getMembers" },
-
-		// Special functions
-		{ "alloca" },
-		{ "main" },
-		{ "WinMain" },
-		{ "DllMain" },
-		{ "tls_get_addr", "___tls_get_addr" },
-
-		// Builtin functions
-		{ "std" },
-		{ "math" },
-		{ "sin" },
-		{ "cos" },
-		{ "tan" },
-		{ "_sqrt", "sqrt" },
-		{ "fabs" },
-
-		// Traits
-		{ "isAbstractClass" },
-		{ "isArithmetic" },
-		{ "isAssociativeArray" },
-		{ "isFinalClass" },
-		{ "isFloating" },
-		{ "isIntegral" },
-		{ "isScalar" },
-		{ "isStaticArray" },
-		{ "isUnsigned" },
-		{ "isVirtualFunction" },
-		{ "isAbstractFunction" },
-		{ "isFinalFunction" },
-		{ "hasMember" },
-		{ "getMember" },
-		{ "getVirtualFunctions" },
-		{ "classInstanceSize" },
-		{ "allMembers" },
-		{ "derivedMembers" },
-		{ "isSame" },
-		{ "compiles" },
-	];
-private string idgen()
-{
-	string res = "struct Id\n{";
-
-	foreach(entry; msgtable)
+	foreach(entry; ts)
 		res ~= "\tstatic Identifier " ~ entry.ident ~ ";\n";
 	
 	res ~= "\tstatic void initialize()\n\t{\n";
 	string tmp;
-	foreach (entry; msgtable)
+	foreach (entry; ts)
 	{
 		if (entry.name_ is null)
 			tmp = entry.ident;
@@ -297,4 +25,273 @@
 	return res;
 }
 
-mixin(idgen());
\ No newline at end of file
+private struct ID
+{
+	string ident;		// name to use in DMD source
+	string name_;	// name in D executable
+}
+
+mixin(idgen(
+		ID( "IUnknown" ),
+		ID( "Object_", "Object" ),
+		ID( "object" ),
+		ID( "max" ),
+		ID( "min" ),
+		ID( "This", "this" ),
+		ID( "ctor", "__ctor" ),
+		ID( "dtor", "__dtor" ),
+		ID( "cpctor", "__cpctor" ),
+		ID( "_postblit", "__postblit" ),
+		ID( "classInvariant", "__invariant" ),
+		ID( "unitTest", "__unitTest" ),
+		ID( "require", "__require" ),
+		ID( "ensure", "__ensure" ),
+		ID( "init_", "init" ),
+		ID( "size" ),
+		ID( "__sizeof", "sizeof" ),
+		ID( "alignof_", "alignof" ),
+		ID( "mangleof_", "mangleof" ),
+		ID( "stringof_", "stringof" ),
+		ID( "tupleof_", "tupleof" ),
+		ID( "length" ),
+		ID( "remove" ),
+		ID( "ptr" ),
+		ID( "funcptr" ),
+		ID( "dollar", "__dollar" ),
+		ID( "offset" ),
+		ID( "offsetof" ),
+		ID( "ModuleInfo" ),
+		ID( "ClassInfo" ),
+		ID( "classinfo_", "classinfo" ),
+		ID( "typeinfo_", "typeinfo" ),
+		ID( "outer" ),
+		ID( "Exception" ),
+		ID( "AssociativeArray" ),
+		ID( "Throwable" ),
+		ID( "withSym", "__withSym" ),
+		ID( "result", "__result" ),
+		ID( "returnLabel", "__returnLabel" ),
+		ID( "delegate_", "delegate" ),
+		ID( "line" ),
+		ID( "empty", "" ),
+		ID( "p" ),
+		ID( "coverage", "__coverage" ),
+		ID( "__vptr" ),
+		ID( "__monitor" ),
+		ID( "system" ),
+
+		ID( "TypeInfo" ),
+		ID( "TypeInfo_Class" ),
+		ID( "TypeInfo_Interface" ),
+		ID( "TypeInfo_Struct" ),
+		ID( "TypeInfo_Enum" ),
+		ID( "TypeInfo_Typedef" ),
+		ID( "TypeInfo_Pointer" ),
+		ID( "TypeInfo_Array" ),
+		ID( "TypeInfo_StaticArray" ),
+		ID( "TypeInfo_AssociativeArray" ),
+		ID( "TypeInfo_Function" ),
+		ID( "TypeInfo_Delegate" ),
+		ID( "TypeInfo_Tuple" ),
+		ID( "TypeInfo_Const" ),
+		ID( "TypeInfo_Invariant" ),
+		ID( "TypeInfo_Shared" ),
+		ID( "elements" ),
+		ID( "_arguments_typeinfo" ),
+		ID( "_arguments" ),
+		ID( "_argptr" ),
+		ID( "_match" ),
+		ID( "destroy" ),
+
+		ID( "LINE", "__LINE__" ),
+		ID( "FILE", "__FILE__" ),
+		ID( "DATE", "__DATE__" ),
+		ID( "TIME", "__TIME__" ),
+		ID( "TIMESTAMP", "__TIMESTAMP__" ),
+		ID( "VENDOR", "__VENDOR__" ),
+		ID( "VERSIONX", "__VERSION__" ),
+		ID( "EOFX", "__EOF__" ),
+
+		ID( "nan" ),
+		ID( "infinity" ),
+		ID( "dig" ),
+		ID( "epsilon" ),
+		ID( "mant_dig" ),
+		ID( "max_10_exp" ),
+		ID( "max_exp" ),
+		ID( "min_10_exp" ),
+		ID( "min_exp" ),
+		ID( "min_normal" ),
+		ID( "re" ),
+		ID( "im" ),
+
+		ID( "C" ),
+		ID( "D" ),
+		ID( "Windows" ),
+		ID( "Pascal" ),
+		ID( "System" ),
+
+		ID( "exit" ),
+		ID( "success" ),
+		ID( "failure" ),
+
+		ID( "keys" ),
+		ID( "values" ),
+		ID( "rehash" ),
+
+		ID( "sort" ),
+		ID( "reverse" ),
+		ID( "dup" ),
+		ID( "idup" ),
+
+		ID( "property" ),
+
+		// For inline assembler
+		ID( "___out", "out" ),
+		ID( "___in", "in" ),
+		ID( "__int", "int" ),
+		ID( "__dollar", "$" ),
+		ID( "__LOCAL_SIZE" ),
+
+		// For operator overloads
+		ID( "uadd",	 "opPos" ),
+		ID( "neg",	 "opNeg" ),
+		ID( "com",	 "opCom" ),
+		ID( "add",	 "opAdd" ),
+		ID( "add_r",   "opAdd_r" ),
+		ID( "sub",	 "opSub" ),
+		ID( "sub_r",   "opSub_r" ),
+		ID( "mul",	 "opMul" ),
+		ID( "mul_r",   "opMul_r" ),
+		ID( "div",	 "opDiv" ),
+		ID( "div_r",   "opDiv_r" ),
+		ID( "mod",	 "opMod" ),
+		ID( "mod_r",   "opMod_r" ),
+		ID( "eq",	  "opEquals" ),
+		ID( "cmp",	 "opCmp" ),
+		ID( "iand",	"opAnd" ),
+		ID( "iand_r",  "opAnd_r" ),
+		ID( "ior",	 "opOr" ),
+		ID( "ior_r",   "opOr_r" ),
+		ID( "ixor",	"opXor" ),
+		ID( "ixor_r",  "opXor_r" ),
+		ID( "shl",	 "opShl" ),
+		ID( "shl_r",   "opShl_r" ),
+		ID( "shr",	 "opShr" ),
+		ID( "shr_r",   "opShr_r" ),
+		ID( "ushr",	"opUShr" ),
+		ID( "ushr_r",  "opUShr_r" ),
+		ID( "cat",	 "opCat" ),
+		ID( "cat_r",   "opCat_r" ),
+		ID( "assign",  "opAssign" ),
+		ID( "addass",  "opAddAssign" ),
+		ID( "subass",  "opSubAssign" ),
+		ID( "mulass",  "opMulAssign" ),
+		ID( "divass",  "opDivAssign" ),
+		ID( "modass",  "opModAssign" ),
+		ID( "andass",  "opAndAssign" ),
+		ID( "orass",   "opOrAssign" ),
+		ID( "xorass",  "opXorAssign" ),
+		ID( "shlass",  "opShlAssign" ),
+		ID( "shrass",  "opShrAssign" ),
+		ID( "ushrass", "opUShrAssign" ),
+		ID( "catass",  "opCatAssign" ),
+		ID( "postinc", "opPostInc" ),
+		ID( "postdec", "opPostDec" ),
+		ID( "index",	 "opIndex" ),
+		ID( "indexass", "opIndexAssign" ),
+		ID( "slice",	 "opSlice" ),
+		ID( "sliceass", "opSliceAssign" ),
+		ID( "call",	 "opCall" ),
+		ID( "cast_",	 "opCast" ),
+		ID( "match",	 "opMatch" ),
+		ID( "next",	 "opNext" ),
+		ID( "opIn" ),
+		ID( "opIn_r" ),
+		ID( "opStar" ),
+		ID( "opDot" ),
+		ID( "opImplicitCast" ),
+
+		ID( "classNew", "new" ),
+		ID( "classDelete", "delete" ),
+
+		// For foreach
+		ID( "apply", "opApply" ),
+		ID( "applyReverse", "opApplyReverse" ),
+
+//		#if 1
+		ID( "Fempty", "empty" ),
+		ID( "Fhead", "front" ),
+		ID( "Ftoe", "back" ),
+		ID( "Fnext", "popFront" ),
+		ID( "Fretreat", "popBack" ),
+	/*#else
+		ID( "Fempty", "empty" ),
+		ID( "Fhead", "head" ),
+		ID( "Ftoe", "toe" ),
+		ID( "Fnext", "next" ),
+		ID( "Fretreat", "retreat" ),
+	#endif*/
+
+		ID( "adDup", "_adDupT" ),
+		ID( "adReverse", "_adReverse" ),
+
+		// For internal functions
+		ID( "aaLen", "_aaLen" ),
+		ID( "aaKeys", "_aaKeys" ),
+		ID( "aaValues", "_aaValues" ),
+		ID( "aaRehash", "_aaRehash" ),
+		ID( "monitorenter", "_d_monitorenter" ),
+		ID( "monitorexit", "_d_monitorexit" ),
+		ID( "criticalenter", "_d_criticalenter" ),
+		ID( "criticalexit", "_d_criticalexit" ),
+
+		// For pragma's
+		ID( "GNU_asm" ),
+		ID( "lib" ),
+		ID( "msg" ),
+		ID( "startaddress" ),
+
+		// For special functions
+		ID( "tohash", "toHash" ),
+		ID( "tostring", "toString" ),
+		ID( "getmembers", "getMembers" ),
+
+		// Special functions
+		ID( "alloca" ),
+		ID( "main" ),
+		ID( "WinMain" ),
+		ID( "DllMain" ),
+		ID( "tls_get_addr", "___tls_get_addr" ),
+
+		// Builtin functions
+		ID( "std" ),
+		ID( "math" ),
+		ID( "sin" ),
+		ID( "cos" ),
+		ID( "tan" ),
+		ID( "_sqrt", "sqrt" ),
+		ID( "fabs" ),
+
+		// Traits
+		ID( "isAbstractClass" ),
+		ID( "isArithmetic" ),
+		ID( "isAssociativeArray" ),
+		ID( "isFinalClass" ),
+		ID( "isFloating" ),
+		ID( "isIntegral" ),
+		ID( "isScalar" ),
+		ID( "isStaticArray" ),
+		ID( "isUnsigned" ),
+		ID( "isVirtualFunction" ),
+		ID( "isAbstractFunction" ),
+		ID( "isFinalFunction" ),
+		ID( "hasMember" ),
+		ID( "getMember" ),
+		ID( "getVirtualFunctions" ),
+		ID( "classInstanceSize" ),
+		ID( "allMembers" ),
+		ID( "derivedMembers" ),
+		ID( "isSame" ),
+		ID( "compiles" )
+	));
\ No newline at end of file
--- a/dmd/StaticDtorDeclaration.d	Tue Aug 31 04:04:33 2010 +0200
+++ b/dmd/StaticDtorDeclaration.d	Tue Aug 31 16:22:22 2010 +0200
@@ -38,7 +38,7 @@
 		super(loc, endloc, Identifier.generateId("_staticDtor"), STCstatic, null);
 	}
 	
-	override Dsymbol syntaxCopy(Dsymbol)
+	override Dsymbol syntaxCopy(Dsymbol s)
 	{
 		assert(!s);
 		StaticDtorDeclaration sdd = new StaticDtorDeclaration(loc, endloc);
--- a/dmd/StructDeclaration.d	Tue Aug 31 04:04:33 2010 +0200
+++ b/dmd/StructDeclaration.d	Tue Aug 31 16:22:22 2010 +0200
@@ -578,7 +578,7 @@
 					ea = new CastExp(Loc(0), ea, Type.tvoid.pointerTo());
 	
 					Expression et = v.type.getTypeInfo(sc);
-					et = new DotIdExp(Loc(0), et, Id.postblit);
+					et = new DotIdExp(Loc(0), et, Id._postblit);
 	
 					ex = new CallExp(Loc(0), et, ea);
 				}
--- a/dmd/TypeAArray.d	Tue Aug 31 04:04:33 2010 +0200
+++ b/dmd/TypeAArray.d	Tue Aug 31 16:22:22 2010 +0200
@@ -176,8 +176,8 @@
 				 */
 				TemplateInstance ti = new TemplateInstance(loc, Id.AssociativeArray);
 				Objects tiargs = new Objects();
-				tiargs.push(index);
-				tiargs.push(next);
+				tiargs.push(cast(void*)index);
+				tiargs.push(cast(void*)next);
 				ti.tiargs = tiargs;
 	
 				ti.semantic(sc);
--- a/dmd/VarDeclaration.d	Tue Aug 31 04:04:33 2010 +0200
+++ b/dmd/VarDeclaration.d	Tue Aug 31 16:22:22 2010 +0200
@@ -582,7 +582,7 @@
 }
 				if (!ei.exp.implicitConvTo(type))
 				{
-					Type *ti = ei.exp.type.toBasetype();
+					Type ti = ei.exp.type.toBasetype();
 					// Look for constructor first
 					if (sd.ctor &&
 					    /* Initializing with the same type is done differently