From 3c4d31c963d4a08317d54a63bfd960d33aeff459 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Tue, 19 Oct 2021 16:50:08 -0700 Subject: [PATCH] Reduce complexity of DataConstructor --- schala-lang/language/src/reduced_ast.rs | 4 ++-- schala-lang/language/src/symbol_table/mod.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/schala-lang/language/src/reduced_ast.rs b/schala-lang/language/src/reduced_ast.rs index a87ad0b..228eb2b 100644 --- a/schala-lang/language/src/reduced_ast.rs +++ b/schala-lang/language/src/reduced_ast.rs @@ -190,11 +190,11 @@ impl<'a> Reducer<'a> { match spec { SymbolSpec::RecordConstructor { .. } => Expr::ReductionError(format!("AST reducer doesn't expect a RecordConstructor here")), - SymbolSpec::DataConstructor { index, type_args, type_name } => Expr::Constructor { + SymbolSpec::DataConstructor { index, arity, type_name } => Expr::Constructor { type_name: type_name.clone(), name: local_name.clone(), tag: index.clone(), - arity: type_args.len(), + arity: *arity, }, SymbolSpec::Func(_) => Expr::Sym(local_name.clone()), SymbolSpec::Binding => Expr::Sym(local_name.clone()), //TODO not sure if this is right, probably needs to eventually be fqsn diff --git a/schala-lang/language/src/symbol_table/mod.rs b/schala-lang/language/src/symbol_table/mod.rs index 85bd054..c8d52e0 100644 --- a/schala-lang/language/src/symbol_table/mod.rs +++ b/schala-lang/language/src/symbol_table/mod.rs @@ -151,8 +151,8 @@ pub enum SymbolSpec { Func(Vec), DataConstructor { index: usize, + arity: usize, type_name: TypeName, //TODO this eventually needs to be some kind of ID - type_args: Vec>, //TODO this should be a lookup table into type information, it's not the concern of the symbol table }, RecordConstructor { index: usize, @@ -167,7 +167,7 @@ impl fmt::Display for SymbolSpec { use self::SymbolSpec::*; match self { Func(type_names) => write!(f, "Func({:?})", type_names), - DataConstructor { index, type_name, type_args } => write!(f, "DataConstructor(idx: {})({:?} -> {})", index, type_args, type_name), + DataConstructor { index, type_name, arity } => write!(f, "DataConstructor(idx: {}, arity: {}, type: {})", index, arity, type_name), RecordConstructor { type_name, index, ..} => write!(f, "RecordConstructor(idx: {})( -> {})", index, type_name), Binding => write!(f, "Binding"), } @@ -298,8 +298,8 @@ impl SymbolTable { let fq_name = FQSN::from_scope_stack(scope_stack.as_ref(), name.as_ref().to_owned()); let spec = SymbolSpec::DataConstructor { index, + arity: 0, type_name: name.clone(), - type_args: vec![], }; register(fq_name, spec); }, @@ -307,8 +307,8 @@ impl SymbolTable { let fq_name = FQSN::from_scope_stack(scope_stack.as_ref(), name.as_ref().to_owned()); let spec = SymbolSpec::DataConstructor { index, + arity: items.len(), type_name: name.clone(), - type_args: items.iter().map(|_| Rc::new("DUMMY_TYPE_ID".to_string())).collect() }; register(fq_name, spec); },