about summary refs log tree commit diff
path: root/users/tazjin/rlox/src/bytecode/vm.rs
diff options
context:
space:
mode:
Diffstat (limited to 'users/tazjin/rlox/src/bytecode/vm.rs')
-rw-r--r--users/tazjin/rlox/src/bytecode/vm.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/users/tazjin/rlox/src/bytecode/vm.rs b/users/tazjin/rlox/src/bytecode/vm.rs
index 53431a083785..0cd0853764e0 100644
--- a/users/tazjin/rlox/src/bytecode/vm.rs
+++ b/users/tazjin/rlox/src/bytecode/vm.rs
@@ -170,6 +170,17 @@ impl VM {
                         self.globals.insert(name, val);
                     });
                 }
+
+                OpCode::OpGetGlobal(name_idx) => {
+                    let name = self.chunk.constant(*name_idx);
+                    with_type!(self, name, Value::String(name), {
+                        let val = match self.globals.get(name) {
+                            None => unimplemented!("variable not found error"),
+                            Some(val) => val.clone(),
+                        };
+                        self.push(val)
+                    });
+                }
             }
 
             #[cfg(feature = "disassemble")]