diff --git a/schala-lang/language/src/lib.rs b/schala-lang/language/src/lib.rs index e6c17f7..5dbfaa1 100644 --- a/schala-lang/language/src/lib.rs +++ b/schala-lang/language/src/lib.rs @@ -21,6 +21,7 @@ use stopwatch::Stopwatch; use std::cell::RefCell; use std::rc::Rc; +use std::collections::HashSet; use itertools::Itertools; use schala_repl::{ProgrammingLanguageInterface, @@ -83,7 +84,7 @@ impl Schala { let prelude = include_str!("prelude.schala"); let mut s = Schala::new_blank_env(); - let request = ComputationRequest { source: prelude, debug_requests: vec![] }; + let request = ComputationRequest { source: prelude, debug_requests: HashSet::default() }; s.run_computation(request); s } @@ -262,39 +263,44 @@ impl ProgrammingLanguageInterface for Schala { let stage_names = stage_names(); self.source_reference.load_new_source(source); - let token_debug_artifact = None; - let parsing_debug_artifact = None; - let symbol_debug_artifact = None; - let typechecking_debug_artifact = None; - let reducing_debug_artifact = None; - let eval_debug_artifact = None; - let sw = Stopwatch::start_new(); let mut stage_durations = Vec::new(); let main_output: Result = { - let output = tokenizing(source, self, token_debug_artifact); - stage_durations.push((stage_names[0].to_string(), sw.elapsed())); + let n = 0; + let debug_artifact = None; + let output = tokenizing(source, self, debug_artifact); + stage_durations.push((stage_names[n].to_string(), sw.elapsed())); output }.and_then(|tokens| { - let output = parsing(tokens, self, parsing_debug_artifact); - stage_durations.push((stage_names[1].to_string(), sw.elapsed())); + let n = 1; + let debug_artifact = None; + let output = parsing(tokens, self, debug_artifact); + stage_durations.push((stage_names[n].to_string(), sw.elapsed())); output }).and_then(|ast| { - let output = symbol_table(ast, self, symbol_debug_artifact); - stage_durations.push((stage_names[2].to_string(), sw.elapsed())); + let n = 2; + let debug_artifact = None; + let output = symbol_table(ast, self, debug_artifact); + stage_durations.push((stage_names[n].to_string(), sw.elapsed())); output }).and_then(|ast| { - let output = typechecking(ast, self, typechecking_debug_artifact); - stage_durations.push((stage_names[3].to_string(), sw.elapsed())); + let n = 3; + let debug_artifact = None; + let output = typechecking(ast, self, debug_artifact); + stage_durations.push((stage_names[n].to_string(), sw.elapsed())); output }).and_then(|ast| { - let output = ast_reducing(ast, self, reducing_debug_artifact); - stage_durations.push((stage_names[4].to_string(), sw.elapsed())); + let n = 4; + let debug_artifact = None; + let output = ast_reducing(ast, self, debug_artifact); + stage_durations.push((stage_names[n].to_string(), sw.elapsed())); output }).and_then(|reduced_ast| { - let output = eval(reduced_ast, self, eval_debug_artifact); - stage_durations.push((stage_names[5].to_string(), sw.elapsed())); + let n = 5; + let debug_artifact = None; + let output = eval(reduced_ast, self, debug_artifact); + stage_durations.push((stage_names[n].to_string(), sw.elapsed())); output }); diff --git a/schala-repl/src/language.rs b/schala-repl/src/language.rs index abf8bb6..161b30d 100644 --- a/schala-repl/src/language.rs +++ b/schala-repl/src/language.rs @@ -1,4 +1,5 @@ use std::time; +use std::collections::HashSet; pub trait ProgrammingLanguageInterface { fn get_language_name(&self) -> String; @@ -19,7 +20,7 @@ pub trait ProgrammingLanguageInterface { pub struct ComputationRequest<'a> { pub source: &'a str, - pub debug_requests: Vec, + pub debug_requests: HashSet, } pub struct ComputationResponse { diff --git a/schala-repl/src/lib.rs b/schala-repl/src/lib.rs index f42d4fd..2e02d41 100644 --- a/schala-repl/src/lib.rs +++ b/schala-repl/src/lib.rs @@ -12,6 +12,7 @@ extern crate serde_json; extern crate includedir; extern crate phf; +use std::collections::HashSet; use std::path::Path; use std::fs::File; use std::io::Read; @@ -68,7 +69,7 @@ fn run_noninteractive(filename: &str, languages: Vec String { - let mut debug_requests = vec![]; + let mut debug_requests = HashSet::new(); for ask in self.options.debug_asks.iter() { - debug_requests.push(ask.clone()); + debug_requests.insert(ask.clone()); } let request = ComputationRequest {