Get rid of stand alone evaluator

This commit is contained in:
greg 2017-02-02 00:23:48 -08:00
parent 902c85ccd7
commit 455fe2abe2

View File

@ -94,30 +94,25 @@ fn run_noninteractive<'a, T: ProgrammingLanguage>(filename: &str, compile: bool,
} }
type LineReader = linefeed::Reader<linefeed::terminal::DefaultTerminal>; type LineReader = linefeed::Reader<linefeed::terminal::DefaultTerminal>;
struct Repl<'a> { struct Repl {
show_tokens: bool, show_tokens: bool,
show_parse: bool, show_parse: bool,
show_llvm_ir: bool, show_llvm_ir: bool,
languages: Vec<Box<LanguageInterface>>, languages: Vec<Box<LanguageInterface>>,
evaluator: SchalaEvaluator<'a>,
interpreter_directive_sigil: char, interpreter_directive_sigil: char,
reader: LineReader, reader: LineReader,
} }
impl<'a> Repl<'a> { impl Repl {
fn new(trace_evaluation: bool, show_llvm: bool) -> Repl<'a> { fn new(trace_evaluation: bool, show_llvm: bool) -> Repl {
let mut reader: linefeed::Reader<_> = linefeed::Reader::new("Schala").unwrap(); let mut reader: linefeed::Reader<_> = linefeed::Reader::new("Schala").unwrap();
reader.set_prompt(">> "); reader.set_prompt(">> ");
let mut evaluator = <SchalaEvaluator as EvaluationMachine>::new();
evaluator.set_option("trace_evaluation", trace_evaluation);
Repl { Repl {
show_tokens: false, show_tokens: false,
show_parse: false, show_parse: false,
show_llvm_ir: show_llvm, show_llvm_ir: show_llvm,
languages: vec![Box::new((Schala::new(), SchalaEvaluator::new(None)))], languages: vec![Box::new((Schala::new(), SchalaEvaluator::new(None)))],
evaluator: evaluator,
interpreter_directive_sigil: '.', interpreter_directive_sigil: '.',
reader: reader, reader: reader,
} }
@ -190,7 +185,7 @@ impl<'a> Repl<'a> {
match commands[2] { match commands[2] {
"tokens" => self.show_tokens = show, "tokens" => self.show_tokens = show,
"parse" => self.show_parse = show, "parse" => self.show_parse = show,
"eval" => { self.evaluator.set_option("trace_evaluation", show); }, "eval" => { /*self.evaluator.set_option("trace_evaluation", show);*/ },
"llvm" => self.show_llvm_ir = show, "llvm" => self.show_llvm_ir = show,
e => { e => {
println!("Bad `show`/`hide` argument: {}", e); println!("Bad `show`/`hide` argument: {}", e);