Kill useless DebugRequest type

This commit is contained in:
greg 2019-05-25 19:31:41 -07:00
parent a8583f6bc4
commit 6a232907c5
5 changed files with 12 additions and 19 deletions

View File

@ -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<String, String> = tokenizing(source, self, token_debug_artifact)

View File

@ -19,7 +19,7 @@ pub trait ProgrammingLanguageInterface {
pub struct ComputationRequest<'a> {
pub source: &'a str,
pub debug_requests: Vec<DebugRequest>,
pub debug_requests: Vec<DebugAsk>,
}
pub struct ComputationResponse {
@ -34,10 +34,6 @@ pub struct GlobalOutputStats {
pub stage_durations: Option<Vec<(String, time::Duration)>>
}
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 {

View File

@ -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";

View File

@ -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<ProgrammingLanguageInterface>) -> CommandTree {
let pass_names = match language_state.request_meta(LangMetaRequest::StageNames) {
@ -53,9 +53,8 @@ pub fn get_directives(language_state: &mut Box<ProgrammingLanguageInterface>) ->
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 }) {

View File

@ -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 {