public object VisitCallExpr(Expr.Call expr) { object callee = Evaluate(expr.Callee); List <object> arguments = new List <object>(); foreach (var argument in expr.Arguments) { arguments.Add(Evaluate(argument)); } if (!(callee is ICallable)) { throw new RuntimeError(expr.Paren, "Can only call functions and classes."); } ICallable function = (ICallable)callee; if (arguments.Count != function.Arity()) { throw new RuntimeError(expr.Paren, $"Expected {function.Arity()} arguments but got {arguments.Count}."); } return(function.Call(this, arguments)); }
public Nothing VisitCallExpr(Expr.Call expr) { Resolve(expr.Callee); foreach (var arg in expr.Arguments) { Resolve(arg); } return(Nothing.AtAll); }
public string VisitCallExpr(Expr.Call expr) { throw new System.NotImplementedException(); }