Exemple #1
0
        public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args)
        {
            var restrictions = BindingRestrictions.Empty;
            var callArgs     = LambdaHelpers.FillDataFrame(lambda.Definition.Signature, args, ref restrictions);
            var method       = typeof(LambdaClosure).GetMethod("ApplyLambdaFast", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
            var expr         = Expression.Call(Expression.Convert(Expression, typeof(LambdaClosure)), method, callArgs);

            restrictions = BindingRestrictions.GetInstanceRestriction(Expression, Value).Merge(restrictions);
            return(new DynamicMetaObject(Runtime.EnsureObjectResult(expr), restrictions));
        }
Exemple #2
0
        public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args)
        {
            var methods = Match(args);

            if (methods == null)
            {
                throw new LispException("No matching multi-method found");
            }
            var lambda = (LambdaClosure)methods.Car;

            if (lambda.GenericRestrictions == null)
            {
                lambda.GenericRestrictions = LambdaHelpers.GetGenericRestrictions(lambda, args);
            }
            var        restrictions = lambda.GenericRestrictions;
            var        callArgs     = LambdaHelpers.FillDataFrame(lambda.Definition.Signature, args, ref restrictions);
            MethodInfo method       = Runtime.RuntimeMethod("CallNextMethod");
            var        expr         = Expression.Call(method, Expression.Constant(methods), callArgs);

            restrictions = BindingRestrictions.GetInstanceRestriction(Expression, Value).Merge(restrictions);
            return(new DynamicMetaObject(Runtime.EnsureObjectResult(expr), restrictions));
        }