Skip to content

Commit

Permalink
Fixed a bug with Value type
Browse files Browse the repository at this point in the history
  • Loading branch information
liiir1985 committed Apr 22, 2020
1 parent 46dd75c commit f0e537f
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 136 deletions.
1 change: 1 addition & 0 deletions ILRuntime/Runtime/Intepreter/ILIntepreter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,7 @@ public object Run(ILMethod method, object instance, object[] p)
switch (objRef->ObjectType)
{
case ObjectTypes.Object:
mStack[objRef->Value] = obj;
break;
case ObjectTypes.FieldReference:
{
Expand Down
2 changes: 1 addition & 1 deletion ILRuntimeTest/AutoGenerate/CLRBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public static void Initialize(ILRuntime.Runtime.Enviorment.AppDomain app)
System_Math_Binding.Register(app);
ILRuntimeTest_TestFramework_TestStruct_Binding.Register(app);
ILRuntimeTest_TestFramework_TestClass3_Binding.Register(app);
System_Single_Binding.Register(app);
System_Byte_Binding.Register(app);
System_Char_Binding.Register(app);
System_IO_File_Binding.Register(app);
Expand All @@ -94,7 +95,6 @@ public static void Initialize(ILRuntime.Runtime.Enviorment.AppDomain 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);
System_Collections_Generic_KeyValuePair_2_String_Int32_Binding.Register(app);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
FieldInfo field;
Type[] args;
Type type = typeof(ILRuntimeTest.TestFramework.TestVector3NoBinding);
args = new Type[]{};
method = type.GetMethod("get_zero", flag, null, args, null);
app.RegisterCLRMethodRedirection(method, get_zero_0);

field = type.GetField("y", flag);
app.RegisterCLRFieldGetter(field, get_y_0);
Expand Down Expand Up @@ -85,6 +88,17 @@ static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, S
}
}

static StackObject* get_zero_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
{
ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
StackObject* __ret = ILIntepreter.Minus(__esp, 0);


var result_of_this_method = ILRuntimeTest.TestFramework.TestVector3NoBinding.zero;

return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
}


static object get_y_0(ref object o)
{
Expand Down
20 changes: 20 additions & 0 deletions ILRuntimeTest/AutoGenerate/System_Double_Binding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ unsafe class System_Double_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.Double);
args = new Type[]{};
method = type.GetMethod("ToString", flag, null, args, null);
app.RegisterCLRMethodRedirection(method, ToString_0);

app.RegisterCLRCreateArrayInstance(type, s => new System.Double[s]);

Expand Down Expand Up @@ -71,6 +77,20 @@ static System.Double GetInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain
return instance_of_this_method;
}

static StackObject* ToString_0(ILIntepreter __intp, StackObject* __esp, IList<object> __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 instance_of_this_method = GetInstance(__domain, ptr_of_this_method, __mStack);

var result_of_this_method = instance_of_this_method.ToString();

return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
}



}
Expand Down
26 changes: 0 additions & 26 deletions ILRuntimeTest/AutoGenerate/System_Int32_Array2_Binding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
args = new Type[]{typeof(System.Int32), typeof(System.Int32), typeof(System.Int32)};
method = type.GetMethod("Set", flag, null, args, null);
app.RegisterCLRMethodRedirection(method, Set_0);
args = new Type[]{typeof(System.Int32), typeof(System.Int32)};
method = type.GetMethod("Get", flag, null, args, null);
app.RegisterCLRMethodRedirection(method, Get_1);

args = new Type[]{typeof(System.Int32), typeof(System.Int32)};
method = type.GetConstructor(flag, null, args, null);
Expand Down Expand Up @@ -60,29 +57,6 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
return __ret;
}

static StackObject* Get_1(ILIntepreter __intp, StackObject* __esp, IList<object> __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 a2 = ptr_of_this_method->Value;

ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
System.Int32 a1 = ptr_of_this_method->Value;

ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
System.Int32[,] instance_of_this_method = (System.Int32[,])typeof(System.Int32[,]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
__intp.Free(ptr_of_this_method);

var result_of_this_method = instance_of_this_method[a1, a2];

__ret->ObjectType = ObjectTypes.Integer;
__ret->Value = result_of_this_method;
return __ret + 1;
}


static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
{
Expand Down
20 changes: 20 additions & 0 deletions ILRuntimeTest/AutoGenerate/System_Single_Binding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ unsafe class System_Single_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.Single);
args = new Type[]{};
method = type.GetMethod("ToString", flag, null, args, null);
app.RegisterCLRMethodRedirection(method, ToString_0);

app.RegisterCLRCreateArrayInstance(type, s => new System.Single[s]);

Expand Down Expand Up @@ -71,6 +77,20 @@ static System.Single GetInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain
return instance_of_this_method;
}

static StackObject* ToString_0(ILIntepreter __intp, StackObject* __esp, IList<object> __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.Single instance_of_this_method = GetInstance(__domain, ptr_of_this_method, __mStack);

var result_of_this_method = instance_of_this_method.ToString();

return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
}



}
Expand Down
Loading

0 comments on commit f0e537f

Please sign in to comment.