Esempio n. 1
0
        public object visitCallExpr(Expr.Call expr)
        {
            object callee = evaluate(expr.callee);

            List <object> arguments = new List <object>();

            foreach (Expr argument in expr.arguments)
            {
                arguments.Add(evaluate(argument));
            }

            if (!(callee is CallableFunc))
            {
                throw new RuntimeError(expr.paren, "Can only call functions and classes.");
            }

            CallableFunc function = (CallableFunc)callee;

            if (arguments.Count != function.arity())
            {
                throw new RuntimeError(expr.paren, "Expected " + function.arity() + " arguments but got " + arguments.Count + ".");
            }


            return(function.call(this, arguments));
        }
Esempio n. 2
0
        public object visitCallExpr(Expr.Call expr)
        {
            resolve(expr.callee);

            foreach (Expr argument in expr.arguments)
            {
                resolve(argument);
            }

            return(null);
        }
Esempio n. 3
0
 public string visitCallExpr(Expr.Call expr)
 {
     return("");
 }