More work on fully-qualified names

This commit is contained in:
greg 2019-09-03 10:23:38 -07:00
parent a5c9aca4d7
commit fd66a9711d
2 changed files with 35 additions and 4 deletions

View File

@ -242,6 +242,7 @@ pub enum PatternLiteral {
},
StringPattern(Rc<String>),
BoolPattern(bool),
//TODO I think VarPattern also needs to know about FQSNs
VarPattern(Rc<String>)
}

View File

@ -29,18 +29,48 @@ impl ScopeResolver {
}
fn expr(&mut self, expr: &mut Meta<Expression>) -> Result<(), String> {
match &expr.node().kind {
//TODO this needs to fully recurse
use ExpressionKind::*;
let inner_expr = expr.mut_node();
match &mut inner_expr.kind {
ExpressionKind::Value(qualified_name) => {
//TODO fill this out
let fqsn = lookup_name_in_scope(&qualified_name);
expr.fqsn = Some(fqsn);
},
NamedStruct { name, .. } => {
let fqsn = lookup_name_in_scope(&name);
expr.fqsn = Some(fqsn);
},
BinExp(_, ref mut lhs, ref mut rhs) => {
self.expr(lhs)?;
self.expr(rhs)?;
},
PrefixExp(_, ref mut arg) => {
self.expr(arg)?;
},
TupleLiteral(exprs) => {
for expr in exprs.iter_mut() {
self.expr(expr)?;
}
},
Call { ref mut f, arguments } => {
self.expr(f)?;
for arg in arguments.iter_mut() {
self.invoc(arg)?;
}
}
_ => ()
};
Ok(())
}
fn invoc(&mut self, invoc: &mut InvocationArgument) -> Result<(), String> {
use InvocationArgument::*;
match invoc {
Positional(expr) => self.expr(expr),
Keyword { expr, .. } => self.expr(expr),
_ => Ok(())
}
}
}
//TODO this is incomplete