Kill useless DebugRequest type
This commit is contained in:
parent
a8583f6bc4
commit
6a232907c5
@ -26,7 +26,7 @@ use itertools::Itertools;
|
|||||||
use schala_repl::{ProgrammingLanguageInterface,
|
use schala_repl::{ProgrammingLanguageInterface,
|
||||||
ComputationRequest, ComputationResponse,
|
ComputationRequest, ComputationResponse,
|
||||||
LangMetaRequest, LangMetaResponse, GlobalOutputStats,
|
LangMetaRequest, LangMetaResponse, GlobalOutputStats,
|
||||||
DebugRequest, DebugResponse, DebugAsk};
|
DebugResponse, DebugAsk};
|
||||||
|
|
||||||
macro_rules! bx {
|
macro_rules! bx {
|
||||||
($e:expr) => { Box::new($e) }
|
($e:expr) => { Box::new($e) }
|
||||||
@ -88,10 +88,9 @@ impl Schala {
|
|||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_debug_immediate(&self, request: DebugRequest) -> DebugResponse {
|
fn handle_debug_immediate(&self, request: DebugAsk) -> DebugResponse {
|
||||||
use DebugAsk::*;
|
use DebugAsk::*;
|
||||||
let ask = request.ask;
|
match request {
|
||||||
match ask {
|
|
||||||
Timing => DebugResponse { ask: Timing, value: format!("Invalid") },
|
Timing => DebugResponse { ask: Timing, value: format!("Invalid") },
|
||||||
ByStage { stage_name } => match &stage_name[..] {
|
ByStage { stage_name } => match &stage_name[..] {
|
||||||
"symbol-table" => {
|
"symbol-table" => {
|
||||||
@ -249,6 +248,7 @@ impl ProgrammingLanguageInterface for Schala {
|
|||||||
|
|
||||||
fn run_computation(&mut self, request: ComputationRequest) -> ComputationResponse {
|
fn run_computation(&mut self, request: ComputationRequest) -> ComputationResponse {
|
||||||
let ComputationRequest { source, debug_requests } = request;
|
let ComputationRequest { source, debug_requests } = request;
|
||||||
|
self.source_reference.load_new_source(source);
|
||||||
|
|
||||||
let token_debug_artifact = None;
|
let token_debug_artifact = None;
|
||||||
let parsing_debug_artifact = None;
|
let parsing_debug_artifact = None;
|
||||||
@ -257,7 +257,6 @@ impl ProgrammingLanguageInterface for Schala {
|
|||||||
let reducing_debug_artifact = None;
|
let reducing_debug_artifact = None;
|
||||||
let eval_debug_artifact = None;
|
let eval_debug_artifact = None;
|
||||||
|
|
||||||
self.source_reference.load_new_source(source);
|
|
||||||
let sw = Stopwatch::start_new();
|
let sw = Stopwatch::start_new();
|
||||||
|
|
||||||
let main_output: Result<String, String> = tokenizing(source, self, token_debug_artifact)
|
let main_output: Result<String, String> = tokenizing(source, self, token_debug_artifact)
|
||||||
|
@ -19,7 +19,7 @@ pub trait ProgrammingLanguageInterface {
|
|||||||
|
|
||||||
pub struct ComputationRequest<'a> {
|
pub struct ComputationRequest<'a> {
|
||||||
pub source: &'a str,
|
pub source: &'a str,
|
||||||
pub debug_requests: Vec<DebugRequest>,
|
pub debug_requests: Vec<DebugAsk>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ComputationResponse {
|
pub struct ComputationResponse {
|
||||||
@ -34,10 +34,6 @@ pub struct GlobalOutputStats {
|
|||||||
pub stage_durations: Option<Vec<(String, time::Duration)>>
|
pub stage_durations: Option<Vec<(String, time::Duration)>>
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DebugRequest {
|
|
||||||
pub ask: DebugAsk,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Hash, Eq, PartialEq, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Hash, Eq, PartialEq, Deserialize, Serialize)]
|
||||||
pub enum DebugAsk {
|
pub enum DebugAsk {
|
||||||
Timing,
|
Timing,
|
||||||
@ -58,7 +54,7 @@ pub enum LangMetaRequest {
|
|||||||
kind: String,
|
kind: String,
|
||||||
value: String
|
value: String
|
||||||
},
|
},
|
||||||
ImmediateDebug(DebugRequest),
|
ImmediateDebug(DebugAsk),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum LangMetaResponse {
|
pub enum LangMetaResponse {
|
||||||
|
@ -23,7 +23,7 @@ mod language;
|
|||||||
pub use language::{ProgrammingLanguageInterface,
|
pub use language::{ProgrammingLanguageInterface,
|
||||||
ComputationRequest, ComputationResponse,
|
ComputationRequest, ComputationResponse,
|
||||||
LangMetaRequest, LangMetaResponse,
|
LangMetaRequest, LangMetaResponse,
|
||||||
DebugRequest, DebugResponse, DebugAsk, GlobalOutputStats};
|
DebugResponse, DebugAsk, GlobalOutputStats};
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/static.rs"));
|
include!(concat!(env!("OUT_DIR"), "/static.rs"));
|
||||||
const VERSION_STRING: &'static str = "0.1.0";
|
const VERSION_STRING: &'static str = "0.1.0";
|
||||||
|
@ -3,7 +3,7 @@ use itertools::Itertools;
|
|||||||
|
|
||||||
use crate::repl::Repl;
|
use crate::repl::Repl;
|
||||||
use crate::repl::command_tree::CommandTree;
|
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 {
|
pub fn get_directives(language_state: &mut Box<ProgrammingLanguageInterface>) -> CommandTree {
|
||||||
let pass_names = match language_state.request_meta(LangMetaRequest::StageNames) {
|
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(),
|
Some(s) => s.to_string(),
|
||||||
None => return Some(format!("Must specify a thing to debug")),
|
None => return Some(format!("Must specify a thing to debug")),
|
||||||
};
|
};
|
||||||
let meta = LangMetaRequest::ImmediateDebug(
|
let meta = LangMetaRequest::ImmediateDebug(DebugAsk::ByStage { stage_name: stage_name.clone() });
|
||||||
DebugRequest { ask: DebugAsk::ByStage { stage_name: stage_name.clone() } }
|
|
||||||
);
|
|
||||||
let response = match cur_state.request_meta(meta) {
|
let response = match cur_state.request_meta(meta) {
|
||||||
LangMetaResponse::ImmediateDebug(DebugResponse { ask, value }) => {
|
LangMetaResponse::ImmediateDebug(DebugResponse { ask, value }) => {
|
||||||
if (ask != DebugAsk::ByStage { stage_name: stage_name }) {
|
if (ask != DebugAsk::ByStage { stage_name: stage_name }) {
|
||||||
|
@ -4,8 +4,7 @@ use std::sync::Arc;
|
|||||||
use colored::*;
|
use colored::*;
|
||||||
use crate::language::{ProgrammingLanguageInterface,
|
use crate::language::{ProgrammingLanguageInterface,
|
||||||
ComputationRequest, ComputationResponse,
|
ComputationRequest, ComputationResponse,
|
||||||
LangMetaRequest, LangMetaResponse,
|
LangMetaRequest, LangMetaResponse};
|
||||||
DebugRequest};
|
|
||||||
|
|
||||||
mod command_tree;
|
mod command_tree;
|
||||||
use self::command_tree::{CommandTree, BoxedCommandFunction};
|
use self::command_tree::{CommandTree, BoxedCommandFunction};
|
||||||
@ -177,7 +176,7 @@ 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 = vec![];
|
||||||
for ask in self.options.debug_asks.iter() {
|
for ask in self.options.debug_asks.iter() {
|
||||||
debug_requests.push(DebugRequest { ask: ask.clone() });
|
debug_requests.push(ask.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
let request = ComputationRequest {
|
let request = ComputationRequest {
|
||||||
|
Loading…
Reference in New Issue
Block a user