public object VisitCallExpr(Expr.Call expr) { Resolve(expr.Callee); foreach (Expr argument in expr.Arguments) { Resolve(argument); } return(null); }
public object VisitCallExpr(Expr.Call expr) { object callee = Evaluate(expr.Callee); List <object> arguments = expr.Arguments.Select(Evaluate).ToList(); if (!(callee is ILoxCallable)) { throw new RuntimeError(expr.Paren, "Can only call functions and classes."); } ILoxCallable function = (ILoxCallable)callee; if (arguments.Count() != function.Arity()) { throw new RuntimeError(expr.Paren, $"Expect {function.Arity()} arguments but got {arguments.Count()} instead."); } return(function.Call(this, arguments)); }
public string Visit(Expr.Call expr) { throw new NotImplementedException(); }