Walk impl block
This commit is contained in:
parent
8e8be1b449
commit
934a390f2d
@ -98,7 +98,11 @@ impl<'a, 'b> Reducer<'a, 'b> {
|
||||
}
|
||||
ast::Declaration::Binding { constant, expr, .. } => {
|
||||
let symbol = self.symbol_table.lookup_symbol(item_id).unwrap();
|
||||
Some(Statement::Binding { id: symbol.def_id(), constant: *constant, expr: self.expression(expr) })
|
||||
Some(Statement::Binding {
|
||||
id: symbol.def_id(),
|
||||
constant: *constant,
|
||||
expr: self.expression(expr),
|
||||
})
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
|
@ -15,11 +15,14 @@ enum NameType {
|
||||
Import(Fqsn),
|
||||
}
|
||||
|
||||
type LexScope<'a> = ScopeStack<'a, Rc<String>, NameType, ScopeType>;
|
||||
|
||||
#[derive(Debug)]
|
||||
enum ScopeType {
|
||||
Function { name: Rc<String> },
|
||||
Lambda,
|
||||
PatternMatch,
|
||||
ImplBlock,
|
||||
//TODO add some notion of a let-like scope?
|
||||
}
|
||||
|
||||
@ -27,7 +30,7 @@ pub struct ScopeResolver<'a> {
|
||||
symbol_table: &'a mut super::SymbolTable,
|
||||
//TODO maybe this shouldn't be a scope stack, b/c the recursion behavior comes from multiple
|
||||
//instances of ScopeResolver
|
||||
lexical_scopes: ScopeStack<'a, Rc<String>, NameType, ScopeType>,
|
||||
lexical_scopes: LexScope<'a>,
|
||||
}
|
||||
|
||||
impl<'a> ScopeResolver<'a> {
|
||||
@ -138,6 +141,8 @@ impl<'a> ASTVisitor for ScopeResolver<'a> {
|
||||
let param_names = signature.params.iter().map(|param| param.name.clone());
|
||||
//TODO I'm 90% sure this is right, until I get to closures
|
||||
//let mut new_scope = self.lexical_scopes.new_scope(Some(ScopeType::Function { name: signature.name.clone() }));
|
||||
//TODO this will recurse unwantedly into scopes; need to pop an outer function
|
||||
//scope off first before going into a non-closure scope
|
||||
let mut new_scope =
|
||||
ScopeStack::new(Some(ScopeType::Function { name: signature.name.clone() }));
|
||||
|
||||
@ -162,6 +167,15 @@ impl<'a> ASTVisitor for ScopeResolver<'a> {
|
||||
}
|
||||
Recursion::Continue
|
||||
}
|
||||
Declaration::Impl { block, .. } => {
|
||||
let mut new_scope = ScopeStack::new(Some(ScopeType::ImplBlock));
|
||||
let mut new_resolver =
|
||||
ScopeResolver { symbol_table: self.symbol_table, lexical_scopes: new_scope };
|
||||
for stmt in block.iter() {
|
||||
walk_declaration(&mut new_resolver, &stmt.kind, &stmt.id);
|
||||
}
|
||||
Recursion::Stop
|
||||
}
|
||||
_ => Recursion::Continue,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user