Mercurial > projects > ldc
changeset 956:369996c08420
Change the numbering of static ctors/dtors to be module based instead of being global.
This fixes #210 by making sure that the static ctor always gets the same
number, regardless of the order of the modules given at the command line.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sun, 15 Feb 2009 11:46:28 +0100 |
parents | 8a70b4381369 |
children | 31bbc7f3b817 |
files | dmd/func.c dmd/module.c dmd/module.h |
diffstat | 3 files changed, 18 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/dmd/func.c Sat Feb 14 21:18:47 2009 +0100 +++ b/dmd/func.c Sun Feb 15 11:46:28 2009 +0100 @@ -2420,7 +2420,7 @@ StaticCtorDeclaration::StaticCtorDeclaration(Loc loc, Loc endloc) : FuncDeclaration(loc, endloc, - Identifier::generateId("_staticCtor"), STCstatic, NULL) + Lexer::idPool("_staticCtor"), STCstatic, NULL) { } @@ -2438,6 +2438,9 @@ { //printf("StaticCtorDeclaration::semantic()\n"); + // get ourselves a scope-unique id + ident = sc->module->generateId(ident); + type = new TypeFunction(NULL, Type::tvoid, FALSE, LINKd); /* If the static ctor appears within a template instantiation, @@ -2521,7 +2524,7 @@ StaticDtorDeclaration::StaticDtorDeclaration(Loc loc, Loc endloc) : FuncDeclaration(loc, endloc, - Identifier::generateId("_staticDtor"), STCstatic, NULL) + Lexer::idPool("_staticDtor"), STCstatic, NULL) { vgate = NULL; } @@ -2538,6 +2541,9 @@ void StaticDtorDeclaration::semantic(Scope *sc) { + // get ourselves a scope-unique id + ident = sc->module->generateId(ident); + ClassDeclaration *cd; Type *tret;
--- a/dmd/module.c Sat Feb 14 21:18:47 2009 +0100 +++ b/dmd/module.c Sun Feb 15 11:46:28 2009 +0100 @@ -130,6 +130,7 @@ llvmForceLogging = false; this->doDocComment = doDocComment; this->doHdrGen = doHdrGen; + uniqueId = 0; } File* Module::buildFilePath(char* forcename, char* path, char* ext) @@ -1007,3 +1008,8 @@ } return dst; } + +Identifier* Module::generateId(Identifier* id) +{ + return Identifier::generateId(id->string, uniqueId++); +}