about summary refs log tree commit diff
path: root/users/tazjin/rlox/src/bytecode/vm.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-10-03T11·20+0300
committertazjin <mail@tazj.in>2021-10-19T12·58+0000
commitc318f42c119f3dd13bf0cfd7917bfdd41fea7085 (patch)
tree19ab277a770dc12fd0ca7b7615b3ba0df38723f8 /users/tazjin/rlox/src/bytecode/vm.rs
parentad7e591c8046d6e179476192ef9928d5fae78422 (diff)
feat(tazjin/rlox): Support local variables r/2978
WIP

Change-Id: I78fbc885faaac165c380cbd9aa98b4b64a9b8274
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3685
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'users/tazjin/rlox/src/bytecode/vm.rs')
-rw-r--r--users/tazjin/rlox/src/bytecode/vm.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/users/tazjin/rlox/src/bytecode/vm.rs b/users/tazjin/rlox/src/bytecode/vm.rs
index 4432473ee649..10d0f595d6d4 100644
--- a/users/tazjin/rlox/src/bytecode/vm.rs
+++ b/users/tazjin/rlox/src/bytecode/vm.rs
@@ -194,6 +194,16 @@ impl VM {
                         }
                     });
                 }
+
+                OpCode::OpGetLocal(local_idx) => {
+                    let value = self.stack[*local_idx].clone();
+                    self.push(value);
+                }
+
+                OpCode::OpSetLocal(local_idx) => {
+                    debug_assert!(self.stack.len() > *local_idx, "stack is not currently large enough for local");
+                    self.stack[*local_idx] = self.stack.last().unwrap().clone();
+                }
             }
 
             #[cfg(feature = "disassemble")]