public abstract FallbackInvoke ( |
||
target | The target of the dynamic invoke operation. | |
args | The arguments of the dynamic invoke operation. | |
errorSuggestion | The binding result to use if binding fails, or null. | |
return |
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) { var result = TryBindGetMember(binder.Name); if (result != null) { return binder.FallbackInvoke(result, args, null); } return base.BindInvokeMember(binder, args); }
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) { // Generate a tree like: // // { // object result; // TryInvokeMember(payload, out result) // ? result // : TryGetMember(payload, out result) // ? FallbackInvoke(result) // : fallbackResult // } // // Then it calls FallbackInvokeMember with this tree as the // "error", giving the language the option of using this // tree or doing .NET binding. // Fallback fallback = e => binder.FallbackInvokeMember(this, args, e); var call = BuildCallMethodWithResult( "TryInvokeMember", binder, DynamicMetaObject.GetExpressions(args), BuildCallMethodWithResult( "TryGetMember", new GetBinderAdapter(binder), NoArgs, fallback(null), (e) => binder.FallbackInvoke(e, args, null) ), null ); return fallback(call); }
/// <summary> /// Transforms an invoke member into a Python GetMember/Invoke. The caller should /// verify that the given attribute is not resolved against a normal .NET class /// before calling this. If it is a normal .NET member then a fallback InvokeMember /// is preferred. /// </summary> internal static DynamicMetaObject/*!*/ GenericInvokeMember(InvokeMemberBinder/*!*/ action, ValidationInfo valInfo, DynamicMetaObject target, DynamicMetaObject/*!*/[]/*!*/ args) { if (target.NeedsDeferral()) { return action.Defer(args); } return AddDynamicTestAndDefer(action, action.FallbackInvoke( new DynamicMetaObject( Binders.Get( PythonContext.GetCodeContext(action), PythonContext.GetPythonContext(action), typeof(object), action.Name, target.Expression ), BindingRestrictionsHelpers.GetRuntimeTypeRestriction(target) ), args, null ), args, valInfo ); }
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) { return DynamicTryGetMember(binder.Name, binder.FallbackInvokeMember(this, args).Expression, (tmp) => binder.FallbackInvoke(new DynamicMetaObject(tmp, BindingRestrictions.Empty), args, null).Expression ); }
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) { ContractUtils.RequiresNotNull(binder, "binder"); DynamicMetaObject memberValue = GetDynamicMetaObjectForMember( binder.Name, binder.IgnoreCase, binder.FallbackInvokeMember(this, args) ); //invoke the member value using the language's binder return AddDynamicTestAndDefer( binder, new DynamicMetaObject[] { this }, Value.Class, null, binder.FallbackInvoke(memberValue, args, null) ); }
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) { Fallback fallback = e => binder.FallbackInvokeMember(this, args, e); DynamicMetaObject errorSuggestion = this.BuildCallMethodWithResult("TryInvokeMember", binder, GetArgArray(args), this.BuildCallMethodWithResult("TryGetMember", new GetBinderAdapter(binder), NoArgs, fallback(null), e => binder.FallbackInvoke(e, args, null)), null); return fallback(errorSuggestion); }
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) { if (IsOverridden("TryInvokeMember")) { return CallMethodWithResult("TryInvokeMember", binder, GetArgArray(args), (e) => binder.FallbackInvokeMember(this, args, e)); } else if (IsOverridden("TryGetMember")) { // Generate a tree like: // // { // object result; // TryGetMember(payload, out result) ? FallbackInvoke(result) : fallbackResult // } // // Then it calls FallbackInvokeMember with this tree as the // "error", giving the language the option of using this // tree or doing .NET binding. // return CallMethodWithResult( "TryGetMember", new GetBinderAdapter(binder), NoArgs, (e) => binder.FallbackInvokeMember(this, args, e), (e) => binder.FallbackInvoke(e, args, null) ); } return base.BindInvokeMember(binder, args); }
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) { // Generate a tree like: // // { // object result; // TryInvokeMember(payload, out result) // ? result // : TryGetMember(payload, out result) // ? FallbackInvoke(result) // : fallbackResult // } // // Then it calls FallbackInvokeMember with this tree as the // "error", giving the language the option of using this // tree or doing .NET binding. // DynamicMetaObject call = BuildCallMethodWithResult( DynamicObjectTryInvokeMember, binder, GetExpressions(args), BuildCallMethodWithResult( DynamicObjectTryGetMember, new GetBinderAdapter(binder), _noArgs, binder.FallbackInvokeMember(this, args, null), (MetaDynamic @this, GetMemberBinder ignored, DynamicMetaObject e) => binder.FallbackInvoke(e, args, null) ), null ); return(binder.FallbackInvokeMember(this, args, call)); }
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) { Fallback fallback = e => binder.FallbackInvokeMember(this, args, e); DynamicMetaObject errorSuggestion = this.BuildCallMethodWithResult("TryInvokeMember", binder, GetArgArray(args), this.BuildCallMethodWithResult("TryGetMember", new GetBinderAdapter(binder), NoArgs, fallback(null), e => binder.FallbackInvoke(e, args, null)), null); return(fallback(errorSuggestion)); }
public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) { var expression = Expr.Dynamic(new LuaGetMemberBinder(binder.Name), typeof(object), Expression); return binder.FallbackInvoke(new DynamicMetaObject(expression, Restrictions), args, null); }