Mercurial > projects > ddmd
view dmd/Id.d @ 99:903b95002d4e
Id and Macro are quite experimental currently
author | Trass3r |
---|---|
date | Tue, 31 Aug 2010 04:04:33 +0200 |
parents | ef02e2e203c2 |
children | e6090d1aea7c |
line wrap: on
line source
module dmd.Id; import dmd.Identifier; import dmd.Lexer; struct Msgtable { 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" }, // 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) { if (entry.name_ is null) tmp = entry.ident; else tmp = entry.name_; res ~= "\t\t" ~ entry.ident ~ ` = Lexer.idPool("` ~ tmp ~ "\");\n"; } res ~= "\t}\n}"; return res; } mixin(idgen());