feat(joinir): Phase 47-A-IMPL - P3 Normalized infrastructure
Implement Pattern3 (if-sum) Normalized infrastructure, extending existing P2
StepSchedule and ShapeGuard systems.
Key changes:
1. StepSchedule generalization (P2 → P2/P3):
- Renamed: pattern2_step_schedule.rs → step_schedule.rs
- Extended StepKind enum with P3 variants:
- IfCond (if condition in body)
- ThenUpdates (carrier updates in then branch)
- ElseUpdates (carrier updates in else branch)
- Added pattern3_if_sum_schedule() function
- Added unit test: test_pattern3_if_sum_schedule()
- Updated module references (mod.rs, loop_with_break_minimal.rs)
2. ShapeGuard extension:
- Added Pattern3IfSumMinimal variant to NormalizedDevShape
- Added is_pattern3_if_sum_minimal() detector (placeholder)
- Updated shape detector table
- Extended capability_for_shape() mapping
3. Bridge integration:
- bridge.rs: Added P3 shape handling in normalize_for_shape()
- normalized.rs: Added P3 roundtrip match (uses P2 temporarily)
4. P2/P3 separation:
- loop_with_break_minimal.rs: Added panic for P3 steps in P2 lowering
- Clear boundary enforcement (P2 lowerer rejects P3 steps)
5. Documentation:
- CURRENT_TASK.md: Phase 47-A-IMPL status
- phase47-norm-p3-design.md: Implementation status section
Benefits:
- Reuses 90% of P2 infrastructure (ConditionEnv, CarrierInfo, ExitLine)
- Clean P2/P3 separation via StepKind
- Pure additive changes (no P2 behavioral changes)
- Ready for Phase 47-A-LOWERING (full P3 Normalized implementation)
Tests: 938/938 PASS (+1 from step_schedule unit test)
- All existing P1/P2 tests pass (no regressions)
- P3 test uses Structured path temporarily (proper lowering in next phase)
Next phase: Implement full P3 Normalized→MIR(direct) lowering
This commit is contained in:
@ -50,6 +50,8 @@ pub enum NormalizedDevShape {
|
||||
JsonparserAtoiMini,
|
||||
JsonparserAtoiReal,
|
||||
JsonparserParseNumberReal,
|
||||
// Phase 47-A: Pattern3 (if-sum) minimal
|
||||
Pattern3IfSumMinimal,
|
||||
}
|
||||
|
||||
type Detector = fn(&JoinModule) -> bool;
|
||||
@ -77,6 +79,11 @@ const SHAPE_DETECTORS: &[(NormalizedDevShape, Detector)] = &[
|
||||
NormalizedDevShape::JsonparserParseNumberReal,
|
||||
detectors::is_jsonparser_parse_number_real,
|
||||
),
|
||||
// Phase 47-A: Pattern3 if-sum minimal
|
||||
(
|
||||
NormalizedDevShape::Pattern3IfSumMinimal,
|
||||
detectors::is_pattern3_if_sum_minimal,
|
||||
),
|
||||
];
|
||||
|
||||
/// direct ブリッジで扱う shape(dev 限定)。
|
||||
@ -104,6 +111,8 @@ pub fn capability_for_shape(shape: &NormalizedDevShape) -> ShapeCapability {
|
||||
JsonparserAtoiMini | JsonparserAtoiReal => P2CoreAtoi,
|
||||
JsonparserParseNumberReal => P2MidParseNumber,
|
||||
Pattern1Mini => P2CoreSimple, // Also core simple pattern
|
||||
// Phase 47-A: P3 minimal maps to P2CoreSimple for now (future: P3CoreSimple)
|
||||
Pattern3IfSumMinimal => P2CoreSimple,
|
||||
};
|
||||
|
||||
ShapeCapability::new(kind)
|
||||
@ -338,6 +347,18 @@ mod detectors {
|
||||
.any(|f| f.name == "jsonparser_parse_number_real")
|
||||
}
|
||||
|
||||
/// Phase 47-A: Check if module matches Pattern3 if-sum minimal shape
|
||||
pub(crate) fn is_pattern3_if_sum_minimal(module: &JoinModule) -> bool {
|
||||
// For now, simple heuristic:
|
||||
// - Has Pattern3 structure (if-sum)
|
||||
// - Single carrier (sum)
|
||||
// - Simple loop condition
|
||||
|
||||
// TODO: Implement proper detection based on fixture
|
||||
// For Phase 47-A, this will be called explicitly in tests
|
||||
false // Placeholder - will be refined in later commits
|
||||
}
|
||||
|
||||
pub(super) fn find_loop_step(module: &JoinModule) -> Option<&JoinFunction> {
|
||||
module
|
||||
.functions
|
||||
|
||||
Reference in New Issue
Block a user