Checkpoint
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
use super::{Primitive, Type, ValueOrRef};
|
||||
use crate::eval::{EvalEnvironment, EvalError, Value};
|
||||
use crate::ir::{Expression, Program, Statement, TopLevel};
|
||||
|
||||
use super::{Primitive, Type, ValueOrRef};
|
||||
|
||||
impl Program {
|
||||
/// Evaluate the program, returning either an error or a string containing everything
|
||||
/// the program printed out.
|
||||
@@ -14,7 +13,7 @@ impl Program {
|
||||
|
||||
for stmt in self.items.iter() {
|
||||
match stmt {
|
||||
TopLevel::Function(_, _, _) => unimplemented!(),
|
||||
TopLevel::Function(_, _, _, _) => unimplemented!(),
|
||||
|
||||
TopLevel::Statement(Statement::Binding(_, name, _, value)) => {
|
||||
let actual_value = value.eval(&env)?;
|
||||
@@ -43,6 +42,7 @@ impl Expression {
|
||||
|
||||
match t {
|
||||
Type::Primitive(pt) => Ok(pt.safe_cast(&value)?),
|
||||
Type::Function(_, _) => Err(EvalError::CastToFunction(t.to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user