Beispiel #1
0
        public object Call(InterpretingVisitor interpreter, List <object> arguments)
        {
            var environment = new LoxEnvironment(_closure);

            for (var i = 0; i < Arity(); i++)
            {
                environment.Define(_functionStmt.Params[i].Lexeme, arguments[i]);
            }

            try {
                interpreter.Execute(_functionStmt.Body, environment);
            } catch (LoxReturnException ex) {
                if (_isInitializer)
                {
                    throw new LoxReturnException(_closure.GetAt(0, new Token(TokenType.This, "this", null, 0)));
                }

                throw;
            }

            return(null);
        }
Beispiel #2
0
 public object Call(InterpretingVisitor interpreter, List <object> arguments)
 {
     throw new LoxReturnException(_func(arguments));
 }