Mercurial > projects > ldc
diff tango/lib/compiler/llvmdc/genobj.d @ 133:44a95ac7368a trunk
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
In particular, assertions has been fixed to include file/line info, and much more!
author | lindquist |
---|---|
date | Mon, 14 Jan 2008 05:11:54 +0100 |
parents | 1700239cab2e |
children | 7816aafeea3c |
line wrap: on
line diff
--- a/tango/lib/compiler/llvmdc/genobj.d Fri Jan 11 17:57:40 2008 +0100 +++ b/tango/lib/compiler/llvmdc/genobj.d Mon Jan 14 05:11:54 2008 +0100 @@ -37,6 +37,8 @@ module object; +//debug=PRINTF; + private { import tango.stdc.string; // : memcmp, memcpy; @@ -962,19 +964,8 @@ // linux: this gets initialized in _moduleCtor() extern (C) ModuleInfo[] _moduleinfo_array; - -version (linux) -{ - // This linked list is created by a compiler generated function inserted - // into the .ctor list by the compiler. - struct ModuleReference - { - ModuleReference* next; - ModuleInfo mod; - } - - extern (C) ModuleReference* _Dmodule_ref; // start of linked list -} +// llvmdc method +extern (C) void** _d_get_moduleinfo_array(); ModuleInfo[] _moduleinfo_dtors; uint _moduleinfo_dtors_i; @@ -989,19 +980,20 @@ extern (C) void _moduleCtor() { debug(PRINTF) printf("_moduleCtor()\n"); - version (linux) - { - int len = 0; - ModuleReference *mr; + + ModuleInfo* mrbegin = cast(ModuleInfo*)_d_get_moduleinfo_array(); + assert(mrbegin !is null); - for (mr = _Dmodule_ref; mr; mr = mr.next) - len++; - _moduleinfo_array = new ModuleInfo[len]; - len = 0; - for (mr = _Dmodule_ref; mr; mr = mr.next) - { _moduleinfo_array[len] = mr.mod; - len++; - } + int len = 0; + ModuleInfo* mr; + for (mr = mrbegin; *mr !is null; ++mr) + len++; + _moduleinfo_array = new ModuleInfo[len]; + + len = 0; + for (mr = mrbegin; *mr !is null; ++mr) + { _moduleinfo_array[len] = *mr; + len++; } version (Win32) @@ -1014,6 +1006,7 @@ debug(PRINTF) printf("_moduleinfo_dtors = x%x\n", cast(void *)_moduleinfo_dtors); _moduleIndependentCtors(); _moduleCtor2(_moduleinfo_array, 0); + debug(PRINTF) printf("_moduleCtor() DONE\n"); } extern (C) void _moduleIndependentCtors() @@ -1026,6 +1019,7 @@ (*m.ictor)(); } } + debug(PRINTF) printf("_moduleIndependentCtors() DONE\n"); } void _moduleCtor2(ModuleInfo[] mi, int skip) @@ -1038,10 +1032,10 @@ debug(PRINTF) printf("\tmodule[%d] = '%p'\n", i, m); if (!m) continue; - debug(PRINTF) printf("\tmodule[%d] = '%.*s'\n", i, m.name); + debug(PRINTF) printf("\tmodule[%d] = '%.*s'\n", i, m.name.length, m.name.ptr); if (m.flags & MIctordone) continue; - debug(PRINTF) printf("\tmodule[%d] = '%.*s', m = x%x\n", i, m.name, m); + debug(PRINTF) printf("\tmodule[%d] = '%.*s', m = x%x\n", i, m.name.length, m.name.ptr, m); if (m.ctor || m.dtor) { @@ -1069,6 +1063,7 @@ _moduleCtor2(m.importedModules, 1); } } + debug(PRINTF) printf("_moduleCtor2() DONE\n"); } /**