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