use crate::cst::Kind;
use super::state::TypeChecker;
impl TypeChecker<'_> {
#[cfg(feature = "debug")]
pub(super) fn trace_stack(&self, depth: u32, arrow: &str, kind: Kind) {
if std::env::var("RB_STACK").is_err() {
return;
}
let indent = " ".repeat(depth.saturating_sub(1) as _);
eprintln!("{indent}{arrow} d:{depth} | {kind:?}");
eprint!("{indent} stack: ");
if self.stack.is_empty() {
eprint!("empty");
}
eprintln!();
for s in &self.stack {
eprintln!("{indent} - {}: {:?}", s.0, s.1);
}
}
#[cfg(not(feature = "debug"))]
pub(super) fn trace_stack(&self, _depth: u32, _arrow: &str, _kind: Kind) {}
#[cfg(feature = "debug")]
pub(super) fn trace_popped(&self, indent_depth: u32, popped_depth: u32) {
if std::env::var("RB_STACK").is_ok() {
let indent = " ".repeat(indent_depth.saturating_sub(1) as _);
eprintln!("{indent}< popped {popped_depth}");
}
}
#[cfg(not(feature = "debug"))]
pub(super) fn trace_popped(&self, _indent_depth: u32, _popped_depth: u32) {}
}
macro_rules! trace {
($($arg:tt)*) => {
#[cfg(feature = "debug")]
if ::std::env::var("RB_STACK").is_ok() {
eprintln!($($arg)*);
}
};
}
pub(super) use trace;