diff --git a/schala-lang/language/src/reduced_ast.rs b/schala-lang/language/src/reduced_ast.rs index ae79e37..f563bc1 100644 --- a/schala-lang/language/src/reduced_ast.rs +++ b/schala-lang/language/src/reduced_ast.rs @@ -33,7 +33,7 @@ pub enum Expr { type_name: Rc, name: Rc, tag: usize, - arity: usize, + arity: usize, // n.b. arity here is always the value from the symbol table - if it doesn't match what it's being called with, that's an eval error, eval will handle it }, Call { f: Box, @@ -150,7 +150,7 @@ impl Expression { TupleLiteral(exprs) => Expr::Tuple(exprs.iter().map(|e| e.node().reduce(symbol_table)).collect()), IfExpression { discriminator, body } => reduce_if_expression(discriminator, body, symbol_table), Lambda { params, body, .. } => reduce_lambda(params, body, symbol_table), - NamedStruct { name, fields } => reduce_named_struct(name, fields), + NamedStruct { name, fields } => reduce_named_struct(name, fields, symbol_table), Index { .. } => Expr::UnimplementedSigilValue, WhileExpression { .. } => Expr::UnimplementedSigilValue, ForExpression { .. } => Expr::UnimplementedSigilValue, @@ -167,8 +167,20 @@ fn reduce_lambda(params: &Vec, body: &Block, symbol_table: &SymbolT }) } -fn reduce_named_struct(name: &Rc, fields: &Vec<(Rc, Meta)>) -> Expr { - panic!() +fn reduce_named_struct(name: &Rc, fields: &Vec<(Rc, Meta)>, symbol_table: &SymbolTable) -> Expr { + /* + let (type_name, table_fields) = match symbol_table.lookup_by_name(name) { + Some(Symbol { spec: SymbolSpec::RecordConstructor { fields }, name, .. }) => (name, fields), + None => panic!("YOLO SWAGG"), + }; + let arity = table_fields.len(); + let f = Expr::Constructor { + type_name, arity, + }; + let args = fields.map(; + Expr::Call { f, args } + */ + panic!("Still not done") } fn reduce_call_expression(func: &Meta, arguments: &Vec>, symbol_table: &SymbolTable) -> Expr {