comparison dmd/Id.d @ 103:e6090d1aea7c

fixed dmd.Id + some small fixups
author Trass3r
date Tue, 31 Aug 2010 16:22:22 +0200
parents 903b95002d4e
children e28b18c23469
comparison
equal deleted inserted replaced
99:903b95002d4e 103:e6090d1aea7c
1 module dmd.Id; 1 module dmd.Id;
2 2
3 import dmd.Identifier; 3 import dmd.Identifier;
4 import dmd.Lexer; 4 import dmd.Lexer;
5 5
6 struct Msgtable 6 private string idgen(T...)(T ts)
7 { 7 {
8 string ident; // name to use in DMD source 8 string res = "struct Id\n{\n";
9 string name_; // name in D executable 9
10 } 10 foreach(entry; ts)
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" },
135
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"; 11 res ~= "\tstatic Identifier " ~ entry.ident ~ ";\n";
284 12
285 res ~= "\tstatic void initialize()\n\t{\n"; 13 res ~= "\tstatic void initialize()\n\t{\n";
286 string tmp; 14 string tmp;
287 foreach (entry; msgtable) 15 foreach (entry; ts)
288 { 16 {
289 if (entry.name_ is null) 17 if (entry.name_ is null)
290 tmp = entry.ident; 18 tmp = entry.ident;
291 else 19 else
292 tmp = entry.name_; 20 tmp = entry.name_;
295 23
296 res ~= "\t}\n}"; 24 res ~= "\t}\n}";
297 return res; 25 return res;
298 } 26 }
299 27
300 mixin(idgen()); 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 ));