refactor(tvix/eval): improve naming for locals manipulator methods
`push_local`/`push_phantom` were worse names because they sound like the value itself is being pushed, where in actuality it is just being declared to the compiler. Change-Id: Ibfda5c4c8e47d5d3262bfe005b0f1f84908a117e Reviewed-on: https://cl.tvl.fyi/c/depot/+/6228 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
0f739cd944
commit
f153a163a6
1 changed files with 9 additions and 5 deletions
|
@ -751,7 +751,7 @@ impl Compiler {
|
||||||
self.compile(from.inner().unwrap())?;
|
self.compile(from.inner().unwrap())?;
|
||||||
self.emit_literal_ident(&ident);
|
self.emit_literal_ident(&ident);
|
||||||
self.chunk.push_op(OpCode::OpAttrsSelect);
|
self.chunk.push_op(OpCode::OpAttrsSelect);
|
||||||
self.push_local(ident.as_str());
|
self.declare_local(ident.as_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -766,7 +766,7 @@ impl Compiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.compile(entry.value().unwrap())?;
|
self.compile(entry.value().unwrap())?;
|
||||||
self.push_local(path.pop().unwrap());
|
self.declare_local(path.pop().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deal with the body, then clean up the locals afterwards.
|
// Deal with the body, then clean up the locals afterwards.
|
||||||
|
@ -784,7 +784,7 @@ impl Compiler {
|
||||||
// stack).
|
// stack).
|
||||||
self.compile(node.namespace().unwrap())?;
|
self.compile(node.namespace().unwrap())?;
|
||||||
|
|
||||||
self.push_phantom();
|
self.declare_phantom();
|
||||||
self.scope.with_stack.push(With {
|
self.scope.with_stack.push(With {
|
||||||
depth: self.scope.scope_depth,
|
depth: self.scope.scope_depth,
|
||||||
});
|
});
|
||||||
|
@ -868,7 +868,10 @@ impl Compiler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push_local<S: Into<String>>(&mut self, name: S) {
|
/// Declare a local variable known in the scope that is being
|
||||||
|
/// compiled by pushing it to the locals. This is used to
|
||||||
|
/// determine the stack offset of variables.
|
||||||
|
fn declare_local<S: Into<String>>(&mut self, name: S) {
|
||||||
// Set up scope poisoning if required.
|
// Set up scope poisoning if required.
|
||||||
let name = name.into();
|
let name = name.into();
|
||||||
match name.as_str() {
|
match name.as_str() {
|
||||||
|
@ -886,6 +889,7 @@ impl Compiler {
|
||||||
|
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.scope.locals.push(Local {
|
self.scope.locals.push(Local {
|
||||||
name: name.into(),
|
name: name.into(),
|
||||||
depth: self.scope.scope_depth,
|
depth: self.scope.scope_depth,
|
||||||
|
@ -893,7 +897,7 @@ impl Compiler {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push_phantom(&mut self) {
|
fn declare_phantom(&mut self) {
|
||||||
self.scope.locals.push(Local {
|
self.scope.locals.push(Local {
|
||||||
name: "".into(),
|
name: "".into(),
|
||||||
depth: self.scope.scope_depth,
|
depth: self.scope.scope_depth,
|
||||||
|
|
Loading…
Reference in a new issue