Exemple #1
0
        public virtual StandardRule <T> MakeRule()
        {
            CallAction callAction = CallAction.Make(Action.Signature);

            // TODO: First try to make a rule for get-member and see if we get back a constant method to call
            //GetMemberAction getAction = GetMemberAction.Make(Action.Name);
            //StandardRule<T> getRule = Binder.GetRule<T>(Context, getAction, new object[] { _args[0] });

            // otherwise, make a generic rule with embedded dynamic sites
            StandardRule <T> rule = new StandardRule <T>();

            rule.SetTest(Ast.True());
            Expression getExpr = Ast.Action.GetMember(Action.Name, typeof(object), rule.Parameters[0]);

            Expression[] callArgs = new Expression[rule.ParameterCount];
            callArgs[0] = getExpr;
            for (int i = 1; i < callArgs.Length; i++)
            {
                callArgs[i] = rule.Parameters[i];
            }

            //TODO support non-object return types
            Expression callExpr = Ast.Action.Call(callAction, typeof(object), callArgs);

            rule.SetTarget(Ast.Return(callExpr));

            return(rule);
        }
Exemple #2
0
 public static CallAction Call(int argumentCount)
 {
     return(CallAction.Make(argumentCount));
 }