DebugRequests should be set
This commit is contained in:
parent
d80d0d0904
commit
548a7b5f36
@ -21,6 +21,7 @@ use stopwatch::Stopwatch;
|
|||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use schala_repl::{ProgrammingLanguageInterface,
|
use schala_repl::{ProgrammingLanguageInterface,
|
||||||
@ -83,7 +84,7 @@ impl Schala {
|
|||||||
let prelude = include_str!("prelude.schala");
|
let prelude = include_str!("prelude.schala");
|
||||||
let mut s = Schala::new_blank_env();
|
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.run_computation(request);
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
@ -262,39 +263,44 @@ impl ProgrammingLanguageInterface for Schala {
|
|||||||
let stage_names = stage_names();
|
let stage_names = stage_names();
|
||||||
self.source_reference.load_new_source(source);
|
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 sw = Stopwatch::start_new();
|
||||||
let mut stage_durations = Vec::new();
|
let mut stage_durations = Vec::new();
|
||||||
|
|
||||||
let main_output: Result<String, String> = {
|
let main_output: Result<String, String> = {
|
||||||
let output = tokenizing(source, self, token_debug_artifact);
|
let n = 0;
|
||||||
stage_durations.push((stage_names[0].to_string(), sw.elapsed()));
|
let debug_artifact = None;
|
||||||
|
let output = tokenizing(source, self, debug_artifact);
|
||||||
|
stage_durations.push((stage_names[n].to_string(), sw.elapsed()));
|
||||||
output
|
output
|
||||||
}.and_then(|tokens| {
|
}.and_then(|tokens| {
|
||||||
let output = parsing(tokens, self, parsing_debug_artifact);
|
let n = 1;
|
||||||
stage_durations.push((stage_names[1].to_string(), sw.elapsed()));
|
let debug_artifact = None;
|
||||||
|
let output = parsing(tokens, self, debug_artifact);
|
||||||
|
stage_durations.push((stage_names[n].to_string(), sw.elapsed()));
|
||||||
output
|
output
|
||||||
}).and_then(|ast| {
|
}).and_then(|ast| {
|
||||||
let output = symbol_table(ast, self, symbol_debug_artifact);
|
let n = 2;
|
||||||
stage_durations.push((stage_names[2].to_string(), sw.elapsed()));
|
let debug_artifact = None;
|
||||||
|
let output = symbol_table(ast, self, debug_artifact);
|
||||||
|
stage_durations.push((stage_names[n].to_string(), sw.elapsed()));
|
||||||
output
|
output
|
||||||
}).and_then(|ast| {
|
}).and_then(|ast| {
|
||||||
let output = typechecking(ast, self, typechecking_debug_artifact);
|
let n = 3;
|
||||||
stage_durations.push((stage_names[3].to_string(), sw.elapsed()));
|
let debug_artifact = None;
|
||||||
|
let output = typechecking(ast, self, debug_artifact);
|
||||||
|
stage_durations.push((stage_names[n].to_string(), sw.elapsed()));
|
||||||
output
|
output
|
||||||
}).and_then(|ast| {
|
}).and_then(|ast| {
|
||||||
let output = ast_reducing(ast, self, reducing_debug_artifact);
|
let n = 4;
|
||||||
stage_durations.push((stage_names[4].to_string(), sw.elapsed()));
|
let debug_artifact = None;
|
||||||
|
let output = ast_reducing(ast, self, debug_artifact);
|
||||||
|
stage_durations.push((stage_names[n].to_string(), sw.elapsed()));
|
||||||
output
|
output
|
||||||
}).and_then(|reduced_ast| {
|
}).and_then(|reduced_ast| {
|
||||||
let output = eval(reduced_ast, self, eval_debug_artifact);
|
let n = 5;
|
||||||
stage_durations.push((stage_names[5].to_string(), sw.elapsed()));
|
let debug_artifact = None;
|
||||||
|
let output = eval(reduced_ast, self, debug_artifact);
|
||||||
|
stage_durations.push((stage_names[n].to_string(), sw.elapsed()));
|
||||||
output
|
output
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use std::time;
|
use std::time;
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
pub trait ProgrammingLanguageInterface {
|
pub trait ProgrammingLanguageInterface {
|
||||||
fn get_language_name(&self) -> String;
|
fn get_language_name(&self) -> String;
|
||||||
@ -19,7 +20,7 @@ pub trait ProgrammingLanguageInterface {
|
|||||||
|
|
||||||
pub struct ComputationRequest<'a> {
|
pub struct ComputationRequest<'a> {
|
||||||
pub source: &'a str,
|
pub source: &'a str,
|
||||||
pub debug_requests: Vec<DebugAsk>,
|
pub debug_requests: HashSet<DebugAsk>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ComputationResponse {
|
pub struct ComputationResponse {
|
||||||
|
@ -12,6 +12,7 @@ extern crate serde_json;
|
|||||||
extern crate includedir;
|
extern crate includedir;
|
||||||
extern crate phf;
|
extern crate phf;
|
||||||
|
|
||||||
|
use std::collections::HashSet;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
@ -68,7 +69,7 @@ fn run_noninteractive(filename: &str, languages: Vec<Box<ProgrammingLanguageInte
|
|||||||
|
|
||||||
let request = ComputationRequest {
|
let request = ComputationRequest {
|
||||||
source: &buffer,
|
source: &buffer,
|
||||||
debug_requests: vec![]
|
debug_requests: HashSet::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let response = language.run_computation(request);
|
let response = language.run_computation(request);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use std::fmt::Write as FmtWrite;
|
use std::fmt::Write as FmtWrite;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use colored::*;
|
use colored::*;
|
||||||
use crate::language::{ProgrammingLanguageInterface,
|
use crate::language::{ProgrammingLanguageInterface,
|
||||||
@ -174,9 +175,9 @@ impl Repl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn handle_input(&mut self, input: &str) -> String {
|
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() {
|
for ask in self.options.debug_asks.iter() {
|
||||||
debug_requests.push(ask.clone());
|
debug_requests.insert(ask.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
let request = ComputationRequest {
|
let request = ComputationRequest {
|
||||||
|
Loading…
Reference in New Issue
Block a user