nasser / magic

Morgan And Grand Iron Clojure
http://nas.sr/magic/
365 stars 18 forks source link

Compile Init types into .clj.dll files #158

Closed nasser closed 4 years ago

nasser commented 4 years ago

ClojureCLR looks for a specially named init type when loading a namespace from a compiled dll file. For compatibility and simplicity MAGIC should produce the same thing.

for a namespace named foo ClojureCLR produces the following

public class __Init__$foo
{
    static __Init__$foo()
    {
        try
        {
            Compiler.PushNS();
            __Init__$foo.__static_ctor_helper_constants();
        }
        finally
        {
            Var.popThreadBindings();
        }
    }

    private static void __static_ctor_helper_constants()
    {
    }

    public static void Initialize()
    {
        // ...
    }
}

The contents of Initialize are currently designed to work with our namespace load optimization but we can skip that for now and emit the expression method invocations that MAGIC currently uses instead.