DebugRequests should be set

This commit is contained in:
greg 2019-05-26 04:16:40 -07:00
parent d80d0d0904
commit 548a7b5f36
4 changed files with 33 additions and 24 deletions

View File

@ -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<String, String> = {
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
});

View File

@ -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<DebugAsk>,
pub debug_requests: HashSet<DebugAsk>,
}
pub struct ComputationResponse {

View File

@ -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<Box<ProgrammingLanguageInte
let request = ComputationRequest {
source: &buffer,
debug_requests: vec![]
debug_requests: HashSet::new(),
};
let response = language.run_computation(request);

View File

@ -1,5 +1,6 @@
use std::fmt::Write as FmtWrite;
use std::sync::Arc;
use std::collections::HashSet;
use colored::*;
use crate::language::{ProgrammingLanguageInterface,
@ -174,9 +175,9 @@ impl Repl {
}
fn handle_input(&mut self, input: &str) -> 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 {