From 17e78596b5fbf5072855348ae1d0d99bfb58d6ce Mon Sep 17 00:00:00 2001 From: Rex Magana Date: Mon, 4 Mar 2024 14:11:02 -0800 Subject: [PATCH 1/2] update variable storage --- crates/runtime/src/virtual_machine.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/runtime/src/virtual_machine.rs b/crates/runtime/src/virtual_machine.rs index 927c1a5b..cc6f237d 100644 --- a/crates/runtime/src/virtual_machine.rs +++ b/crates/runtime/src/virtual_machine.rs @@ -501,16 +501,19 @@ impl VirtualMachine { // value may be found in the program. (If it's // not, then the variable's value is undefined, // which isn't allowed.) - - Ok(self + let initial_value = self .program .as_ref() .unwrap() .initial_values .get(&variable_name) .unwrap_or_else(|| panic!("The loaded program does not contain an initial value for the variable {variable_name}")) - .clone() - .into()) + .clone(); + + // Store the initial value in the variable_storage + self.variable_storage.set(variable_name.clone(), initial_value.clone().into())?; + + Ok(initial_value.into()) } else { Err(e) } From c24f2ff482c7465e34e2eb15694335bb32a56525 Mon Sep 17 00:00:00 2001 From: Rex Magana Date: Mon, 4 Mar 2024 14:18:19 -0800 Subject: [PATCH 2/2] whitespace --- crates/runtime/src/virtual_machine.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/runtime/src/virtual_machine.rs b/crates/runtime/src/virtual_machine.rs index cc6f237d..1d823c32 100644 --- a/crates/runtime/src/virtual_machine.rs +++ b/crates/runtime/src/virtual_machine.rs @@ -509,10 +509,10 @@ impl VirtualMachine { .get(&variable_name) .unwrap_or_else(|| panic!("The loaded program does not contain an initial value for the variable {variable_name}")) .clone(); - + // Store the initial value in the variable_storage self.variable_storage.set(variable_name.clone(), initial_value.clone().into())?; - + Ok(initial_value.into()) } else { Err(e)