D Paste by h3
Description: DDL vs stack tracing
Hide line numbers

Create new paste
Post a reply
View replies

Paste:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
// ---- Plugin.d ----
class MyPlugin {
    char[] toString() {
        foo();
        return "I am a plugin object";
    }
    
    void foo() {
        bar();
    }
    
    void bar() {
        throw new Exception("zomg");
    }
}
// ----


// ---- Host.d ----
module Host;

private {
    import xf.linker.DefaultLinker;
    import tango.io.Stdout;
}

void main() {
    auto linker = createDefaultLinkerCfgString(`
        type    host        regex .*\.map
        type    lib            regex .*\.obj
        order    host        self
        order    lib            host self
        load    Host.map    .
    `);
    
    auto lib = linker.load("Plugin.obj", ".");
    auto pluginClass = lib.getClass!(Object, "Plugin.MyPlugin");
    pluginClass.newObject().toString();
}
// ----


/* ---- Output ----
> Host.exe
object.Exception: zomg
----------------
    at Plugin.MyPlugin.bar(Plugin.d:13) -9 [a1b66f]
    at Plugin.MyPlugin.foo(Plugin.d:9) -3 [a1b63b]
    at Plugin.MyPlugin.toString(Plugin.d:4) -3 [a1b617]
    at main(Host.d:20) -5 [40205d]
*/

Replies:
No replies posted yet