diff --git a/ILRuntime/CLR/TypeSystem/ILType.cs b/ILRuntime/CLR/TypeSystem/ILType.cs index 36edd62c..0cbb74e7 100644 --- a/ILRuntime/CLR/TypeSystem/ILType.cs +++ b/ILRuntime/CLR/TypeSystem/ILType.cs @@ -17,6 +17,7 @@ public class ILType : IType TypeReference typeRef; TypeDefinition definition; ILRuntime.Runtime.Enviorment.AppDomain appdomain; + bool staticConstructorCalled; ILMethod staticConstructor; List constructors; IType[] fieldTypes; @@ -127,6 +128,14 @@ public ILTypeStaticInstance StaticInstance InitializeFields(); if (methods == null) InitializeMethods(); + if (staticInstance != null && !staticConstructorCalled) + { + staticConstructorCalled = true; + if (staticConstructor != null && (!TypeReference.HasGenericParameters || IsGenericInstance)) + { + appdomain.Invoke(staticConstructor, null, null); + } + } return staticInstance; } } @@ -677,11 +686,6 @@ void InitializeMethods() lst.Add(m); } } - - if (staticConstructor != null && (!TypeReference.HasGenericParameters || IsGenericInstance)) - { - appdomain.Invoke(staticConstructor, null, null); - } } public IMethod GetVirtualMethod(IMethod method) diff --git a/ILRuntime/Runtime/Enviorment/CLRRedirections.cs b/ILRuntime/Runtime/Enviorment/CLRRedirections.cs index 80a140c2..373fd55e 100644 --- a/ILRuntime/Runtime/Enviorment/CLRRedirections.cs +++ b/ILRuntime/Runtime/Enviorment/CLRRedirections.cs @@ -829,35 +829,31 @@ unsafe static class CLRRedirections esp = ILIntepreter.PushObject(ret, mStack, obj); else esp = ret; + var ilmethod = ((ILRuntimeMethodInfo)instance).ILMethod; if (p != null) { object[] arr = (object[])p; - foreach (var i in arr) + for(int i = 0; i < ilmethod.ParameterCount; i++) { - esp = ILIntepreter.PushObject(esp, mStack, CheckCrossBindingAdapter(i)); + esp = ILIntepreter.PushObject(esp, mStack, CheckCrossBindingAdapter(arr[i])); } } bool unhandled; - var ilmethod = ((ILRuntimeMethodInfo)instance).ILMethod; ret = intp.Execute(ilmethod, esp, out unhandled); ILRuntimeMethodInfo imi = (ILRuntimeMethodInfo)instance; - var rt = imi.ReturnType; + var rt = imi.ILMethod.ReturnType; if (rt != domain.VoidType) { var res = ret - 1; if (res->ObjectType < ObjectTypes.Object) { - if (rt is ILRuntimeWrapperType) - rt = ((ILRuntimeWrapperType)rt).CLRType.TypeForCLR; - if (rt is ILRuntimeType) - rt = ((ILRuntimeType)rt).ILType.TypeForCLR; - return ILIntepreter.PushObject(res, mStack, rt.CheckCLRTypes(StackObject.ToObject(res, domain, mStack)), true); + return ILIntepreter.PushObject(res, mStack, rt.TypeForCLR.CheckCLRTypes(StackObject.ToObject(res, domain, mStack)), true); } else return ret; } else - return ret; + return ILIntepreter.PushNull(ret); } else return ILIntepreter.PushObject(ret, mStack, ((MethodInfo)instance).Invoke(obj, (object[])p)); diff --git a/ILRuntimeTest/AutoGenerate/CLRBindings.cs b/ILRuntimeTest/AutoGenerate/CLRBindings.cs index 39e5686d..8e09317a 100644 --- a/ILRuntimeTest/AutoGenerate/CLRBindings.cs +++ b/ILRuntimeTest/AutoGenerate/CLRBindings.cs @@ -24,23 +24,12 @@ public static void Initialize(ILRuntime.Runtime.Enviorment.AppDomain app) System_Type_Binding.Register(app); System_Runtime_CompilerServices_AsyncTaskMethodBuilder_Binding.Register(app); System_Runtime_CompilerServices_AsyncTaskMethodBuilder_1_Int32_Binding.Register(app); - System_Runtime_CompilerServices_AsyncVoidMethodBuilder_Binding.Register(app); - System_Runtime_CompilerServices_AsyncTaskMethodBuilder_1_List_1_String_Binding.Register(app); System_Threading_Tasks_Task_Binding.Register(app); System_Runtime_CompilerServices_TaskAwaiter_Binding.Register(app); System_Threading_Tasks_Task_1_Int32_Binding.Register(app); System_Runtime_CompilerServices_TaskAwaiter_1_Int32_Binding.Register(app); System_Exception_Binding.Register(app); System_Collections_IDictionary_Binding.Register(app); - System_Threading_Tasks_Task_1_List_1_String_Binding.Register(app); - System_Runtime_CompilerServices_TaskAwaiter_1_List_1_String_Binding.Register(app); - System_Collections_Generic_List_1_Task_Binding.Register(app); - System_IO_File_Binding.Register(app); - System_Collections_Generic_List_1_String_Binding.Register(app); - System_IO_TextReader_Binding.Register(app); - System_Threading_Tasks_Task_1_String_Binding.Register(app); - System_Runtime_CompilerServices_TaskAwaiter_1_String_Binding.Register(app); - System_IDisposable_Binding.Register(app); System_Collections_Generic_List_1_Int32_Binding.Register(app); System_Linq_Enumerable_Binding.Register(app); System_Collections_Generic_List_1_Dictionary_2_String_Object_Binding.Register(app); @@ -57,6 +46,7 @@ public static void Initialize(ILRuntime.Runtime.Enviorment.AppDomain app) System_ArgumentException_Binding.Register(app); ILRuntimeTest_TestBase_StaticGenericMethods_Binding.Register(app); System_Action_1_ILTypeInstance_Binding.Register(app); + System_Array_Binding.Register(app); System_Collections_Generic_Dictionary_2_Int32_ILTypeInstance_Binding.Register(app); LitJson_JsonMapper_Binding.Register(app); System_Collections_Generic_List_1_ILTypeInstance_Binding.Register(app); @@ -89,18 +79,21 @@ public static void Initialize(ILRuntime.Runtime.Enviorment.AppDomain app) ILRuntimeTest_TestFramework_TestClass3_Binding.Register(app); System_Byte_Binding.Register(app); System_Char_Binding.Register(app); + System_IO_File_Binding.Register(app); System_IO_FileStream_Binding.Register(app); System_IO_Stream_Binding.Register(app); + System_IDisposable_Binding.Register(app); System_Collections_Generic_Dictionary_2_Int64_Int32_Binding.Register(app); System_Enum_Binding.Register(app); - System_Array_Binding.Register(app); System_Collections_IEnumerator_Binding.Register(app); + System_Collections_Generic_Dictionary_2_String_Int64_Binding.Register(app); System_Int32_Array_Binding.Register(app); System_Int32_Array_Binding_Array_Binding.Register(app); System_Double_Binding.Register(app); ILRuntimeTest_TestFramework_TestVector3_Binding.Register(app); System_Int32_Array3_Binding.Register(app); System_Int32_Array2_Binding.Register(app); + ILRuntimeTest_TestFramework_TestClass4_Binding.Register(app); System_Single_Binding.Register(app); System_Nullable_1_Int32_Binding.Register(app); System_Collections_Generic_Dictionary_2_String_Int32_Binding_Enumerator_Binding.Register(app); @@ -116,9 +109,11 @@ public static void Initialize(ILRuntime.Runtime.Enviorment.AppDomain app) System_Collections_Generic_Dictionary_2_ILTypeInstance_Int32_Binding.Register(app); System_Collections_Generic_List_1_Int32_Array_Binding.Register(app); System_Collections_Generic_List_1_Object_Binding.Register(app); + System_Linq_IGrouping_2_Byte_Byte_Binding.Register(app); System_Convert_Binding.Register(app); System_Collections_Generic_Dictionary_2_Int32_ILTypeInstance_Binding_ValueCollection_Binding.Register(app); System_Collections_Generic_Dictionary_2_Int32_ILTypeInstance_Binding_ValueCollection_Binding_Enumerator_Binding.Register(app); + System_Collections_Generic_List_1_String_Binding.Register(app); System_Collections_Generic_List_1_String_Binding_Enumerator_Binding.Register(app); System_NotSupportedException_Binding.Register(app); System_Collections_Generic_List_1_ILTypeInstance_Binding_Enumerator_Binding.Register(app); @@ -135,6 +130,7 @@ public static void Initialize(ILRuntime.Runtime.Enviorment.AppDomain 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); + System_Collections_Generic_EqualityComparer_1_Int32_Binding.Register(app); ILRuntime.CLR.TypeSystem.CLRType __clrType = null; __clrType = (ILRuntime.CLR.TypeSystem.CLRType)app.GetType (typeof(ILRuntimeTest.TestFramework.TestVector3)); diff --git a/ILRuntimeTest/AutoGenerate/ILRuntimeTest_TestBase_StaticGenericMethods_Binding.cs b/ILRuntimeTest/AutoGenerate/ILRuntimeTest_TestBase_StaticGenericMethods_Binding.cs index 1d29a267..e239c5b8 100644 --- a/ILRuntimeTest/AutoGenerate/ILRuntimeTest_TestBase_StaticGenericMethods_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/ILRuntimeTest_TestBase_StaticGenericMethods_Binding.cs @@ -104,6 +104,9 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) } } } + args = new Type[]{typeof(System.String), typeof(System.Collections.Generic.KeyValuePair[])}; + method = type.GetMethod("Method", flag, null, args, null); + app.RegisterCLRMethodRedirection(method, Method_8); } @@ -237,6 +240,26 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return __ret; } + static StackObject* Method_8(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.Collections.Generic.KeyValuePair[] @panels = (System.Collections.Generic.KeyValuePair[])typeof(System.Collections.Generic.KeyValuePair[]).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); + + + ILRuntimeTest.TestBase.StaticGenericMethods.Method(@name, @panels); + + return __ret; + } + } diff --git a/ILRuntimeTest/AutoGenerate/ILRuntimeTest_TestFramework_TestClass4_Binding.cs b/ILRuntimeTest/AutoGenerate/ILRuntimeTest_TestFramework_TestClass4_Binding.cs new file mode 100644 index 00000000..d3af38e6 --- /dev/null +++ b/ILRuntimeTest/AutoGenerate/ILRuntimeTest_TestFramework_TestClass4_Binding.cs @@ -0,0 +1,123 @@ +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_TestClass4_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(ILRuntimeTest.TestFramework.TestClass4); + args = new Type[]{typeof(ILRuntimeTest.TestFramework.TestStruct[]).MakeByRefType()}; + method = type.GetMethod("TestArrayOut", flag, null, args, null); + app.RegisterCLRMethodRedirection(method, TestArrayOut_0); + + args = new Type[]{}; + method = type.GetConstructor(flag, null, args, null); + app.RegisterCLRMethodRedirection(method, Ctor_0); + + } + + + static StackObject* TestArrayOut_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, 2); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 1); + ILRuntimeTest.TestFramework.TestStruct[] @arr = (ILRuntimeTest.TestFramework.TestStruct[])typeof(ILRuntimeTest.TestFramework.TestStruct[]).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack)); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 2); + ILRuntimeTest.TestFramework.TestClass4 instance_of_this_method = (ILRuntimeTest.TestFramework.TestClass4)typeof(ILRuntimeTest.TestFramework.TestClass4).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + + instance_of_this_method.TestArrayOut(out @arr); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 1); + switch(ptr_of_this_method->ObjectType) + { + case ObjectTypes.StackObjectReference: + { + var ___dst = ILIntepreter.ResolveReference(ptr_of_this_method); + object ___obj = @arr; + if (___dst->ObjectType >= ObjectTypes.Object) + { + if (___obj is CrossBindingAdaptorType) + ___obj = ((CrossBindingAdaptorType)___obj).ILInstance; + __mStack[___dst->Value] = ___obj; + } + else + { + ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain); + } + } + break; + case ObjectTypes.FieldReference: + { + var ___obj = __mStack[ptr_of_this_method->Value]; + if(___obj is ILTypeInstance) + { + ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = @arr; + } + else + { + var ___type = __domain.GetType(___obj.GetType()) as CLRType; + ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, @arr); + } + } + break; + case ObjectTypes.StaticFieldReference: + { + var ___type = __domain.GetType(ptr_of_this_method->Value); + if(___type is ILType) + { + ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = @arr; + } + else + { + ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, @arr); + } + } + break; + case ObjectTypes.ArrayReference: + { + var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as ILRuntimeTest.TestFramework.TestStruct[][]; + instance_of_arrayReference[ptr_of_this_method->ValueLow] = @arr; + } + break; + } + + __intp.Free(ptr_of_this_method); + ptr_of_this_method = ILIntepreter.Minus(__esp, 2); + __intp.Free(ptr_of_this_method); + return __ret; + } + + + 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 ILRuntimeTest.TestFramework.TestClass4(); + + return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); + } + + + } +} diff --git a/ILRuntimeTest/AutoGenerate/System_Activator_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Activator_Binding.cs index f439dbad..e1f08682 100644 --- a/ILRuntimeTest/AutoGenerate/System_Activator_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_Activator_Binding.cs @@ -117,6 +117,11 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) var result_of_this_method = System.Activator.CreateInstance(@type, @args); + object obj_result_of_this_method = result_of_this_method; + if(obj_result_of_this_method is CrossBindingAdaptorType) + { + return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance, true); + } return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method, true); } @@ -133,6 +138,11 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) var result_of_this_method = System.Activator.CreateInstance(@type); + object obj_result_of_this_method = result_of_this_method; + if(obj_result_of_this_method is CrossBindingAdaptorType) + { + return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance, true); + } return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method, true); } @@ -160,6 +170,11 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) var result_of_this_method = System.Activator.CreateInstance(); + object obj_result_of_this_method = result_of_this_method; + if(obj_result_of_this_method is CrossBindingAdaptorType) + { + return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance, true); + } return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method, true); } diff --git a/ILRuntimeTest/AutoGenerate/System_Array_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Array_Binding.cs index da4b7ce9..e5a938df 100644 --- a/ILRuntimeTest/AutoGenerate/System_Array_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_Array_Binding.cs @@ -22,18 +22,6 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) MethodBase method; Type[] args; Type type = typeof(System.Array); - args = new Type[]{}; - method = type.GetMethod("GetEnumerator", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, GetEnumerator_0); - args = new Type[]{typeof(System.Type), typeof(System.Int32)}; - method = type.GetMethod("CreateInstance", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, CreateInstance_1); - args = new Type[]{typeof(System.Object), typeof(System.Int32)}; - method = type.GetMethod("SetValue", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, SetValue_2); - args = new Type[]{}; - method = type.GetMethod("get_Length", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, get_Length_3); Dictionary> genericMethods = new Dictionary>(); List lst = null; foreach(var m in type.GetMethods()) @@ -48,6 +36,32 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) lst.Add(m); } } + args = new Type[]{typeof(System.Collections.Generic.KeyValuePair)}; + if (genericMethods.TryGetValue("Empty", out lst)) + { + foreach(var m in lst) + { + if(m.MatchGenericParameters(args, typeof(System.Collections.Generic.KeyValuePair[]))) + { + method = m.MakeGenericMethod(args); + app.RegisterCLRMethodRedirection(method, Empty_0); + + break; + } + } + } + args = new Type[]{}; + method = type.GetMethod("GetEnumerator", flag, null, args, null); + app.RegisterCLRMethodRedirection(method, GetEnumerator_1); + args = new Type[]{typeof(System.Type), typeof(System.Int32)}; + method = type.GetMethod("CreateInstance", flag, null, args, null); + app.RegisterCLRMethodRedirection(method, CreateInstance_2); + 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); args = new Type[]{typeof(System.Byte)}; if (genericMethods.TryGetValue("IndexOf", out lst)) { @@ -56,7 +70,7 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) if(m.MatchGenericParameters(args, typeof(System.Int32), typeof(System.Byte[]), typeof(System.Byte))) { method = m.MakeGenericMethod(args); - app.RegisterCLRMethodRedirection(method, IndexOf_4); + app.RegisterCLRMethodRedirection(method, IndexOf_5); break; } @@ -70,7 +84,7 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) if(m.MatchGenericParameters(args, typeof(System.Int32), typeof(System.Int32[]), typeof(System.Int32))) { method = m.MakeGenericMethod(args); - app.RegisterCLRMethodRedirection(method, IndexOf_5); + app.RegisterCLRMethodRedirection(method, IndexOf_6); break; } @@ -84,7 +98,7 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) if(m.MatchGenericParameters(args, typeof(System.Int32), typeof(System.Collections.Generic.List[]), typeof(System.Collections.Generic.List))) { method = m.MakeGenericMethod(args); - app.RegisterCLRMethodRedirection(method, IndexOf_6); + app.RegisterCLRMethodRedirection(method, IndexOf_7); break; } @@ -95,7 +109,18 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) } - static StackObject* GetEnumerator_0(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + static StackObject* Empty_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 = System.Array.Empty>(); + + return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); + } + + static StackObject* GetEnumerator_1(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject* ptr_of_this_method; @@ -110,7 +135,7 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); } - static StackObject* CreateInstance_1(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + static StackObject* CreateInstance_2(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject* ptr_of_this_method; @@ -129,7 +154,7 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); } - static StackObject* SetValue_2(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + static StackObject* SetValue_3(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject* ptr_of_this_method; @@ -151,7 +176,7 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return __ret; } - static StackObject* get_Length_3(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + 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; @@ -168,7 +193,7 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return __ret + 1; } - static StackObject* IndexOf_4(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + static StackObject* IndexOf_5(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject* ptr_of_this_method; @@ -189,7 +214,7 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return __ret + 1; } - static StackObject* IndexOf_5(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + static StackObject* IndexOf_6(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject* ptr_of_this_method; @@ -210,7 +235,7 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return __ret + 1; } - static StackObject* IndexOf_6(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + static StackObject* IndexOf_7(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject* ptr_of_this_method; diff --git a/ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_String_Int64_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_String_Int64_Binding.cs new file mode 100644 index 00000000..5c8cdb6d --- /dev/null +++ b/ILRuntimeTest/AutoGenerate/System_Collections_Generic_Dictionary_2_String_Int64_Binding.cs @@ -0,0 +1,146 @@ +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_Collections_Generic_Dictionary_2_String_Int64_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.Collections.Generic.Dictionary); + args = new Type[]{typeof(System.String), typeof(System.Int64)}; + method = type.GetMethod("set_Item", flag, null, args, null); + app.RegisterCLRMethodRedirection(method, set_Item_0); + args = new Type[]{typeof(System.String), typeof(System.Int64).MakeByRefType()}; + method = type.GetMethod("TryGetValue", flag, null, args, null); + app.RegisterCLRMethodRedirection(method, TryGetValue_1); + + args = new Type[]{}; + method = type.GetConstructor(flag, null, args, null); + app.RegisterCLRMethodRedirection(method, Ctor_0); + + } + + + static StackObject* set_Item_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.Int64 @value = *(long*)&ptr_of_this_method->Value; + + ptr_of_this_method = ILIntepreter.Minus(__esp, 2); + System.String @key = (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.Collections.Generic.Dictionary instance_of_this_method = (System.Collections.Generic.Dictionary)typeof(System.Collections.Generic.Dictionary).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + instance_of_this_method[key] = value; + + return __ret; + } + + static StackObject* TryGetValue_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, 3); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 1); + System.Int64 @value = __intp.RetriveInt64(ptr_of_this_method, __mStack); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 2); + System.String @key = (System.String)typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 3); + System.Collections.Generic.Dictionary instance_of_this_method = (System.Collections.Generic.Dictionary)typeof(System.Collections.Generic.Dictionary).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + + var result_of_this_method = instance_of_this_method.TryGetValue(@key, out @value); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 1); + switch(ptr_of_this_method->ObjectType) + { + case ObjectTypes.StackObjectReference: + { + var ___dst = ILIntepreter.ResolveReference(ptr_of_this_method); + ___dst->ObjectType = ObjectTypes.Long; + *(long*)&___dst->Value = @value; + } + break; + case ObjectTypes.FieldReference: + { + var ___obj = __mStack[ptr_of_this_method->Value]; + if(___obj is ILTypeInstance) + { + ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = @value; + } + else + { + var ___type = __domain.GetType(___obj.GetType()) as CLRType; + ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, @value); + } + } + break; + case ObjectTypes.StaticFieldReference: + { + var ___type = __domain.GetType(ptr_of_this_method->Value); + if(___type is ILType) + { + ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = @value; + } + else + { + ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, @value); + } + } + break; + case ObjectTypes.ArrayReference: + { + var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Int64[]; + instance_of_arrayReference[ptr_of_this_method->ValueLow] = @value; + } + break; + } + + __intp.Free(ptr_of_this_method); + ptr_of_this_method = ILIntepreter.Minus(__esp, 2); + __intp.Free(ptr_of_this_method); + ptr_of_this_method = ILIntepreter.Minus(__esp, 3); + __intp.Free(ptr_of_this_method); + __ret->ObjectType = ObjectTypes.Integer; + __ret->Value = result_of_this_method ? 1 : 0; + return __ret + 1; + } + + + 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.Collections.Generic.Dictionary(); + + return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); + } + + + } +} diff --git a/ILRuntimeTest/AutoGenerate/System_Collections_Generic_EqualityComparer_1_Int32_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Collections_Generic_EqualityComparer_1_Int32_Binding.cs new file mode 100644 index 00000000..c80a716c --- /dev/null +++ b/ILRuntimeTest/AutoGenerate/System_Collections_Generic_EqualityComparer_1_Int32_Binding.cs @@ -0,0 +1,96 @@ +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_Collections_Generic_EqualityComparer_1_Int32_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.Collections.Generic.EqualityComparer); + args = new Type[]{}; + method = type.GetMethod("get_Default", flag, null, args, null); + app.RegisterCLRMethodRedirection(method, get_Default_0); + args = new Type[]{typeof(System.Int32), typeof(System.Int32)}; + method = type.GetMethod("Equals", flag, null, args, null); + app.RegisterCLRMethodRedirection(method, Equals_1); + args = new Type[]{typeof(System.Int32)}; + method = type.GetMethod("GetHashCode", flag, null, args, null); + app.RegisterCLRMethodRedirection(method, GetHashCode_2); + + + } + + + static StackObject* get_Default_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 = System.Collections.Generic.EqualityComparer.Default; + + return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); + } + + static StackObject* Equals_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, 3); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 1); + System.Int32 @y = ptr_of_this_method->Value; + + ptr_of_this_method = ILIntepreter.Minus(__esp, 2); + System.Int32 @x = ptr_of_this_method->Value; + + ptr_of_this_method = ILIntepreter.Minus(__esp, 3); + System.Collections.Generic.EqualityComparer instance_of_this_method = (System.Collections.Generic.EqualityComparer)typeof(System.Collections.Generic.EqualityComparer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + var result_of_this_method = instance_of_this_method.Equals(@x, @y); + + __ret->ObjectType = ObjectTypes.Integer; + __ret->Value = result_of_this_method ? 1 : 0; + return __ret + 1; + } + + static StackObject* GetHashCode_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.Int32 @obj = ptr_of_this_method->Value; + + ptr_of_this_method = ILIntepreter.Minus(__esp, 2); + System.Collections.Generic.EqualityComparer instance_of_this_method = (System.Collections.Generic.EqualityComparer)typeof(System.Collections.Generic.EqualityComparer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + var result_of_this_method = instance_of_this_method.GetHashCode(@obj); + + __ret->ObjectType = ObjectTypes.Integer; + __ret->Value = result_of_this_method; + return __ret + 1; + } + + + + } +} diff --git a/ILRuntimeTest/AutoGenerate/System_Collections_Generic_List_1_Task_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Collections_Generic_List_1_Task_Binding.cs deleted file mode 100644 index 8a2034df..00000000 --- a/ILRuntimeTest/AutoGenerate/System_Collections_Generic_List_1_Task_Binding.cs +++ /dev/null @@ -1,68 +0,0 @@ -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_Collections_Generic_List_1_Task_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.Collections.Generic.List); - args = new Type[]{typeof(System.Threading.Tasks.Task)}; - method = type.GetMethod("Add", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, Add_0); - - args = new Type[]{}; - method = type.GetConstructor(flag, null, args, null); - app.RegisterCLRMethodRedirection(method, Ctor_0); - - } - - - static StackObject* Add_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, 2); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - System.Threading.Tasks.Task @item = (System.Threading.Tasks.Task)typeof(System.Threading.Tasks.Task).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - __intp.Free(ptr_of_this_method); - - 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); - - instance_of_this_method.Add(@item); - - return __ret; - } - - - 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.Collections.Generic.List(); - - return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); - } - - - } -} diff --git a/ILRuntimeTest/AutoGenerate/System_Collections_IDictionary_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Collections_IDictionary_Binding.cs index b5723a1d..c889fa2f 100644 --- a/ILRuntimeTest/AutoGenerate/System_Collections_IDictionary_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_Collections_IDictionary_Binding.cs @@ -46,6 +46,11 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) var result_of_this_method = instance_of_this_method[key]; + object obj_result_of_this_method = result_of_this_method; + if(obj_result_of_this_method is CrossBindingAdaptorType) + { + return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance, true); + } return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method, true); } diff --git a/ILRuntimeTest/AutoGenerate/System_Collections_IEnumerator_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Collections_IEnumerator_Binding.cs index 5622d4df..6f71a71d 100644 --- a/ILRuntimeTest/AutoGenerate/System_Collections_IEnumerator_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_Collections_IEnumerator_Binding.cs @@ -45,6 +45,11 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) var result_of_this_method = instance_of_this_method.Current; + object obj_result_of_this_method = result_of_this_method; + if(obj_result_of_this_method is CrossBindingAdaptorType) + { + return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance, true); + } return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method, true); } diff --git a/ILRuntimeTest/AutoGenerate/System_Console_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Console_Binding.cs index c2945b14..40dc5332 100644 --- a/ILRuntimeTest/AutoGenerate/System_Console_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_Console_Binding.cs @@ -58,6 +58,9 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) args = new Type[]{typeof(System.String), typeof(System.Object[])}; method = type.GetMethod("WriteLine", flag, null, args, null); app.RegisterCLRMethodRedirection(method, WriteLine_11); + args = new Type[]{typeof(System.Double)}; + method = type.GetMethod("WriteLine", flag, null, args, null); + app.RegisterCLRMethodRedirection(method, WriteLine_12); } @@ -256,6 +259,21 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return __ret; } + static StackObject* WriteLine_12(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.Double @value = *(double*)&ptr_of_this_method->Value; + + + System.Console.WriteLine(@value); + + return __ret; + } + } diff --git a/ILRuntimeTest/AutoGenerate/System_Convert_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Convert_Binding.cs index 23cfa429..db4445bd 100644 --- a/ILRuntimeTest/AutoGenerate/System_Convert_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_Convert_Binding.cs @@ -47,6 +47,11 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) var result_of_this_method = System.Convert.ChangeType(@value, @conversionType); + object obj_result_of_this_method = result_of_this_method; + if(obj_result_of_this_method is CrossBindingAdaptorType) + { + return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance, true); + } return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method, true); } diff --git a/ILRuntimeTest/AutoGenerate/System_IO_File_Binding.cs b/ILRuntimeTest/AutoGenerate/System_IO_File_Binding.cs index 84d5e3a1..7ba42307 100644 --- a/ILRuntimeTest/AutoGenerate/System_IO_File_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_IO_File_Binding.cs @@ -26,14 +26,8 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) method = type.GetMethod("Exists", flag, null, args, null); app.RegisterCLRMethodRedirection(method, Exists_0); args = new Type[]{typeof(System.String)}; - method = type.GetMethod("CreateText", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, CreateText_1); - args = new Type[]{typeof(System.String)}; - method = type.GetMethod("OpenText", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, OpenText_2); - args = new Type[]{typeof(System.String)}; method = type.GetMethod("Delete", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, Delete_3); + app.RegisterCLRMethodRedirection(method, Delete_1); } @@ -57,49 +51,7 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return __ret + 1; } - static StackObject* CreateText_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, 1); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - System.String @path = (System.String)typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - __intp.Free(ptr_of_this_method); - - - var result_of_this_method = System.IO.File.CreateText(@path); - - object obj_result_of_this_method = result_of_this_method; - if(obj_result_of_this_method is CrossBindingAdaptorType) - { - return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance); - } - return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); - } - - static StackObject* OpenText_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.String @path = (System.String)typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - __intp.Free(ptr_of_this_method); - - - var result_of_this_method = System.IO.File.OpenText(@path); - - object obj_result_of_this_method = result_of_this_method; - if(obj_result_of_this_method is CrossBindingAdaptorType) - { - return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance); - } - return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); - } - - static StackObject* Delete_3(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + static StackObject* Delete_1(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject* ptr_of_this_method; diff --git a/ILRuntimeTest/AutoGenerate/System_IO_TextReader_Binding.cs b/ILRuntimeTest/AutoGenerate/System_IO_TextReader_Binding.cs deleted file mode 100644 index c9d46f7a..00000000 --- a/ILRuntimeTest/AutoGenerate/System_IO_TextReader_Binding.cs +++ /dev/null @@ -1,56 +0,0 @@ -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_IO_TextReader_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.IO.TextReader); - args = new Type[]{}; - method = type.GetMethod("ReadLineAsync", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, ReadLineAsync_0); - - - } - - - static StackObject* ReadLineAsync_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, 1); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - System.IO.TextReader instance_of_this_method = (System.IO.TextReader)typeof(System.IO.TextReader).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - __intp.Free(ptr_of_this_method); - - var result_of_this_method = instance_of_this_method.ReadLineAsync(); - - object obj_result_of_this_method = result_of_this_method; - if(obj_result_of_this_method is CrossBindingAdaptorType) - { - return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance); - } - return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); - } - - - - } -} diff --git a/ILRuntimeTest/AutoGenerate/System_Linq_Enumerable_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Linq_Enumerable_Binding.cs index 771a726d..47d08a47 100644 --- a/ILRuntimeTest/AutoGenerate/System_Linq_Enumerable_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_Linq_Enumerable_Binding.cs @@ -91,6 +91,90 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) } } } + args = new Type[]{typeof(System.Byte)}; + if (genericMethods.TryGetValue("Where", out lst)) + { + foreach(var m in lst) + { + if(m.MatchGenericParameters(args, typeof(System.Collections.Generic.IEnumerable), typeof(System.Collections.Generic.IEnumerable), typeof(System.Func))) + { + method = m.MakeGenericMethod(args); + app.RegisterCLRMethodRedirection(method, Where_4); + + break; + } + } + } + args = new Type[]{typeof(System.Byte), typeof(System.Byte)}; + if (genericMethods.TryGetValue("GroupBy", out lst)) + { + foreach(var m in lst) + { + if(m.MatchGenericParameters(args, typeof(System.Collections.Generic.IEnumerable>), typeof(System.Collections.Generic.IEnumerable), typeof(System.Func))) + { + method = m.MakeGenericMethod(args); + app.RegisterCLRMethodRedirection(method, GroupBy_5); + + break; + } + } + } + args = new Type[]{typeof(System.Linq.IGrouping), typeof(ILRuntime.Runtime.Intepreter.ILTypeInstance)}; + if (genericMethods.TryGetValue("Select", out lst)) + { + foreach(var m in lst) + { + if(m.MatchGenericParameters(args, typeof(System.Collections.Generic.IEnumerable), typeof(System.Collections.Generic.IEnumerable>), typeof(System.Func, ILRuntime.Runtime.Intepreter.ILTypeInstance>))) + { + method = m.MakeGenericMethod(args); + app.RegisterCLRMethodRedirection(method, Select_6); + + break; + } + } + } + args = new Type[]{typeof(ILRuntime.Runtime.Intepreter.ILTypeInstance), typeof(System.Int32)}; + if (genericMethods.TryGetValue("OrderBy", out lst)) + { + foreach(var m in lst) + { + if(m.MatchGenericParameters(args, typeof(System.Linq.IOrderedEnumerable), typeof(System.Collections.Generic.IEnumerable), typeof(System.Func))) + { + method = m.MakeGenericMethod(args); + app.RegisterCLRMethodRedirection(method, OrderBy_7); + + break; + } + } + } + args = new Type[]{typeof(ILRuntime.Runtime.Intepreter.ILTypeInstance)}; + if (genericMethods.TryGetValue("ToArray", out lst)) + { + foreach(var m in lst) + { + if(m.MatchGenericParameters(args, typeof(ILRuntime.Runtime.Intepreter.ILTypeInstance[]), typeof(System.Collections.Generic.IEnumerable))) + { + method = m.MakeGenericMethod(args); + app.RegisterCLRMethodRedirection(method, ToArray_8); + + break; + } + } + } + args = new Type[]{typeof(System.Byte)}; + if (genericMethods.TryGetValue("Count", out lst)) + { + foreach(var m in lst) + { + if(m.MatchGenericParameters(args, typeof(System.Int32), typeof(System.Collections.Generic.IEnumerable))) + { + method = m.MakeGenericMethod(args); + app.RegisterCLRMethodRedirection(method, Count_9); + + break; + } + } + } } @@ -172,6 +256,120 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return __ret + 1; } + static StackObject* Where_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, 2); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 1); + System.Func @predicate = (System.Func)typeof(System.Func).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 2); + System.Collections.Generic.IEnumerable @source = (System.Collections.Generic.IEnumerable)typeof(System.Collections.Generic.IEnumerable).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + + var result_of_this_method = System.Linq.Enumerable.Where(@source, @predicate); + + return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); + } + + static StackObject* GroupBy_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, 2); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 1); + System.Func @keySelector = (System.Func)typeof(System.Func).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 2); + System.Collections.Generic.IEnumerable @source = (System.Collections.Generic.IEnumerable)typeof(System.Collections.Generic.IEnumerable).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + + var result_of_this_method = System.Linq.Enumerable.GroupBy(@source, @keySelector); + + return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); + } + + static StackObject* Select_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, 2); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 1); + System.Func, ILRuntime.Runtime.Intepreter.ILTypeInstance> @selector = (System.Func, ILRuntime.Runtime.Intepreter.ILTypeInstance>)typeof(System.Func, ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 2); + System.Collections.Generic.IEnumerable> @source = (System.Collections.Generic.IEnumerable>)typeof(System.Collections.Generic.IEnumerable>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + + var result_of_this_method = System.Linq.Enumerable.Select, ILRuntime.Runtime.Intepreter.ILTypeInstance>(@source, @selector); + + return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); + } + + static StackObject* OrderBy_7(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.Func @keySelector = (System.Func)typeof(System.Func).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + ptr_of_this_method = ILIntepreter.Minus(__esp, 2); + System.Collections.Generic.IEnumerable @source = (System.Collections.Generic.IEnumerable)typeof(System.Collections.Generic.IEnumerable).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + + var result_of_this_method = System.Linq.Enumerable.OrderBy(@source, @keySelector); + + return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); + } + + static StackObject* ToArray_8(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.Collections.Generic.IEnumerable @source = (System.Collections.Generic.IEnumerable)typeof(System.Collections.Generic.IEnumerable).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + + var result_of_this_method = System.Linq.Enumerable.ToArray(@source); + + return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); + } + + static StackObject* Count_9(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.Collections.Generic.IEnumerable @source = (System.Collections.Generic.IEnumerable)typeof(System.Collections.Generic.IEnumerable).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + + var result_of_this_method = System.Linq.Enumerable.Count(@source); + + __ret->ObjectType = ObjectTypes.Integer; + __ret->Value = result_of_this_method; + return __ret + 1; + } + } diff --git a/ILRuntimeTest/AutoGenerate/System_Threading_Tasks_Task_1_String_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Linq_IGrouping_2_Byte_Byte_Binding.cs similarity index 57% rename from ILRuntimeTest/AutoGenerate/System_Threading_Tasks_Task_1_String_Binding.cs rename to ILRuntimeTest/AutoGenerate/System_Linq_IGrouping_2_Byte_Byte_Binding.cs index eda1053e..8e92c624 100644 --- a/ILRuntimeTest/AutoGenerate/System_Threading_Tasks_Task_1_String_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_Linq_IGrouping_2_Byte_Byte_Binding.cs @@ -14,35 +14,37 @@ namespace ILRuntime.Runtime.Generated { - unsafe class System_Threading_Tasks_Task_1_String_Binding + unsafe class System_Linq_IGrouping_2_Byte_Byte_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.Threading.Tasks.Task); + Type type = typeof(System.Linq.IGrouping); args = new Type[]{}; - method = type.GetMethod("GetAwaiter", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, GetAwaiter_0); + method = type.GetMethod("get_Key", flag, null, args, null); + app.RegisterCLRMethodRedirection(method, get_Key_0); } - static StackObject* GetAwaiter_0(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + static StackObject* get_Key_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, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - System.Threading.Tasks.Task instance_of_this_method = (System.Threading.Tasks.Task)typeof(System.Threading.Tasks.Task).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + System.Linq.IGrouping instance_of_this_method = (System.Linq.IGrouping)typeof(System.Linq.IGrouping).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); - var result_of_this_method = instance_of_this_method.GetAwaiter(); + var result_of_this_method = instance_of_this_method.Key; - return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); + __ret->ObjectType = ObjectTypes.Integer; + __ret->Value = result_of_this_method; + return __ret + 1; } diff --git a/ILRuntimeTest/AutoGenerate/System_Reflection_FieldInfo_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Reflection_FieldInfo_Binding.cs index b62707f0..52861fe1 100644 --- a/ILRuntimeTest/AutoGenerate/System_Reflection_FieldInfo_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_Reflection_FieldInfo_Binding.cs @@ -52,6 +52,11 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) var result_of_this_method = instance_of_this_method.GetValue(@obj); + object obj_result_of_this_method = result_of_this_method; + if(obj_result_of_this_method is CrossBindingAdaptorType) + { + return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance, true); + } return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method, true); } diff --git a/ILRuntimeTest/AutoGenerate/System_Reflection_MethodBase_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Reflection_MethodBase_Binding.cs index 96478248..fd638969 100644 --- a/ILRuntimeTest/AutoGenerate/System_Reflection_MethodBase_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_Reflection_MethodBase_Binding.cs @@ -50,6 +50,11 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) var result_of_this_method = instance_of_this_method.Invoke(@obj, @parameters); + object obj_result_of_this_method = result_of_this_method; + if(obj_result_of_this_method is CrossBindingAdaptorType) + { + return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance, true); + } return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method, true); } diff --git a/ILRuntimeTest/AutoGenerate/System_Reflection_PropertyInfo_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Reflection_PropertyInfo_Binding.cs index d0e2a54f..f119e0d7 100644 --- a/ILRuntimeTest/AutoGenerate/System_Reflection_PropertyInfo_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_Reflection_PropertyInfo_Binding.cs @@ -77,6 +77,11 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) var result_of_this_method = instance_of_this_method.GetValue(@obj, @index); + object obj_result_of_this_method = result_of_this_method; + if(obj_result_of_this_method is CrossBindingAdaptorType) + { + return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance, true); + } return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method, true); } diff --git a/ILRuntimeTest/AutoGenerate/System_Runtime_CompilerServices_AsyncTaskMethodBuilder_1_List_1_String_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Runtime_CompilerServices_AsyncTaskMethodBuilder_1_List_1_String_Binding.cs deleted file mode 100644 index 7e263c9a..00000000 --- a/ILRuntimeTest/AutoGenerate/System_Runtime_CompilerServices_AsyncTaskMethodBuilder_1_List_1_String_Binding.cs +++ /dev/null @@ -1,576 +0,0 @@ -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_Runtime_CompilerServices_AsyncTaskMethodBuilder_1_List_1_String_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.Runtime.CompilerServices.AsyncTaskMethodBuilder>); - args = new Type[]{}; - method = type.GetMethod("Create", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, Create_0); - Dictionary> genericMethods = new Dictionary>(); - List lst = null; - foreach(var m in type.GetMethods()) - { - if(m.IsGenericMethodDefinition) - { - if (!genericMethods.TryGetValue(m.Name, out lst)) - { - lst = new List(); - genericMethods[m.Name] = lst; - } - lst.Add(m); - } - } - args = new Type[]{typeof(ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor)}; - if (genericMethods.TryGetValue("Start", out lst)) - { - foreach(var m in lst) - { - if(m.MatchGenericParameters(args, typeof(void), typeof(ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor).MakeByRefType())) - { - method = m.MakeGenericMethod(args); - app.RegisterCLRMethodRedirection(method, Start_1); - - break; - } - } - } - args = new Type[]{}; - method = type.GetMethod("get_Task", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, get_Task_2); - args = new Type[]{typeof(System.Runtime.CompilerServices.TaskAwaiter>), typeof(ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor)}; - if (genericMethods.TryGetValue("AwaitUnsafeOnCompleted", out lst)) - { - foreach(var m in lst) - { - if(m.MatchGenericParameters(args, typeof(void), typeof(System.Runtime.CompilerServices.TaskAwaiter>).MakeByRefType(), typeof(ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor).MakeByRefType())) - { - method = m.MakeGenericMethod(args); - app.RegisterCLRMethodRedirection(method, AwaitUnsafeOnCompleted_3); - - break; - } - } - } - args = new Type[]{typeof(System.Exception)}; - method = type.GetMethod("SetException", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, SetException_4); - args = new Type[]{typeof(System.Collections.Generic.List)}; - method = type.GetMethod("SetResult", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, SetResult_5); - args = new Type[]{typeof(System.Runtime.CompilerServices.TaskAwaiter), typeof(ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor)}; - if (genericMethods.TryGetValue("AwaitUnsafeOnCompleted", out lst)) - { - foreach(var m in lst) - { - if(m.MatchGenericParameters(args, typeof(void), typeof(System.Runtime.CompilerServices.TaskAwaiter).MakeByRefType(), typeof(ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor).MakeByRefType())) - { - method = m.MakeGenericMethod(args); - app.RegisterCLRMethodRedirection(method, AwaitUnsafeOnCompleted_6); - - break; - } - } - } - - app.RegisterCLRCreateDefaultInstance(type, () => new System.Runtime.CompilerServices.AsyncTaskMethodBuilder>()); - - - } - - static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject* ptr_of_this_method, IList __mStack, ref System.Runtime.CompilerServices.AsyncTaskMethodBuilder> 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 System.Runtime.CompilerServices.AsyncTaskMethodBuilder>[]; - instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method; - } - break; - } - } - - static StackObject* Create_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 = System.Runtime.CompilerServices.AsyncTaskMethodBuilder>.Create(); - - return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); - } - - static StackObject* Start_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); - ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor @stateMachine = (ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor)typeof(ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack)); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 2); - ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); - System.Runtime.CompilerServices.AsyncTaskMethodBuilder> instance_of_this_method = (System.Runtime.CompilerServices.AsyncTaskMethodBuilder>)typeof(System.Runtime.CompilerServices.AsyncTaskMethodBuilder>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - - instance_of_this_method.Start(ref @stateMachine); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - switch(ptr_of_this_method->ObjectType) - { - case ObjectTypes.StackObjectReference: - { - var ___dst = ILIntepreter.ResolveReference(ptr_of_this_method); - object ___obj = @stateMachine; - if (___dst->ObjectType >= ObjectTypes.Object) - { - if (___obj is CrossBindingAdaptorType) - ___obj = ((CrossBindingAdaptorType)___obj).ILInstance; - __mStack[___dst->Value] = ___obj; - } - else - { - ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain); - } - } - break; - case ObjectTypes.FieldReference: - { - var ___obj = __mStack[ptr_of_this_method->Value]; - if(___obj is ILTypeInstance) - { - ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = @stateMachine; - } - else - { - var ___type = __domain.GetType(___obj.GetType()) as CLRType; - ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, @stateMachine); - } - } - break; - case ObjectTypes.StaticFieldReference: - { - var ___type = __domain.GetType(ptr_of_this_method->Value); - if(___type is ILType) - { - ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = @stateMachine; - } - else - { - ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, @stateMachine); - } - } - break; - case ObjectTypes.ArrayReference: - { - var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor[]; - instance_of_arrayReference[ptr_of_this_method->ValueLow] = @stateMachine; - } - break; - } - - __intp.Free(ptr_of_this_method); - ptr_of_this_method = ILIntepreter.Minus(__esp, 2); - WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); - - __intp.Free(ptr_of_this_method); - return __ret; - } - - static StackObject* get_Task_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); - ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); - System.Runtime.CompilerServices.AsyncTaskMethodBuilder> instance_of_this_method = (System.Runtime.CompilerServices.AsyncTaskMethodBuilder>)typeof(System.Runtime.CompilerServices.AsyncTaskMethodBuilder>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - - var result_of_this_method = instance_of_this_method.Task; - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); - - __intp.Free(ptr_of_this_method); - object obj_result_of_this_method = result_of_this_method; - if(obj_result_of_this_method is CrossBindingAdaptorType) - { - return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance); - } - return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); - } - - static StackObject* AwaitUnsafeOnCompleted_3(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); - ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor @stateMachine = (ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor)typeof(ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack)); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 2); - System.Runtime.CompilerServices.TaskAwaiter> @awaiter = (System.Runtime.CompilerServices.TaskAwaiter>)typeof(System.Runtime.CompilerServices.TaskAwaiter>).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack)); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 3); - ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); - System.Runtime.CompilerServices.AsyncTaskMethodBuilder> instance_of_this_method = (System.Runtime.CompilerServices.AsyncTaskMethodBuilder>)typeof(System.Runtime.CompilerServices.AsyncTaskMethodBuilder>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - - instance_of_this_method.AwaitUnsafeOnCompleted>, ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor>(ref @awaiter, ref @stateMachine); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - switch(ptr_of_this_method->ObjectType) - { - case ObjectTypes.StackObjectReference: - { - var ___dst = ILIntepreter.ResolveReference(ptr_of_this_method); - object ___obj = @stateMachine; - if (___dst->ObjectType >= ObjectTypes.Object) - { - if (___obj is CrossBindingAdaptorType) - ___obj = ((CrossBindingAdaptorType)___obj).ILInstance; - __mStack[___dst->Value] = ___obj; - } - else - { - ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain); - } - } - break; - case ObjectTypes.FieldReference: - { - var ___obj = __mStack[ptr_of_this_method->Value]; - if(___obj is ILTypeInstance) - { - ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = @stateMachine; - } - else - { - var ___type = __domain.GetType(___obj.GetType()) as CLRType; - ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, @stateMachine); - } - } - break; - case ObjectTypes.StaticFieldReference: - { - var ___type = __domain.GetType(ptr_of_this_method->Value); - if(___type is ILType) - { - ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = @stateMachine; - } - else - { - ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, @stateMachine); - } - } - break; - case ObjectTypes.ArrayReference: - { - var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor[]; - instance_of_arrayReference[ptr_of_this_method->ValueLow] = @stateMachine; - } - break; - } - - __intp.Free(ptr_of_this_method); - ptr_of_this_method = ILIntepreter.Minus(__esp, 2); - switch(ptr_of_this_method->ObjectType) - { - case ObjectTypes.StackObjectReference: - { - var ___dst = ILIntepreter.ResolveReference(ptr_of_this_method); - object ___obj = @awaiter; - if (___dst->ObjectType >= ObjectTypes.Object) - { - if (___obj is CrossBindingAdaptorType) - ___obj = ((CrossBindingAdaptorType)___obj).ILInstance; - __mStack[___dst->Value] = ___obj; - } - else - { - ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain); - } - } - break; - case ObjectTypes.FieldReference: - { - var ___obj = __mStack[ptr_of_this_method->Value]; - if(___obj is ILTypeInstance) - { - ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = @awaiter; - } - else - { - var ___type = __domain.GetType(___obj.GetType()) as CLRType; - ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, @awaiter); - } - } - break; - case ObjectTypes.StaticFieldReference: - { - var ___type = __domain.GetType(ptr_of_this_method->Value); - if(___type is ILType) - { - ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = @awaiter; - } - else - { - ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, @awaiter); - } - } - break; - case ObjectTypes.ArrayReference: - { - var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Runtime.CompilerServices.TaskAwaiter>[]; - instance_of_arrayReference[ptr_of_this_method->ValueLow] = @awaiter; - } - break; - } - - __intp.Free(ptr_of_this_method); - ptr_of_this_method = ILIntepreter.Minus(__esp, 3); - WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); - - __intp.Free(ptr_of_this_method); - return __ret; - } - - static StackObject* SetException_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, 2); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - System.Exception @exception = (System.Exception)typeof(System.Exception).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - __intp.Free(ptr_of_this_method); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 2); - ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); - System.Runtime.CompilerServices.AsyncTaskMethodBuilder> instance_of_this_method = (System.Runtime.CompilerServices.AsyncTaskMethodBuilder>)typeof(System.Runtime.CompilerServices.AsyncTaskMethodBuilder>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - - instance_of_this_method.SetException(@exception); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 2); - WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); - - __intp.Free(ptr_of_this_method); - return __ret; - } - - static StackObject* SetResult_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, 2); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - System.Collections.Generic.List @result = (System.Collections.Generic.List)typeof(System.Collections.Generic.List).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - __intp.Free(ptr_of_this_method); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 2); - ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); - System.Runtime.CompilerServices.AsyncTaskMethodBuilder> instance_of_this_method = (System.Runtime.CompilerServices.AsyncTaskMethodBuilder>)typeof(System.Runtime.CompilerServices.AsyncTaskMethodBuilder>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - - instance_of_this_method.SetResult(@result); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 2); - WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); - - __intp.Free(ptr_of_this_method); - return __ret; - } - - static StackObject* AwaitUnsafeOnCompleted_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, 3); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor @stateMachine = (ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor)typeof(ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack)); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 2); - System.Runtime.CompilerServices.TaskAwaiter @awaiter = (System.Runtime.CompilerServices.TaskAwaiter)typeof(System.Runtime.CompilerServices.TaskAwaiter).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack)); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 3); - ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); - System.Runtime.CompilerServices.AsyncTaskMethodBuilder> instance_of_this_method = (System.Runtime.CompilerServices.AsyncTaskMethodBuilder>)typeof(System.Runtime.CompilerServices.AsyncTaskMethodBuilder>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - - instance_of_this_method.AwaitUnsafeOnCompleted, ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor>(ref @awaiter, ref @stateMachine); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - switch(ptr_of_this_method->ObjectType) - { - case ObjectTypes.StackObjectReference: - { - var ___dst = ILIntepreter.ResolveReference(ptr_of_this_method); - object ___obj = @stateMachine; - if (___dst->ObjectType >= ObjectTypes.Object) - { - if (___obj is CrossBindingAdaptorType) - ___obj = ((CrossBindingAdaptorType)___obj).ILInstance; - __mStack[___dst->Value] = ___obj; - } - else - { - ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain); - } - } - break; - case ObjectTypes.FieldReference: - { - var ___obj = __mStack[ptr_of_this_method->Value]; - if(___obj is ILTypeInstance) - { - ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = @stateMachine; - } - else - { - var ___type = __domain.GetType(___obj.GetType()) as CLRType; - ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, @stateMachine); - } - } - break; - case ObjectTypes.StaticFieldReference: - { - var ___type = __domain.GetType(ptr_of_this_method->Value); - if(___type is ILType) - { - ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = @stateMachine; - } - else - { - ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, @stateMachine); - } - } - break; - case ObjectTypes.ArrayReference: - { - var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor[]; - instance_of_arrayReference[ptr_of_this_method->ValueLow] = @stateMachine; - } - break; - } - - __intp.Free(ptr_of_this_method); - ptr_of_this_method = ILIntepreter.Minus(__esp, 2); - switch(ptr_of_this_method->ObjectType) - { - case ObjectTypes.StackObjectReference: - { - var ___dst = ILIntepreter.ResolveReference(ptr_of_this_method); - object ___obj = @awaiter; - if (___dst->ObjectType >= ObjectTypes.Object) - { - if (___obj is CrossBindingAdaptorType) - ___obj = ((CrossBindingAdaptorType)___obj).ILInstance; - __mStack[___dst->Value] = ___obj; - } - else - { - ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain); - } - } - break; - case ObjectTypes.FieldReference: - { - var ___obj = __mStack[ptr_of_this_method->Value]; - if(___obj is ILTypeInstance) - { - ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = @awaiter; - } - else - { - var ___type = __domain.GetType(___obj.GetType()) as CLRType; - ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, @awaiter); - } - } - break; - case ObjectTypes.StaticFieldReference: - { - var ___type = __domain.GetType(ptr_of_this_method->Value); - if(___type is ILType) - { - ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = @awaiter; - } - else - { - ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, @awaiter); - } - } - break; - case ObjectTypes.ArrayReference: - { - var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Runtime.CompilerServices.TaskAwaiter[]; - instance_of_arrayReference[ptr_of_this_method->ValueLow] = @awaiter; - } - break; - } - - __intp.Free(ptr_of_this_method); - ptr_of_this_method = ILIntepreter.Minus(__esp, 3); - WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); - - __intp.Free(ptr_of_this_method); - return __ret; - } - - - - } -} diff --git a/ILRuntimeTest/AutoGenerate/System_Runtime_CompilerServices_AsyncVoidMethodBuilder_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Runtime_CompilerServices_AsyncVoidMethodBuilder_Binding.cs deleted file mode 100644 index 786598a7..00000000 --- a/ILRuntimeTest/AutoGenerate/System_Runtime_CompilerServices_AsyncVoidMethodBuilder_Binding.cs +++ /dev/null @@ -1,396 +0,0 @@ -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_Runtime_CompilerServices_AsyncVoidMethodBuilder_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.Runtime.CompilerServices.AsyncVoidMethodBuilder); - args = new Type[]{}; - method = type.GetMethod("Create", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, Create_0); - Dictionary> genericMethods = new Dictionary>(); - List lst = null; - foreach(var m in type.GetMethods()) - { - if(m.IsGenericMethodDefinition) - { - if (!genericMethods.TryGetValue(m.Name, out lst)) - { - lst = new List(); - genericMethods[m.Name] = lst; - } - lst.Add(m); - } - } - args = new Type[]{typeof(ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor)}; - if (genericMethods.TryGetValue("Start", out lst)) - { - foreach(var m in lst) - { - if(m.MatchGenericParameters(args, typeof(void), typeof(ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor).MakeByRefType())) - { - method = m.MakeGenericMethod(args); - app.RegisterCLRMethodRedirection(method, Start_1); - - break; - } - } - } - args = new Type[]{typeof(System.Runtime.CompilerServices.TaskAwaiter), typeof(ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor)}; - if (genericMethods.TryGetValue("AwaitUnsafeOnCompleted", out lst)) - { - foreach(var m in lst) - { - if(m.MatchGenericParameters(args, typeof(void), typeof(System.Runtime.CompilerServices.TaskAwaiter).MakeByRefType(), typeof(ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor).MakeByRefType())) - { - method = m.MakeGenericMethod(args); - app.RegisterCLRMethodRedirection(method, AwaitUnsafeOnCompleted_2); - - break; - } - } - } - args = new Type[]{typeof(System.Exception)}; - method = type.GetMethod("SetException", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, SetException_3); - args = new Type[]{}; - method = type.GetMethod("SetResult", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, SetResult_4); - - app.RegisterCLRCreateDefaultInstance(type, () => new System.Runtime.CompilerServices.AsyncVoidMethodBuilder()); - - - } - - static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject* ptr_of_this_method, IList __mStack, ref System.Runtime.CompilerServices.AsyncVoidMethodBuilder 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 System.Runtime.CompilerServices.AsyncVoidMethodBuilder[]; - instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method; - } - break; - } - } - - static StackObject* Create_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 = System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Create(); - - return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); - } - - static StackObject* Start_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); - ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor @stateMachine = (ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor)typeof(ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack)); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 2); - ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); - System.Runtime.CompilerServices.AsyncVoidMethodBuilder instance_of_this_method = (System.Runtime.CompilerServices.AsyncVoidMethodBuilder)typeof(System.Runtime.CompilerServices.AsyncVoidMethodBuilder).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - - instance_of_this_method.Start(ref @stateMachine); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - switch(ptr_of_this_method->ObjectType) - { - case ObjectTypes.StackObjectReference: - { - var ___dst = ILIntepreter.ResolveReference(ptr_of_this_method); - object ___obj = @stateMachine; - if (___dst->ObjectType >= ObjectTypes.Object) - { - if (___obj is CrossBindingAdaptorType) - ___obj = ((CrossBindingAdaptorType)___obj).ILInstance; - __mStack[___dst->Value] = ___obj; - } - else - { - ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain); - } - } - break; - case ObjectTypes.FieldReference: - { - var ___obj = __mStack[ptr_of_this_method->Value]; - if(___obj is ILTypeInstance) - { - ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = @stateMachine; - } - else - { - var ___type = __domain.GetType(___obj.GetType()) as CLRType; - ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, @stateMachine); - } - } - break; - case ObjectTypes.StaticFieldReference: - { - var ___type = __domain.GetType(ptr_of_this_method->Value); - if(___type is ILType) - { - ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = @stateMachine; - } - else - { - ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, @stateMachine); - } - } - break; - case ObjectTypes.ArrayReference: - { - var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor[]; - instance_of_arrayReference[ptr_of_this_method->ValueLow] = @stateMachine; - } - break; - } - - __intp.Free(ptr_of_this_method); - ptr_of_this_method = ILIntepreter.Minus(__esp, 2); - WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); - - __intp.Free(ptr_of_this_method); - return __ret; - } - - static StackObject* AwaitUnsafeOnCompleted_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, 3); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor @stateMachine = (ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor)typeof(ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack)); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 2); - System.Runtime.CompilerServices.TaskAwaiter @awaiter = (System.Runtime.CompilerServices.TaskAwaiter)typeof(System.Runtime.CompilerServices.TaskAwaiter).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack)); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 3); - ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); - System.Runtime.CompilerServices.AsyncVoidMethodBuilder instance_of_this_method = (System.Runtime.CompilerServices.AsyncVoidMethodBuilder)typeof(System.Runtime.CompilerServices.AsyncVoidMethodBuilder).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - - instance_of_this_method.AwaitUnsafeOnCompleted(ref @awaiter, ref @stateMachine); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - switch(ptr_of_this_method->ObjectType) - { - case ObjectTypes.StackObjectReference: - { - var ___dst = ILIntepreter.ResolveReference(ptr_of_this_method); - object ___obj = @stateMachine; - if (___dst->ObjectType >= ObjectTypes.Object) - { - if (___obj is CrossBindingAdaptorType) - ___obj = ((CrossBindingAdaptorType)___obj).ILInstance; - __mStack[___dst->Value] = ___obj; - } - else - { - ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain); - } - } - break; - case ObjectTypes.FieldReference: - { - var ___obj = __mStack[ptr_of_this_method->Value]; - if(___obj is ILTypeInstance) - { - ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = @stateMachine; - } - else - { - var ___type = __domain.GetType(___obj.GetType()) as CLRType; - ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, @stateMachine); - } - } - break; - case ObjectTypes.StaticFieldReference: - { - var ___type = __domain.GetType(ptr_of_this_method->Value); - if(___type is ILType) - { - ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = @stateMachine; - } - else - { - ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, @stateMachine); - } - } - break; - case ObjectTypes.ArrayReference: - { - var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as ILRuntimeTest.TestFramework.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor[]; - instance_of_arrayReference[ptr_of_this_method->ValueLow] = @stateMachine; - } - break; - } - - __intp.Free(ptr_of_this_method); - ptr_of_this_method = ILIntepreter.Minus(__esp, 2); - switch(ptr_of_this_method->ObjectType) - { - case ObjectTypes.StackObjectReference: - { - var ___dst = ILIntepreter.ResolveReference(ptr_of_this_method); - object ___obj = @awaiter; - if (___dst->ObjectType >= ObjectTypes.Object) - { - if (___obj is CrossBindingAdaptorType) - ___obj = ((CrossBindingAdaptorType)___obj).ILInstance; - __mStack[___dst->Value] = ___obj; - } - else - { - ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain); - } - } - break; - case ObjectTypes.FieldReference: - { - var ___obj = __mStack[ptr_of_this_method->Value]; - if(___obj is ILTypeInstance) - { - ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = @awaiter; - } - else - { - var ___type = __domain.GetType(___obj.GetType()) as CLRType; - ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, @awaiter); - } - } - break; - case ObjectTypes.StaticFieldReference: - { - var ___type = __domain.GetType(ptr_of_this_method->Value); - if(___type is ILType) - { - ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = @awaiter; - } - else - { - ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, @awaiter); - } - } - break; - case ObjectTypes.ArrayReference: - { - var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Runtime.CompilerServices.TaskAwaiter[]; - instance_of_arrayReference[ptr_of_this_method->ValueLow] = @awaiter; - } - break; - } - - __intp.Free(ptr_of_this_method); - ptr_of_this_method = ILIntepreter.Minus(__esp, 3); - WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); - - __intp.Free(ptr_of_this_method); - return __ret; - } - - static StackObject* SetException_3(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.Exception @exception = (System.Exception)typeof(System.Exception).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - __intp.Free(ptr_of_this_method); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 2); - ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); - System.Runtime.CompilerServices.AsyncVoidMethodBuilder instance_of_this_method = (System.Runtime.CompilerServices.AsyncVoidMethodBuilder)typeof(System.Runtime.CompilerServices.AsyncVoidMethodBuilder).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - - instance_of_this_method.SetException(@exception); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 2); - WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); - - __intp.Free(ptr_of_this_method); - return __ret; - } - - static StackObject* SetResult_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); - ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); - System.Runtime.CompilerServices.AsyncVoidMethodBuilder instance_of_this_method = (System.Runtime.CompilerServices.AsyncVoidMethodBuilder)typeof(System.Runtime.CompilerServices.AsyncVoidMethodBuilder).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - - instance_of_this_method.SetResult(); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); - - __intp.Free(ptr_of_this_method); - return __ret; - } - - - - } -} diff --git a/ILRuntimeTest/AutoGenerate/System_Runtime_CompilerServices_TaskAwaiter_1_List_1_String_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Runtime_CompilerServices_TaskAwaiter_1_List_1_String_Binding.cs deleted file mode 100644 index 90d7e9b7..00000000 --- a/ILRuntimeTest/AutoGenerate/System_Runtime_CompilerServices_TaskAwaiter_1_List_1_String_Binding.cs +++ /dev/null @@ -1,126 +0,0 @@ -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_Runtime_CompilerServices_TaskAwaiter_1_List_1_String_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.Runtime.CompilerServices.TaskAwaiter>); - args = new Type[]{}; - method = type.GetMethod("get_IsCompleted", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, get_IsCompleted_0); - args = new Type[]{}; - method = type.GetMethod("GetResult", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, GetResult_1); - - app.RegisterCLRCreateDefaultInstance(type, () => new System.Runtime.CompilerServices.TaskAwaiter>()); - - - } - - static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject* ptr_of_this_method, IList __mStack, ref System.Runtime.CompilerServices.TaskAwaiter> 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 System.Runtime.CompilerServices.TaskAwaiter>[]; - instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method; - } - break; - } - } - - static StackObject* get_IsCompleted_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, 1); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); - System.Runtime.CompilerServices.TaskAwaiter> instance_of_this_method = (System.Runtime.CompilerServices.TaskAwaiter>)typeof(System.Runtime.CompilerServices.TaskAwaiter>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - - var result_of_this_method = instance_of_this_method.IsCompleted; - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); - - __intp.Free(ptr_of_this_method); - __ret->ObjectType = ObjectTypes.Integer; - __ret->Value = result_of_this_method ? 1 : 0; - return __ret + 1; - } - - static StackObject* GetResult_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, 1); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); - System.Runtime.CompilerServices.TaskAwaiter> instance_of_this_method = (System.Runtime.CompilerServices.TaskAwaiter>)typeof(System.Runtime.CompilerServices.TaskAwaiter>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - - var result_of_this_method = instance_of_this_method.GetResult(); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); - - __intp.Free(ptr_of_this_method); - return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); - } - - - - } -} diff --git a/ILRuntimeTest/AutoGenerate/System_Runtime_CompilerServices_TaskAwaiter_1_String_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Runtime_CompilerServices_TaskAwaiter_1_String_Binding.cs deleted file mode 100644 index 66585b14..00000000 --- a/ILRuntimeTest/AutoGenerate/System_Runtime_CompilerServices_TaskAwaiter_1_String_Binding.cs +++ /dev/null @@ -1,126 +0,0 @@ -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_Runtime_CompilerServices_TaskAwaiter_1_String_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.Runtime.CompilerServices.TaskAwaiter); - args = new Type[]{}; - method = type.GetMethod("get_IsCompleted", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, get_IsCompleted_0); - args = new Type[]{}; - method = type.GetMethod("GetResult", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, GetResult_1); - - app.RegisterCLRCreateDefaultInstance(type, () => new System.Runtime.CompilerServices.TaskAwaiter()); - - - } - - static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject* ptr_of_this_method, IList __mStack, ref System.Runtime.CompilerServices.TaskAwaiter 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 System.Runtime.CompilerServices.TaskAwaiter[]; - instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method; - } - break; - } - } - - static StackObject* get_IsCompleted_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, 1); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); - System.Runtime.CompilerServices.TaskAwaiter instance_of_this_method = (System.Runtime.CompilerServices.TaskAwaiter)typeof(System.Runtime.CompilerServices.TaskAwaiter).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - - var result_of_this_method = instance_of_this_method.IsCompleted; - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); - - __intp.Free(ptr_of_this_method); - __ret->ObjectType = ObjectTypes.Integer; - __ret->Value = result_of_this_method ? 1 : 0; - return __ret + 1; - } - - static StackObject* GetResult_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, 1); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); - System.Runtime.CompilerServices.TaskAwaiter instance_of_this_method = (System.Runtime.CompilerServices.TaskAwaiter)typeof(System.Runtime.CompilerServices.TaskAwaiter).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - - var result_of_this_method = instance_of_this_method.GetResult(); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); - - __intp.Free(ptr_of_this_method); - return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); - } - - - - } -} diff --git a/ILRuntimeTest/AutoGenerate/System_String_Binding.cs b/ILRuntimeTest/AutoGenerate/System_String_Binding.cs index 7563627a..d4824a47 100644 --- a/ILRuntimeTest/AutoGenerate/System_String_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_String_Binding.cs @@ -67,6 +67,9 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) args = new Type[]{typeof(System.String), typeof(System.String)}; method = type.GetMethod("op_Equality", flag, null, args, null); app.RegisterCLRMethodRedirection(method, op_Equality_14); + args = new Type[]{typeof(System.IFormatProvider), typeof(System.String), typeof(System.Object[])}; + method = type.GetMethod("Format", flag, null, args, null); + app.RegisterCLRMethodRedirection(method, Format_15); } @@ -393,6 +396,30 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return __ret + 1; } + static StackObject* Format_15(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.Object[] @args = (System.Object[])typeof(System.Object[]).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 @format = (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.IFormatProvider @provider = (System.IFormatProvider)typeof(System.IFormatProvider).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); + __intp.Free(ptr_of_this_method); + + + var result_of_this_method = System.String.Format(@provider, @format, @args); + + return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); + } + } diff --git a/ILRuntimeTest/AutoGenerate/System_Threading_Tasks_Task_1_List_1_String_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Threading_Tasks_Task_1_List_1_String_Binding.cs deleted file mode 100644 index e7e3840a..00000000 --- a/ILRuntimeTest/AutoGenerate/System_Threading_Tasks_Task_1_List_1_String_Binding.cs +++ /dev/null @@ -1,51 +0,0 @@ -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_Threading_Tasks_Task_1_List_1_String_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.Threading.Tasks.Task>); - args = new Type[]{}; - method = type.GetMethod("GetAwaiter", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, GetAwaiter_0); - - - } - - - static StackObject* GetAwaiter_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, 1); - - ptr_of_this_method = ILIntepreter.Minus(__esp, 1); - System.Threading.Tasks.Task> instance_of_this_method = (System.Threading.Tasks.Task>)typeof(System.Threading.Tasks.Task>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - __intp.Free(ptr_of_this_method); - - var result_of_this_method = instance_of_this_method.GetAwaiter(); - - return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); - } - - - - } -} diff --git a/ILRuntimeTest/AutoGenerate/System_Threading_Tasks_Task_Binding.cs b/ILRuntimeTest/AutoGenerate/System_Threading_Tasks_Task_Binding.cs index 6b544374..da6173ea 100644 --- a/ILRuntimeTest/AutoGenerate/System_Threading_Tasks_Task_Binding.cs +++ b/ILRuntimeTest/AutoGenerate/System_Threading_Tasks_Task_Binding.cs @@ -70,23 +70,6 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) } } } - args = new Type[]{typeof(System.Collections.Generic.List)}; - if (genericMethods.TryGetValue("Run", out lst)) - { - foreach(var m in lst) - { - if(m.MatchGenericParameters(args, typeof(System.Threading.Tasks.Task>), typeof(System.Func>>))) - { - method = m.MakeGenericMethod(args); - app.RegisterCLRMethodRedirection(method, Run_4); - - break; - } - } - } - args = new Type[]{typeof(System.Collections.Generic.IEnumerable)}; - method = type.GetMethod("WhenAll", flag, null, args, null); - app.RegisterCLRMethodRedirection(method, WhenAll_5); args = new Type[]{typeof(System.Int32)}; if (genericMethods.TryGetValue("FromResult", out lst)) { @@ -95,7 +78,7 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) if(m.MatchGenericParameters(args, typeof(System.Threading.Tasks.Task), typeof(System.Int32))) { method = m.MakeGenericMethod(args); - app.RegisterCLRMethodRedirection(method, FromResult_6); + app.RegisterCLRMethodRedirection(method, FromResult_4); break; } @@ -183,49 +166,7 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app) return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); } - static StackObject* Run_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.Func>> @function = (System.Func>>)typeof(System.Func>>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - __intp.Free(ptr_of_this_method); - - - var result_of_this_method = System.Threading.Tasks.Task.Run>(@function); - - object obj_result_of_this_method = result_of_this_method; - if(obj_result_of_this_method is CrossBindingAdaptorType) - { - return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance); - } - return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); - } - - static StackObject* WhenAll_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.Collections.Generic.IEnumerable @tasks = (System.Collections.Generic.IEnumerable)typeof(System.Collections.Generic.IEnumerable).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); - __intp.Free(ptr_of_this_method); - - - var result_of_this_method = System.Threading.Tasks.Task.WhenAll(@tasks); - - object obj_result_of_this_method = result_of_this_method; - if(obj_result_of_this_method is CrossBindingAdaptorType) - { - return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance); - } - return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method); - } - - static StackObject* FromResult_6(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) + static StackObject* FromResult_4(ILIntepreter __intp, StackObject* __esp, IList __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject* ptr_of_this_method; diff --git a/ILRuntimeTest/ILRuntimeTest.csproj b/ILRuntimeTest/ILRuntimeTest.csproj index 94460624..5ece5431 100644 --- a/ILRuntimeTest/ILRuntimeTest.csproj +++ b/ILRuntimeTest/ILRuntimeTest.csproj @@ -83,6 +83,7 @@ + @@ -117,10 +118,12 @@ + + @@ -138,7 +141,6 @@ - @@ -160,8 +162,8 @@ - + @@ -173,18 +175,12 @@ - - - - - - diff --git a/ILRuntimeTest/TestFramework/TestClass3.cs b/ILRuntimeTest/TestFramework/TestClass3.cs index e9513cae..08a3f7e1 100644 --- a/ILRuntimeTest/TestFramework/TestClass3.cs +++ b/ILRuntimeTest/TestFramework/TestClass3.cs @@ -23,6 +23,11 @@ public virtual void KKK() a = 1; b = 2; } + + public void TestArrayOut(out TestStruct[] arr) + { + arr = new TestStruct[10]; + } } public struct TestStruct diff --git a/ILRuntimeTest/TestMainForm.cs b/ILRuntimeTest/TestMainForm.cs index af4ddc35..a973b7c6 100644 --- a/ILRuntimeTest/TestMainForm.cs +++ b/ILRuntimeTest/TestMainForm.cs @@ -264,11 +264,12 @@ private void btnGenerateBinding_Click(object sender, EventArgs e) using (FileStream fs = new FileStream(txtPath.Text, FileMode.Open, FileAccess.Read)) { domain.LoadAssembly(fs); + + //Crossbind Adapter is needed to generate the correct binding code + ILRuntimeHelper.Init(domain); + string outputPath = ".." + Path.DirectorySeparatorChar + ".." + Path.DirectorySeparatorChar + "AutoGenerate"; // "..\\..\\AutoGenerate" + ILRuntime.Runtime.CLRBinding.BindingCodeGenerator.GenerateBindingCode(domain, outputPath); } - //Crossbind Adapter is needed to generate the correct binding code - ILRuntimeHelper.Init(domain); - string outputPath = ".." + Path.DirectorySeparatorChar + ".." + Path.DirectorySeparatorChar + "AutoGenerate"; // "..\\..\\AutoGenerate" - ILRuntime.Runtime.CLRBinding.BindingCodeGenerator.GenerateBindingCode(domain, outputPath); } } } diff --git a/TestCases/ArrayTest.cs b/TestCases/ArrayTest.cs index a3fe8d0a..27fc2fbc 100644 --- a/TestCases/ArrayTest.cs +++ b/TestCases/ArrayTest.cs @@ -79,5 +79,12 @@ public static void ArrayTest07() a[0, 0] = 1; //ios il2cpp ipad test: invocation exception a[0, 0].ToString(); //unityeditor crash on windows pc test } + + public static void ArrayBindTest() + { + ILRuntimeTest.TestFramework.TestClass4 cls = new ILRuntimeTest.TestFramework.TestClass4(); + cls.TestArrayOut(out var arr); + Console.WriteLine(arr.Length); + } } } diff --git a/TestCases/EnumTest.cs b/TestCases/EnumTest.cs index 63e05d76..8ee81dc7 100644 --- a/TestCases/EnumTest.cs +++ b/TestCases/EnumTest.cs @@ -246,6 +246,18 @@ public static void Test17() Console.WriteLine(e); } } + + public static void Test18() + { + var a = TestEnum.Enum2; + Test18Sub(0x123456789, out a); + Console.WriteLine(a); + } + + static void Test18Sub(ulong val, out TestEnum e) + { + e = (TestEnum)val; + } class SystemType { public int value = 10; diff --git a/TestCases/ReflectionTest.cs b/TestCases/ReflectionTest.cs index 6c3f459b..7eb4584d 100644 --- a/TestCases/ReflectionTest.cs +++ b/TestCases/ReflectionTest.cs @@ -317,7 +317,7 @@ static void ReflectionTest11Sub(object o) var p = o.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);//error foreach (var i in p) { - Console.WriteLine(i.GetValue(o, new object[] { 1, 2L ,3333})); + Console.WriteLine(i.GetValue(o, new object[] { 1, 2L, 3333 })); i.SetValue(o, 333, new object[] { 123, 345L, 678 }); } } @@ -409,5 +409,34 @@ public sealed class TestController { public static TestController instance = new TestController(); } + + public static void ReflectionTest16() + { + MethodInfo info = typeof(ReflectionTest).GetMethod(nameof(ReflectionTest16Sub), BindingFlags.NonPublic | BindingFlags.Static); + info.Invoke(null, new object[] { null }); + info.Invoke(null, new object[] { null }); + } + + public static void ReflectionTest17() + { + MethodInfo info = typeof(ReflectionTest).GetMethod(nameof(ReflectionTest17Sub), BindingFlags.NonPublic | BindingFlags.Static); + int cnt = 0; + cnt += (int)info.Invoke(null, new object[] { null }); + cnt += (int)info.Invoke(null, new object[] { null }); + + Console.WriteLine(cnt); + if (cnt != 40) + throw new Exception("Wrong result"); + } + + static void ReflectionTest16Sub(TestCases.TestCls t) + { + Console.WriteLine("OK"); + } + + static int ReflectionTest17Sub() + { + return 20; + } } }