docs(tvix/eval): StackIdx, LocalIdx UpvalueIdx
This adds a comment noting that StackIdx is an offset relative to the base of the current CallFrame, whereas UpvalueIdx is an absolute index into the upvalues array. It also removes the confusing mention of StackIdx in the descriptive comment for LocalIdx. They index into totally different structures; one exists at runtime and the other exists at compile time. Change-Id: Ib932b1b0679734c15001e8c5c95a08293fa016b4 Signed-off-by: Adam Joseph <adam@westernsemico.com> Reviewed-on: https://cl.tvl.fyi/c/depot/+/7017 Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
parent
499a443032
commit
4384418877
2 changed files with 7 additions and 5 deletions
|
@ -121,9 +121,7 @@ pub struct Upvalue {
|
||||||
pub span: codemap::Span,
|
pub span: codemap::Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents the index of a local in the scope's local array, which
|
/// The index of a local in the scope's local array at compile time.
|
||||||
/// is subtly different from its `StackIdx` (which excludes
|
|
||||||
/// uninitialised values in between).
|
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd)]
|
||||||
pub struct LocalIdx(usize);
|
pub struct LocalIdx(usize);
|
||||||
|
|
|
@ -27,12 +27,16 @@ impl Sub<usize> for CodeIdx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Index of a value in the runtime stack.
|
/// Index of a value in the runtime stack. This is an offset
|
||||||
|
/// *relative to* the VM value stack_base of the CallFrame
|
||||||
|
/// containing the opcode which contains this StackIdx.
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd)]
|
||||||
pub struct StackIdx(pub usize);
|
pub struct StackIdx(pub usize);
|
||||||
|
|
||||||
/// Index of an upvalue within a closure's upvalue list.
|
/// Index of an upvalue within a closure's bound-variable upvalue
|
||||||
|
/// list. This is an absolute index into the Upvalues of the
|
||||||
|
/// CallFrame containing the opcode which contains this UpvalueIdx.
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
pub struct UpvalueIdx(pub usize);
|
pub struct UpvalueIdx(pub usize);
|
||||||
|
|
Loading…
Reference in a new issue