2 // Compiler implementation of the D programming language
3 // Copyright (c) 1999-2008 by Digital Mars
5 // written by Walter Bright
6 // http://www.digitalmars.com
7 // License for redistribution is by either the Artistic License
8 // in artistic.txt, or the GNU General Public License in gnu.txt.
9 // See the included readme.txt for details.
11 /* NOTE: This file has been patched from the original DMD distribution to
12 work with the GDC compiler.
14 Modified by David Friedman, January 2007
17 // Program to generate string files in d data structures.
18 // Saves much tedious typing, and eliminates typo problems.
31 char *ident
; // name to use in DMD source
32 char *name
; // name in D executable
35 struct Msgtable msgtable
[] =
44 { "cpctor", "_cpctor" },
46 { "_postblit", "_postblit" },
47 { "classInvariant", "__invariant" },
48 { "unitTest", "_unitTest" },
51 { "__sizeof", "sizeof" },
60 { "dollar", "__dollar" },
69 { "withSym", "__withSym" },
70 { "result", "__result" },
71 { "returnLabel", "__returnLabel" },
76 { "coverage", "__coverage" },
80 { "TypeInfo_Interface" },
81 { "TypeInfo_Struct" },
83 { "TypeInfo_Typedef" },
84 { "TypeInfo_Pointer" },
86 { "TypeInfo_StaticArray" },
87 { "TypeInfo_AssociativeArray" },
88 { "TypeInfo_Function" },
89 { "TypeInfo_Delegate" },
92 { "TypeInfo_Invariant" },
94 { "_arguments_typeinfo" },
101 { "LINE", "__LINE__" },
102 { "FILE", "__FILE__" },
103 { "DATE", "__DATE__" },
104 { "TIME", "__TIME__" },
105 { "TIMESTAMP", "__TIMESTAMP__" },
106 { "VENDOR", "__VENDOR__" },
107 { "VERSIONX", "__VERSION__" },
108 { "EOFX", "__EOF__" },
141 // For inline assembler
148 // For operator overloads
153 { "add_r", "opAdd_r" },
155 { "sub_r", "opSub_r" },
157 { "mul_r", "opMul_r" },
159 { "div_r", "opDiv_r" },
161 { "mod_r", "opMod_r" },
162 { "eq", "opEquals" },
165 { "iand_r", "opAnd_r" },
167 { "ior_r", "opOr_r" },
169 { "ixor_r", "opXor_r" },
171 { "shl_r", "opShl_r" },
173 { "shr_r", "opShr_r" },
174 { "ushr", "opUShr" },
175 { "ushr_r", "opUShr_r" },
177 { "cat_r", "opCat_r" },
178 { "assign", "opAssign" },
179 { "addass", "opAddAssign" },
180 { "subass", "opSubAssign" },
181 { "mulass", "opMulAssign" },
182 { "divass", "opDivAssign" },
183 { "modass", "opModAssign" },
184 { "andass", "opAndAssign" },
185 { "orass", "opOrAssign" },
186 { "xorass", "opXorAssign" },
187 { "shlass", "opShlAssign" },
188 { "shrass", "opShrAssign" },
189 { "ushrass", "opUShrAssign" },
190 { "catass", "opCatAssign" },
191 { "postinc", "opPostInc" },
192 { "postdec", "opPostDec" },
193 { "index", "opIndex" },
194 { "indexass", "opIndexAssign" },
195 { "slice", "opSlice" },
196 { "sliceass", "opSliceAssign" },
197 { "call", "opCall" },
198 { "cast", "opCast" },
199 { "match", "opMatch" },
200 { "next", "opNext" },
205 { "opImplicitCast" },
207 { "classNew", "new" },
208 { "classDelete", "delete" },
211 { "apply", "opApply" },
212 { "applyReverse", "opApplyReverse" },
214 { "adDup", "_adDupT" },
215 { "adReverse", "_adReverse" },
217 // For internal functions
218 { "aaLen", "_aaLen" },
219 { "aaKeys", "_aaKeys" },
220 { "aaValues", "_aaValues" },
221 { "aaRehash", "_aaRehash" },
226 { "GNU_set_attribute" },
231 // For special functions
232 { "tohash", "toHash" },
233 { "tostring", "toString" },
234 { "getmembers", "getMembers" },
252 { "isAbstractClass" },
254 { "isAssociativeArray" },
261 { "isVirtualFunction" },
262 { "isAbstractFunction" },
263 { "isFinalFunction" },
266 { "getVirtualFunctions" },
267 { "classInstanceSize" },
269 { "derivedMembers" },
281 fp
= fopen("id.h","w");
283 { printf("can't open id.h\n");
287 fprintf(fp
, "// File generated by idgen.c\n");
289 fprintf(fp
, "#pragma once\n");
291 fprintf(fp
, "#ifndef DMD_ID_H\n");
292 fprintf(fp
, "#define DMD_ID_H 1\n");
293 fprintf(fp
, "struct Identifier;\n");
294 fprintf(fp
, "struct Id\n");
297 for (i
= 0; i
< sizeof(msgtable
) / sizeof(msgtable
[0]); i
++)
298 { char *id
= msgtable
[i
].ident
;
300 fprintf(fp
," static Identifier *%s;\n", id
);
303 fprintf(fp
, " static void initialize();\n");
305 fprintf(fp
, "#endif\n");
311 fp
= fopen("id.c","w");
313 { printf("can't open id.c\n");
317 fprintf(fp
, "// File generated by idgen.c\n");
318 fprintf(fp
, "#include \"id.h\"\n");
319 fprintf(fp
, "#include \"identifier.h\"\n");
320 fprintf(fp
, "#include \"lexer.h\"\n");
322 for (i
= 0; i
< sizeof(msgtable
) / sizeof(msgtable
[0]); i
++)
323 { char *id
= msgtable
[i
].ident
;
324 char *p
= msgtable
[i
].name
;
328 fprintf(fp
,"Identifier *Id::%s;\n", id
);
331 fprintf(fp
, "void Id::initialize()\n");
334 for (i
= 0; i
< sizeof(msgtable
) / sizeof(msgtable
[0]); i
++)
335 { char *id
= msgtable
[i
].ident
;
336 char *p
= msgtable
[i
].name
;
340 fprintf(fp
," %s = Lexer::idPool(\"%s\");\n", id
, p
);