Kill old type structure

This commit is contained in:
greg 2018-05-12 02:20:50 -07:00
parent 822420a9d5
commit 9e393d2753
2 changed files with 6 additions and 8 deletions

View File

@ -302,7 +302,7 @@ impl Expr {
}
impl<'a> State<'a> {
pub fn evaluate_new(&mut self, ast: ReducedAST, repl: bool) -> Vec<Result<String, String>> {
pub fn evaluate(&mut self, ast: ReducedAST, repl: bool) -> Vec<Result<String, String>> {
use ast_reducing::*;
let mut acc = vec![];
@ -440,7 +440,7 @@ mod eval_tests {
macro_rules! fresh_env {
($string:expr, $correct:expr) => {
let mut state = State::new();
let all_output = state.evaluate_new(parse(tokenize($string)).0.unwrap().reduce(), true);
let all_output = state.evaluate(parse(tokenize($string)).0.unwrap().reduce(), true);
let ref output = all_output[0];
assert_eq!(*output, Ok($correct.to_string()));
}

View File

@ -93,17 +93,15 @@ fn typechecking(handle: &mut Schala, input: parsing::AST, comp: Option<&mut Unfi
}
}
type TempASTReduction = (ast_reducing::ReducedAST, parsing::AST);
fn ast_reducing(handle: &mut Schala, input: parsing::AST, comp: Option<&mut UnfinishedComputation>) -> Result<TempASTReduction, String> {
fn ast_reducing(handle: &mut Schala, input: parsing::AST, comp: Option<&mut UnfinishedComputation>) -> Result<ast_reducing::ReducedAST, String> {
let output = input.reduce();
comp.map(|comp| comp.add_artifact(TraceArtifact::new("ast_reducing", format!("{:?}", output))));
Ok((output, input))
Ok(output)
}
fn eval(handle: &mut Schala, input: TempASTReduction, comp: Option<&mut UnfinishedComputation>) -> Result<String, String> {
fn eval(handle: &mut Schala, input: ast_reducing::ReducedAST, comp: Option<&mut UnfinishedComputation>) -> Result<String, String> {
comp.map(|comp| comp.add_artifact(TraceArtifact::new("value_state", handle.state.debug_print())));
let new_input = input.0;
let evaluation_outputs = handle.state.evaluate_new(new_input, true);
let evaluation_outputs = handle.state.evaluate(input, true);
let text_output: Result<Vec<String>, String> = evaluation_outputs
.into_iter()
.collect();