Add flag for llvm

This commit is contained in:
greg 2017-01-16 02:47:05 -08:00
parent bdd6f75cf6
commit 1702163478

View File

@ -30,9 +30,10 @@ fn main() {
} }
}; };
let trace = option_matches.opt_present("t"); let trace = option_matches.opt_present("t");
let show_llvm = option_matches.opt_present("l");
match option_matches.free[..] { match option_matches.free[..] {
[] | [_] => { [] | [_] => {
let mut repl = Repl::new(trace); let mut repl = Repl::new(trace, show_llvm);
repl.run(); repl.run();
} }
[_, ref filename, _..] => { [_, ref filename, _..] => {
@ -49,6 +50,9 @@ fn program_options() -> getopts::Options {
options.optflag("t", options.optflag("t",
"trace-evaluation", "trace-evaluation",
"Print out trace of evaluation"); "Print out trace of evaluation");
options.optflag("l",
"llvm-in-repl",
"Show LLVM IR in REPL");
options options
} }
@ -96,13 +100,13 @@ struct Repl<'a> {
} }
impl<'a> Repl<'a> { impl<'a> Repl<'a> {
fn new(trace_evaluation: bool) -> Repl<'a> { fn new(trace_evaluation: bool, show_llvm: bool) -> Repl<'a> {
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(">> ");
Repl { Repl {
show_tokens: false, show_tokens: false,
show_parse: false, show_parse: false,
show_llvm_ir: false, show_llvm_ir: show_llvm,
evaluator: Evaluator::new_with_opts(None, trace_evaluation), evaluator: Evaluator::new_with_opts(None, trace_evaluation),
interpreter_directive_sigil: '.', interpreter_directive_sigil: '.',
reader: reader, reader: reader,