From 6a232907c52335a7b874456306364c0dc18e8690 Mon Sep 17 00:00:00 2001 From: greg Date: Sat, 25 May 2019 19:31:41 -0700 Subject: [PATCH] Kill useless DebugRequest type --- schala-lang/language/src/lib.rs | 9 ++++----- schala-repl/src/language.rs | 8 ++------ schala-repl/src/lib.rs | 2 +- schala-repl/src/repl/directives.rs | 7 +++---- schala-repl/src/repl/mod.rs | 5 ++--- 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/schala-lang/language/src/lib.rs b/schala-lang/language/src/lib.rs index 57dcab6..6b3ecb7 100644 --- a/schala-lang/language/src/lib.rs +++ b/schala-lang/language/src/lib.rs @@ -26,7 +26,7 @@ use itertools::Itertools; use schala_repl::{ProgrammingLanguageInterface, ComputationRequest, ComputationResponse, LangMetaRequest, LangMetaResponse, GlobalOutputStats, -DebugRequest, DebugResponse, DebugAsk}; +DebugResponse, DebugAsk}; macro_rules! bx { ($e:expr) => { Box::new($e) } @@ -88,10 +88,9 @@ impl Schala { s } - fn handle_debug_immediate(&self, request: DebugRequest) -> DebugResponse { + fn handle_debug_immediate(&self, request: DebugAsk) -> DebugResponse { use DebugAsk::*; - let ask = request.ask; - match ask { + match request { Timing => DebugResponse { ask: Timing, value: format!("Invalid") }, ByStage { stage_name } => match &stage_name[..] { "symbol-table" => { @@ -249,6 +248,7 @@ impl ProgrammingLanguageInterface for Schala { fn run_computation(&mut self, request: ComputationRequest) -> ComputationResponse { let ComputationRequest { source, debug_requests } = request; + self.source_reference.load_new_source(source); let token_debug_artifact = None; let parsing_debug_artifact = None; @@ -257,7 +257,6 @@ impl ProgrammingLanguageInterface for Schala { let reducing_debug_artifact = None; let eval_debug_artifact = None; - self.source_reference.load_new_source(source); let sw = Stopwatch::start_new(); let main_output: Result = tokenizing(source, self, token_debug_artifact) diff --git a/schala-repl/src/language.rs b/schala-repl/src/language.rs index f60257b..6126707 100644 --- a/schala-repl/src/language.rs +++ b/schala-repl/src/language.rs @@ -19,7 +19,7 @@ pub trait ProgrammingLanguageInterface { pub struct ComputationRequest<'a> { pub source: &'a str, - pub debug_requests: Vec, + pub debug_requests: Vec, } pub struct ComputationResponse { @@ -34,10 +34,6 @@ pub struct GlobalOutputStats { pub stage_durations: Option> } -pub struct DebugRequest { - pub ask: DebugAsk, -} - #[derive(Debug, Clone, Hash, Eq, PartialEq, Deserialize, Serialize)] pub enum DebugAsk { Timing, @@ -58,7 +54,7 @@ pub enum LangMetaRequest { kind: String, value: String }, - ImmediateDebug(DebugRequest), + ImmediateDebug(DebugAsk), } pub enum LangMetaResponse { diff --git a/schala-repl/src/lib.rs b/schala-repl/src/lib.rs index 5b7b7ce..f42d4fd 100644 --- a/schala-repl/src/lib.rs +++ b/schala-repl/src/lib.rs @@ -23,7 +23,7 @@ mod language; pub use language::{ProgrammingLanguageInterface, ComputationRequest, ComputationResponse, LangMetaRequest, LangMetaResponse, -DebugRequest, DebugResponse, DebugAsk, GlobalOutputStats}; +DebugResponse, DebugAsk, GlobalOutputStats}; include!(concat!(env!("OUT_DIR"), "/static.rs")); const VERSION_STRING: &'static str = "0.1.0"; diff --git a/schala-repl/src/repl/directives.rs b/schala-repl/src/repl/directives.rs index 05b9f31..0f7ae82 100644 --- a/schala-repl/src/repl/directives.rs +++ b/schala-repl/src/repl/directives.rs @@ -3,7 +3,7 @@ use itertools::Itertools; use crate::repl::Repl; use crate::repl::command_tree::CommandTree; -use crate::language::{ProgrammingLanguageInterface, LangMetaRequest, LangMetaResponse, DebugRequest, DebugAsk, DebugResponse}; +use crate::language::{ProgrammingLanguageInterface, LangMetaRequest, LangMetaResponse, DebugAsk, DebugResponse}; pub fn get_directives(language_state: &mut Box) -> CommandTree { let pass_names = match language_state.request_meta(LangMetaRequest::StageNames) { @@ -53,9 +53,8 @@ pub fn get_directives(language_state: &mut Box) -> Some(s) => s.to_string(), None => return Some(format!("Must specify a thing to debug")), }; - let meta = LangMetaRequest::ImmediateDebug( - DebugRequest { ask: DebugAsk::ByStage { stage_name: stage_name.clone() } } - ); + let meta = LangMetaRequest::ImmediateDebug(DebugAsk::ByStage { stage_name: stage_name.clone() }); + let response = match cur_state.request_meta(meta) { LangMetaResponse::ImmediateDebug(DebugResponse { ask, value }) => { if (ask != DebugAsk::ByStage { stage_name: stage_name }) { diff --git a/schala-repl/src/repl/mod.rs b/schala-repl/src/repl/mod.rs index 7e686c7..12ad8a0 100644 --- a/schala-repl/src/repl/mod.rs +++ b/schala-repl/src/repl/mod.rs @@ -4,8 +4,7 @@ use std::sync::Arc; use colored::*; use crate::language::{ProgrammingLanguageInterface, ComputationRequest, ComputationResponse, -LangMetaRequest, LangMetaResponse, -DebugRequest}; +LangMetaRequest, LangMetaResponse}; mod command_tree; use self::command_tree::{CommandTree, BoxedCommandFunction}; @@ -177,7 +176,7 @@ impl Repl { fn handle_input(&mut self, input: &str) -> String { let mut debug_requests = vec![]; for ask in self.options.debug_asks.iter() { - debug_requests.push(DebugRequest { ask: ask.clone() }); + debug_requests.push(ask.clone()); } let request = ComputationRequest {