comparison dmd/idgen.c @ 658:50383e476c7e

Upgraded frontend to DMD 1.035
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Mon, 06 Oct 2008 16:22:11 +0200
parents a34078905d01
children 6aaa3d3c1183
comparison
equal deleted inserted replaced
657:c42173b3557b 658:50383e476c7e
1 1
2 // Compiler implementation of the D programming language 2 // Compiler implementation of the D programming language
3 // Copyright (c) 1999-2006 by Digital Mars 3 // Copyright (c) 1999-2008 by Digital Mars
4 // All Rights Reserved 4 // All Rights Reserved
5 // written by Walter Bright 5 // written by Walter Bright
6 // http://www.digitalmars.com 6 // http://www.digitalmars.com
7 // License for redistribution is by either the Artistic License 7 // License for redistribution is by either the Artistic License
8 // in artistic.txt, or the GNU General Public License in gnu.txt. 8 // in artistic.txt, or the GNU General Public License in gnu.txt.
20 #include <stdarg.h> 20 #include <stdarg.h>
21 #include <assert.h> 21 #include <assert.h>
22 22
23 struct Msgtable 23 struct Msgtable
24 { 24 {
25 char *ident; // name to use in DMD source 25 const char *ident; // name to use in DMD source
26 char *name; // name in D executable 26 const char *name; // name in D executable
27 }; 27 };
28 28
29 Msgtable msgtable[] = 29 Msgtable msgtable[] =
30 { 30 {
31 { "IUnknown" }, 31 { "IUnknown" },
207 { "aaKeys", "_aaKeys" }, 207 { "aaKeys", "_aaKeys" },
208 { "aaValues", "_aaValues" }, 208 { "aaValues", "_aaValues" },
209 { "aaRehash", "_aaRehash" }, 209 { "aaRehash", "_aaRehash" },
210 210
211 // For pragma's 211 // For pragma's
212 { "GNU_asm" },
212 { "lib" }, 213 { "lib" },
213 { "msg" }, 214 { "msg" },
214 { "GNU_asm" },
215 215
216 // LLVMDC pragma's 216 // LLVMDC pragma's
217 { "intrinsic" }, 217 { "intrinsic" },
218 { "va_intrinsic" }, 218 { "va_intrinsic" },
219 { "no_typeinfo" }, 219 { "no_typeinfo" },
223 { "vacopy", "va_copy" }, 223 { "vacopy", "va_copy" },
224 { "vaend", "va_end" }, 224 { "vaend", "va_end" },
225 { "vaarg", "va_arg" }, 225 { "vaarg", "va_arg" },
226 { "llvmdc" }, 226 { "llvmdc" },
227 227
228 // For toHash/toString 228 // For special functions
229 { "tohash", "toHash" }, 229 { "tohash", "toHash" },
230 { "tostring", "toString" }, 230 { "tostring", "toString" },
231 231
232 // Special functions 232 // Special functions
233 //{ "alloca" }, 233 //{ "alloca" },
258 fprintf(fp, "struct Identifier;\n"); 258 fprintf(fp, "struct Identifier;\n");
259 fprintf(fp, "struct Id\n"); 259 fprintf(fp, "struct Id\n");
260 fprintf(fp, "{\n"); 260 fprintf(fp, "{\n");
261 261
262 for (i = 0; i < sizeof(msgtable) / sizeof(msgtable[0]); i++) 262 for (i = 0; i < sizeof(msgtable) / sizeof(msgtable[0]); i++)
263 { char *id = msgtable[i].ident; 263 { const char *id = msgtable[i].ident;
264 264
265 fprintf(fp," static Identifier *%s;\n", id); 265 fprintf(fp," static Identifier *%s;\n", id);
266 } 266 }
267 267
268 fprintf(fp, " static void initialize();\n"); 268 fprintf(fp, " static void initialize();\n");
283 fprintf(fp, "#include \"id.h\"\n"); 283 fprintf(fp, "#include \"id.h\"\n");
284 fprintf(fp, "#include \"identifier.h\"\n"); 284 fprintf(fp, "#include \"identifier.h\"\n");
285 fprintf(fp, "#include \"lexer.h\"\n"); 285 fprintf(fp, "#include \"lexer.h\"\n");
286 286
287 for (i = 0; i < sizeof(msgtable) / sizeof(msgtable[0]); i++) 287 for (i = 0; i < sizeof(msgtable) / sizeof(msgtable[0]); i++)
288 { char *id = msgtable[i].ident; 288 { const char *id = msgtable[i].ident;
289 char *p = msgtable[i].name; 289 const char *p = msgtable[i].name;
290 290
291 if (!p) 291 if (!p)
292 p = id; 292 p = id;
293 fprintf(fp,"Identifier *Id::%s;\n", id); 293 fprintf(fp,"Identifier *Id::%s;\n", id);
294 } 294 }
295 295
296 fprintf(fp, "void Id::initialize()\n"); 296 fprintf(fp, "void Id::initialize()\n");
297 fprintf(fp, "{\n"); 297 fprintf(fp, "{\n");
298 298
299 for (i = 0; i < sizeof(msgtable) / sizeof(msgtable[0]); i++) 299 for (i = 0; i < sizeof(msgtable) / sizeof(msgtable[0]); i++)
300 { char *id = msgtable[i].ident; 300 { const char *id = msgtable[i].ident;
301 char *p = msgtable[i].name; 301 const char *p = msgtable[i].name;
302 302
303 if (!p) 303 if (!p)
304 p = id; 304 p = id;
305 fprintf(fp," %s = Lexer::idPool(\"%s\");\n", id, p); 305 fprintf(fp," %s = Lexer::idPool(\"%s\");\n", id, p);
306 } 306 }