Changeset 295
- Timestamp:
- 04/21/08 06:52:37 (8 months ago)
- Files:
-
- trunk/ddl/ExportClass.d (modified) (5 diffs)
- trunk/ddl/Linker.d (modified) (6 diffs)
- trunk/etc/zlib.d (added)
- trunk/examples/quick/bnr.bat (added)
- trunk/utils/bless_bn.d (modified) (1 diff)
- trunk/utils/ddlinfo_bn.d (modified) (1 diff)
- trunk/utils/insitu_bn.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ddl/ExportClass.d
r292 r295 45 45 46 46 this(ClassInfo classInfo, char[] name, DynamicLibrary lib) { 47 if (name.length > 2 && name[0..2] == "_D") { 48 name = name[2..$]; 49 } 50 47 51 this.classInfo = classInfo; 48 52 this.name = name; … … 61 65 auto ctor = cast(Object function (Object)) dynamicLib.getSymbol( 62 66 "_D" ~ name ~ mangleSymbolName!("_ctor") 63 ~ " F"67 ~ "MF" 64 68 ~ "ZC" ~ name).address; 65 69 … … 69 73 auto Regex ctorMatch = new Regex( 70 74 `^_D` ~ name ~ mangleSymbolName!("_ctor") 71 ~ ` F` ~ `.*`75 ~ `MF` ~ `.*` 72 76 ~ `ZC` ~ name ~ `$`); 73 77 … … 85 89 return cast(baseType)obj; 86 90 } 91 92 baseType newObject(P...)(P p) { 93 assert (!isAbstract); 87 94 88 baseType newObject(P1)(P1 p1) { 95 char[] symName = "_D" ~ name ~ mangleSymbolName!("_ctor") ~ "MF"; 96 foreach (par; P) { 97 symName ~= par.mangleof; 98 } 99 symName ~= "ZC" ~ name; 100 auto ctor = cast(Object function (P, Object)) dynamicLib.getSymbol(symName).address; 101 assert (ctor !is null, symName); 102 103 auto obj = _d_newclass(classInfo); 104 ctor(p, obj); 105 return cast(baseType)obj; 106 } 107 108 /+baseType newObject(P1)(P1 p1) { 89 109 assert (!isAbstract); 90 110 91 111 auto ctor = cast(Object function (P1, Object)) dynamicLib.getSymbol( 92 112 "_D" ~ name ~ mangleSymbolName!("_ctor") 93 ~ " F" ~ P1.mangleof113 ~ "MF" ~ P1.mangleof 94 114 ~ "ZC" ~ name).address; 95 115 assert (ctor !is null); … … 104 124 assert (!isAbstract); 105 125 106 auto ctor = cast(Object function (P1, P2, Object)) dynamicLib.getSymbol( 126 char[] symName = 107 127 "_D" ~ name ~ mangleSymbolName!("_ctor") 108 ~ "F" ~ P1.mangleof ~ P2.mangleof 109 ~ "ZC" ~ name).address; 110 assert (ctor !is null); 128 ~ "MF" ~ P1.mangleof ~ P2.mangleof 129 ~ "ZC" ~ name; 130 131 auto ctor = cast(Object function (P1, P2, Object)) dynamicLib.getSymbol(symName).address; 132 assert (ctor !is null, symName); 111 133 112 134 auto obj = _d_newclass(classInfo); 113 135 ctor(p1, p2, obj); 114 136 return cast(baseType)obj; 115 } 137 } +/ 116 138 } trunk/ddl/Linker.d
r294 r295 96 96 } 97 97 98 99 100 struct LinkerBehavior { 101 bool runModuleCtors = true; 102 bool replaceStrongSymbols = false; 103 bool delegate(DynamicModule mod, ExportSymbol sym, DynamicModule otherMod, ExportSymbol otherSym) shouldReplaceSymbol; 104 } 105 106 107 98 108 /** 99 109 General-Purpose runtime linker for DDL. 100 110 */ 101 111 class Linker{ 102 public bool autoRunModuleCtors = true;112 public LinkerBehavior behavior;// bool autoRunModuleCtors = true; 103 113 104 114 … … 247 257 alias ModuleInfo[char[]] ModuleSet; 248 258 249 public void link(DynamicModule mod, inout ModuleSet moduleSet, bool canSelfResolve ){259 public void link(DynamicModule mod, inout ModuleSet moduleSet, bool canSelfResolve, int callDepth = 0) { 250 260 if (mod.isLinking) { 251 261 return; … … 257 267 auto modSymbols = mod.getSymbols(); 258 268 symbolIter: foreach (ref sym; modSymbols) { 259 if (SymbolType.Strong == sym.type) { 269 // outsource all symbols when commented out 270 // this is equivalent to ignoring multiple symbol definitions and choosing the 'first' one 271 // should probably be driven by some flexible linking mechanism 272 273 if (SymbolType.Strong == sym.type && (!behavior.replaceStrongSymbols || callDepth > 0)) { 260 274 continue; 261 275 } … … 270 284 271 285 if (!otherMod.isResolved) { 272 this.link(otherMod, moduleSet, true );286 this.link(otherMod, moduleSet, true, callDepth+1); 273 287 } 274 288 275 289 auto otherSym = otherMod.getSymbol(sym.name); 276 290 277 if (SymbolType.Unresolved != otherSym.type) {278 /+if (291 //if (SymbolType.Unresolved != otherSym.type) { 292 if ( 279 293 SymbolType.Strong == otherSym.type 280 294 || (SymbolType.Weak == otherSym.type && SymbolType.Unresolved == sym.type) 281 ) {+/ 282 sym.address = otherSym.address; 283 sym.type = SymbolType.Strong; 284 sym.isExternal = true; 285 continue symbolIter; 295 ) { 296 if (behavior.shouldReplaceSymbol is null || behavior.shouldReplaceSymbol(mod, sym, otherMod, *otherSym)) { 297 /+printf("Binding %.*s symbol %.*s :: %.*s to %.*s symbol %.*s :: %.*s"\n, 298 sym.getTypeName, mod.getName, sym.name, 299 otherSym.getTypeName, otherMod.getName, otherSym.name);+/ 300 sym.address = otherSym.address; 301 sym.type = otherSym.type;//SymbolType.Strong; 302 sym.isExternal = true; 303 continue symbolIter; 304 } 286 305 } 287 306 } … … 313 332 if (sym.name.length > suffix.length && sym.name[$ - suffix.length .. $] == suffix) { 314 333 debug debugLog("Found moduleinfo for {0} at [{1:8X}] {2}", mod.getName, sym.address, sym.name); 334 //printf("Found moduleinfo for %.*s at %d %.*s"\n, mod.getName, sym.address, sym.name); 315 335 moduleSet[sym.name] = cast(ModuleInfo)(sym.address); 316 336 } … … 493 513 +/ 494 514 495 if ( autoRunModuleCtors) {515 if (behavior.runModuleCtors) { 496 516 runModuleCtors(moduleSet); 497 517 } trunk/utils/bless_bn.d
r292 r295 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 7 69;4 long auto_build_number = 770; trunk/utils/ddlinfo_bn.d
r292 r295 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 8 49;4 long auto_build_number = 850; trunk/utils/insitu_bn.d
r292 r295 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 76 6;4 long auto_build_number = 767;
