public void executeBlock(IList <Stmt> statements, RosellaEnvironment environment)
        {
            var previous = this.environment;

            try
            {
                this.environment = environment;

                foreach (var statement in statements)
                {
                    execute(statement);
                }
            }
            finally
            {
                this.environment = previous;
            }
        }
        public object call(Interpreter interpreter, IList <object> arguments)
        {
            var environment = new RosellaEnvironment(closure);

            for (var i = 0; i < [email protected]; i++)
            {
                environment.define(declaration.@params[i].lexeme, arguments[i]);
            }

            try
            {
                interpreter.executeBlock(declaration.body, environment);
            }
            catch (Return returnValue)
            {
                return(returnValue.value);
            }
            return(null);
        }
 public Interpreter(Action <RuntimeError> errorFunc)
 {
     this.errorFunc = errorFunc;
     environment    = globals;
     globals.define("clock", new Clock());
 }
 public RosellaFunction(Stmt.Function declaration, RosellaEnvironment closure)
 {
     this.declaration = declaration;
     this.closure     = closure;
 }
 public RosellaEnvironment(RosellaEnvironment enclosing = null)
 {
     this.enclosing = enclosing;
 }