Minor code rearrangement

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-10-19 17:00:12 -07:00
parent 1d6b2e35bc
commit fee1ce2a47

View File

@@ -418,7 +418,6 @@ impl Visit for CompileBody<'_> {
fn visit_atom(&mut self, atom: &Atom) -> Self::Out { fn visit_atom(&mut self, atom: &Atom) -> Self::Out {
let thunk = match atom { let thunk = match atom {
Atom::Ident(ident) => { Atom::Ident(ident) => {
let sym = global_sym(ident.to_string());
// Small gotcha: // Small gotcha:
// Looking up a name will either result in a local or a global lookup. If it's // Looking up a name will either result in a local or a global lookup. If it's
// a local variable first, then it's determined as a local and that's the end // a local variable first, then it's determined as a local and that's the end
@@ -427,6 +426,7 @@ impl Visit for CompileBody<'_> {
// //
// This checks to make sure that it's both a local variable and that there's more // This checks to make sure that it's both a local variable and that there's more
// than one scope layer. // than one scope layer.
let sym = global_sym(ident.to_string());
if let (true, Some(local)) = (self.compile.scope().layers_len() > 1, self.compile.lookup_local(sym)) { if let (true, Some(local)) = (self.compile.scope().layers_len() > 1, self.compile.lookup_local(sym)) {
// get local // get local
Inst::LoadLocal(local).into() Inst::LoadLocal(local).into()