public static void Test(string s) { var dm = ILCompiler.Eval(s); var r = dm.Invoke(null, new object[] { }); Console.WriteLine(r); //OpCodes.Du }
public static System.Reflection.Emit.DynamicMethod Eval(Node n) { var type = GetTypeFromNode(n["DotName"]); var name = n["Name"].Text; var types = n["ArgList"].GetNodes("Arg").Select(arg => GetTypeFromNode(arg["TypeName"])).ToArray(); var r = new System.Reflection.Emit.DynamicMethod(name, type, types, true); var e = new ILCompiler(r.GetILGenerator()); e.EmitTerm(n["Block"]); return(r); }
public static System.Reflection.Emit.DynamicMethod Eval(Node n) { var type = GetTypeFromNode(n["DotName"]); var name = n["Name"].Text; var types = n["ArgList"].GetNodes("Arg").Select(arg => GetTypeFromNode(arg["TypeName"])).ToArray(); var r = new System.Reflection.Emit.DynamicMethod(name, type, types, true); var e = new ILCompiler(r.GetILGenerator()); e.EmitTerm(n["Block"]); return r; }