diff --git a/ILRuntime/Runtime/CLRBinding/BindingCodeGenerator.cs b/ILRuntime/Runtime/CLRBinding/BindingCodeGenerator.cs index 0980b961..74c8f599 100644 --- a/ILRuntime/Runtime/CLRBinding/BindingCodeGenerator.cs +++ b/ILRuntime/Runtime/CLRBinding/BindingCodeGenerator.cs @@ -204,7 +204,7 @@ public static void GenerateBindingCode(ILRuntime.Runtime.Enviorment.AppDomain do oriFileName = oriFileName.Substring(0, len); int extraNameIndex = 0; - string oFileName = oriFileName + "_t" + extraNameIndex; + string oFileName = oriFileName; while (files.Contains(oFileName)) { extraNameIndex++; diff --git a/ILRuntimeTest/AutoGenerate/CLRBindings.cs b/ILRuntimeTest/AutoGenerate/CLRBindings.cs index 8e09317a..172357e8 100644 --- a/ILRuntimeTest/AutoGenerate/CLRBindings.cs +++ b/ILRuntimeTest/AutoGenerate/CLRBindings.cs @@ -126,7 +126,10 @@ public static void Initialize(ILRuntime.Runtime.Enviorment.AppDomain app) System_Collections_Generic_Dictionary_2_UInt32_ILTypeInstance_Binding.Register(app); System_Collections_Generic_Dictionary_2_UInt32_ILTypeInstance_Binding_Enumerator_Binding.Register(app); System_Collections_Generic_KeyValuePair_2_UInt32_ILTypeInstance_Binding.Register(app); + ILRuntimeTest_TestFramework_TestVector3NoBinding_Binding.Register(app); + System_AccessViolationException_Binding.Register(app); System_Collections_Generic_Dictionary_2_Object_Object_Binding.Register(app); + ILRuntimeTest_TestFramework_TestCLREnumClass_Binding.Register(app); System_IComparable_1_Int32_Binding.Register(app); System_Collections_Generic_Dictionary_2_Int32_Int32_Binding.Register(app); System_Collections_Generic_Dictionary_2_Int32_Int32_Binding_Enumerator_Binding.Register(app); diff --git a/ILRuntimeTest/AutoGenerate/ILRuntimeTest_TestFramework_ClassInheritanceTest2_1_ILRuntimeTest_TestFramework_C_t.cs b/ILRuntimeTest/AutoGenerate/ILRuntimeTest_TestFramework_ClassInheritanceTest2_1_ILRuntimeTest_TestFramework_C.cs similarity index 100% rename from ILRuntimeTest/AutoGenerate/ILRuntimeTest_TestFramework_ClassInheritanceTest2_1_ILRuntimeTest_TestFramework_C_t.cs rename to ILRuntimeTest/AutoGenerate/ILRuntimeTest_TestFramework_ClassInheritanceTest2_1_ILRuntimeTest_TestFramework_C.cs diff --git a/ILRuntimeTest/AutoGenerate/ILRuntimeTest_TestFramework_TestCLREnumClass_Binding.cs b/ILRuntimeTest/AutoGenerate/ILRuntimeTest_TestFramework_TestCLREnumClass_Binding.cs new file mode 100644 index 00000000..bd3267ac --- /dev/null +++ b/ILRuntimeTest/AutoGenerate/ILRuntimeTest_TestFramework_TestCLREnumClass_Binding.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; + +using ILRuntime.CLR.TypeSystem; +using ILRuntime.CLR.Method; +using ILRuntime.Runtime.Enviorment; +using ILRuntime.Runtime.Intepreter; +using ILRuntime.Runtime.Stack; +using ILRuntime.Reflection; +using ILRuntime.CLR.Utils; + +namespace ILRuntime.Runtime.Generated +{ + unsafe class ILRuntimeTest_TestFramework_TestCLREnumClass_Binding + { + public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) + { + BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly; + MethodBase method; + FieldInfo field; + Type[] args; + Type type = typeof(ILRuntimeTest.TestFramework.TestCLREnumClass); + args = new Type[]{}; + method = type.GetMethod("get_Test2", flag, null, args, null); + app.RegisterCLRMethodRedirection(method, get_Test2_0); + + field = type.GetField("Test", flag); + app.RegisterCLRFieldGetter(field, get_Test_0); + app.RegisterCLRFieldSetter(field, set_Test_0); + + + } + + + static StackObject* get_Test2_0(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + { + ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; + StackObject* __ret = ILIntepreter.Minus(__esp, 0); + + + var result_of_this_method = ILRuntimeTest.TestFramework.TestCLREnumClass.Test2; + + return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); + } + + + static object get_Test_0(ref object o) + { + return ILRuntimeTest.TestFramework.TestCLREnumClass.Test; + } + static void set_Test_0(ref object o, object v) + { + ILRuntimeTest.TestFramework.TestCLREnumClass.Test = (ILRuntimeTest.TestFramework.TestCLREnum)v; + } + + + } +} diff --git a/ILRuntimeTest/AutoGenerate/ILRuntimeTest_TestFramework_TestVector3NoBinding_Binding.cs b/ILRuntimeTest/AutoGenerate/ILRuntimeTest_TestFramework_TestVector3NoBinding_Binding.cs new file mode 100644 index 00000000..d077f929 --- /dev/null +++ b/ILRuntimeTest/AutoGenerate/ILRuntimeTest_TestFramework_TestVector3NoBinding_Binding.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; + +using ILRuntime.CLR.TypeSystem; +using ILRuntime.CLR.Method; +using ILRuntime.Runtime.Enviorment; +using ILRuntime.Runtime.Intepreter; +using ILRuntime.Runtime.Stack; +using ILRuntime.Reflection; +using ILRuntime.CLR.Utils; + +namespace ILRuntime.Runtime.Generated +{ + unsafe class ILRuntimeTest_TestFramework_TestVector3NoBinding_Binding + { + public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) + { + BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly; + MethodBase method; + FieldInfo field; + Type[] args; + Type type = typeof(ILRuntimeTest.TestFramework.TestVector3NoBinding); + + field = type.GetField("y", flag); + app.RegisterCLRFieldGetter(field, get_y_0); + app.RegisterCLRFieldSetter(field, set_y_0); + + app.RegisterCLRMemberwiseClone(type, PerformMemberwiseClone); + + app.RegisterCLRCreateDefaultInstance(type, () => new ILRuntimeTest.TestFramework.TestVector3NoBinding()); + + args = new Type[]{typeof(System.Single), typeof(System.Single), typeof(System.Single)}; + method = type.GetConstructor(flag, null, args, null); + app.RegisterCLRMethodRedirection(method, Ctor_0); + + } + + static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject* ptr_of_this_method, IList __mStack, ref ILRuntimeTest.TestFramework.TestVector3NoBinding instance_of_this_method) + { + ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); + switch(ptr_of_this_method->ObjectType) + { + case ObjectTypes.Object: + { + __mStack[ptr_of_this_method->Value] = instance_of_this_method; + } + break; + case ObjectTypes.FieldReference: + { + var ___obj = __mStack[ptr_of_this_method->Value]; + if(___obj is ILTypeInstance) + { + ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method; + } + else + { + var t = __domain.GetType(___obj.GetType()) as CLRType; + t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method); + } + } + break; + case ObjectTypes.StaticFieldReference: + { + var t = __domain.GetType(ptr_of_this_method->Value); + if(t is ILType) + { + ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method; + } + else + { + ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method); + } + } + break; + case ObjectTypes.ArrayReference: + { + var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as ILRuntimeTest.TestFramework.TestVector3NoBinding[]; + instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method; + } + break; + } + } + + + static object get_y_0(ref object o) + { + return ((ILRuntimeTest.TestFramework.TestVector3NoBinding)o).y; + } + static void set_y_0(ref object o, object v) + { + var h = GCHandle.Alloc(o, GCHandleType.Pinned); + ILRuntimeTest.TestFramework.TestVector3NoBinding* p = (ILRuntimeTest.TestFramework.TestVector3NoBinding *)(void *)h.AddrOfPinnedObject(); + p->y = (System.Single)v; + h.Free(); + } + + static object PerformMemberwiseClone(ref object o) + { + var ins = new ILRuntimeTest.TestFramework.TestVector3NoBinding(); + ins = (ILRuntimeTest.TestFramework.TestVector3NoBinding)o; + return ins; + } + + static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + { + ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; + StackObject* ptr_of_this_method; + StackObject* __ret = ILIntepreter.Minus(__esp, 3); + ptr_of_this_method = ILIntepreter.Minus(__esp, 1); + System.Single @z = *(float*)&ptr_of_this_method->Value; + + ptr_of_this_method = ILIntepreter.Minus(__esp, 2); + System.Single @y = *(float*)&ptr_of_this_method->Value; + + ptr_of_this_method = ILIntepreter.Minus(__esp, 3); + System.Single @x = *(float*)&ptr_of_this_method->Value; + + + var result_of_this_method = new ILRuntimeTest.TestFramework.TestVector3NoBinding(@x, @y, @z); + + if(!isNewObj) + { + __ret--; + WriteBackInstance(__domain, __ret, __mStack, ref result_of_this_method); + return __ret; + } + + return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); + } + + + } +} diff --git a/ILRuntimeTest/AutoGenerate/System_AccessViolationException_Binding.cs b/ILRuntimeTest/AutoGenerate/System_AccessViolationException_Binding.cs new file mode 100644 index 00000000..0a98212f --- /dev/null +++ b/ILRuntimeTest/AutoGenerate/System_AccessViolationException_Binding.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; + +using ILRuntime.CLR.TypeSystem; +using ILRuntime.CLR.Method; +using ILRuntime.Runtime.Enviorment; +using ILRuntime.Runtime.Intepreter; +using ILRuntime.Runtime.Stack; +using ILRuntime.Reflection; +using ILRuntime.CLR.Utils; + +namespace ILRuntime.Runtime.Generated +{ + unsafe class System_AccessViolationException_Binding + { + public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) + { + BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly; + MethodBase method; + Type[] args; + Type type = typeof(System.AccessViolationException); + + args = new Type[]{}; + method = type.GetConstructor(flag, null, args, null); + app.RegisterCLRMethodRedirection(method, Ctor_0); + + } + + + + static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + { + ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; + StackObject* __ret = ILIntepreter.Minus(__esp, 0); + + var result_of_this_method = new System.AccessViolationException(); + + return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); + } + + + } +} diff --git a/ILRuntimeTest/AutoGenerate/System_Array_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Array_Binding.cs index e5a938df..067caf69 100644 --- a/ILRuntimeTest/AutoGenerate/System_Array_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_Array_Binding.cs @@ -53,15 +53,15 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) args = new Type[]{}; method = type.GetMethod("GetEnumerator", flag, null, args, null); app.RegisterCLRMethodRedirection(method, GetEnumerator_1); + args = new Type[]{}; + method = type.GetMethod("get_Length", flag, null, args, null); + app.RegisterCLRMethodRedirection(method, get_Length_2); args = new Type[]{typeof(System.Type), typeof(System.Int32)}; method = type.GetMethod("CreateInstance", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, CreateInstance_2); + app.RegisterCLRMethodRedirection(method, CreateInstance_3); args = new Type[]{typeof(System.Object), typeof(System.Int32)}; method = type.GetMethod("SetValue", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, SetValue_3); - args = new Type[]{}; - method = type.GetMethod("get_Length", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, get_Length_4); + app.RegisterCLRMethodRedirection(method, SetValue_4); args = new Type[]{typeof(System.Byte)}; if (genericMethods.TryGetValue("IndexOf", out lst)) { @@ -135,7 +135,24 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); } - static StackObject* CreateInstance_2(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + static StackObject* get_Length_2(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + { + ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; + StackObject* ptr_of_this_method; + StackObject* __ret = ILIntepreter.Minus(__esp, 1); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 1); + System.Array instance_of_this_method = (System.Array)typeof(System.Array).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + var result_of_this_method = instance_of_this_method.Length; + + __ret->ObjectType = ObjectTypes.Integer; + __ret->Value = result_of_this_method; + return __ret + 1; + } + + static StackObject* CreateInstance_3(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject* ptr_of_this_method; @@ -154,7 +171,7 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); } - static StackObject* SetValue_3(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + static StackObject* SetValue_4(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject* ptr_of_this_method; @@ -176,23 +193,6 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return __ret; } - static StackObject* get_Length_4(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) - { - ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; - StackObject* ptr_of_this_method; - StackObject* __ret = ILIntepreter.Minus(__esp, 1); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - System.Array instance_of_this_method = (System.Array)typeof(System.Array).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - __intp.Free(ptr_of_this_method); - - var result_of_this_method = instance_of_this_method.Length; - - __ret->ObjectType = ObjectTypes.Integer; - __ret->Value = result_of_this_method; - return __ret + 1; - } - static StackObject* IndexOf_5(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; diff --git a/ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_Int32_ILRuntimeTest_TestFramework_ClassIn_t.cs b/ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_Int32_ILRuntimeTest_TestFramework_ClassIn.cs similarity index 100% rename from ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_Int32_ILRuntimeTest_TestFramework_ClassIn_t.cs rename to ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_Int32_ILRuntimeTest_TestFramework_ClassIn.cs diff --git a/ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_Int32_ILTypeInstance_Binding_ValueCollect_t.cs b/ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_Int32_ILTypeInstance_Binding_ValueCollect.cs similarity index 100% rename from ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_Int32_ILTypeInstance_Binding_ValueCollect_t.cs rename to ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_Int32_ILTypeInstance_Binding_ValueCollect.cs diff --git a/ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_Int32_ILTypeInstance_Binding_ValueCollect_t_t.cs b/ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_Int32_ILTypeInstance_Binding_ValueCollect_t1.cs similarity index 100% rename from ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_Int32_ILTypeInstance_Binding_ValueCollect_t_t.cs rename to ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_Int32_ILTypeInstance_Binding_ValueCollect_t1.cs diff --git a/ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_UInt32_ILTypeInstance_Binding_Enumerator__t.cs b/ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_UInt32_ILTypeInstance_Binding_Enumerator_.cs similarity index 100% rename from ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_UInt32_ILTypeInstance_Binding_Enumerator__t.cs rename to ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_UInt32_ILTypeInstance_Binding_Enumerator_.cs diff --git a/ILRuntimeTest/AutoGenerate/System_Collections_Generic_List_1_ILRuntimeTest_TestFramework_ClassInheritanceTes_t.cs b/ILRuntimeTest/AutoGenerate/System_Collections_Generic_List_1_ILRuntimeTest_TestFramework_ClassInheritanceTes.cs similarity index 100% rename from ILRuntimeTest/AutoGenerate/System_Collections_Generic_List_1_ILRuntimeTest_TestFramework_ClassInheritanceTes_t.cs rename to ILRuntimeTest/AutoGenerate/System_Collections_Generic_List_1_ILRuntimeTest_TestFramework_ClassInheritanceTes.cs diff --git a/ILRuntimeTest/AutoGenerate/System_Collections_Generic_List_1_ILRuntimeTest_TestFramework_TestClass3Adaptor_B_t.cs b/ILRuntimeTest/AutoGenerate/System_Collections_Generic_List_1_ILRuntimeTest_TestFramework_TestClass3Adaptor_B.cs similarity index 100% rename from ILRuntimeTest/AutoGenerate/System_Collections_Generic_List_1_ILRuntimeTest_TestFramework_TestClass3Adaptor_B_t.cs rename to ILRuntimeTest/AutoGenerate/System_Collections_Generic_List_1_ILRuntimeTest_TestFramework_TestClass3Adaptor_B.cs diff --git a/ILRuntimeTest/AutoGenerate/System_Collections_Generic_List_1_Int32_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Collections_Generic_List_1_Int32_Binding.cs index 44d51d35..5859c1f6 100644 --- a/ILRuntimeTest/AutoGenerate/System_Collections_Generic_List_1_Int32_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_Collections_Generic_List_1_Int32_Binding.cs @@ -25,6 +25,9 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) args = new Type[]{typeof(System.Int32)}; method = type.GetMethod("Add", flag, null, args, null); app.RegisterCLRMethodRedirection(method, Add_0); + args = new Type[]{typeof(System.Int32)}; + method = type.GetMethod("get_Item", flag, null, args, null); + app.RegisterCLRMethodRedirection(method, get_Item_1); args = new Type[]{}; method = type.GetConstructor(flag, null, args, null); @@ -51,6 +54,26 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return __ret; } + static StackObject* get_Item_1(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + { + ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; + StackObject* ptr_of_this_method; + StackObject* __ret = ILIntepreter.Minus(__esp, 2); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 1); + System.Int32 @index = ptr_of_this_method->Value; + + ptr_of_this_method = ILIntepreter.Minus(__esp, 2); + System.Collections.Generic.List instance_of_this_method = (System.Collections.Generic.List)typeof(System.Collections.Generic.List).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + var result_of_this_method = instance_of_this_method[index]; + + __ret->ObjectType = ObjectTypes.Integer; + __ret->Value = result_of_this_method; + return __ret + 1; + } + static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) { diff --git a/ILRuntimeTest/AutoGenerate/System_Console_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Console_Binding.cs index 40dc5332..0aa61eaa 100644 --- a/ILRuntimeTest/AutoGenerate/System_Console_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_Console_Binding.cs @@ -31,18 +31,18 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) args = new Type[]{typeof(System.Int32)}; method = type.GetMethod("WriteLine", flag, null, args, null); app.RegisterCLRMethodRedirection(method, WriteLine_2); - args = new Type[]{typeof(System.Int64)}; + args = new Type[]{typeof(System.Object)}; method = type.GetMethod("WriteLine", flag, null, args, null); app.RegisterCLRMethodRedirection(method, WriteLine_3); - args = new Type[]{typeof(System.Boolean)}; + args = new Type[]{typeof(System.Int64)}; method = type.GetMethod("WriteLine", flag, null, args, null); app.RegisterCLRMethodRedirection(method, WriteLine_4); + args = new Type[]{typeof(System.Boolean)}; + method = type.GetMethod("WriteLine", flag, null, args, null); + app.RegisterCLRMethodRedirection(method, WriteLine_5); args = new Type[]{typeof(System.String)}; method = type.GetMethod("Write", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, Write_5); - args = new Type[]{typeof(System.Object)}; - method = type.GetMethod("WriteLine", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, WriteLine_6); + app.RegisterCLRMethodRedirection(method, Write_6); args = new Type[]{typeof(System.Single)}; method = type.GetMethod("WriteLine", flag, null, args, null); app.RegisterCLRMethodRedirection(method, WriteLine_7); @@ -124,7 +124,8 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) StackObject* __ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - System.Int64 @value = *(long*)&ptr_of_this_method->Value; + System.Object @value = (System.Object)typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); System.Console.WriteLine(@value); @@ -139,7 +140,7 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) StackObject* __ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - System.Boolean @value = ptr_of_this_method->Value == 1; + System.Int64 @value = *(long*)&ptr_of_this_method->Value; System.Console.WriteLine(@value); @@ -147,34 +148,33 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return __ret; } - static StackObject* Write_5(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + static StackObject* WriteLine_5(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject* ptr_of_this_method; StackObject* __ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - System.String @value = (System.String)typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - __intp.Free(ptr_of_this_method); + System.Boolean @value = ptr_of_this_method->Value == 1; - System.Console.Write(@value); + System.Console.WriteLine(@value); return __ret; } - static StackObject* WriteLine_6(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + static StackObject* Write_6(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject* ptr_of_this_method; StackObject* __ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - System.Object @value = (System.Object)typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + System.String @value = (System.String)typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); - System.Console.WriteLine(@value); + System.Console.Write(@value); return __ret; } diff --git a/ILRuntimeTest/AutoGenerate/System_Enum_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Enum_Binding.cs index 28812e4b..49c35565 100644 --- a/ILRuntimeTest/AutoGenerate/System_Enum_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_Enum_Binding.cs @@ -28,6 +28,9 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) args = new Type[]{typeof(System.Type)}; method = type.GetMethod("GetNames", flag, null, args, null); app.RegisterCLRMethodRedirection(method, GetNames_1); + args = new Type[]{typeof(System.Enum)}; + method = type.GetMethod("HasFlag", flag, null, args, null); + app.RegisterCLRMethodRedirection(method, HasFlag_2); } @@ -65,6 +68,27 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); } + static StackObject* HasFlag_2(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + { + ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; + StackObject* ptr_of_this_method; + StackObject* __ret = ILIntepreter.Minus(__esp, 2); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 1); + System.Enum @flag = (System.Enum)typeof(System.Enum).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 2); + System.Enum instance_of_this_method = (System.Enum)typeof(System.Enum).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + var result_of_this_method = instance_of_this_method.HasFlag(@flag); + + __ret->ObjectType = ObjectTypes.Integer; + __ret->Value = result_of_this_method ? 1 : 0; + return __ret + 1; + } + } diff --git a/ILRuntimeTest/AutoGenerate/System_Type_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Type_Binding.cs index 3e6d2ba6..ce170a61 100644 --- a/ILRuntimeTest/AutoGenerate/System_Type_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_Type_Binding.cs @@ -64,6 +64,9 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) args = new Type[]{typeof(System.Type)}; method = type.GetMethod("IsAssignableFrom", flag, null, args, null); app.RegisterCLRMethodRedirection(method, IsAssignableFrom_13); + args = new Type[]{typeof(System.String), typeof(System.Reflection.BindingFlags)}; + method = type.GetMethod("GetMethod", flag, null, args, null); + app.RegisterCLRMethodRedirection(method, GetMethod_14); app.RegisterCLRCreateArrayInstance(type, s => new System.Type[s]); @@ -329,6 +332,29 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return __ret + 1; } + static StackObject* GetMethod_14(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + { + ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; + StackObject* ptr_of_this_method; + StackObject* __ret = ILIntepreter.Minus(__esp, 3); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 1); + System.Reflection.BindingFlags @bindingAttr = (System.Reflection.BindingFlags)typeof(System.Reflection.BindingFlags).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 2); + System.String @name = (System.String)typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 3); + System.Type instance_of_this_method = (System.Type)typeof(System.Type).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + var result_of_this_method = instance_of_this_method.GetMethod(@name, @bindingAttr); + + return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); + } + } diff --git a/ILRuntimeTest/ILRuntimeTest.csproj b/ILRuntimeTest/ILRuntimeTest.csproj index 5ece5431..4df92a04 100644 --- a/ILRuntimeTest/ILRuntimeTest.csproj +++ b/ILRuntimeTest/ILRuntimeTest.csproj @@ -76,7 +76,7 @@ - + @@ -84,7 +84,9 @@ + + @@ -93,6 +95,7 @@ + @@ -105,10 +108,10 @@ - + - - + + @@ -122,7 +125,7 @@ - + @@ -130,8 +133,8 @@ - - + + diff --git a/ILRuntimeTest/TestFramework/TestCLREnum.cs b/ILRuntimeTest/TestFramework/TestCLREnum.cs index 127cb755..0d62eb58 100644 --- a/ILRuntimeTest/TestFramework/TestCLREnum.cs +++ b/ILRuntimeTest/TestFramework/TestCLREnum.cs @@ -6,4 +6,10 @@ public enum TestCLREnum Test2 = 1, Test3 = 2 } + + public class TestCLREnumClass + { + public static TestCLREnum Test = TestCLREnum.Test2; + public static TestCLREnum Test2 => TestCLREnum.Test3; + } } \ No newline at end of file diff --git a/TestCases/TestCLREnum.cs b/TestCases/TestCLREnum.cs index 6fb1af48..a8883e49 100644 --- a/TestCases/TestCLREnum.cs +++ b/TestCases/TestCLREnum.cs @@ -53,5 +53,21 @@ public static void Test05() Console.WriteLine(dict.ContainsValue(MyEnum9.AAA)); } + static ILRuntimeTest.TestFramework.TestCLREnum clrEnumTestField = ILRuntimeTest.TestFramework.TestCLREnum.Test2; + public static void Test06() + { + var res = ILRuntimeTest.TestFramework.TestCLREnumClass.Test == ILRuntimeTest.TestFramework.TestCLREnum.Test2; + Console.WriteLine(res); + if (!res) + throw new Exception(); + res = ILRuntimeTest.TestFramework.TestCLREnumClass.Test2 == ILRuntimeTest.TestFramework.TestCLREnum.Test3; + Console.WriteLine(res); + if (!res) + throw new Exception(); + res = clrEnumTestField == ILRuntimeTest.TestFramework.TestCLREnum.Test2; + Console.WriteLine(res); + if (!res) + throw new Exception(); + } } } \ No newline at end of file