From 127ef984865500d70176347861b2e8bad29a39be Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sun, 28 Feb 2021 14:37:35 +0200 Subject: refactor(tazjin/rlox): Represent VM values as enums 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 Tested-by: BuildkiteCI --- users/tazjin/rlox/src/bytecode/chunk.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'users/tazjin/rlox/src/bytecode/chunk.rs') diff --git a/users/tazjin/rlox/src/bytecode/chunk.rs b/users/tazjin/rlox/src/bytecode/chunk.rs index b2a7c7b6a2c1..7132be430a0f 100644 --- a/users/tazjin/rlox/src/bytecode/chunk.rs +++ b/users/tazjin/rlox/src/bytecode/chunk.rs @@ -49,7 +49,7 @@ impl Chunk { } } - fn get_line(&self, offset: usize) -> usize { + pub fn get_line(&self, offset: usize) -> usize { let mut pos = 0; for span in &self.lines { pos += span.count; -- cgit 1.4.1