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