Reduce complexity of DataConstructor
This commit is contained in:
parent
736aa8aad2
commit
3c4d31c963
@ -190,11 +190,11 @@ impl<'a> Reducer<'a> {
|
|||||||
|
|
||||||
match spec {
|
match spec {
|
||||||
SymbolSpec::RecordConstructor { .. } => Expr::ReductionError(format!("AST reducer doesn't expect a RecordConstructor here")),
|
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(),
|
type_name: type_name.clone(),
|
||||||
name: local_name.clone(),
|
name: local_name.clone(),
|
||||||
tag: index.clone(),
|
tag: index.clone(),
|
||||||
arity: type_args.len(),
|
arity: *arity,
|
||||||
},
|
},
|
||||||
SymbolSpec::Func(_) => Expr::Sym(local_name.clone()),
|
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
|
SymbolSpec::Binding => Expr::Sym(local_name.clone()), //TODO not sure if this is right, probably needs to eventually be fqsn
|
||||||
|
@ -151,8 +151,8 @@ pub enum SymbolSpec {
|
|||||||
Func(Vec<TypeName>),
|
Func(Vec<TypeName>),
|
||||||
DataConstructor {
|
DataConstructor {
|
||||||
index: usize,
|
index: usize,
|
||||||
|
arity: usize,
|
||||||
type_name: TypeName, //TODO this eventually needs to be some kind of ID
|
type_name: TypeName, //TODO this eventually needs to be some kind of ID
|
||||||
type_args: Vec<Rc<String>>, //TODO this should be a lookup table into type information, it's not the concern of the symbol table
|
|
||||||
},
|
},
|
||||||
RecordConstructor {
|
RecordConstructor {
|
||||||
index: usize,
|
index: usize,
|
||||||
@ -167,7 +167,7 @@ impl fmt::Display for SymbolSpec {
|
|||||||
use self::SymbolSpec::*;
|
use self::SymbolSpec::*;
|
||||||
match self {
|
match self {
|
||||||
Func(type_names) => write!(f, "Func({:?})", type_names),
|
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: {})(<members> -> {})", index, type_name),
|
RecordConstructor { type_name, index, ..} => write!(f, "RecordConstructor(idx: {})(<members> -> {})", index, type_name),
|
||||||
Binding => write!(f, "Binding"),
|
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 fq_name = FQSN::from_scope_stack(scope_stack.as_ref(), name.as_ref().to_owned());
|
||||||
let spec = SymbolSpec::DataConstructor {
|
let spec = SymbolSpec::DataConstructor {
|
||||||
index,
|
index,
|
||||||
|
arity: 0,
|
||||||
type_name: name.clone(),
|
type_name: name.clone(),
|
||||||
type_args: vec![],
|
|
||||||
};
|
};
|
||||||
register(fq_name, spec);
|
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 fq_name = FQSN::from_scope_stack(scope_stack.as_ref(), name.as_ref().to_owned());
|
||||||
let spec = SymbolSpec::DataConstructor {
|
let spec = SymbolSpec::DataConstructor {
|
||||||
index,
|
index,
|
||||||
|
arity: items.len(),
|
||||||
type_name: name.clone(),
|
type_name: name.clone(),
|
||||||
type_args: items.iter().map(|_| Rc::new("DUMMY_TYPE_ID".to_string())).collect()
|
|
||||||
};
|
};
|
||||||
register(fq_name, spec);
|
register(fq_name, spec);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user