feat(control_tree): add StepTree builder (dev-only)
This commit is contained in:
@ -42,6 +42,34 @@ pub(in crate::mir::builder) fn choose_pattern_kind(
|
||||
let has_continue = ast_features::detect_continue_in_body(body);
|
||||
let has_break = ast_features::detect_break_in_body(body);
|
||||
|
||||
// Phase 110: StepTree parity check (structure-only SSOT).
|
||||
//
|
||||
// This is dev-only; strict mode turns mismatch into a fail-fast.
|
||||
if crate::config::env::joinir_dev_enabled() {
|
||||
use crate::ast::Span;
|
||||
use crate::mir::control_tree::StepTreeBuilderBox;
|
||||
|
||||
let loop_ast = ASTNode::Loop {
|
||||
condition: Box::new(condition.clone()),
|
||||
body: body.to_vec(),
|
||||
span: Span::unknown(),
|
||||
};
|
||||
|
||||
let tree = StepTreeBuilderBox::build_from_ast(&loop_ast);
|
||||
if tree.features.has_break != has_break || tree.features.has_continue != has_continue {
|
||||
let msg = format!(
|
||||
"[choose_pattern_kind/STEPTREE_PARITY] step_tree(break={}, cont={}) != extractor(break={}, cont={})",
|
||||
tree.features.has_break, tree.features.has_continue, has_break, has_continue
|
||||
);
|
||||
|
||||
if crate::config::env::joinir_dev::strict_enabled() {
|
||||
panic!("{}", msg);
|
||||
} else {
|
||||
trace::trace().dev("choose_pattern_kind/step_tree_parity", &msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 193: Extract features using modularized extractor
|
||||
let features = ast_features::extract_features(condition, body, has_continue, has_break);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user