Wire up all the qualified names
This commit is contained in:
parent
9a28ccfd85
commit
cfa65e5339
@ -144,7 +144,7 @@ fn symbol_table(input: ast::AST, handle: &mut Schala, comp: Option<&mut PassDebu
|
|||||||
Ok(input)
|
Ok(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scope_resolution(mut input: ast::AST, handle: &mut Schala, com: Option<&mut PassDebugArtifact>) -> Result<ast::AST, String> {
|
fn scope_resolution(mut input: ast::AST, _handle: &mut Schala, _com: Option<&mut PassDebugArtifact>) -> Result<ast::AST, String> {
|
||||||
let mut resolver = crate::scope_resolution::ScopeResolver::new();
|
let mut resolver = crate::scope_resolution::ScopeResolver::new();
|
||||||
let () = resolver.resolve(&mut input)?;
|
let () = resolver.resolve(&mut input)?;
|
||||||
Ok(input)
|
Ok(input)
|
||||||
|
@ -55,7 +55,20 @@ impl ScopeResolver {
|
|||||||
for arg in arguments.iter_mut() {
|
for arg in arguments.iter_mut() {
|
||||||
self.invoc(arg)?;
|
self.invoc(arg)?;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
IfExpression { ref mut body, .. } => match &mut **body {
|
||||||
|
IfExpressionBody::SimplePatternMatch(ref mut pat, _, _) => {
|
||||||
|
self.pattern(pat)?;
|
||||||
|
},
|
||||||
|
IfExpressionBody::GuardList(guardarms) => {
|
||||||
|
for arm in guardarms.iter_mut() {
|
||||||
|
if let Guard::Pat(ref mut pat) = arm.guard {
|
||||||
|
self.pattern(pat)?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => ()
|
||||||
|
},
|
||||||
_ => ()
|
_ => ()
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -69,6 +82,41 @@ impl ScopeResolver {
|
|||||||
_ => Ok(())
|
_ => Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn pattern(&mut self, pat: &mut Pattern) -> Result<(), String> {
|
||||||
|
use Pattern::*;
|
||||||
|
match pat {
|
||||||
|
Ignored => (),
|
||||||
|
TuplePattern(patterns) => {
|
||||||
|
for pat in patterns {
|
||||||
|
self.pattern(pat)?;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Literal(_) => (),
|
||||||
|
TupleStruct(name, patterns) => {
|
||||||
|
self.qualified_name(name);
|
||||||
|
for pat in patterns {
|
||||||
|
self.pattern(pat)?;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Record(name, key_patterns) => {
|
||||||
|
self.qualified_name(name);
|
||||||
|
for (_, pat) in key_patterns {
|
||||||
|
self.pattern(pat)?;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
VarOrName(name) => {
|
||||||
|
self.qualified_name(name);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn qualified_name(&mut self, meta_qualified_name: &mut Meta<QualifiedName>, ) {
|
||||||
|
let inner_name = meta_qualified_name.node();
|
||||||
|
let fqsn = lookup_name_in_scope(inner_name);
|
||||||
|
meta_qualified_name.fqsn = Some(fqsn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO this is incomplete
|
//TODO this is incomplete
|
||||||
|
Loading…
Reference in New Issue
Block a user