Make type for DataConstructor
This commit is contained in:
parent
b00df64f55
commit
e18ddbded9
@ -201,25 +201,18 @@ impl<'a> Reducer<'a> {
|
||||
rval: Box::new(self.expression(rhs)),
|
||||
}
|
||||
},
|
||||
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())
|
||||
}
|
||||
Some(op) => Expression::Call {
|
||||
f: Box::new(Expression::Callable(Function::Builtin(op))),
|
||||
args: vec![self.expression(lhs), self.expression(rhs)],
|
||||
},
|
||||
//TODO handle a user-defined operation
|
||||
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))
|
||||
|
@ -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)]
|
||||
|
@ -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!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user