Exemple #1
0
 public object Visit(Expr.Call _call)
 {
     Resolve(_call.callee);
     foreach (Expr argument in _call.arguments)
     {
         Resolve(argument);
     }
     return(null);
 }
Exemple #2
0
        public object Visit(Expr.Call _call)
        {
            object callee = Evaluate(_call.callee);

            object[] arguments = new object[_call.arguments.Count];
            for (int i = 0; i < _call.arguments.Count; i++)
            {
                arguments[i] = Evaluate(_call.arguments[i]);
            }

            ILoxCallable function = callee as ILoxCallable;

            if (callee == null)
            {
                throw new RuntimeError(_call.paren, "Can only call functions on classes");
            }

            if (arguments.Length != function.arity)
            {
                throw new RuntimeError(_call.paren, "Expected " + function.arity + " arguments but got " + arguments.Length + ".");
            }

            return(function.Call(this, arguments));
        }
Exemple #3
0
 public string Visit(Expr.Call _call)
 {
     throw new NotImplementedException();
 }