コード例 #1
0
        public object visitCallExpr(Expr.Call expr)
        {
            object callee = evaluate(expr.callee);

            List <object> arguments = new List <object>();

            foreach (Expr argument in expr.arguments)
            {
                arguments.Add(evaluate(argument));
            }

            if (!(callee is LoxCallable))
            {
                throw new RuntimeError(expr.paren, "Can only call functions and classes.");
            }

            LoxCallable function = (LoxCallable)callee;

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


            return(function.call(this, arguments));
        }
コード例 #2
0
        public object visitCallExpr(Expr.Call expr)
        {
            resolve(expr.callee);

            foreach (Expr argument in expr.arguments)
            {
                resolve(argument);
            }

            return(null);
        }
コード例 #3
0
ファイル: AstPrinter.cs プロジェクト: drewbanas/jloxcs
 public string visitCallExpr(Expr.Call expr)
 {
     return("");
 }