Start work on named struct
This commit is contained in:
parent
e4592ddfb2
commit
264fc2ae58
@ -136,7 +136,28 @@ impl<'a> Reducer<'a> {
|
||||
body: self.function_internal_block(body),
|
||||
})
|
||||
},
|
||||
NamedStruct { .. } => Expression::ReductionError("NamedStruct not implemented".to_string()), //self.reduce_named_struct(name, fields),
|
||||
NamedStruct { name, fields } => {
|
||||
let symbol = self.symbol_table.lookup_symbol(&name.id).unwrap();
|
||||
let constructor = match symbol.spec() {
|
||||
SymbolSpec::RecordConstructor { index, members: _, type_id } => Expression::Callable(Callable::RecordConstructor {
|
||||
type_id,
|
||||
tag: index as u32,
|
||||
}),
|
||||
e => return Expression::ReductionError(format!("Bad symbol for NamedStruct: {:?}", e)),
|
||||
};
|
||||
|
||||
//TODO need to order the fields correctly, which needs symbol table information
|
||||
// Until this happens, NamedStructs won't work
|
||||
let mut ordered_args = vec![];
|
||||
for (_name, _type_id) in fields {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
Expression::Call {
|
||||
f: Box::new(constructor),
|
||||
args: ordered_args,
|
||||
}
|
||||
},
|
||||
Index { .. } => Expression::ReductionError("Index expr not implemented".to_string()),
|
||||
WhileExpression { .. } => Expression::ReductionError("While expr not implemented".to_string()),
|
||||
ForExpression { .. } => Expression::ReductionError("For expr not implemented".to_string()),
|
||||
|
@ -98,6 +98,10 @@ pub enum Callable {
|
||||
arity: u32,
|
||||
tag: u32
|
||||
},
|
||||
RecordConstructor {
|
||||
type_id: TypeId,
|
||||
tag: u32,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -358,6 +358,9 @@ impl<'a> State<'a> {
|
||||
items: evaluated_args
|
||||
})
|
||||
}
|
||||
Callable::RecordConstructor { type_id: _, tag: _ } => {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user