From 742d6706b00b72c8da0d69f627e819c9caf553e3 Mon Sep 17 00:00:00 2001 From: Daniel M Date: Thu, 10 Feb 2022 21:27:05 +0100 Subject: [PATCH] Array values are now pass-by-reference --- src/interpreter.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/interpreter.rs b/src/interpreter.rs index 70cf0b7..2cae525 100644 --- a/src/interpreter.rs +++ b/src/interpreter.rs @@ -41,7 +41,7 @@ pub enum RuntimeError { pub enum Value { I64(i64), String(Sid), - Array(RefCell>), + Array(Rc>>), Void, } @@ -245,7 +245,7 @@ impl Interpreter { Value::I64(size) if !size.is_negative() => size, val => return Err(RuntimeError::InvalidArrayIndex(val)), }; - Value::Array(RefCell::new(vec![Value::I64(0); size as usize])) + Value::Array(Rc::new(RefCell::new(vec![Value::I64(0); size as usize]))) } Expression::String(text) => Value::String(text.clone()), Expression::BinOp(bo, lhs, rhs) => self.resolve_binop(bo, lhs, rhs)?,