public bool AssignFieldFromStack(int hash, ref object target, Runtime.Intepreter.ILIntepreter intp, StackObject *esp, IList <object> mStack) { if (fieldMapping == null) { InitializeFields(); } if (fieldBindingCache == null) { return(false); } var binding = GetFieldBinding(hash); if (binding.Value != null) { esp = binding.Value(ref target, intp, esp, mStack); return(true); } else { return(false); } }
public unsafe object Invoke(Runtime.Intepreter.ILIntepreter intepreter, StackObject *esp, IList <object> mStack, bool isNewObj = false) { if (parameters == null) { InitParameters(); } int paramCount = ParameterCount; if (invocationParam == null) { invocationParam = new object[paramCount]; } object[] param = invocationParam; for (int i = paramCount; i >= 1; i--) { var p = Minus(esp, i); var pt = this.param[paramCount - i].ParameterType; var obj = pt.CheckCLRTypes(StackObject.ToObject(p, appdomain, mStack)); obj = ILIntepreter.CheckAndCloneValueType(obj, appdomain); param[paramCount - i] = obj; } if (isConstructor) { if (!isNewObj) { if (!cDef.IsStatic) { object instance = declaringType.TypeForCLR.CheckCLRTypes(StackObject.ToObject((Minus(esp, paramCount + 1)), appdomain, mStack)); if (instance == null) { throw new NullReferenceException(); } if (instance is CrossBindingAdaptorType && paramCount == 0)//It makes no sense to call the Adaptor's default constructor { return(null); } cDef.Invoke(instance, param); return(null); } else { throw new NotImplementedException(); } } else { var res = cDef.Invoke(param); FixReference(paramCount, esp, param, mStack, null, false); return(res); } } else { object instance = null; if (!def.IsStatic) { instance = StackObject.ToObject((Minus(esp, paramCount + 1)), appdomain, mStack); if (!(instance is Reflection.ILRuntimeWrapperType)) { instance = declaringType.TypeForCLR.CheckCLRTypes(instance); } if (declaringType.IsValueType) { instance = ILIntepreter.CheckAndCloneValueType(instance, appdomain); } if (instance == null) { throw new NullReferenceException(); } } object res = null; /*if (redirect != null) * res = redirect(new ILContext(appdomain, intepreter, esp, mStack, this), instance, param, genericArguments); * else*/ { res = def.Invoke(instance, param); } FixReference(paramCount, esp, param, mStack, instance, !def.IsStatic); return(res); } }
public unsafe object Invoke(Runtime.Intepreter.ILIntepreter intepreter, StackObject *esp, List <object> mStack, bool isNewObj = false) { if (parameters == null) { InitParameters(); } int paramCount = ParameterCount; if (invocationParam == null) { invocationParam = new object[paramCount]; } object[] param = invocationParam; for (int i = paramCount; i >= 1; i--) { var p = Minus(esp, i); var obj = this.param[paramCount - i].ParameterType.CheckCLRTypes(appdomain, StackObject.ToObject(p, appdomain, mStack)); param[paramCount - i] = obj; } if (isConstructor) { if (!isNewObj) { if (!cDef.IsStatic) { object instance = declaringType.TypeForCLR.CheckCLRTypes(appdomain, StackObject.ToObject((Minus(esp, paramCount + 1)), appdomain, mStack)); if (instance == null) { throw new NullReferenceException(); } if (instance is CrossBindingAdaptorType)//It makes no sense to call the Adaptor's constructor { return(null); } cDef.Invoke(instance, param); return(null); } else { throw new NotImplementedException(); } } else { var res = cDef.Invoke(param); return(res); } } else { object instance = null; if (!def.IsStatic) { instance = declaringType.TypeForCLR.CheckCLRTypes(appdomain, StackObject.ToObject((Minus(esp, paramCount + 1)), appdomain, mStack)); if (instance == null) { throw new NullReferenceException(); } } object res = null; if (redirect != null) { res = redirect(new ILContext(appdomain, intepreter, esp, mStack, this), instance, param, genericArguments); } else { res = def.Invoke(instance, param); } return(res); } }