Mercurial > projects > ldc
comparison dmd/func.c @ 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 | 03d7c4aac654 |
children | 31bbc7f3b817 |
comparison
equal
deleted
inserted
replaced
955:8a70b4381369 | 956:369996c08420 |
---|---|
2418 | 2418 |
2419 /********************************* StaticCtorDeclaration ****************************/ | 2419 /********************************* StaticCtorDeclaration ****************************/ |
2420 | 2420 |
2421 StaticCtorDeclaration::StaticCtorDeclaration(Loc loc, Loc endloc) | 2421 StaticCtorDeclaration::StaticCtorDeclaration(Loc loc, Loc endloc) |
2422 : FuncDeclaration(loc, endloc, | 2422 : FuncDeclaration(loc, endloc, |
2423 Identifier::generateId("_staticCtor"), STCstatic, NULL) | 2423 Lexer::idPool("_staticCtor"), STCstatic, NULL) |
2424 { | 2424 { |
2425 } | 2425 } |
2426 | 2426 |
2427 Dsymbol *StaticCtorDeclaration::syntaxCopy(Dsymbol *s) | 2427 Dsymbol *StaticCtorDeclaration::syntaxCopy(Dsymbol *s) |
2428 { | 2428 { |
2435 | 2435 |
2436 | 2436 |
2437 void StaticCtorDeclaration::semantic(Scope *sc) | 2437 void StaticCtorDeclaration::semantic(Scope *sc) |
2438 { | 2438 { |
2439 //printf("StaticCtorDeclaration::semantic()\n"); | 2439 //printf("StaticCtorDeclaration::semantic()\n"); |
2440 | |
2441 // get ourselves a scope-unique id | |
2442 ident = sc->module->generateId(ident); | |
2440 | 2443 |
2441 type = new TypeFunction(NULL, Type::tvoid, FALSE, LINKd); | 2444 type = new TypeFunction(NULL, Type::tvoid, FALSE, LINKd); |
2442 | 2445 |
2443 /* If the static ctor appears within a template instantiation, | 2446 /* If the static ctor appears within a template instantiation, |
2444 * it could get called multiple times by the module constructors | 2447 * it could get called multiple times by the module constructors |
2519 | 2522 |
2520 /********************************* StaticDtorDeclaration ****************************/ | 2523 /********************************* StaticDtorDeclaration ****************************/ |
2521 | 2524 |
2522 StaticDtorDeclaration::StaticDtorDeclaration(Loc loc, Loc endloc) | 2525 StaticDtorDeclaration::StaticDtorDeclaration(Loc loc, Loc endloc) |
2523 : FuncDeclaration(loc, endloc, | 2526 : FuncDeclaration(loc, endloc, |
2524 Identifier::generateId("_staticDtor"), STCstatic, NULL) | 2527 Lexer::idPool("_staticDtor"), STCstatic, NULL) |
2525 { | 2528 { |
2526 vgate = NULL; | 2529 vgate = NULL; |
2527 } | 2530 } |
2528 | 2531 |
2529 Dsymbol *StaticDtorDeclaration::syntaxCopy(Dsymbol *s) | 2532 Dsymbol *StaticDtorDeclaration::syntaxCopy(Dsymbol *s) |
2536 } | 2539 } |
2537 | 2540 |
2538 | 2541 |
2539 void StaticDtorDeclaration::semantic(Scope *sc) | 2542 void StaticDtorDeclaration::semantic(Scope *sc) |
2540 { | 2543 { |
2544 // get ourselves a scope-unique id | |
2545 ident = sc->module->generateId(ident); | |
2546 | |
2541 ClassDeclaration *cd; | 2547 ClassDeclaration *cd; |
2542 Type *tret; | 2548 Type *tret; |
2543 | 2549 |
2544 cd = sc->scopesym->isClassDeclaration(); | 2550 cd = sc->scopesym->isClassDeclaration(); |
2545 if (!cd) | 2551 if (!cd) |