Beispiel #1
0
        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);
        }
Beispiel #3
0
 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;
 }