From 48a7449834246ad967301f2dc011b019171a5bbc Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sun, 7 Aug 2022 23:40:29 +0300 Subject: feat(tvix/eval): add initial opcode representation Change-Id: Ibc7685a6b0b92e08f0b6c82cf7d9b04fbb593a4e Reviewed-on: https://cl.tvl.fyi/c/depot/+/6068 Tested-by: BuildkiteCI Reviewed-by: grfn --- tvix/eval/src/main.rs | 1 + tvix/eval/src/opcode.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tvix/eval/src/opcode.rs diff --git a/tvix/eval/src/main.rs b/tvix/eval/src/main.rs index 7cc5a380e5..fc366961b5 100644 --- a/tvix/eval/src/main.rs +++ b/tvix/eval/src/main.rs @@ -6,6 +6,7 @@ use std::{ mod errors; mod eval; +mod opcode; mod value; fn main() { diff --git a/tvix/eval/src/opcode.rs b/tvix/eval/src/opcode.rs new file mode 100644 index 0000000000..b43f75efaa --- /dev/null +++ b/tvix/eval/src/opcode.rs @@ -0,0 +1,19 @@ +//! This module implements the instruction set running on the abstract +//! machine implemented by tvix. + +#[derive(Clone, Copy, Debug)] +pub struct ConstantIdx(pub usize); + +#[derive(Clone, Copy, Debug)] +pub struct CodeIdx(pub usize); + +#[derive(Clone, Copy, Debug)] +pub enum OpCode { + // Push a constant onto the stack. + OpConstant(ConstantIdx), + + // Push a literal value. + OpNull, + OpTrue, + OpFalse, +} -- cgit 1.4.1