public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args) { var method = (ESMethod)Value; Expression invokeExpression = null; var numArgs = args.Length; if (numArgs - method.NumArgs != 1) { var esClass = ValueClass; var kernel = esClass.ObjectSpace; return(metaObjectToThrowInvalidFunctionCallException( kernel.selectorToEvaluatMethodWithNumArgs(Math.Max(0, numArgs - 1)), args, "Argument count mismatch", ESCompiledCode.methodFunctionTypeForNumArgs(method.NumArgs), ESCompiledCode.blockFunctionTypeForNumArgs(args.Length))); } invokeExpression = ExpressionTreeGuru.expressionToInvokeESMethod(this.asExpressionWithFormalType(), expressionArrayFor(args)); return(new DynamicMetaObject(invokeExpression, DefaultBindingRestrictions, method)); }
public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args) { var block = (ESBlock)Value; Expression invokeExpression = null; var numArgs = args.Length; if (numArgs != block.NumArgs) { var esClass = ValueClass; var objectSpace = esClass.ObjectSpace; return(metaObjectToThrowInvalidFunctionCallException( objectSpace.selectorToEvaluatBlockWithNumArgs(numArgs), args, "Argument count mismatch", ESCompiledCode.blockFunctionTypeForNumArgs(block.NumArgs), ESCompiledCode.blockFunctionTypeForNumArgs(args.Length))); } invokeExpression = ExpressionTreeGuru.expressionToInvokeESBlock(this.asExpressionWithFormalType(), expressionArrayFor(args)); return(new DynamicMetaObject(invokeExpression, DefaultBindingRestrictions, block)); }
public DynamicMetaObject metaObjectToThrowInvalidFunctionCallException(ESSymbol selector, DynamicMetaObject[] args, String messageText, Type expectedFunctionType, Type actualFunctionType) { return(ExpressionTreeGuru.expressionToThrowInvalidFunctionCallException(Expression, ValueClass, selector, messageText, (long)args.Length, expectedFunctionType, actualFunctionType).asDynamicMetaObject(BindingRestrictions.GetInstanceRestriction(Expression, Value), Value)); }
public DynamicMetaObject metaObjectToSendDoesNotUnderstand(ESSymbol selector, DynamicMetaObject[] args) { return(ExpressionTreeGuru.expressionToSendDoesNotUnderstand(Expression, ValueClass, selector, args).asDynamicMetaObject(DefaultBindingRestrictions, Value)); }