From e46b399399cfc77255b3451863e01edb52ad0161 Mon Sep 17 00:00:00 2001 From: Emmanuel Benoit Date: Mon, 9 Jan 2023 08:03:41 +0100 Subject: [PATCH] Interpreter - Handle references to "this" --- src/interpreter/interpretable.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/interpreter/interpretable.rs b/src/interpreter/interpretable.rs index ee9bc89..fa35f8b 100644 --- a/src/interpreter/interpretable.rs +++ b/src/interpreter/interpretable.rs @@ -348,7 +348,9 @@ impl Interpretable for ExprNode { ExprNode::Unary { operator, right } => self.on_unary(es, operator, right), ExprNode::Grouping { expression } => expression.interpret(es), ExprNode::Litteral { value } => self.on_litteral(value), - ExprNode::Variable(var_expr) => Ok(es.lookup_var(var_expr)?.into()), + ExprNode::Variable(var_expr) | ExprNode::This(var_expr) => { + Ok(es.lookup_var(var_expr)?.into()) + } ExprNode::Call { callee, right_paren,