# HG changeset patch # User Trass3r # Date 1283220273 -7200 # Node ID 903b95002d4efc1b86183ff5980a17e8cdc44a26 # Parent 5c859d5fbe275c198828d253daa13fd95c9ea593 Id and Macro are quite experimental currently diff -r 5c859d5fbe27 -r 903b95002d4e dmd/Dsymbol.d --- a/dmd/Dsymbol.d Tue Aug 31 03:53:49 2010 +0200 +++ b/dmd/Dsymbol.d Tue Aug 31 04:04:33 2010 +0200 @@ -67,6 +67,7 @@ import dmd.backend.SC; import dmd.backend.FL; import dmd.backend.LIST; +public import dmd.PASS; import core.stdc.string : strcmp, memcpy, strlen; version (Bug4054) import core.memory; diff -r 5c859d5fbe27 -r 903b95002d4e dmd/Id.d --- a/dmd/Id.d Tue Aug 31 03:53:49 2010 +0200 +++ b/dmd/Id.d Tue Aug 31 04:04:33 2010 +0200 @@ -3,458 +3,298 @@ import dmd.Identifier; import dmd.Lexer; -struct Id +struct Msgtable { - static Identifier IUnknown; - static Identifier Object_; - static Identifier object; - static Identifier max; - static Identifier min; - static Identifier This; - static Identifier ctor; - static Identifier dtor; - static Identifier cpctor; - static Identifier _postblit; - static Identifier classInvariant; - static Identifier unitTest; - static Identifier require; - static Identifier ensure; - static Identifier init_; - static Identifier size; - static Identifier __sizeof; - static Identifier alignof_; - static Identifier mangleof_; - static Identifier stringof_; - static Identifier tupleof_; - static Identifier length; - static Identifier remove; - static Identifier ptr; - static Identifier funcptr; - static Identifier dollar; - static Identifier offset; - static Identifier offsetof; - static Identifier ModuleInfo; - static Identifier ClassInfo; - static Identifier classinfo_; - static Identifier typeinfo_; - static Identifier outer; - static Identifier Exception; - static Identifier Throwable; - static Identifier withSym; - static Identifier result; - static Identifier returnLabel; - static Identifier delegate_; - static Identifier line; - static Identifier empty; - static Identifier p; - static Identifier coverage; - static Identifier __vptr; - static Identifier __monitor; - static Identifier system; - static Identifier TypeInfo; - static Identifier TypeInfo_Class; - static Identifier TypeInfo_Interface; - static Identifier TypeInfo_Struct; - static Identifier TypeInfo_Enum; - static Identifier TypeInfo_Typedef; - static Identifier TypeInfo_Pointer; - static Identifier TypeInfo_Array; - static Identifier TypeInfo_StaticArray; - static Identifier TypeInfo_AssociativeArray; - static Identifier TypeInfo_Function; - static Identifier TypeInfo_Delegate; - static Identifier TypeInfo_Tuple; - static Identifier TypeInfo_Const; - static Identifier TypeInfo_Invariant; - static Identifier TypeInfo_Shared; - static Identifier elements; - static Identifier _arguments_typeinfo; - static Identifier _arguments; - static Identifier _argptr; - static Identifier _match; - static Identifier destroy; - static Identifier postblit; - static Identifier LINE; - static Identifier FILE; - static Identifier DATE; - static Identifier TIME; - static Identifier TIMESTAMP; - static Identifier VENDOR; - static Identifier VERSIONX; - static Identifier EOFX; - static Identifier nan; - static Identifier infinity; - static Identifier dig; - static Identifier epsilon; - static Identifier mant_dig; - static Identifier max_10_exp; - static Identifier max_exp; - static Identifier min_10_exp; - static Identifier min_exp; - static Identifier re; - static Identifier im; - static Identifier C; - static Identifier D; - static Identifier Windows; - static Identifier Pascal; - static Identifier System; - static Identifier exit; - static Identifier success; - static Identifier failure; - static Identifier keys; - static Identifier values; - static Identifier rehash; - static Identifier sort; - static Identifier reverse; - static Identifier dup; - static Identifier idup; - static Identifier property; - static Identifier ___out; - static Identifier ___in; - static Identifier __int; - static Identifier __dollar; - static Identifier __LOCAL_SIZE; - static Identifier uadd; - static Identifier neg; - static Identifier com; - static Identifier add; - static Identifier add_r; - static Identifier sub; - static Identifier sub_r; - static Identifier mul; - static Identifier mul_r; - static Identifier div; - static Identifier div_r; - static Identifier mod; - static Identifier mod_r; - static Identifier eq; - static Identifier cmp; - static Identifier iand; - static Identifier iand_r; - static Identifier ior; - static Identifier ior_r; - static Identifier ixor; - static Identifier ixor_r; - static Identifier shl; - static Identifier shl_r; - static Identifier shr; - static Identifier shr_r; - static Identifier ushr; - static Identifier ushr_r; - static Identifier cat; - static Identifier cat_r; - static Identifier assign; - static Identifier addass; - static Identifier subass; - static Identifier mulass; - static Identifier divass; - static Identifier modass; - static Identifier andass; - static Identifier orass; - static Identifier xorass; - static Identifier shlass; - static Identifier shrass; - static Identifier ushrass; - static Identifier catass; - static Identifier postinc; - static Identifier postdec; - static Identifier index; - static Identifier indexass; - static Identifier slice; - static Identifier sliceass; - static Identifier call; - static Identifier cast_; - static Identifier match; - static Identifier next; - static Identifier opIn; - static Identifier opIn_r; - static Identifier opStar; - static Identifier opDot; - static Identifier opImplicitCast; - static Identifier classNew; - static Identifier classDelete; - static Identifier apply; - static Identifier applyReverse; - static Identifier Fempty; - static Identifier Fhead; - static Identifier Ftoe; - static Identifier Fnext; - static Identifier Fretreat; - static Identifier adDup; - static Identifier adReverse; - static Identifier aaLen; - static Identifier aaKeys; - static Identifier aaValues; - static Identifier aaRehash; - static Identifier monitorenter; - static Identifier monitorexit; - static Identifier criticalenter; - static Identifier criticalexit; - static Identifier GNU_asm; - static Identifier lib; - static Identifier msg; - static Identifier startaddress; - static Identifier tohash; - static Identifier tostring; - static Identifier getmembers; - static Identifier alloca; - static Identifier main; - static Identifier WinMain; - static Identifier DllMain; - static Identifier tls_get_addr; - static Identifier std; - static Identifier math; - static Identifier sin; - static Identifier cos; - static Identifier tan; - static Identifier _sqrt; - static Identifier fabs; - static Identifier isAbstractClass; - static Identifier isArithmetic; - static Identifier isAssociativeArray; - static Identifier isFinalClass; - static Identifier isFloating; - static Identifier isIntegral; - static Identifier isScalar; - static Identifier isStaticArray; - static Identifier isUnsigned; - static Identifier isVirtualFunction; - static Identifier isAbstractFunction; - static Identifier isFinalFunction; - static Identifier hasMember; - static Identifier getMember; - static Identifier getVirtualFunctions; - static Identifier classInstanceSize; - static Identifier allMembers; - static Identifier derivedMembers; - static Identifier isSame; - static Identifier compiles; + 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" }, - static void initialize() + // 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) + res ~= "\tstatic Identifier " ~ entry.ident ~ ";\n"; + + res ~= "\tstatic void initialize()\n\t{\n"; + string tmp; + foreach (entry; msgtable) { - IUnknown = Lexer.idPool("IUnknown"); - Object_ = Lexer.idPool("Object"); - object = Lexer.idPool("object"); - max = Lexer.idPool("max"); - min = Lexer.idPool("min"); - This = Lexer.idPool("this"); - ctor = Lexer.idPool("__ctor"); - dtor = Lexer.idPool("__dtor"); - cpctor = Lexer.idPool("__cpctor"); - _postblit = Lexer.idPool("__postblit"); - classInvariant = Lexer.idPool("__invariant"); - unitTest = Lexer.idPool("__unitTest"); - require = Lexer.idPool("__require"); - ensure = Lexer.idPool("__ensure"); - init_ = Lexer.idPool("init"); - size = Lexer.idPool("size"); - __sizeof = Lexer.idPool("sizeof"); - alignof_ = Lexer.idPool("alignof"); - mangleof_ = Lexer.idPool("mangleof"); - stringof_ = Lexer.idPool("stringof"); - tupleof_ = Lexer.idPool("tupleof"); - length = Lexer.idPool("length"); - remove = Lexer.idPool("remove"); - ptr = Lexer.idPool("ptr"); - funcptr = Lexer.idPool("funcptr"); - dollar = Lexer.idPool("__dollar"); - offset = Lexer.idPool("offset"); - offsetof = Lexer.idPool("offsetof"); - ModuleInfo = Lexer.idPool("ModuleInfo"); - ClassInfo = Lexer.idPool("ClassInfo"); - classinfo_ = Lexer.idPool("classinfo"); - typeinfo_ = Lexer.idPool("typeinfo"); - outer = Lexer.idPool("outer"); - Exception = Lexer.idPool("Exception"); - Throwable = Lexer.idPool("Throwable"); - withSym = Lexer.idPool("__withSym"); - result = Lexer.idPool("__result"); - returnLabel = Lexer.idPool("__returnLabel"); - delegate_ = Lexer.idPool("delegate"); - line = Lexer.idPool("line"); - empty = Lexer.idPool(""); - p = Lexer.idPool("p"); - coverage = Lexer.idPool("__coverage"); - __vptr = Lexer.idPool("__vptr"); - __monitor = Lexer.idPool("__monitor"); - system = Lexer.idPool("system"); - TypeInfo = Lexer.idPool("TypeInfo"); - TypeInfo_Class = Lexer.idPool("TypeInfo_Class"); - TypeInfo_Interface = Lexer.idPool("TypeInfo_Interface"); - TypeInfo_Struct = Lexer.idPool("TypeInfo_Struct"); - TypeInfo_Enum = Lexer.idPool("TypeInfo_Enum"); - TypeInfo_Typedef = Lexer.idPool("TypeInfo_Typedef"); - TypeInfo_Pointer = Lexer.idPool("TypeInfo_Pointer"); - TypeInfo_Array = Lexer.idPool("TypeInfo_Array"); - TypeInfo_StaticArray = Lexer.idPool("TypeInfo_StaticArray"); - TypeInfo_AssociativeArray = Lexer.idPool("TypeInfo_AssociativeArray"); - TypeInfo_Function = Lexer.idPool("TypeInfo_Function"); - TypeInfo_Delegate = Lexer.idPool("TypeInfo_Delegate"); - TypeInfo_Tuple = Lexer.idPool("TypeInfo_Tuple"); - TypeInfo_Const = Lexer.idPool("TypeInfo_Const"); - TypeInfo_Invariant = Lexer.idPool("TypeInfo_Invariant"); - TypeInfo_Shared = Lexer.idPool("TypeInfo_Shared"); - elements = Lexer.idPool("elements"); - _arguments_typeinfo = Lexer.idPool("_arguments_typeinfo"); - _arguments = Lexer.idPool("_arguments"); - _argptr = Lexer.idPool("_argptr"); - _match = Lexer.idPool("_match"); - destroy = Lexer.idPool("destroy"); - postblit = Lexer.idPool("postblit"); - LINE = Lexer.idPool("__LINE__"); - FILE = Lexer.idPool("__FILE__"); - DATE = Lexer.idPool("__DATE__"); - TIME = Lexer.idPool("__TIME__"); - TIMESTAMP = Lexer.idPool("__TIMESTAMP__"); - VENDOR = Lexer.idPool("__VENDOR__"); - VERSIONX = Lexer.idPool("__VERSION__"); - EOFX = Lexer.idPool("__EOF__"); - nan = Lexer.idPool("nan"); - infinity = Lexer.idPool("infinity"); - dig = Lexer.idPool("dig"); - epsilon = Lexer.idPool("epsilon"); - mant_dig = Lexer.idPool("mant_dig"); - max_10_exp = Lexer.idPool("max_10_exp"); - max_exp = Lexer.idPool("max_exp"); - min_10_exp = Lexer.idPool("min_10_exp"); - min_exp = Lexer.idPool("min_exp"); - re = Lexer.idPool("re"); - im = Lexer.idPool("im"); - C = Lexer.idPool("C"); - D = Lexer.idPool("D"); - Windows = Lexer.idPool("Windows"); - Pascal = Lexer.idPool("Pascal"); - System = Lexer.idPool("System"); - exit = Lexer.idPool("exit"); - success = Lexer.idPool("success"); - failure = Lexer.idPool("failure"); - keys = Lexer.idPool("keys"); - values = Lexer.idPool("values"); - rehash = Lexer.idPool("rehash"); - sort = Lexer.idPool("sort"); - reverse = Lexer.idPool("reverse"); - dup = Lexer.idPool("dup"); - idup = Lexer.idPool("idup"); - property = Lexer.idPool("property"); - ___out = Lexer.idPool("out"); - ___in = Lexer.idPool("in"); - __int = Lexer.idPool("int"); - __dollar = Lexer.idPool("$"); - __LOCAL_SIZE = Lexer.idPool("__LOCAL_SIZE"); - uadd = Lexer.idPool("opPos"); - neg = Lexer.idPool("opNeg"); - com = Lexer.idPool("opCom"); - add = Lexer.idPool("opAdd"); - add_r = Lexer.idPool("opAdd_r"); - sub = Lexer.idPool("opSub"); - sub_r = Lexer.idPool("opSub_r"); - mul = Lexer.idPool("opMul"); - mul_r = Lexer.idPool("opMul_r"); - div = Lexer.idPool("opDiv"); - div_r = Lexer.idPool("opDiv_r"); - mod = Lexer.idPool("opMod"); - mod_r = Lexer.idPool("opMod_r"); - eq = Lexer.idPool("opEquals"); - cmp = Lexer.idPool("opCmp"); - iand = Lexer.idPool("opAnd"); - iand_r = Lexer.idPool("opAnd_r"); - ior = Lexer.idPool("opOr"); - ior_r = Lexer.idPool("opOr_r"); - ixor = Lexer.idPool("opXor"); - ixor_r = Lexer.idPool("opXor_r"); - shl = Lexer.idPool("opShl"); - shl_r = Lexer.idPool("opShl_r"); - shr = Lexer.idPool("opShr"); - shr_r = Lexer.idPool("opShr_r"); - ushr = Lexer.idPool("opUShr"); - ushr_r = Lexer.idPool("opUShr_r"); - cat = Lexer.idPool("opCat"); - cat_r = Lexer.idPool("opCat_r"); - assign = Lexer.idPool("opAssign"); - addass = Lexer.idPool("opAddAssign"); - subass = Lexer.idPool("opSubAssign"); - mulass = Lexer.idPool("opMulAssign"); - divass = Lexer.idPool("opDivAssign"); - modass = Lexer.idPool("opModAssign"); - andass = Lexer.idPool("opAndAssign"); - orass = Lexer.idPool("opOrAssign"); - xorass = Lexer.idPool("opXorAssign"); - shlass = Lexer.idPool("opShlAssign"); - shrass = Lexer.idPool("opShrAssign"); - ushrass = Lexer.idPool("opUShrAssign"); - catass = Lexer.idPool("opCatAssign"); - postinc = Lexer.idPool("opPostInc"); - postdec = Lexer.idPool("opPostDec"); - index = Lexer.idPool("opIndex"); - indexass = Lexer.idPool("opIndexAssign"); - slice = Lexer.idPool("opSlice"); - sliceass = Lexer.idPool("opSliceAssign"); - call = Lexer.idPool("opCall"); - cast_ = Lexer.idPool("opCast"); - match = Lexer.idPool("opMatch"); - next = Lexer.idPool("opNext"); - opIn = Lexer.idPool("opIn"); - opIn_r = Lexer.idPool("opIn_r"); - opStar = Lexer.idPool("opStar"); - opDot = Lexer.idPool("opDot"); - opImplicitCast = Lexer.idPool("opImplicitCast"); - classNew = Lexer.idPool("new"); - classDelete = Lexer.idPool("delete"); - apply = Lexer.idPool("opApply"); - applyReverse = Lexer.idPool("opApplyReverse"); - Fempty = Lexer.idPool("empty"); - Fhead = Lexer.idPool("front"); - Ftoe = Lexer.idPool("back"); - Fnext = Lexer.idPool("popFront"); - Fretreat = Lexer.idPool("popBack"); - adDup = Lexer.idPool("_adDupT"); - adReverse = Lexer.idPool("_adReverse"); - aaLen = Lexer.idPool("_aaLen"); - aaKeys = Lexer.idPool("_aaKeys"); - aaValues = Lexer.idPool("_aaValues"); - aaRehash = Lexer.idPool("_aaRehash"); - monitorenter = Lexer.idPool("_d_monitorenter"); - monitorexit = Lexer.idPool("_d_monitorexit"); - criticalenter = Lexer.idPool("_d_criticalenter"); - criticalexit = Lexer.idPool("_d_criticalexit"); - GNU_asm = Lexer.idPool("GNU_asm"); - lib = Lexer.idPool("lib"); - msg = Lexer.idPool("msg"); - startaddress = Lexer.idPool("startaddress"); - tohash = Lexer.idPool("toHash"); - tostring = Lexer.idPool("toString"); - getmembers = Lexer.idPool("getMembers"); - alloca = Lexer.idPool("alloca"); - main = Lexer.idPool("main"); - WinMain = Lexer.idPool("WinMain"); - DllMain = Lexer.idPool("DllMain"); - tls_get_addr = Lexer.idPool("___tls_get_addr"); - std = Lexer.idPool("std"); - math = Lexer.idPool("math"); - sin = Lexer.idPool("sin"); - cos = Lexer.idPool("cos"); - tan = Lexer.idPool("tan"); - _sqrt = Lexer.idPool("sqrt"); - fabs = Lexer.idPool("fabs"); - isAbstractClass = Lexer.idPool("isAbstractClass"); - isArithmetic = Lexer.idPool("isArithmetic"); - isAssociativeArray = Lexer.idPool("isAssociativeArray"); - isFinalClass = Lexer.idPool("isFinalClass"); - isFloating = Lexer.idPool("isFloating"); - isIntegral = Lexer.idPool("isIntegral"); - isScalar = Lexer.idPool("isScalar"); - isStaticArray = Lexer.idPool("isStaticArray"); - isUnsigned = Lexer.idPool("isUnsigned"); - isVirtualFunction = Lexer.idPool("isVirtualFunction"); - isAbstractFunction = Lexer.idPool("isAbstractFunction"); - isFinalFunction = Lexer.idPool("isFinalFunction"); - hasMember = Lexer.idPool("hasMember"); - getMember = Lexer.idPool("getMember"); - getVirtualFunctions = Lexer.idPool("getVirtualFunctions"); - classInstanceSize = Lexer.idPool("classInstanceSize"); - allMembers = Lexer.idPool("allMembers"); - derivedMembers = Lexer.idPool("derivedMembers"); - isSame = Lexer.idPool("isSame"); - compiles = Lexer.idPool("compiles"); + if (entry.name_ is null) + tmp = entry.ident; + else + tmp = entry.name_; + res ~= "\t\t" ~ entry.ident ~ ` = Lexer.idPool("` ~ tmp ~ "\");\n"; } -} \ No newline at end of file + + res ~= "\t}\n}"; + return res; +} + +mixin(idgen()); \ No newline at end of file diff -r 5c859d5fbe27 -r 903b95002d4e dmd/Macro.d --- a/dmd/Macro.d Tue Aug 31 03:53:49 2010 +0200 +++ b/dmd/Macro.d Tue Aug 31 04:04:33 2010 +0200 @@ -2,4 +2,112 @@ struct Macro /// ??? { -} \ No newline at end of file +} + +/** +It is very important to use version control macros correctly - the +idea is that host and target are independent. If these are done +correctly, cross compilers can be built. +The host compiler and host operating system are also different, +and are predefined by the host compiler. The ones used in +dmd are: + +Macros defined by the compiler, not the code: + + Compiler: + __DMC__ Digital Mars compiler + _MSC_VER Microsoft compiler + __GNUC__ Gnu compiler + + Host operating system: + _WIN32 Microsoft NT, Windows 95, Windows 98, Win32s, + Windows 2000, Win XP, Vista + _WIN64 Windows for AMD64 + linux Linux + __APPLE__ Mac OSX + __FreeBSD__ FreeBSD + __sun&&__SVR4 Solaris, OpenSolaris (yes, both macros are necessary) + +For the target systems, there are the target operating system and +the target object file format: + + Target operating system: + TARGET_WINDOS Covers 32 bit windows and 64 bit windows + TARGET_LINUX Covers 32 and 64 bit linux + TARGET_OSX Covers 32 and 64 bit Mac OSX + TARGET_FREEBSD Covers 32 and 64 bit FreeBSD + TARGET_SOLARIS Covers 32 and 64 bit Solaris + TARGET_NET Covers .Net + + It is expected that the compiler for each platform will be able + to generate 32 and 64 bit code from the same compiler binary. + + Target object module format: + OMFOBJ Intel Object Module Format, used on Windows + ELFOBJ Elf Object Module Format, used on linux, FreeBSD and Solaris + MACHOBJ Mach-O Object Module Format, used on Mac OSX + + There are currently no macros for byte endianness order. + */ +//version definitions from mars.h + +version(IN_GCC) // Changes for the GDC compiler by David Friedman +{ + static assert(false, "GDC not supported"); +} + +// default to DMDV2 +version(DMDV1) {} else +version = DMDV2; // Version 2.0 features +version = BREAKABI; // 0 if not ready to break the ABI just yet +version(DMDV2) +{ + version = STRUCTTHISREF; // if 'this' for struct is a reference, not a pointer + version = SNAN_DEFAULT_INIT;// if floats are default initialized to signalling NaN + version = SARRAYVALUE; // static arrays are value types +} + +// Set if C++ mangling is done by the front end +version(DMDV2) +{ + version(POSIX) // TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS + version = CPP_MANGLE; +} + +/* Other targets are TARGET_LINUX, TARGET_OSX, TARGET_FREEBSD and + * TARGET_SOLARIS, which are + * set on the command line via the compiler makefile. + */ + +version(_WIN32) +{ + version = TARGET_WINDOS; // Windows dmd generates Windows targets + version = OMFOBJ; +} + +version(TARGET_LINUX) + version = ELFOBJ; +version(TARGET_FREEBSD) + version = ELFOBJ; +version(TARGET_SOLARIS) + version = ELFOBJ; + + +version(TARGET_OSX) + version = MACHOBJ; + +/* TODO: +//Modify OutBuffer::writewchar to write the correct size of wchar +#if _WIN32 +#define writewchar writeword +#else +//This needs a configuration test... +#define writewchar write4 +#endif + +#define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry +//in interface vtbl[]'s +#define INTERFACE_VIRTUAL 0 // 1 means if an interface appears +//in the inheritance graph multiple +//times, only one is used +*/ \ No newline at end of file diff -r 5c859d5fbe27 -r 903b95002d4e dmd/PASS.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dmd/PASS.d Tue Aug 31 04:04:33 2010 +0200 @@ -0,0 +1,20 @@ +/** + * + */ +module dmd.PASS; + +/* State of symbol in winding its way through the passes of the compiler + */ +enum PASS +{ + PASSinit, // initial state + PASSsemantic, // semantic() started + PASSsemanticdone, // semantic() done + PASSsemantic2, // semantic2() run + PASSsemantic3, // semantic3() started + PASSsemantic3done, // semantic3() done + PASSobj, // toObjFile() run +} + +import dmd.EnumUtils; +mixin(BringToCurrentScope!(PASS)); \ No newline at end of file diff -r 5c859d5fbe27 -r 903b95002d4e dmd/TupleDeclaration.d --- a/dmd/TupleDeclaration.d Tue Aug 31 03:53:49 2010 +0200 +++ b/dmd/TupleDeclaration.d Tue Aug 31 04:04:33 2010 +0200 @@ -90,7 +90,7 @@ tupletype = new TypeTuple(args); if (hasdeco) - return tupletype.semantic(0, null); + return tupletype.semantic(Loc(0), null); } return tupletype; diff -r 5c859d5fbe27 -r 903b95002d4e main.d --- a/main.d Tue Aug 31 03:53:49 2010 +0200 +++ b/main.d Tue Aug 31 04:04:33 2010 +0200 @@ -1,5 +1,6 @@ module main; +import dmd.Macro; import dmd.Array; import dmd.Module; import dmd.Global;