示例#1
0
 def build_fn():
     tInt = typeof(System.Int32)
     args = init_array(System.Type, tInt, tInt)
     meth = Utils.CreateDynamicMethod("add", tInt, args)
     il = meth.GetILGenerator()
     il.Emit(OpCodes.Ldarg_0)
     il.Emit(OpCodes.Ldarg_1)
     il.Emit(OpCodes.Add)
     il.Emit(OpCodes.Ret)
     myfunc = meth.CreateDelegate(typeof(FUNCTYPE))
     return myfunc
示例#2
0
 def build_fn():
     tObjArray = System.Type.GetType("System.Object[]")
     tInt = typeof(System.Int32)
     args = init_array(System.Type, tObjArray, tInt, tInt)
     meth = Utils.CreateDynamicMethod("add", tInt, args)
     il = meth.GetILGenerator()
     il.Emit(OpCodes.Ldarg_1)
     il.Emit(OpCodes.Ldarg_2)
     il.Emit(OpCodes.Add)
     il.Emit(OpCodes.Ret)
     array = new_array(System.Object, 0)
     myfunc = meth.CreateDelegate(typeof(FUNCTYPE), array)
     return myfunc