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" },
84 { "TypeInfo_StaticArray" },
85 { "TypeInfo_AssociativeArray" },
86 { "TypeInfo_Function" },
87 { "TypeInfo_Delegate" },
90 { "TypeInfo_Invariant" },
92 { "_arguments_typeinfo" },
97 { "LINE", "__LINE__" },
98 { "FILE", "__FILE__" },
99 { "DATE", "__DATE__" },
100 { "TIME", "__TIME__" },
101 { "TIMESTAMP", "__TIMESTAMP__" },
102 { "VENDOR", "__VENDOR__" },
103 { "VERSIONX", "__VERSION__" },
136 // For inline assembler
143 // For operator overloads
148 { "add_r", "opAdd_r" },
150 { "sub_r", "opSub_r" },
152 { "mul_r", "opMul_r" },
154 { "div_r", "opDiv_r" },
156 { "mod_r", "opMod_r" },
157 { "eq", "opEquals" },
160 { "iand_r", "opAnd_r" },
162 { "ior_r", "opOr_r" },
164 { "ixor_r", "opXor_r" },
166 { "shl_r", "opShl_r" },
168 { "shr_r", "opShr_r" },
169 { "ushr", "opUShr" },
170 { "ushr_r", "opUShr_r" },
172 { "cat_r", "opCat_r" },
173 { "assign", "opAssign" },
174 { "addass", "opAddAssign" },
175 { "subass", "opSubAssign" },
176 { "mulass", "opMulAssign" },
177 { "divass", "opDivAssign" },
178 { "modass", "opModAssign" },
179 { "andass", "opAndAssign" },
180 { "orass", "opOrAssign" },
181 { "xorass", "opXorAssign" },
182 { "shlass", "opShlAssign" },
183 { "shrass", "opShrAssign" },
184 { "ushrass", "opUShrAssign" },
185 { "catass", "opCatAssign" },
186 { "postinc", "opPostInc" },
187 { "postdec", "opPostDec" },
188 { "index", "opIndex" },
189 { "indexass", "opIndexAssign" },
190 { "slice", "opSlice" },
191 { "sliceass", "opSliceAssign" },
192 { "call", "opCall" },
193 { "cast", "opCast" },
194 { "match", "opMatch" },
195 { "next", "opNext" },
199 { "classNew", "new" },
200 { "classDelete", "delete" },
203 { "apply", "opApply" },
204 { "applyReverse", "opApplyReverse" },
206 { "adDup", "_adDupT" },
207 { "adReverse", "_adReverse" },
209 // For internal functions
210 { "aaLen", "_aaLen" },
211 { "aaKeys", "_aaKeys" },
212 { "aaValues", "_aaValues" },
213 { "aaRehash", "_aaRehash" },
222 { "GNU_set_attribute" },
224 // For toHash/toString
225 { "tohash", "toHash" },
226 { "tostring", "toString" },
245 fp
= fopen("id.h","w");
247 { printf("can't open id.h\n");
251 fprintf(fp
, "// File generated by idgen.c\n");
253 fprintf(fp
, "#pragma once\n");
255 fprintf(fp
, "#ifndef DMD_ID_H\n");
256 fprintf(fp
, "#define DMD_ID_H 1\n");
257 fprintf(fp
, "struct Identifier;\n");
258 fprintf(fp
, "struct Id\n");
261 for (i
= 0; i
< sizeof(msgtable
) / sizeof(msgtable
[0]); i
++)
262 { char *id
= msgtable
[i
].ident
;
264 fprintf(fp
," static Identifier *%s;\n", id
);
267 fprintf(fp
, " static void initialize();\n");
269 fprintf(fp
, "#endif\n");
275 fp
= fopen("id.c","w");
277 { printf("can't open id.c\n");
281 fprintf(fp
, "// File generated by idgen.c\n");
282 fprintf(fp
, "#include \"id.h\"\n");
283 fprintf(fp
, "#include \"identifier.h\"\n");
284 fprintf(fp
, "#include \"lexer.h\"\n");
286 for (i
= 0; i
< sizeof(msgtable
) / sizeof(msgtable
[0]); i
++)
287 { char *id
= msgtable
[i
].ident
;
288 char *p
= msgtable
[i
].name
;
292 fprintf(fp
,"Identifier *Id::%s;\n", id
);
295 fprintf(fp
, "void Id::initialize()\n");
298 for (i
= 0; i
< sizeof(msgtable
) / sizeof(msgtable
[0]); i
++)
299 { char *id
= msgtable
[i
].ident
;
300 char *p
= msgtable
[i
].name
;
304 fprintf(fp
," %s = Lexer::idPool(\"%s\");\n", id
, p
);