diff --git a/compiler/src/utils/debug.rs b/compiler/src/debug/macros.rs similarity index 100% rename from compiler/src/utils/debug.rs rename to compiler/src/debug/macros.rs diff --git a/compiler/src/debug/mod.rs b/compiler/src/debug/mod.rs index eb45737..f772995 100644 --- a/compiler/src/debug/mod.rs +++ b/compiler/src/debug/mod.rs @@ -1,16 +1,20 @@ +#[cfg(feature = "debug")] pub mod display; +pub mod macros; +#[cfg(feature = "debug")] pub mod time; -use clap::ValueEnum; -use miette::miette; -use once_cell::sync::OnceCell; +#[cfg(feature = "debug")] +use {clap::ValueEnum, miette::miette, once_cell::sync::OnceCell}; +#[cfg(feature = "debug")] #[derive(Debug)] pub struct DebugArgs { - time: bool, - display: Option, + pub time: bool, + pub display: Option, } +#[cfg(feature = "debug")] impl DebugArgs { pub fn set(time: bool, display: Option) -> miette::Result<()> { DEBUG_ARGS @@ -19,8 +23,10 @@ impl DebugArgs { } } +#[cfg(feature = "debug")] pub static DEBUG_ARGS: OnceCell = OnceCell::new(); +#[cfg(feature = "debug")] #[derive(ValueEnum, Clone, Debug, PartialEq)] pub enum Pass { Parse, diff --git a/compiler/src/lib.rs b/compiler/src/lib.rs index 2120172..f73b876 100644 --- a/compiler/src/lib.rs +++ b/compiler/src/lib.rs @@ -1,4 +1,3 @@ -#[cfg(feature = "debug")] pub mod debug; pub mod passes; pub mod utils; diff --git a/compiler/src/main.rs b/compiler/src/main.rs index 21d8b9a..5ed5e59 100644 --- a/compiler/src/main.rs +++ b/compiler/src/main.rs @@ -2,11 +2,9 @@ mod run; use clap::Parser; -use compiler::compile; -#[cfg(feature = "debug")] -use compiler::debug::{DebugArgs, Pass}; use compiler::passes::parse::parse::PrettyParseError; use compiler::passes::validate::error::TypeError; +use compiler::{compile, debug}; use miette::{Diagnostic, IntoDiagnostic}; use std::fs; use std::io::Read; @@ -42,7 +40,7 @@ struct Args { /// Specifies the pass to display. Supported passes are defined by the `Pass` enum. #[cfg(feature = "debug")] #[arg(value_enum, short, long, value_name = "PASS")] - display: Option, + display: Option, /// Print timing debug information. #[cfg(feature = "debug")] @@ -60,7 +58,7 @@ fn main() -> miette::Result<()> { let args = Args::parse(); #[cfg(feature = "debug")] - DebugArgs::set(args.time, args.display)?; + debug::DebugArgs::set(args.time, args.display)?; let (program, filename) = match args.input.as_ref() { None => (read_from_stdin().into_diagnostic()?, "stdin"), diff --git a/compiler/src/utils/mod.rs b/compiler/src/utils/mod.rs index da08ee4..6c66e28 100644 --- a/compiler/src/utils/mod.rs +++ b/compiler/src/utils/mod.rs @@ -1,5 +1,4 @@ #![allow(unused)] -pub mod debug; pub mod expect; pub mod gen_sym; pub mod push_map;