diff --git a/ILRuntime/Runtime/Intepreter/ILIntepreter.cs b/ILRuntime/Runtime/Intepreter/ILIntepreter.cs index 8236b494..a9edfc87 100644 --- a/ILRuntime/Runtime/Intepreter/ILIntepreter.cs +++ b/ILRuntime/Runtime/Intepreter/ILIntepreter.cs @@ -4736,10 +4736,24 @@ void StLocSub(StackObject* esp, StackObject* v, int idx, IList mStack) if (v->ObjectType == ObjectTypes.ValueTypeObjectReference) { CopyStackValueType(esp, v, mStack); + FreeStackValueType(esp); + } + else if(v->ObjectType == ObjectTypes.Object) + { + var dst = ILIntepreter.ResolveReference(esp); + if(dst != null) + { + var ct = domain.GetTypeByIndex(dst->Value) as CLRType; + var binder = ct.ValueTypeBinder; + v->ObjectType = ObjectTypes.ValueTypeObjectReference; + int addr = ((IntPtr)dst).ToInt32(); + v->Value = addr; + } + else + throw new NotImplementedException(); } else throw new NotImplementedException(); - FreeStackValueType(esp); break; default: *v = *esp; diff --git a/TestCases/TestValueTypeBinding.cs b/TestCases/TestValueTypeBinding.cs index 548f17fb..52efe223 100644 --- a/TestCases/TestValueTypeBinding.cs +++ b/TestCases/TestValueTypeBinding.cs @@ -477,5 +477,29 @@ public static void UnitTest_10047() if(Math.Abs(arr2[0].X - 1244)>0.001f) throw new Exception(); } + + public static void UnitTest_10048() + { + var pos = new TestVector3(0f, 0.8f, 0.5f); + var obj = pos as object; + UnitTest_10048Sub(obj); + } + + static void UnitTest_10048Sub(object param = null) + { + var context = new UnitTest_10048Context( param); + object data = context.data; + Console.WriteLine("data:" + data.ToString()); + } + + public class UnitTest_10048Context + { + public object data; + + public UnitTest_10048Context(object data = null) + { + this.data = data; + } + } } } \ No newline at end of file