Mercurial > projects > ddmd
comparison dmd/Module.d @ 169:e7769d53e750
Moves static variables from Module to Global
author | korDen |
---|---|
date | Thu, 30 Sep 2010 13:29:54 +0400 |
parents | 010eb8f0e18d |
children | 96c0fff6897d |
comparison
equal
deleted
inserted
replaced
168:ceed63f310fb | 169:e7769d53e750 |
---|---|
162 CFPREFIX = (CFSEG | CFopsize | CFaddrsize), | 162 CFPREFIX = (CFSEG | CFopsize | CFaddrsize), |
163 } | 163 } |
164 | 164 |
165 class Module : Package | 165 class Module : Package |
166 { | 166 { |
167 static Module rootModule; | |
168 static DsymbolTable modules; // symbol table of all modules | |
169 static Array amodules; // array of all modules | |
170 static Array deferred; // deferred Dsymbol's needing semantic() run on them | |
171 static uint dprogress; // progress resolving the deferred list | |
172 | |
173 static void init() | |
174 { | |
175 modules = new DsymbolTable(); | |
176 amodules = new Array(); | |
177 deferred = new Array(); | |
178 } | |
179 | |
180 static ClassDeclaration moduleinfo; | |
181 | |
182 | |
183 string arg; // original argument name | 167 string arg; // original argument name |
184 ModuleDeclaration md; // if !null, the contents of the ModuleDeclaration declaration | 168 ModuleDeclaration md; // if !null, the contents of the ModuleDeclaration declaration |
185 File srcfile; // input source file | 169 File srcfile; // input source file |
186 File objfile; // output .obj file | 170 File objfile; // output .obj file |
187 File hdrfile; // 'header' file | 171 File hdrfile; // 'header' file |
685 this.safe = md.safe; | 669 this.safe = md.safe; |
686 dst = super.resolve(md.packages, &this.parent, null); | 670 dst = super.resolve(md.packages, &this.parent, null); |
687 } | 671 } |
688 else | 672 else |
689 { | 673 { |
690 dst = modules; | 674 dst = global.modules; |
691 | 675 |
692 /* Check to see if module name is a valid identifier | 676 /* Check to see if module name is a valid identifier |
693 */ | 677 */ |
694 if (!Lexer.isValidIdentifier(this.ident.toChars())) | 678 if (!Lexer.isValidIdentifier(this.ident.toChars())) |
695 error("has non-identifier characters in filename, use module declaration instead"); | 679 error("has non-identifier characters in filename, use module declaration instead"); |
703 else | 687 else |
704 error(loc, "is in multiple defined"); | 688 error(loc, "is in multiple defined"); |
705 } | 689 } |
706 else | 690 else |
707 { | 691 { |
708 amodules.push(cast(void*)this); | 692 global.amodules.push(cast(void*)this); |
709 } | 693 } |
710 } | 694 } |
711 } | 695 } |
712 | 696 |
713 override void importAll(Scope prevsc) | 697 override void importAll(Scope prevsc) |
821 //printf("-Module.semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); | 805 //printf("-Module.semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); |
822 } | 806 } |
823 | 807 |
824 void semantic2() // pass 2 semantic analysis | 808 void semantic2() // pass 2 semantic analysis |
825 { | 809 { |
810 auto deferred = global.deferred; | |
826 if (deferred.dim) | 811 if (deferred.dim) |
827 { | 812 { |
828 for (int i = 0; i < deferred.dim; i++) | 813 for (int i = 0; i < deferred.dim; i++) |
829 { | 814 { |
830 Dsymbol sd = cast(Dsymbol)deferred.data[i]; | 815 Dsymbol sd = cast(Dsymbol)deferred.data[i]; |
1280 /******************************************* | 1265 /******************************************* |
1281 * Can't run semantic on s now, try again later. | 1266 * Can't run semantic on s now, try again later. |
1282 */ | 1267 */ |
1283 void addDeferredSemantic(Dsymbol s) | 1268 void addDeferredSemantic(Dsymbol s) |
1284 { | 1269 { |
1270 auto deferred = global.deferred; | |
1285 // Don't add it if it is already there | 1271 // Don't add it if it is already there |
1286 for (int i = 0; i < deferred.dim; i++) | 1272 for (int i = 0; i < deferred.dim; i++) |
1287 { | 1273 { |
1288 Dsymbol sd = cast(Dsymbol)deferred.data[i]; | 1274 Dsymbol sd = cast(Dsymbol)deferred.data[i]; |
1289 | 1275 |
1307 if (nested) | 1293 if (nested) |
1308 return; | 1294 return; |
1309 //if (deferred.dim) printf("+Module.runDeferredSemantic('%s'), len = %d\n", toChars(), deferred.dim); | 1295 //if (deferred.dim) printf("+Module.runDeferredSemantic('%s'), len = %d\n", toChars(), deferred.dim); |
1310 nested++; | 1296 nested++; |
1311 | 1297 |
1298 auto deferred = global.deferred; | |
1299 | |
1312 do | 1300 do |
1313 { | 1301 { |
1314 dprogress = 0; | 1302 global.dprogress = 0; |
1315 len = deferred.dim; | 1303 len = deferred.dim; |
1316 if (!len) | 1304 if (!len) |
1317 break; | 1305 break; |
1318 | 1306 |
1319 Dsymbol *todo; | 1307 Dsymbol *todo; |
1339 | 1327 |
1340 s.semantic(null); | 1328 s.semantic(null); |
1341 //printf("deferred: %s, parent = %s\n", s.toChars(), s.parent.toChars()); | 1329 //printf("deferred: %s, parent = %s\n", s.toChars(), s.parent.toChars()); |
1342 } | 1330 } |
1343 //printf("\tdeferred.dim = %d, len = %d, dprogress = %d\n", deferred.dim, len, dprogress); | 1331 //printf("\tdeferred.dim = %d, len = %d, dprogress = %d\n", deferred.dim, len, dprogress); |
1344 } while (deferred.dim < len || dprogress); // while making progress | 1332 } while (deferred.dim < len || global.dprogress); // while making progress |
1345 nested--; | 1333 nested--; |
1346 //printf("-Module.runDeferredSemantic('%s'), len = %d\n", toChars(), deferred.dim); | 1334 //printf("-Module.runDeferredSemantic('%s'), len = %d\n", toChars(), deferred.dim); |
1347 } | 1335 } |
1348 | 1336 |
1349 /************************************ | 1337 /************************************ |
1564 void*[4] reserved; | 1552 void*[4] reserved; |
1565 } | 1553 } |
1566 */ | 1554 */ |
1567 dt_t* dt = null; | 1555 dt_t* dt = null; |
1568 | 1556 |
1569 if (moduleinfo) | 1557 if (global.moduleinfo) |
1570 dtxoff(&dt, moduleinfo.toVtblSymbol(), 0, TYM.TYnptr); // vtbl for ModuleInfo | 1558 dtxoff(&dt, global.moduleinfo.toVtblSymbol(), 0, TYM.TYnptr); // vtbl for ModuleInfo |
1571 else | 1559 else |
1572 { | 1560 { |
1573 //printf("moduleinfo is null\n"); | 1561 //printf("moduleinfo is null\n"); |
1574 dtdword(&dt, 0); // BUG: should be an assert() | 1562 dtdword(&dt, 0); // BUG: should be an assert() |
1575 } | 1563 } |