2018-08-14 22:56:22 -07:00
|
|
|
use std::time;
|
2017-09-08 03:47:04 -07:00
|
|
|
|
2017-08-30 19:09:22 -07:00
|
|
|
pub trait ProgrammingLanguageInterface {
|
|
|
|
fn get_language_name(&self) -> String;
|
2017-10-02 23:07:05 -07:00
|
|
|
fn get_source_file_suffix(&self) -> String;
|
2019-03-13 00:13:39 -07:00
|
|
|
|
|
|
|
fn run_computation(&mut self, _request: ComputationRequest) -> ComputationResponse {
|
|
|
|
ComputationResponse {
|
|
|
|
main_output: Err(format!("Computation pipeline not implemented")),
|
|
|
|
global_output_stats: GlobalOutputStats::default(),
|
|
|
|
debug_responses: vec![],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn repl_request(&self, repl_request: String) -> String {
|
2019-03-19 18:46:24 -07:00
|
|
|
format!("<<No custom interpreter directives or help info specified>>")
|
2019-03-13 00:13:39 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-14 00:15:13 -07:00
|
|
|
//TODO source can probably be a &str
|
2019-03-13 10:10:42 -07:00
|
|
|
pub struct ComputationRequest {
|
2019-03-13 00:13:39 -07:00
|
|
|
pub source: String,
|
|
|
|
pub debug_requests: Vec<DebugRequest>,
|
|
|
|
}
|
|
|
|
|
2019-03-13 10:10:42 -07:00
|
|
|
pub struct ComputationResponse {
|
2019-03-13 00:13:39 -07:00
|
|
|
pub main_output: Result<String, String>,
|
|
|
|
pub global_output_stats: GlobalOutputStats,
|
|
|
|
pub debug_responses: Vec<DebugResponse>,
|
2017-08-30 19:09:22 -07:00
|
|
|
}
|
2019-03-12 00:01:30 -07:00
|
|
|
|
2019-03-13 10:10:42 -07:00
|
|
|
pub struct DebugRequest {
|
2019-03-13 00:13:39 -07:00
|
|
|
kind: String,
|
|
|
|
value: String
|
|
|
|
}
|
2019-03-12 00:01:30 -07:00
|
|
|
|
2019-03-13 10:10:42 -07:00
|
|
|
pub struct DebugResponse {
|
2019-03-13 00:13:39 -07:00
|
|
|
kind: String,
|
|
|
|
value: String
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Default, Debug)]
|
2019-03-13 10:10:42 -07:00
|
|
|
pub struct GlobalOutputStats {
|
2019-03-13 00:13:39 -07:00
|
|
|
total_duration: Option<time::Duration>,
|
|
|
|
stage_durations: Option<Vec<(String, time::Duration)>>
|
|
|
|
}
|
2019-03-14 00:51:33 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
impl GlobalOutputStats {
|
|
|
|
fn get_timing(&self) -> Option<String> {
|
|
|
|
if self.durations.len() != 0 {
|
|
|
|
let mut buf = String::new();
|
|
|
|
write!(&mut buf, "Timing: ").unwrap();
|
|
|
|
for duration in self.durations.iter() {
|
|
|
|
let timing = (duration.as_secs() as f64) + (duration.subsec_nanos() as f64 * 1e-9);
|
|
|
|
write!(&mut buf, "{}s, ", timing).unwrap()
|
|
|
|
}
|
|
|
|
write!(&mut buf, "\n").unwrap();
|
|
|
|
Some(buf)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|