public override DynamicMetaObject/*!*/ BindInvokeMember(InvokeMemberBinder/*!*/ action, DynamicMetaObject/*!*/[]/*!*/ args) {
ParameterExpression tmp = Expression.Parameter(typeof(object));
// first get the default binder value
DynamicMetaObject fallback = action.FallbackInvokeMember(this, args);
// then fallback w/ an error suggestion that does a late bound lookup.
return action.FallbackInvokeMember(
this,
args,
new DynamicMetaObject(
Ast.Block(
new[] { tmp },
Ast.Condition(
Ast.NotEqual(
Ast.Assign(
tmp,
Ast.Call(
typeof(PythonOps).GetMethod("PythonFunctionGetMember"),
AstUtils.Convert(
Expression,
typeof(PythonFunction)
),
Expression.Constant(action.Name)
)
),
Ast.Constant(OperationFailed.Value)
),
action.FallbackInvoke(
new DynamicMetaObject(tmp, BindingRestrictions.Empty),
args,
null
).Expression,
AstUtils.Convert(fallback.Expression, typeof(object))
)
),
BindingRestrictions.GetTypeRestriction(Expression, typeof(PythonFunction)).Merge(fallback.Restrictions)
)
);
}