Phase 33 NORM canon test: enforce normalized dev route for P1/P2/JP mini
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
//! JoinIR routing logic for loop lowering
|
||||
|
||||
use super::trace;
|
||||
use crate::ast::ASTNode;
|
||||
use crate::mir::builder::MirBuilder;
|
||||
use crate::mir::ValueId;
|
||||
use super::trace;
|
||||
|
||||
impl MirBuilder {
|
||||
/// Phase 49: Try JoinIR Frontend for mainline integration
|
||||
@ -42,16 +42,17 @@ impl MirBuilder {
|
||||
// Phase 196: Default to structure-first routing now that LoopBuilder is removed.
|
||||
// - Default: ON (structure_only = true) to allow JoinIR patterns to run for all loops.
|
||||
// - To revert to the previous whitelist-only behavior, set NYASH_JOINIR_STRUCTURE_ONLY=0.
|
||||
let structure_only = match std::env::var("NYASH_JOINIR_STRUCTURE_ONLY")
|
||||
.ok()
|
||||
.as_deref()
|
||||
{
|
||||
let structure_only = match std::env::var("NYASH_JOINIR_STRUCTURE_ONLY").ok().as_deref() {
|
||||
Some("0") | Some("off") => false,
|
||||
_ => true,
|
||||
};
|
||||
|
||||
if structure_only {
|
||||
trace::trace().routing("router", &func_name, "Structure-only mode enabled, skipping whitelist");
|
||||
trace::trace().routing(
|
||||
"router",
|
||||
&func_name,
|
||||
"Structure-only mode enabled, skipping whitelist",
|
||||
);
|
||||
} else {
|
||||
// Phase 49-4 + Phase 80: Multi-target routing (legacy whitelist)
|
||||
// - JoinIR は常時 ON。legacy LoopBuilder は削除済み。
|
||||
@ -60,25 +61,25 @@ impl MirBuilder {
|
||||
// Phase 188: Add "main" routing for loop pattern expansion
|
||||
// Phase 170: Add JsonParserBox methods for selfhost validation
|
||||
let is_target = match func_name.as_str() {
|
||||
"main" => true, // Phase 188-Impl-1: Enable JoinIR for main function (Pattern 1)
|
||||
"JoinIrMin.main/0" => true, // Phase 188-Impl-2: Enable JoinIR for JoinIrMin.main/0 (Pattern 2)
|
||||
"main" => true, // Phase 188-Impl-1: Enable JoinIR for main function (Pattern 1)
|
||||
"JoinIrMin.main/0" => true, // Phase 188-Impl-2: Enable JoinIR for JoinIrMin.main/0 (Pattern 2)
|
||||
"JsonTokenizer.print_tokens/0" => true,
|
||||
"ArrayExtBox.filter/2" => true,
|
||||
// Phase 170-A-1: Enable JsonParserBox methods for JoinIR routing
|
||||
"JsonParserBox._trim/1" => true,
|
||||
"JsonParserBox._skip_whitespace/2" => true,
|
||||
"JsonParserBox._match_literal/3" => true, // Phase 182: Fixed arity (s, pos, literal)
|
||||
"JsonParserBox._match_literal/3" => true, // Phase 182: Fixed arity (s, pos, literal)
|
||||
"JsonParserBox._parse_string/2" => true,
|
||||
"JsonParserBox._parse_array/2" => true,
|
||||
"JsonParserBox._parse_object/2" => true,
|
||||
// Phase 182: Add simple loop methods
|
||||
"JsonParserBox._parse_number/2" => true, // P2 Break (s, pos)
|
||||
"JsonParserBox._atoi/1" => true, // P2 Break (s)
|
||||
"JsonParserBox._parse_number/2" => true, // P2 Break (s, pos)
|
||||
"JsonParserBox._atoi/1" => true, // P2 Break (s)
|
||||
// Phase 170-A-1: Test methods (simplified versions)
|
||||
"TrimTest.trim/1" => true,
|
||||
"Main.trim/1" => true, // Phase 171-fix: Main box variant
|
||||
"Main.trim_string_simple/1" => true, // Phase 33-13: Simple trim variant
|
||||
"TrimTest.main/0" => true, // Phase 170: TrimTest.main for loop pattern test
|
||||
"Main.trim/1" => true, // Phase 171-fix: Main box variant
|
||||
"Main.trim_string_simple/1" => true, // Phase 33-13: Simple trim variant
|
||||
"TrimTest.main/0" => true, // Phase 170: TrimTest.main for loop pattern test
|
||||
// Phase 173: JsonParser P5 expansion test
|
||||
"JsonParserTest._skip_whitespace/3" => true,
|
||||
"JsonParserTest.main/0" => true,
|
||||
@ -99,7 +100,11 @@ impl MirBuilder {
|
||||
// Debug log when routing through JoinIR Frontend
|
||||
// Phase 195: Check trace flags directly from JoinLoopTrace
|
||||
let debug = trace::trace().is_loopform_enabled() || trace::trace().is_mainline_enabled();
|
||||
trace::trace().routing("router", &func_name, "Routing through JoinIR Frontend mainline");
|
||||
trace::trace().routing(
|
||||
"router",
|
||||
&func_name,
|
||||
"Routing through JoinIR Frontend mainline",
|
||||
);
|
||||
|
||||
// Phase 49-3: Implement JoinIR Frontend integration
|
||||
self.cf_loop_joinir_impl(condition, body, &func_name, debug)
|
||||
@ -123,9 +128,20 @@ impl MirBuilder {
|
||||
// Phase 200-C: Pass fn_body_ast to LoopPatternContext if available
|
||||
// Clone fn_body_ast to avoid borrow checker issues
|
||||
let fn_body_clone = self.fn_body_ast.clone();
|
||||
eprintln!("[routing] fn_body_ast is {} for '{}'", if fn_body_clone.is_some() { "SOME" } else { "NONE" }, func_name);
|
||||
eprintln!(
|
||||
"[routing] fn_body_ast is {} for '{}'",
|
||||
if fn_body_clone.is_some() {
|
||||
"SOME"
|
||||
} else {
|
||||
"NONE"
|
||||
},
|
||||
func_name
|
||||
);
|
||||
let ctx = if let Some(ref fn_body) = fn_body_clone {
|
||||
eprintln!("[routing] Creating ctx with fn_body ({} nodes)", fn_body.len());
|
||||
eprintln!(
|
||||
"[routing] Creating ctx with fn_body ({} nodes)",
|
||||
fn_body.len()
|
||||
);
|
||||
LoopPatternContext::with_fn_body(condition, body, &func_name, debug, fn_body)
|
||||
} else {
|
||||
LoopPatternContext::new(condition, body, &func_name, debug)
|
||||
@ -137,7 +153,11 @@ impl MirBuilder {
|
||||
}
|
||||
|
||||
// Phase 187-2: Pattern router failed, try legacy whitelist
|
||||
trace::trace().routing("router", func_name, "Pattern router found no match, trying legacy whitelist");
|
||||
trace::trace().routing(
|
||||
"router",
|
||||
func_name,
|
||||
"Pattern router found no match, trying legacy whitelist",
|
||||
);
|
||||
|
||||
// Delegate to legacy binding path (routing_legacy_binding.rs)
|
||||
self.cf_loop_joinir_legacy_binding(condition, body, func_name, debug)
|
||||
|
||||
Reference in New Issue
Block a user