Start eval-ing data constructors
This commit is contained in:
parent
25790f8643
commit
3beabf4678
@ -1,7 +1,6 @@
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fmt::Write;
|
|
||||||
|
|
||||||
use self::Type::*; use self::TConstOld::*;
|
use self::Type::*; use self::TConstOld::*;
|
||||||
|
|
||||||
|
@ -140,11 +140,20 @@ impl<'a> State<'a> {
|
|||||||
match expr {
|
match expr {
|
||||||
literal @ Lit(_) => Ok(literal),
|
literal @ Lit(_) => Ok(literal),
|
||||||
Call { box f, args } => {
|
Call { box f, args } => {
|
||||||
let f = match self.expression(f)? {
|
if let Val(name) = f {
|
||||||
Func(f) => f,
|
let symbol_table = self.symbol_table_handle.borrow();
|
||||||
other => return Err(format!("Tried to call {:?} which is not a function", other)),
|
match symbol_table.values.get(&name) {
|
||||||
};
|
Some(Symbol { spec: SymbolSpec::DataConstructor { type_name, type_args }, .. }) => {
|
||||||
self.apply_function(f, args)
|
Ok(Expr::Lit(self::Lit::Nat(99)))
|
||||||
|
},
|
||||||
|
_ => return Err(format!("Bad symbol {}", name))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
match self.expression(f)? {
|
||||||
|
Func(f) => self.apply_function(f, args),
|
||||||
|
other => return Err(format!("Tried to call {:?} which is not a function or data constructor", other)),
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Val(v) => self.value(v),
|
Val(v) => self.value(v),
|
||||||
func @ Func(_) => Ok(func),
|
func @ Func(_) => Ok(func),
|
||||||
|
Loading…
Reference in New Issue
Block a user