about summary refs log tree commit diff
path: root/users/tazjin/rlox/src/bytecode/compiler.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-02-28T12·37+0200
committertazjin <mail@tazj.in>2021-02-28T12·54+0000
commit127ef984865500d70176347861b2e8bad29a39be (patch)
treecb3dc7b380cd58d3c72af1ab0ac65a35b9896bc1 /users/tazjin/rlox/src/bytecode/compiler.rs
parent6b990a757186da0f2766fefac53ce5de140d9174 (diff)
refactor(tazjin/rlox): Represent VM values as enums r/2251
Introduces a new enum which represents the different types of possible
values, and modifies the rest of the existing code to wrap/unwrap
these enum variants correctly.

Notably in the vm module, a new macro has been introduced that makes
it possible to encode a type expectation and return a runtime error in
case of a type mismatch.

Change-Id: I325b5e31e395c62d8819ab2af6d398e1277333c0
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2570
Reviewed-by: tazjin <mail@tazj.in>
Tested-by: BuildkiteCI
Diffstat (limited to 'users/tazjin/rlox/src/bytecode/compiler.rs')
-rw-r--r--users/tazjin/rlox/src/bytecode/compiler.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/users/tazjin/rlox/src/bytecode/compiler.rs b/users/tazjin/rlox/src/bytecode/compiler.rs
index 4c6a99a181c6..63f34fad3ea7 100644
--- a/users/tazjin/rlox/src/bytecode/compiler.rs
+++ b/users/tazjin/rlox/src/bytecode/compiler.rs
@@ -128,7 +128,7 @@ impl<T: Iterator<Item = Token>> Compiler<T> {
 
     fn number(&mut self) -> LoxResult<()> {
         if let TokenKind::Number(num) = self.previous().kind {
-            self.emit_constant(num);
+            self.emit_constant(Value::Number(num));
             return Ok(());
         }