diff --git a/schala-lang/language/src/reduced_ir/mod.rs b/schala-lang/language/src/reduced_ir/mod.rs index 2e607d7..cc50ca2 100644 --- a/schala-lang/language/src/reduced_ir/mod.rs +++ b/schala-lang/language/src/reduced_ir/mod.rs @@ -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()), diff --git a/schala-lang/language/src/reduced_ir/types.rs b/schala-lang/language/src/reduced_ir/types.rs index 6999056..2a85521 100644 --- a/schala-lang/language/src/reduced_ir/types.rs +++ b/schala-lang/language/src/reduced_ir/types.rs @@ -98,6 +98,10 @@ pub enum Callable { arity: u32, tag: u32 }, + RecordConstructor { + type_id: TypeId, + tag: u32, + }, } #[derive(Debug, Clone)] diff --git a/schala-lang/language/src/tree_walk_eval/mod.rs b/schala-lang/language/src/tree_walk_eval/mod.rs index a5c5301..42cdebe 100644 --- a/schala-lang/language/src/tree_walk_eval/mod.rs +++ b/schala-lang/language/src/tree_walk_eval/mod.rs @@ -358,6 +358,9 @@ impl<'a> State<'a> { items: evaluated_args }) } + Callable::RecordConstructor { type_id: _, tag: _ } => { + unimplemented!() + } } }