diff options
author | Vincent Ambo <mail@tazj.in> | 2022-08-26T18·48+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-09-03T21·55+0000 |
commit | 1163ef3e413d239282b8a5fc24b708ee62c6f6a7 (patch) | |
tree | 21f1085fdd7095c54a55059d7b7a7b2f9f1139a7 /tvix/eval/src/opcode.rs | |
parent | 2f93ed297e3cef8486e9160f5d3d68be1939d7d5 (diff) |
feat(tvix/eval): implement compilation of upvalue access r/4623
This adds a new upvalue tracking structure in the compiler to resolve upvalues and track their positions within a function when compiling a closure. The compiler will emit runtime upvalue access instructions after this commit, but the creation of the runtime closure object etc. is not yet wired up. Change-Id: Ib0c2c25f686bfd45f797c528753068858e3a770d Reviewed-on: https://cl.tvl.fyi/c/depot/+/6289 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'tvix/eval/src/opcode.rs')
-rw-r--r-- | tvix/eval/src/opcode.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tvix/eval/src/opcode.rs b/tvix/eval/src/opcode.rs index f2daf9bd8e52..6cce7ea9b176 100644 --- a/tvix/eval/src/opcode.rs +++ b/tvix/eval/src/opcode.rs @@ -13,9 +13,14 @@ pub struct CodeIdx(pub usize); /// Index of a value in the runtime stack. #[repr(transparent)] -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, PartialEq)] pub struct StackIdx(pub usize); +/// Index of an upvalue within a closure's upvalue list. +#[repr(transparent)] +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct UpvalueIdx(pub usize); + /// Offset by which an instruction pointer should change in a jump. #[repr(transparent)] #[derive(Clone, Copy, Debug)] @@ -99,4 +104,5 @@ pub enum OpCode { // Lambdas OpCall, + OpGetUpvalue(UpvalueIdx), } |