public static SlotOrFunction/*!*/ GetSlotOrFunction(PythonContext/*!*/ state, string op, params DynamicMetaObject[] types) {
PythonTypeSlot slot;
SlotOrFunction res;
if (TryGetBinder(state, types, op, null, out res)) {
if (res != SlotOrFunction.Empty) {
return res;
}
} else if (MetaUserObject.GetPythonType(types[0]).TryResolveSlot(state.SharedContext, op, out slot)) {
ParameterExpression tmp = Ast.Variable(typeof(object), "slotVal");
Expression[] args = new Expression[types.Length - 1];
for (int i = 1; i < types.Length; i++) {
args[i - 1] = types[i].Expression;
}
return new SlotOrFunction(
new DynamicMetaObject(
Ast.Block(
new ParameterExpression[] { tmp },
MetaPythonObject.MakeTryGetTypeMember(
state,
slot,
tmp,
types[0].Expression,
Ast.Call(
typeof(DynamicHelpers).GetMethod("GetPythonType"),
types[0].Expression
)
),
Ast.Dynamic(
state.Invoke(
new CallSignature(args.Length)
),
typeof(object),
ArrayUtils.Insert<Expression>(
AstUtils.Constant(state.SharedContext),
tmp,
args
)
)
),
BindingRestrictions.Combine(types).Merge(BindingRestrictionsHelpers.GetRuntimeTypeRestriction(types[0].Expression, types[0].GetLimitType()))
),
slot
);
}
return SlotOrFunction.Empty;
}