From 5147a32c9719ebb1a3742149043b5bc916c4e7e5 Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 25 Oct 2019 19:28:29 -0700 Subject: [PATCH] Handle FQSNs at reduced_eval level --- schala-lang/language/src/reduced_ast.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/schala-lang/language/src/reduced_ast.rs b/schala-lang/language/src/reduced_ast.rs index 3e0cf65..f47b02a 100644 --- a/schala-lang/language/src/reduced_ast.rs +++ b/schala-lang/language/src/reduced_ast.rs @@ -44,7 +44,7 @@ pub enum Expr { Lit(Lit), Tuple(Vec), Func(Func), - Sym(Rc), + Sym(FullyQualifiedSymbolName), Constructor { type_name: Rc, name: Rc, @@ -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),