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> { 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::*; use ast_reducing::*;
let mut acc = vec![]; let mut acc = vec![];
@ -440,7 +440,7 @@ mod eval_tests {
macro_rules! fresh_env { macro_rules! fresh_env {
($string:expr, $correct:expr) => { ($string:expr, $correct:expr) => {
let mut state = State::new(); 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]; let ref output = all_output[0];
assert_eq!(*output, Ok($correct.to_string())); 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<ast_reducing::ReducedAST, String> {
fn ast_reducing(handle: &mut Schala, input: parsing::AST, comp: Option<&mut UnfinishedComputation>) -> Result<TempASTReduction, String> {
let output = input.reduce(); let output = input.reduce();
comp.map(|comp| comp.add_artifact(TraceArtifact::new("ast_reducing", format!("{:?}", output)))); 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()))); 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(input, true);
let evaluation_outputs = handle.state.evaluate_new(new_input, true);
let text_output: Result<Vec<String>, String> = evaluation_outputs let text_output: Result<Vec<String>, String> = evaluation_outputs
.into_iter() .into_iter()
.collect(); .collect();