/// <summary>Compiles the main method.</summary> public void Compile() { // Create the main method builder now: var main = Module.DefineMethod("__.main", typeof(void), new Type[0]); // Invocation for the 'start' method: if (Index != uint.MaxValue) { // Get the function: int paramCount; Type returnType; MethodInfo method = Module.GetFunction((int)Index, out paramCount, out returnType); if (method != null) { // It shouldn't take any args: if (paramCount != 0 || returnType != typeof(void)) { throw new InvalidOperationException( "WebAssembly start method must not have params or a return type." ); } // Call as-is: main.Call(method); } } // Done! main.Complete("__.main", null, typeof(void), true); }
/// <summary>Reads a method from the modules function index space.</summary> public MethodInfo Method(out int paramCount, out Type returnType) { return(Module.GetFunction((int)VarUInt32(), out paramCount, out returnType)); }