2 // Compiler implementation of the D programming language
3 // Copyright (c) 1999-2006 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
[] =
45 { "classInvariant", "__invariant" },
46 { "unitTest", "_unitTest" },
49 { "__sizeof", "sizeof" },
58 { "dollar", "__dollar" },
67 { "withSym", "__withSym" },
68 { "result", "__result" },
69 { "returnLabel", "__returnLabel" },
74 { "coverage", "__coverage" },
78 { "TypeInfo_Interface" },
79 { "TypeInfo_Struct" },
81 { "TypeInfo_Typedef" },
82 { "TypeInfo_Pointer" },
85 { "TypeInfo_StaticArray" },
86 { "TypeInfo_AssociativeArray" },
87 { "TypeInfo_Function" },
88 { "TypeInfo_Delegate" },
91 { "TypeInfo_Invariant" },
93 { "_arguments_typeinfo" },
98 { "LINE", "__LINE__" },
99 { "FILE", "__FILE__" },
100 { "DATE", "__DATE__" },
101 { "TIME", "__TIME__" },
102 { "TIMESTAMP", "__TIMESTAMP__" },
103 { "VENDOR", "__VENDOR__" },
104 { "VERSIONX", "__VERSION__" },
137 // For inline assembler
144 // For operator overloads
149 { "add_r", "opAdd_r" },
151 { "sub_r", "opSub_r" },
153 { "mul_r", "opMul_r" },
155 { "div_r", "opDiv_r" },
157 { "mod_r", "opMod_r" },
158 { "eq", "opEquals" },
161 { "iand_r", "opAnd_r" },
163 { "ior_r", "opOr_r" },
165 { "ixor_r", "opXor_r" },
167 { "shl_r", "opShl_r" },
169 { "shr_r", "opShr_r" },
170 { "ushr", "opUShr" },
171 { "ushr_r", "opUShr_r" },
173 { "cat_r", "opCat_r" },
174 { "assign", "opAssign" },
175 { "addass", "opAddAssign" },
176 { "subass", "opSubAssign" },
177 { "mulass", "opMulAssign" },
178 { "divass", "opDivAssign" },
179 { "modass", "opModAssign" },
180 { "andass", "opAndAssign" },
181 { "orass", "opOrAssign" },
182 { "xorass", "opXorAssign" },
183 { "shlass", "opShlAssign" },
184 { "shrass", "opShrAssign" },
185 { "ushrass", "opUShrAssign" },
186 { "catass", "opCatAssign" },
187 { "postinc", "opPostInc" },
188 { "postdec", "opPostDec" },
189 { "index", "opIndex" },
190 { "indexass", "opIndexAssign" },
191 { "slice", "opSlice" },
192 { "sliceass", "opSliceAssign" },
193 { "call", "opCall" },
194 { "cast", "opCast" },
195 { "match", "opMatch" },
196 { "next", "opNext" },
200 { "classNew", "new" },
201 { "classDelete", "delete" },
204 { "apply", "opApply" },
205 { "applyReverse", "opApplyReverse" },
207 { "adDup", "_adDupT" },
208 { "adReverse", "_adReverse" },
210 // For internal functions
211 { "aaLen", "_aaLen" },
212 { "aaKeys", "_aaKeys" },
213 { "aaValues", "_aaValues" },
214 { "aaRehash", "_aaRehash" },
223 { "__log" }, // dlt.core.__log
230 { "GNU_set_attribute" },
232 // For toHash/toString
233 { "tohash", "toHash" },
234 { "tostring", "toString" },
253 fp
= fopen("id.h","w");
255 { printf("can't open id.h\n");
259 fprintf(fp
, "// File generated by idgen.c\n");
261 fprintf(fp
, "#pragma once\n");
263 fprintf(fp
, "#ifndef DMD_ID_H\n");
264 fprintf(fp
, "#define DMD_ID_H 1\n");
265 fprintf(fp
, "struct Identifier;\n");
266 fprintf(fp
, "struct Id\n");
269 for (i
= 0; i
< sizeof(msgtable
) / sizeof(msgtable
[0]); i
++)
270 { char *id
= msgtable
[i
].ident
;
272 fprintf(fp
," static Identifier *%s;\n", id
);
275 fprintf(fp
, " static void initialize();\n");
277 fprintf(fp
, "#endif\n");
283 fp
= fopen("id.c","w");
285 { printf("can't open id.c\n");
289 fprintf(fp
, "// File generated by idgen.c\n");
290 fprintf(fp
, "#include \"id.h\"\n");
291 fprintf(fp
, "#include \"identifier.h\"\n");
292 fprintf(fp
, "#include \"lexer.h\"\n");
294 for (i
= 0; i
< sizeof(msgtable
) / sizeof(msgtable
[0]); i
++)
295 { char *id
= msgtable
[i
].ident
;
296 char *p
= msgtable
[i
].name
;
300 fprintf(fp
,"Identifier *Id::%s;\n", id
);
303 fprintf(fp
, "void Id::initialize()\n");
306 for (i
= 0; i
< sizeof(msgtable
) / sizeof(msgtable
[0]); i
++)
307 { char *id
= msgtable
[i
].ident
;
308 char *p
= msgtable
[i
].name
;
312 fprintf(fp
," %s = Lexer::idPool(\"%s\");\n", id
, p
);