refactor(tvix/eval): separate out let inherit ...
logic
Compilation of `let`-expressions is going to become a lot more complicated due to attempts to avoid thunking when encountering internal references, so this is just being moved out of the way. Change-Id: Iecfa4b13d14532e21c2540e6561b4235ce29736a Reviewed-on: https://cl.tvl.fyi/c/depot/+/6266 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
This commit is contained in:
parent
b8f36ba097
commit
babc249316
1 changed files with 14 additions and 9 deletions
|
@ -656,15 +656,9 @@ impl Compiler {
|
||||||
self.patch_jump(else_idx); // patch jump *over* else body
|
self.patch_jump(else_idx); // patch jump *over* else body
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile a standard `let ...; in ...` statement.
|
// Compile an `inherit` node of a `let`-expression.
|
||||||
//
|
fn compile_let_inherit<I: Iterator<Item = ast::Inherit>>(&mut self, inherits: I) {
|
||||||
// Unless in a non-standard scope, the encountered values are
|
for inherit in inherits {
|
||||||
// simply pushed on the stack and their indices noted in the
|
|
||||||
// entries vector.
|
|
||||||
fn compile_let_in(&mut self, node: ast::LetIn) {
|
|
||||||
self.begin_scope();
|
|
||||||
|
|
||||||
for inherit in node.inherits() {
|
|
||||||
match inherit.from() {
|
match inherit.from() {
|
||||||
// Within a `let` binding, inheriting from the outer
|
// Within a `let` binding, inheriting from the outer
|
||||||
// scope is a no-op *if* the identifier can be
|
// scope is a no-op *if* the identifier can be
|
||||||
|
@ -708,6 +702,17 @@ impl Compiler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compile a standard `let ...; in ...` statement.
|
||||||
|
//
|
||||||
|
// Unless in a non-standard scope, the encountered values are
|
||||||
|
// simply pushed on the stack and their indices noted in the
|
||||||
|
// entries vector.
|
||||||
|
fn compile_let_in(&mut self, node: ast::LetIn) {
|
||||||
|
self.begin_scope();
|
||||||
|
|
||||||
|
self.compile_let_inherit(node.inherits());
|
||||||
|
|
||||||
for entry in node.attrpath_values() {
|
for entry in node.attrpath_values() {
|
||||||
let mut path = match normalise_ident_path(entry.attrpath().unwrap().attrs()) {
|
let mut path = match normalise_ident_path(entry.attrpath().unwrap().attrs()) {
|
||||||
|
|
Loading…
Reference in a new issue