From 95ddd34f9cbffca677479f13c8f28647bbcb7021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sat, 7 Jan 2023 09:01:24 +0100 Subject: [PATCH] Interpreter - Renamed resolved variables field --- src/interpreter/interpretable.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/interpreter/interpretable.rs b/src/interpreter/interpretable.rs index fb7d2f7..d411500 100644 --- a/src/interpreter/interpretable.rs +++ b/src/interpreter/interpretable.rs @@ -23,17 +23,17 @@ pub fn evaluate(ast: &ast::ProgramNode, vars: ResolvedVariables) -> SloxResult { pub(super) globals: EnvironmentRef, pub(super) environment: EnvironmentRef, - pub(super) variables: &'a ResolvedVariables, + pub(super) locals: &'a ResolvedVariables, } impl<'a> InterpreterState<'a> { /// Initialize the interpreter state from the resolved variables map. - fn new(vars: &'a ResolvedVariables) -> Self { + fn new(locals: &'a ResolvedVariables) -> Self { let env = Rc::new(RefCell::new(Environment::default())); Self { environment: env.clone(), globals: env, - variables: &vars, + locals: &locals, } } @@ -45,19 +45,19 @@ impl<'a> InterpreterState<'a> { InterpreterState { environment: Environment::create_child(&parent.environment), globals: parent.globals.clone(), - variables: parent.variables, + locals: parent.locals, } } fn lookup_var(&self, name: &Token, expr_id: &usize) -> SloxResult { - match self.variables.get(expr_id) { + match self.locals.get(expr_id) { Some(distance) => self.environment.borrow().get_at(*distance, name), None => self.globals.borrow().get(name), } } fn assign_var(&self, name: &Token, expr_id: &usize, value: Value) -> SloxResult<()> { - match self.variables.get(expr_id) { + match self.locals.get(expr_id) { Some(distance) => self .environment .borrow_mut()