Make type for DataConstructor

This commit is contained in:
Greg Shuflin 2021-10-25 15:53:54 -07:00
parent b00df64f55
commit e18ddbded9
3 changed files with 13 additions and 14 deletions

View File

@ -201,25 +201,18 @@ impl<'a> Reducer<'a> {
rval: Box::new(self.expression(rhs)),
}
},
Some(op) => {
Expression::Call {
Some(op) => Expression::Call {
f: Box::new(Expression::Callable(Function::Builtin(op))),
args: vec![self.expression(lhs), self.expression(rhs)],
}
}
None => {
},
//TODO handle a user-defined operation
ReductionError("User-defined operations not supported".to_string())
}
None => ReductionError("User-defined operations not supported".to_string())
}
}
fn value(&mut self, qualified_name: &ast::QualifiedName) -> Expression {
use SymbolSpec::*;
let ast::QualifiedName { id: _, components, .. } = qualified_name;
let _ = components;
let symbol = match self.symbol_table.lookup_symbol(&qualified_name.id) {
Some(s) => s,
None => return Expression::ReductionError(format!("No symbol found for name: {:?}", qualified_name))

View File

@ -81,7 +81,12 @@ pub enum Function {
Lambda {
arity: u8,
body: Vec<Statement>
}
},
DataConstructor {
type_id: Rc<String>, //TODO this can't last
arity: u32,
tag: u32
},
}
#[derive(Debug, Clone)]

View File

@ -278,6 +278,7 @@ impl<'a> State<'a> {
let body = body.clone(); //TODO again ideally, no cloning here
self.apply_function(body, args)
}
Function::DataConstructor { .. } => panic!(),
}
}