Compare commits

...

1 Commits

Author SHA1 Message Date
greg
5147a32c97 Handle FQSNs at reduced_eval level 2019-10-25 19:28:29 -07:00

View File

@ -44,7 +44,7 @@ pub enum Expr {
Lit(Lit),
Tuple(Vec<Expr>),
Func(Func),
Sym(Rc<String>),
Sym(FullyQualifiedSymbolName),
Constructor {
type_name: Rc<String>,
name: Rc<String>,
@ -166,21 +166,19 @@ impl<'a> Reducer<'a> {
PrefixExp(op, arg) => self.prefix(op, arg),
Value(qualified_name) => {
let ref id = qualified_name.id;
let ref sym_name = match symbol_table.get_fqsn_from_id(id) {
let ref fqsn = match symbol_table.get_fqsn_from_id(id) {
Some(fqsn) => fqsn,
None => return Expr::ReductionError(format!("FQSN lookup for Value {:?} failed", qualified_name)),
};
//TODO this probably needs to change
let FullyQualifiedSymbolName(ref v) = sym_name;
let name = v.last().unwrap().name.clone();
match symbol_table.lookup_by_fqsn(&sym_name) {
Some(Symbol { spec: SymbolSpec::DataConstructor { index, type_args, type_name}, .. }) => Expr::Constructor {
match symbol_table.lookup_by_fqsn(&fqsn) {
Some(Symbol { spec: SymbolSpec::DataConstructor { index, type_args, type_name}, local_name, .. }) => Expr::Constructor {
type_name: type_name.clone(),
name: name.clone(),
name: local_name.clone(),
tag: index.clone(),
arity: type_args.len(),
},
_ => Expr::Sym(name.clone()),
_ => Expr::Sym(fqsn.clone()),
}
},
Call { f, arguments } => self.reduce_call_expression(f, arguments),