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 <mail@tazj.in>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2021-02-28 14:37:35 +02:00 committed by tazjin
parent 6b990a7571
commit 127ef98486
6 changed files with 59 additions and 25 deletions

View file

@ -1 +1,6 @@
pub type Value = f64;
#[derive(Clone, Debug, PartialEq)]
pub enum Value {
Nil,
Bool(bool),
Number(f64),
}