Beispiel #1
0
 public object VisitCallExpr(Expr.Call expr)
 {
     Resolve(expr.Callee);
     foreach (Expr argument in expr.Arguments)
     {
         Resolve(argument);
     }
     return(null);
 }
Beispiel #2
0
        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));
        }
Beispiel #3
0
 public string Visit(Expr.Call expr)
 {
     throw new NotImplementedException();
 }