public object visitCallExpr(Expr.Call expr) { object callee = Evaluate(expr.callee); if (!(callee is ICallable)) { throw new RuntimeError(expr.paren, "Can only call on functions and classes."); } List <object> args = new List <object>(); foreach (Expr arg in expr.args) { args.Add(Evaluate(arg)); } ICallable function = (ICallable)callee; if (args.Count != function.Arity()) { throw new RuntimeError(expr.paren, "Expected " + function.Arity() + " arguments but got " + args.Count + "."); } return(function.Call(this, args)); }
public Void visitCallExpr(Expr.Call expr) { Resolve(expr.callee); foreach (Expr arg in expr.args) { Resolve(arg); } return(null); }