-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: various mundane changes to tidy up
Delete AstNodeId struct from ast.rs Remove ast module from lib.rs Rename cfg_reducer.rs to cfg_reducer.rs in montyc_driver/src/typeck/ Remove global_context module and rename it to session_context in montyc_driver/src/ Delete pretty_printer module from montyc_driver/src/ Rename host.rs to host.rs in montyc_driver/src/session_context/ Rename mod.rs to mod.rs in montyc_driver/src/session_context/ Rename query.rs to query.rs in montyc_driver/src/session_context/ Create session_request module in montyc_driver/src/ with SessionRequestBuilder and SessionRequest structs Move block_cfg, typing_machine, and variable_flowgraph modules into typeck/mod.rs
- Loading branch information
Showing
15 changed files
with
151 additions
and
109 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
montyc_driver/src/typeck/cfg_reducer.rs → montyc_driver/src/cfg_reducer.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
#![warn(warnings)] | ||
|
||
pub(crate) mod import; | ||
pub(crate) mod pretty_printer; | ||
pub(crate) mod typeck; | ||
pub(crate) mod value_store; | ||
|
||
mod global_context; | ||
pub use global_context::{SessionContext, SessionMode, SessionOpts, UninitializedSession}; | ||
pub mod cfg_reducer; | ||
pub mod session_request; | ||
|
||
pub mod session_context; | ||
pub use session_context::{SessionContext, SessionMode, SessionOpts, UninitializedSession}; |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
//! A request is used to create a session, to parse, type-check, consteval and compile Python code. | ||
//! | ||
use std::path::PathBuf; | ||
|
||
/// A builder for creating a `Request` instance with various options. | ||
/// | ||
/// A `Request` is used to create a session, to parse, type-check, consteval and compile Python code. | ||
/// | ||
/// # Examples | ||
/// | ||
/// ``` | ||
/// let request = RequestBuilder::default() | ||
/// .entry("__main__:main".to_string()) | ||
/// .libstd("libstd/".into()) | ||
/// .input("input.mt".into()) | ||
/// .output("output".into()) | ||
/// .build(); | ||
/// ``` | ||
#[derive(Debug, Default)] | ||
pub struct SessionRequestBuilder { | ||
entry: Option<String>, | ||
libstd: Option<PathBuf>, | ||
input: Option<PathBuf>, | ||
output: Option<PathBuf>, | ||
show_ir: Option<String>, | ||
cc: Option<PathBuf>, | ||
ld: Option<PathBuf>, | ||
cranelift_settings: Option<Vec<String>>, | ||
} | ||
|
||
impl SessionRequestBuilder { | ||
/// Sets the path to the entry function. | ||
/// | ||
/// The default value is `__main__:main`. | ||
pub fn entry(mut self, entry: &str) -> Self { | ||
self.entry.replace(entry.to_owned()); | ||
self | ||
} | ||
|
||
/// Sets the path to a monty compatible stdlib. | ||
/// | ||
/// The default value is `libstd/`. | ||
pub fn libstd(mut self, libstd: PathBuf) -> Self { | ||
self.libstd.replace(libstd); | ||
self | ||
} | ||
|
||
/// Sets the input file to compile. | ||
pub fn input(mut self, input: PathBuf) -> Self { | ||
self.input.replace(input); | ||
self | ||
} | ||
|
||
/// Sets the name of the output binary. | ||
/// | ||
/// The default value is the input file's name. | ||
pub fn output(mut self, output: PathBuf) -> Self { | ||
self.output.replace(output); | ||
self | ||
} | ||
|
||
/// Shows the Cranelift IR for the specified function. | ||
pub fn show_ir(mut self, show_ir: Option<String>) -> Self { | ||
self.show_ir = show_ir; | ||
self | ||
} | ||
|
||
/// Sets the C compiler to use. | ||
pub fn cc(mut self, cc: Option<PathBuf>) -> Self { | ||
self.cc = cc; | ||
self | ||
} | ||
|
||
/// Sets the linker to use. | ||
pub fn ld(mut self, ld: Option<PathBuf>) -> Self { | ||
self.ld = ld; | ||
self | ||
} | ||
|
||
/// Sets low level codegen settings to pass to Cranelift. | ||
pub fn cranelift_settings(mut self, cranelift_settings: Vec<String>) -> Self { | ||
self.cranelift_settings = Some(cranelift_settings); | ||
self | ||
} | ||
|
||
/// Builds a `Request` instance with the configured options. | ||
pub fn build(self) -> SessionRequest { | ||
SessionRequest { | ||
entry: self.entry.unwrap_or("__main__:main".to_string()), | ||
libstd: self.libstd.unwrap_or(PathBuf::from("libstd/")), | ||
input: self.input.unwrap_or(PathBuf::from("main.py")), | ||
output: self.output.unwrap_or(PathBuf::from("main")), | ||
show_ir: self.show_ir, | ||
cc: self.cc, | ||
ld: self.ld, | ||
cranelift_settings: self.cranelift_settings.unwrap_or_default(), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct SessionRequest { | ||
/// The path to the entry function, for instance `main` in a `__main__.py` would be `__main__:main` (and is the default.) | ||
pub entry: String, | ||
/// The path to a monty compatible stdlib. | ||
pub libstd: PathBuf, | ||
/// The input file to compile. | ||
pub input: PathBuf, | ||
// The name of the output binary, defaults to the input file's name. | ||
pub output: PathBuf, | ||
/// Show the Cranelift IR for the specified function. | ||
pub show_ir: Option<String>, | ||
/// The C compiler to use. | ||
pub cc: Option<PathBuf>, | ||
/// The linker to use. | ||
pub ld: Option<PathBuf>, | ||
/// Low level codegen settings to pass to Cranelift. | ||
pub cranelift_settings: Vec<String>, | ||
} | ||
|
||
impl SessionRequest { | ||
pub fn new() -> SessionRequestBuilder { | ||
SessionRequestBuilder::default() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters