public virtual DynamicMetaObject BindOperation(OperationBinder binder, params DynamicMetaObject[] args) { ContractUtils.RequiresNotNull(binder, nameof(binder)); return(binder.FallbackOperation(this, args)); }
public virtual DynamicMetaObject BindOperation(OperationBinder binder, params DynamicMetaObject[] args) { ContractUtils.RequiresNotNull(binder, "binder"); return binder.FallbackOperation(this, args); }
private static DynamicMetaObject/*!*/ MakeBinaryThrow(OperationBinder/*!*/action, string/*!*/ op, DynamicMetaObject/*!*/[]/*!*/ args) { if (action is IPythonSite) { // produce the custom Python error message return new DynamicMetaObject( Ast.Throw( Ast.Call( typeof(PythonOps).GetMethod("TypeErrorForBinaryOp"), Ast.Constant(SymbolTable.IdToString(Symbols.OperatorToSymbol(NormalizeOperator(op)))), AstUtils.Convert(args[0].Expression, typeof(object)), AstUtils.Convert(args[1].Expression, typeof(object)) ) ), BindingRestrictions.Combine(args) ); } // let the site produce its own error return action.FallbackOperation(args[0], new[] { args[1] }); }
/// <summary> /// Produces an error message for the provided message and type names. The error message should contain /// string formatting characters ({0}, {1}, etc...) for each of the type names. /// </summary> public static DynamicMetaObject/*!*/ TypeError(OperationBinder/*!*/ action, string message, params DynamicMetaObject[] types) { if (action is IPythonSite) { // produce our custom errors for Python... Expression[] formatArgs = new Expression[types.Length + 1]; for (int i = 1; i < formatArgs.Length; i++) { formatArgs[i] = Ast.Constant(MetaPythonObject.GetPythonType(types[i - 1]).Name); } formatArgs[0] = Ast.Constant(message); Type[] typeArgs = CompilerHelpers.MakeRepeatedArray<Type>(typeof(object), types.Length + 1); typeArgs[0] = typeof(string); Expression error = Ast.Throw( Ast.Call( typeof(ScriptingRuntimeHelpers).GetMethod("SimpleTypeError"), AstUtils.ComplexCallHelper( typeof(String).GetMethod("Format", typeArgs), formatArgs ) ) ); return new DynamicMetaObject( error, BindingRestrictions.Combine(types) ); } return action.FallbackOperation(types[0], ArrayUtils.RemoveFirst(types)); }
public virtual MetaObject BindOperation(OperationBinder binder, params MetaObject[] args) { ContractUtils.RequiresNotNull(binder, "binder"); return(binder.FallbackOperation(this, args)); }