0
|
1 module dmd.Id;
|
|
2
|
|
3 import dmd.Identifier;
|
|
4 import dmd.Lexer;
|
|
5
|
99
|
6 struct Msgtable
|
0
|
7 {
|
99
|
8 string ident; // name to use in DMD source
|
|
9 string name_; // name in D executable
|
|
10 }
|
|
11
|
|
12 immutable Msgtable[100] msgtable =
|
|
13 [
|
|
14 { "IUnknown" },
|
|
15 { "Object_", "Object" },
|
|
16 { "object" },
|
|
17 { "max" },
|
|
18 { "min" },
|
|
19 { "This", "this" },
|
|
20 { "ctor", "__ctor" },
|
|
21 { "dtor", "__dtor" },
|
|
22 { "cpctor", "__cpctor" },
|
|
23 { "_postblit", "__postblit" },
|
|
24 { "classInvariant", "__invariant" },
|
|
25 { "unitTest", "__unitTest" },
|
|
26 { "require", "__require" },
|
|
27 { "ensure", "__ensure" },
|
|
28 { "init_", "init" },
|
|
29 { "size" },
|
|
30 { "__sizeof", "sizeof" },
|
|
31 { "alignof_", "alignof" },
|
|
32 { "mangleof_", "mangleof" },
|
|
33 { "stringof_", "stringof" },
|
|
34 { "tupleof_", "tupleof" },
|
|
35 { "length" },
|
|
36 { "remove" },
|
|
37 { "ptr" },
|
|
38 { "funcptr" },
|
|
39 { "dollar", "__dollar" },
|
|
40 { "offset" },
|
|
41 { "offsetof" },
|
|
42 { "ModuleInfo" },
|
|
43 { "ClassInfo" },
|
|
44 { "classinfo_", "classinfo" },
|
|
45 { "typeinfo_", "typeinfo" },
|
|
46 { "outer" },
|
|
47 { "Exception" },
|
|
48 { "AssociativeArray" },
|
|
49 { "Throwable" },
|
|
50 { "withSym", "__withSym" },
|
|
51 { "result", "__result" },
|
|
52 { "returnLabel", "__returnLabel" },
|
|
53 { "delegate_", "delegate" },
|
|
54 { "line" },
|
|
55 { "empty", "" },
|
|
56 { "p" },
|
|
57 { "coverage", "__coverage" },
|
|
58 { "__vptr" },
|
|
59 { "__monitor" },
|
|
60 { "system" },
|
|
61
|
|
62 { "TypeInfo" },
|
|
63 { "TypeInfo_Class" },
|
|
64 { "TypeInfo_Interface" },
|
|
65 { "TypeInfo_Struct" },
|
|
66 { "TypeInfo_Enum" },
|
|
67 { "TypeInfo_Typedef" },
|
|
68 { "TypeInfo_Pointer" },
|
|
69 { "TypeInfo_Array" },
|
|
70 { "TypeInfo_StaticArray" },
|
|
71 { "TypeInfo_AssociativeArray" },
|
|
72 { "TypeInfo_Function" },
|
|
73 { "TypeInfo_Delegate" },
|
|
74 { "TypeInfo_Tuple" },
|
|
75 { "TypeInfo_Const" },
|
|
76 { "TypeInfo_Invariant" },
|
|
77 { "TypeInfo_Shared" },
|
|
78 { "elements" },
|
|
79 { "_arguments_typeinfo" },
|
|
80 { "_arguments" },
|
|
81 { "_argptr" },
|
|
82 { "_match" },
|
|
83 { "destroy" },
|
|
84 { "_postblit", "__postblit" },
|
|
85
|
|
86 { "LINE", "__LINE__" },
|
|
87 { "FILE", "__FILE__" },
|
|
88 { "DATE", "__DATE__" },
|
|
89 { "TIME", "__TIME__" },
|
|
90 { "TIMESTAMP", "__TIMESTAMP__" },
|
|
91 { "VENDOR", "__VENDOR__" },
|
|
92 { "VERSIONX", "__VERSION__" },
|
|
93 { "EOFX", "__EOF__" },
|
|
94
|
|
95 { "nan" },
|
|
96 { "infinity" },
|
|
97 { "dig" },
|
|
98 { "epsilon" },
|
|
99 { "mant_dig" },
|
|
100 { "max_10_exp" },
|
|
101 { "max_exp" },
|
|
102 { "min_10_exp" },
|
|
103 { "min_exp" },
|
|
104 { "min_normal" },
|
|
105 { "re" },
|
|
106 { "im" },
|
|
107
|
|
108 { "C" },
|
|
109 { "D" },
|
|
110 { "Windows" },
|
|
111 { "Pascal" },
|
|
112 { "System" },
|
|
113
|
|
114 { "exit" },
|
|
115 { "success" },
|
|
116 { "failure" },
|
|
117
|
|
118 { "keys" },
|
|
119 { "values" },
|
|
120 { "rehash" },
|
|
121
|
|
122 { "sort" },
|
|
123 { "reverse" },
|
|
124 { "dup" },
|
|
125 { "idup" },
|
|
126
|
|
127 { "property" },
|
|
128
|
|
129 // For inline assembler
|
|
130 { "___out", "out" },
|
|
131 { "___in", "in" },
|
|
132 { "__int", "int" },
|
|
133 { "__dollar", "$" },
|
|
134 { "__LOCAL_SIZE" },
|
0
|
135
|
99
|
136 // For operator overloads
|
|
137 { "uadd", "opPos" },
|
|
138 { "neg", "opNeg" },
|
|
139 { "com", "opCom" },
|
|
140 { "add", "opAdd" },
|
|
141 { "add_r", "opAdd_r" },
|
|
142 { "sub", "opSub" },
|
|
143 { "sub_r", "opSub_r" },
|
|
144 { "mul", "opMul" },
|
|
145 { "mul_r", "opMul_r" },
|
|
146 { "div", "opDiv" },
|
|
147 { "div_r", "opDiv_r" },
|
|
148 { "mod", "opMod" },
|
|
149 { "mod_r", "opMod_r" },
|
|
150 { "eq", "opEquals" },
|
|
151 { "cmp", "opCmp" },
|
|
152 { "iand", "opAnd" },
|
|
153 { "iand_r", "opAnd_r" },
|
|
154 { "ior", "opOr" },
|
|
155 { "ior_r", "opOr_r" },
|
|
156 { "ixor", "opXor" },
|
|
157 { "ixor_r", "opXor_r" },
|
|
158 { "shl", "opShl" },
|
|
159 { "shl_r", "opShl_r" },
|
|
160 { "shr", "opShr" },
|
|
161 { "shr_r", "opShr_r" },
|
|
162 { "ushr", "opUShr" },
|
|
163 { "ushr_r", "opUShr_r" },
|
|
164 { "cat", "opCat" },
|
|
165 { "cat_r", "opCat_r" },
|
|
166 { "assign", "opAssign" },
|
|
167 { "addass", "opAddAssign" },
|
|
168 { "subass", "opSubAssign" },
|
|
169 { "mulass", "opMulAssign" },
|
|
170 { "divass", "opDivAssign" },
|
|
171 { "modass", "opModAssign" },
|
|
172 { "andass", "opAndAssign" },
|
|
173 { "orass", "opOrAssign" },
|
|
174 { "xorass", "opXorAssign" },
|
|
175 { "shlass", "opShlAssign" },
|
|
176 { "shrass", "opShrAssign" },
|
|
177 { "ushrass", "opUShrAssign" },
|
|
178 { "catass", "opCatAssign" },
|
|
179 { "postinc", "opPostInc" },
|
|
180 { "postdec", "opPostDec" },
|
|
181 { "index", "opIndex" },
|
|
182 { "indexass", "opIndexAssign" },
|
|
183 { "slice", "opSlice" },
|
|
184 { "sliceass", "opSliceAssign" },
|
|
185 { "call", "opCall" },
|
|
186 { "cast", "opCast" },
|
|
187 { "match", "opMatch" },
|
|
188 { "next", "opNext" },
|
|
189 { "opIn" },
|
|
190 { "opIn_r" },
|
|
191 { "opStar" },
|
|
192 { "opDot" },
|
|
193 { "opImplicitCast" },
|
|
194
|
|
195 { "classNew", "new" },
|
|
196 { "classDelete", "delete" },
|
|
197
|
|
198 // For foreach
|
|
199 { "apply", "opApply" },
|
|
200 { "applyReverse", "opApplyReverse" },
|
|
201
|
|
202 // #if 1
|
|
203 { "Fempty", "empty" },
|
|
204 { "Fhead", "front" },
|
|
205 { "Ftoe", "back" },
|
|
206 { "Fnext", "popFront" },
|
|
207 { "Fretreat", "popBack" },
|
|
208 /*#else
|
|
209 { "Fempty", "empty" },
|
|
210 { "Fhead", "head" },
|
|
211 { "Ftoe", "toe" },
|
|
212 { "Fnext", "next" },
|
|
213 { "Fretreat", "retreat" },
|
|
214 #endif*/
|
|
215
|
|
216 { "adDup", "_adDupT" },
|
|
217 { "adReverse", "_adReverse" },
|
|
218
|
|
219 // For internal functions
|
|
220 { "aaLen", "_aaLen" },
|
|
221 { "aaKeys", "_aaKeys" },
|
|
222 { "aaValues", "_aaValues" },
|
|
223 { "aaRehash", "_aaRehash" },
|
|
224 { "monitorenter", "_d_monitorenter" },
|
|
225 { "monitorexit", "_d_monitorexit" },
|
|
226 { "criticalenter", "_d_criticalenter" },
|
|
227 { "criticalexit", "_d_criticalexit" },
|
|
228
|
|
229 // For pragma's
|
|
230 { "GNU_asm" },
|
|
231 { "lib" },
|
|
232 { "msg" },
|
|
233 { "startaddress" },
|
|
234
|
|
235 // For special functions
|
|
236 { "tohash", "toHash" },
|
|
237 { "tostring", "toString" },
|
|
238 { "getmembers", "getMembers" },
|
|
239
|
|
240 // Special functions
|
|
241 { "alloca" },
|
|
242 { "main" },
|
|
243 { "WinMain" },
|
|
244 { "DllMain" },
|
|
245 { "tls_get_addr", "___tls_get_addr" },
|
|
246
|
|
247 // Builtin functions
|
|
248 { "std" },
|
|
249 { "math" },
|
|
250 { "sin" },
|
|
251 { "cos" },
|
|
252 { "tan" },
|
|
253 { "_sqrt", "sqrt" },
|
|
254 { "fabs" },
|
|
255
|
|
256 // Traits
|
|
257 { "isAbstractClass" },
|
|
258 { "isArithmetic" },
|
|
259 { "isAssociativeArray" },
|
|
260 { "isFinalClass" },
|
|
261 { "isFloating" },
|
|
262 { "isIntegral" },
|
|
263 { "isScalar" },
|
|
264 { "isStaticArray" },
|
|
265 { "isUnsigned" },
|
|
266 { "isVirtualFunction" },
|
|
267 { "isAbstractFunction" },
|
|
268 { "isFinalFunction" },
|
|
269 { "hasMember" },
|
|
270 { "getMember" },
|
|
271 { "getVirtualFunctions" },
|
|
272 { "classInstanceSize" },
|
|
273 { "allMembers" },
|
|
274 { "derivedMembers" },
|
|
275 { "isSame" },
|
|
276 { "compiles" },
|
|
277 ];
|
|
278 private string idgen()
|
|
279 {
|
|
280 string res = "struct Id\n{";
|
|
281
|
|
282 foreach(entry; msgtable)
|
|
283 res ~= "\tstatic Identifier " ~ entry.ident ~ ";\n";
|
|
284
|
|
285 res ~= "\tstatic void initialize()\n\t{\n";
|
|
286 string tmp;
|
|
287 foreach (entry; msgtable)
|
0
|
288 {
|
99
|
289 if (entry.name_ is null)
|
|
290 tmp = entry.ident;
|
|
291 else
|
|
292 tmp = entry.name_;
|
|
293 res ~= "\t\t" ~ entry.ident ~ ` = Lexer.idPool("` ~ tmp ~ "\");\n";
|
0
|
294 }
|
99
|
295
|
|
296 res ~= "\t}\n}";
|
|
297 return res;
|
|
298 }
|
|
299
|
|
300 mixin(idgen()); |