}
}
-public struct AStruct {
+public struct AStruct : ITest2 {
public int i;
public string s;
public byte k;
public void invoke_mutate () {
l = 5;
}
+
+ public int invoke_iface () {
+ return i;
+ }
+
+ public override string ToString () {
+ return i.ToString ();
+ }
}
public class GClass<T> {
AssertValue ("AB", vals [i]);
if (locals [i].Name == "t")
AssertValue ("ABC", vals [i]);
- if (locals [i].Name == "alist")
- ;
+ if (locals [i].Name == "alist") {
+ }
}
// Argument checking
task = s.InvokeMethodAsyncWithResult (e.Thread, m, null);
out_this = task.Result.OutThis as StructMirror;
Assert.AreEqual (null, out_this);
+
+ // interface method
+ var cl1 = frame.Method.DeclaringType.Assembly.GetType ("ITest2");
+ m = cl1.GetMethod ("invoke_iface");
+ v = s.InvokeMethod (e.Thread, m, null);
+ AssertValue (42, v);
+
+ // virtual method
+ m = vm.RootDomain.Corlib.GetType ("System.Object").GetMethod ("ToString");
+ v = s.InvokeMethod (e.Thread, m, null, InvokeOptions.Virtual);
+ AssertValue ("42", v);
#endif
}
return ERR_INVALID_ARGUMENT;
}
m = mono_object_get_virtual_method (this, m);
+ /* Transform this to the format the rest of the code expects it to be */
+ if (m->klass->valuetype) {
+ this_buf = g_alloca (mono_class_instance_size (m->klass));
+ memcpy (this_buf, mono_object_unbox (this), mono_class_instance_size (m->klass));
+ }
} else if ((m->flags & METHOD_ATTRIBUTE_VIRTUAL) && !m->klass->valuetype && invoke->flags & INVOKE_FLAG_VIRTUAL) {
if (!this) {
DEBUG_PRINTF (1, "[%p] Error: invoke with INVOKE_FLAG_VIRTUAL flag set without this argument.\n", (gpointer)GetCurrentThreadId ());
return ERR_INVALID_ARGUMENT;
}
m = mono_object_get_virtual_method (this, m);
+ if (m->klass->valuetype) {
+ this_buf = g_alloca (mono_class_instance_size (m->klass));
+ memcpy (this_buf, mono_object_unbox (this), mono_class_instance_size (m->klass));
+ }
}
DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer)GetCurrentThreadId (), mono_method_full_name (m, TRUE), this ? this->vtable->klass->name : "<null>");