From 32acf89814595687cf3f421e950b554e6c0b77d5 Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 5 Aug 2018 16:04:52 -0700 Subject: [PATCH] New Constructor --- schala-lang/src/eval.rs | 4 +++- schala-lang/src/reduced_ast.rs | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/schala-lang/src/eval.rs b/schala-lang/src/eval.rs index f7ad42c..30557a1 100644 --- a/schala-lang/src/eval.rs +++ b/schala-lang/src/eval.rs @@ -77,7 +77,9 @@ impl Expr { UserDefined { name: None, .. } => format!(""), UserDefined { name: Some(name), .. } => format!("", name), }, - Expr::Constructor { name } => format!("", name), + Expr::NewConstructor { + type_name, tag, arity, + } => unimplemented!(), Expr::Tuple(exprs) => paren_wrapped_vec(exprs), _ => format!("{:?}", self), } diff --git a/schala-lang/src/reduced_ast.rs b/schala-lang/src/reduced_ast.rs index 7523807..9c355cf 100644 --- a/schala-lang/src/reduced_ast.rs +++ b/schala-lang/src/reduced_ast.rs @@ -32,7 +32,7 @@ pub enum Expr { NewConstructor { type_name: Rc, tag: usize, - arg: Box, + arity: usize, }, Constructor { name: Rc, @@ -117,8 +117,10 @@ impl Expression { PrefixExp(op, arg) => op.reduce(symbol_table, arg), Value(name) => { match symbol_table.values.get(name) { - Some(Symbol { spec: SymbolSpec::DataConstructor { type_args, .. }, .. }) => { - Expr::Constructor { name: name.clone() } + Some(Symbol { spec: SymbolSpec::DataConstructor { index, type_args, type_name}, .. }) => Expr::NewConstructor { + type_name: type_name.clone(), + tag: index.clone(), + arity: type_args.len(), }, _ => Expr::Val(name.clone()), }