public sealed override int Run(InterpretedFrame frame) { int first = frame.StackIndex - _argumentCount; var args = GetArgs(frame, first); try { object ret; try { ret = _constructor.Invoke(args); } catch (TargetInvocationException e) { throw ExceptionHelpers.UpdateForRethrow(e.InnerException); } frame.Data[first] = ret; frame.StackIndex = first + 1; } finally { if (args != null) { foreach (var arg in _byrefArgs) { arg.Update(frame, args[arg.ArgumentIndex]); } } } return(1); }
/// <summary> /// Uses reflection to create new instance of the appropriate ReflectedCaller /// </summary> private static CallInstruction SlowCreate(MethodInfo info, ParameterInfo[] pis) { List <Type> types = new List <Type>(); if (!info.IsStatic) { types.Add(info.DeclaringType); } foreach (ParameterInfo pi in pis) { types.Add(pi.ParameterType); } if (info.ReturnType != typeof(void)) { types.Add(info.ReturnType); } Type[] arrTypes = types.ToArray(); try { return((CallInstruction)Activator.CreateInstance(GetHelperType(info, arrTypes), info)); } catch (TargetInvocationException e) { throw ExceptionHelpers.UpdateForRethrow(e.InnerException); } }
private object InvokeWorker(params object[] args) { if (_target.IsStatic) { try { return(_target.Invoke(null, args)); } catch (TargetInvocationException e) { throw ExceptionHelpers.UpdateForRethrow(e.InnerException); } } LightLambda targetLambda; if (TryGetLightLambdaTarget(args[0], out targetLambda)) { // no need to Invoke, just interpret the lambda body return(InterpretLambdaInvoke(targetLambda, SkipFirstArg(args))); } try { return(_target.Invoke(args[0], SkipFirstArg(args))); } catch (TargetInvocationException e) { throw ExceptionHelpers.UpdateForRethrow(e.InnerException); } }
public override object InvokeInstance(object instance, params object[] args) { if (_target.IsStatic) { try { return(_target.Invoke(null, args)); } catch (TargetInvocationException e) { throw ExceptionHelpers.UpdateForRethrow(e.InnerException); } } LightLambda targetLambda; if (TryGetLightLambdaTarget(instance, out targetLambda)) { // no need to Invoke, just interpret the lambda body return(InterpretLambdaInvoke(targetLambda, SkipFirstArg(args))); } try { NullCheck(instance); return(_target.Invoke(instance, args)); } catch (TargetInvocationException e) { throw ExceptionHelpers.UpdateForRethrow(e.InnerException); } }
public override int Run(InterpretedFrame frame) { int first = frame.StackIndex - _argumentCount; object ret; if (_target.IsStatic) { object[] args = GetArgs(frame, first, 0); try { ret = _target.Invoke(null, args); } catch (TargetInvocationException e) { throw ExceptionHelpers.UpdateForRethrow(e.InnerException); } } else { object instance = frame.Data[first]; NullCheck(instance); object[] args = GetArgs(frame, first, 1); LightLambda targetLambda; if (TryGetLightLambdaTarget(instance, out targetLambda)) { // no need to Invoke, just interpret the lambda body ret = InterpretLambdaInvoke(targetLambda, args); } else { try { ret = _target.Invoke(instance, args); } catch (TargetInvocationException e) { throw ExceptionHelpers.UpdateForRethrow(e.InnerException); } } } if (_target.ReturnType != typeof(void)) { frame.Data[first] = ret; frame.StackIndex = first + 1; } else { frame.StackIndex = first; } return(1); }
public override int Run(InterpretedFrame frame) { try { frame.Data[_index] = Activator.CreateInstance(_type); } catch (TargetInvocationException e) { ExceptionHelpers.UpdateForRethrow(e.InnerException); throw e.InnerException; } return(1); }
public override int Run(InterpretedFrame frame) { object value = default(object); try { value = Activator.CreateInstance(_type); } catch (TargetInvocationException e) { ExceptionHelpers.UpdateForRethrow(e.InnerException); throw e.InnerException; } frame.Data[_index] = new StrongBox <object>(value); return(1); }
public override int Run(InterpretedFrame frame) { int first = frame.StackIndex - _argumentCount; var args = GetArgs(frame, first); object ret; try { ret = _constructor.Invoke(args); } catch (TargetInvocationException e) { ExceptionHelpers.UpdateForRethrow(e.InnerException); throw e.InnerException; } frame.Data[first] = ret; frame.StackIndex = first + 1; return(+1); }
private object InvokeWorker(params object[] args) { if (_target.IsStatic) { try { return(_target.Invoke(null, args)); } catch (TargetInvocationException e) { throw ExceptionHelpers.UpdateForRethrow(e.InnerException); } } try { return(_target.Invoke(args[0], GetNonStaticArgs(args))); } catch (TargetInvocationException e) { throw ExceptionHelpers.UpdateForRethrow(e.InnerException); } }
public override object InvokeInstance(object instance, params object[] args) { if (_target.IsStatic) { try { return(_target.Invoke(null, args)); } catch (TargetInvocationException e) { throw ExceptionHelpers.UpdateForRethrow(e.InnerException); } } try { return(_target.Invoke(instance, args)); } catch (TargetInvocationException e) { throw ExceptionHelpers.UpdateForRethrow(e.InnerException); } }
public sealed override int Run(InterpretedFrame frame) { int first = frame.StackIndex - _argumentCount; object[] args = null; object instance = null; try { object ret; if (_target.IsStatic) { args = GetArgs(frame, first, 0); try { ret = _target.Invoke(null, args); } catch (TargetInvocationException e) { throw ExceptionHelpers.UpdateForRethrow(e.InnerException); } } else { instance = frame.Data[first]; NullCheck(instance); args = GetArgs(frame, first, 1); LightLambda targetLambda; if (TryGetLightLambdaTarget(instance, out targetLambda)) { // no need to Invoke, just interpret the lambda body ret = InterpretLambdaInvoke(targetLambda, args); } else { try { ret = _target.Invoke(instance, args); } catch (TargetInvocationException e) { throw ExceptionHelpers.UpdateForRethrow(e.InnerException); } } } if (_target.ReturnType != typeof(void)) { frame.Data[first] = ret; frame.StackIndex = first + 1; } else { frame.StackIndex = first; } } finally { if (args != null) { foreach (ByRefUpdater arg in _byrefArgs) { if (arg.ArgumentIndex == -1) { // instance param, just copy back the exact instance invoked with, which // gets passed by reference from reflection for value types. arg.Update(frame, instance); } else { arg.Update(frame, args[arg.ArgumentIndex]); } } } } return(1); }
public sealed override int Run(InterpretedFrame frame) { int first = frame.StackIndex - _argumentCount; object[] args = null; object instance = null; try { object ret; if (_target.IsStatic) { args = new object[_argumentCount]; for (int i = 0; i < args.Length; i++) { args[i] = frame.Data[first + i]; } try { ret = _target.Invoke(null, args); } catch (TargetInvocationException e) { throw ExceptionHelpers.UpdateForRethrow(e.InnerException); } } else { args = new object[_argumentCount - 1]; for (int i = 0; i < args.Length; i++) { args[i] = frame.Data[first + i + 1]; } try { ret = _target.Invoke(instance = frame.Data[first], args); } catch (TargetInvocationException e) { throw ExceptionHelpers.UpdateForRethrow(e.InnerException); } } if (_target.ReturnType != typeof(void)) { frame.Data[first] = ret; frame.StackIndex = first + 1; } else { frame.StackIndex = first; } } finally { if (args != null) { foreach (var arg in _byrefArgs) { if (arg.ArgumentIndex == -1) { // instance param, just copy back the exact instance invoked with, which // gets passed by reference from reflection for value types. arg.Update(frame, instance); } else { arg.Update(frame, args[arg.ArgumentIndex]); } } } } return(1); }