diff --git a/schala-lang/language/src/schala.rs b/schala-lang/language/src/schala.rs index fc48dca..11e428f 100644 --- a/schala-lang/language/src/schala.rs +++ b/schala-lang/language/src/schala.rs @@ -2,7 +2,6 @@ use stopwatch::Stopwatch; use std::cell::RefCell; use std::rc::Rc; -use std::collections::HashSet; use schala_repl::{ProgrammingLanguageInterface, ComputationRequest, ComputationResponse, @@ -58,15 +57,13 @@ impl Schala { /// Schala code in the file `prelude.schala` pub fn new() -> Schala { let prelude = include_str!("prelude.schala"); - let mut s = Schala::new_blank_env(); + let mut env = Schala::new_blank_env(); - //TODO this shouldn't depend on schala-repl types - let request = ComputationRequest { source: prelude, debug_requests: HashSet::default() }; - let response = s.run_computation(request); - if let Err(msg) = response.main_output { + let response = env.run_pipeline(prelude); + if let Err(msg) = response { panic!("Error in prelude, panicking: {}", msg); } - s + env } /// This is where the actual action of interpreting/compilation happens. @@ -174,7 +171,7 @@ fn stage_names() -> Vec<&'static str> { impl ProgrammingLanguageInterface for Schala { - type Options = (); + type Config = (); fn language_name() -> String { "Schala".to_owned() } @@ -183,8 +180,8 @@ impl ProgrammingLanguageInterface for Schala { "schala".to_owned() } - fn run_computation(&mut self, request: ComputationRequest) -> ComputationResponse { - let ComputationRequest { source, debug_requests: _ } = request; + fn run_computation(&mut self, request: ComputationRequest) -> ComputationResponse { + let ComputationRequest { source, debug_requests: _, config: _ } = request; self.source_reference.load_new_source(source); let sw = Stopwatch::start_new(); diff --git a/schala-repl/src/language.rs b/schala-repl/src/language.rs index b7923a0..cd5d28f 100644 --- a/schala-repl/src/language.rs +++ b/schala-repl/src/language.rs @@ -2,11 +2,11 @@ use std::collections::HashSet; use std::time; pub trait ProgrammingLanguageInterface { - type Options; + type Config: Default; fn language_name() -> String; fn source_file_suffix() -> String; - fn run_computation(&mut self, _request: ComputationRequest) -> ComputationResponse; + fn run_computation(&mut self, _request: ComputationRequest) -> ComputationResponse; fn request_meta(&mut self, _request: LangMetaRequest) -> LangMetaResponse { LangMetaResponse::Custom { @@ -23,9 +23,9 @@ struct Options { } */ -pub struct ComputationRequest<'a> { +pub struct ComputationRequest<'a, T> { pub source: &'a str, - //pub options: Options<()>, + pub config: T, pub debug_requests: HashSet, } diff --git a/schala-repl/src/lib.rs b/schala-repl/src/lib.rs index f738484..6d4cdf4 100644 --- a/schala-repl/src/lib.rs +++ b/schala-repl/src/lib.rs @@ -187,6 +187,7 @@ impl Repl { let request = ComputationRequest { source: input, + config: Default::default(), debug_requests, }; let response = self.language_state.run_computation(request); diff --git a/src/main.rs b/src/main.rs index fe151e2..af17153 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,6 +52,7 @@ pub fn run_noninteractive(filenames: Vec