Skip to content

Commit

Permalink
Cleanup debug module.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlamonster committed Dec 8, 2023
1 parent bf0e3d2 commit 9e36c33
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
File renamed without changes.
16 changes: 11 additions & 5 deletions compiler/src/debug/mod.rs
Original file line number Diff line number Diff line change
@@ -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<Pass>,
pub time: bool,
pub display: Option<Pass>,
}

#[cfg(feature = "debug")]
impl DebugArgs {
pub fn set(time: bool, display: Option<Pass>) -> miette::Result<()> {
DEBUG_ARGS
Expand All @@ -19,8 +23,10 @@ impl DebugArgs {
}
}

#[cfg(feature = "debug")]
pub static DEBUG_ARGS: OnceCell<DebugArgs> = OnceCell::new();

#[cfg(feature = "debug")]
#[derive(ValueEnum, Clone, Debug, PartialEq)]
pub enum Pass {
Parse,
Expand Down
1 change: 0 additions & 1 deletion compiler/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(feature = "debug")]
pub mod debug;
pub mod passes;
pub mod utils;
Expand Down
8 changes: 3 additions & 5 deletions compiler/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Pass>,
display: Option<debug::Pass>,

/// Print timing debug information.
#[cfg(feature = "debug")]
Expand All @@ -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"),
Expand Down
1 change: 0 additions & 1 deletion compiler/src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![allow(unused)]
pub mod debug;
pub mod expect;
pub mod gen_sym;
pub mod push_map;
Expand Down

0 comments on commit 9e36c33

Please sign in to comment.