refactor(joinir): centralize balanced depth-scan policy decision
This commit is contained in:
@ -0,0 +1,34 @@
|
||||
//! BalancedDepthScanPolicyBox (Phase 107)
|
||||
//!
|
||||
//! Responsibility:
|
||||
//! - Provide a single SSOT entry point for the balanced depth-scan policy decision
|
||||
//! so callers (routing/apply) don't duplicate Use/Reject/None handling.
|
||||
|
||||
use crate::ast::ASTNode;
|
||||
|
||||
use super::balanced_depth_scan_policy::{classify_balanced_depth_scan_array_end, BalancedDepthScanPolicyResult};
|
||||
use super::PolicyDecision;
|
||||
|
||||
pub(crate) struct BalancedDepthScanPolicyBox;
|
||||
|
||||
impl BalancedDepthScanPolicyBox {
|
||||
pub(crate) fn decide(
|
||||
condition: &ASTNode,
|
||||
body: &[ASTNode],
|
||||
) -> PolicyDecision<BalancedDepthScanPolicyResult> {
|
||||
let decision = classify_balanced_depth_scan_array_end(condition, body);
|
||||
|
||||
if crate::config::env::joinir_dev_enabled() {
|
||||
use crate::mir::builder::control_flow::joinir::trace;
|
||||
let summary = match &decision {
|
||||
PolicyDecision::Use(_) => "Use".to_string(),
|
||||
PolicyDecision::Reject(reason) => format!("Reject: {}", reason),
|
||||
PolicyDecision::None => "None".to_string(),
|
||||
};
|
||||
trace::trace().dev("phase107/balanced_depth_scan_policy", &summary);
|
||||
}
|
||||
|
||||
decision
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,3 +34,4 @@ pub(in crate::mir::builder) mod p5b_escape_derived_policy;
|
||||
pub(in crate::mir::builder) mod trim_policy;
|
||||
pub(in crate::mir::builder) mod loop_true_read_digits_policy;
|
||||
pub(in crate::mir::builder) mod balanced_depth_scan_policy;
|
||||
pub(in crate::mir::builder) mod balanced_depth_scan_policy_box;
|
||||
|
||||
Reference in New Issue
Block a user