extract new_toplevel
This commit is contained in:
parent
5077daf8f3
commit
6dbe397ebf
|
|
@ -112,6 +112,13 @@ struct BuildContext<'a> {
|
|||
}
|
||||
|
||||
impl BuildContext<'_> {
|
||||
fn new_toplevel() -> Self {
|
||||
BuildContext {
|
||||
parent: None,
|
||||
scope: RefCell::new(Scope::new_toplevel()),
|
||||
}
|
||||
}
|
||||
|
||||
fn request(&self, name: &ast::Ident) -> Option<Ident> {
|
||||
if let Some(ident) = self.scope.borrow().lookup(name) {
|
||||
return Some(ident);
|
||||
|
|
@ -214,9 +221,5 @@ fn build_function(parent: &BuildContext<'_>, code: &ast::Function) -> Function {
|
|||
}
|
||||
|
||||
pub fn build(code: &ast::Function) -> Function {
|
||||
let mut root = BuildContext {
|
||||
parent: None,
|
||||
scope: RefCell::new(Scope::new_toplevel()),
|
||||
};
|
||||
build_function(&mut root, &code)
|
||||
build_function(&BuildContext::new_toplevel(), &code)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user