feat(tvix/eval): implement compilation of upvalue access
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>
This commit is contained in:
parent
2f93ed297e
commit
1163ef3e41
4 changed files with 66 additions and 4 deletions
|
|
@ -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),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue