Phase47-B/C: extend P3 normalized shapes and quiet dev warnings
This commit is contained in:
@ -19,6 +19,9 @@ pub enum ShapeCapabilityKind {
|
||||
/// P2 Mid: _parse_number real (p + num_str + result)
|
||||
P2MidParseNumber,
|
||||
|
||||
/// P3 If-Sum family (minimal/multi/json)
|
||||
P3IfSum,
|
||||
|
||||
// Future: Other P2 patterns
|
||||
// P2MidAtOfLoop,
|
||||
// P2HeavyString,
|
||||
@ -52,6 +55,9 @@ pub enum NormalizedDevShape {
|
||||
JsonparserParseNumberReal,
|
||||
// Phase 47-A: Pattern3 (if-sum) minimal
|
||||
Pattern3IfSumMinimal,
|
||||
// Phase 47-B: Pattern3 extended (multi/json)
|
||||
Pattern3IfSumMulti,
|
||||
Pattern3IfSumJson,
|
||||
// Phase 48-A: Pattern4 (continue) minimal
|
||||
Pattern4ContinueMinimal,
|
||||
}
|
||||
@ -86,6 +92,14 @@ const SHAPE_DETECTORS: &[(NormalizedDevShape, Detector)] = &[
|
||||
NormalizedDevShape::Pattern3IfSumMinimal,
|
||||
detectors::is_pattern3_if_sum_minimal,
|
||||
),
|
||||
(
|
||||
NormalizedDevShape::Pattern3IfSumMulti,
|
||||
detectors::is_pattern3_if_sum_multi,
|
||||
),
|
||||
(
|
||||
NormalizedDevShape::Pattern3IfSumJson,
|
||||
detectors::is_pattern3_if_sum_json,
|
||||
),
|
||||
// Phase 48-A: Pattern4 continue minimal
|
||||
(
|
||||
NormalizedDevShape::Pattern4ContinueMinimal,
|
||||
@ -118,8 +132,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,
|
||||
// Phase 47-B: P3 if-sum family
|
||||
Pattern3IfSumMinimal | Pattern3IfSumMulti | Pattern3IfSumJson => P3IfSum,
|
||||
// Phase 48-A: P4 minimal maps to P2CoreSimple for now (future: P4CoreSimple)
|
||||
Pattern4ContinueMinimal => P2CoreSimple,
|
||||
};
|
||||
@ -146,6 +160,10 @@ pub fn is_canonical_shape(shape: &NormalizedDevShape) -> bool {
|
||||
// Phase 46: Add P2-Mid patterns
|
||||
| JsonparserAtoiReal
|
||||
| JsonparserParseNumberReal
|
||||
// Phase 47-C: P3 if-sum canonical set
|
||||
| Pattern3IfSumMinimal
|
||||
| Pattern3IfSumMulti
|
||||
| Pattern3IfSumJson
|
||||
)
|
||||
}
|
||||
|
||||
@ -155,7 +173,10 @@ pub fn is_canonical_shape(shape: &NormalizedDevShape) -> bool {
|
||||
/// Use `is_canonical_shape()` for exact canonical filtering.
|
||||
pub fn is_p2_core_capability(cap: &ShapeCapability) -> bool {
|
||||
use ShapeCapabilityKind::*;
|
||||
matches!(cap.kind, P2CoreSimple | P2CoreSkipWs | P2CoreAtoi | P2MidParseNumber)
|
||||
matches!(
|
||||
cap.kind,
|
||||
P2CoreSimple | P2CoreSkipWs | P2CoreAtoi | P2MidParseNumber | P3IfSum
|
||||
)
|
||||
}
|
||||
|
||||
/// Phase 44: Check if capability is supported by Normalized dev
|
||||
@ -398,12 +419,34 @@ mod detectors {
|
||||
.iter()
|
||||
.any(|inst| matches!(inst, JoinInst::Call { k_next: None, .. }));
|
||||
|
||||
// P3 minimal has 2-4 params (i, sum, possibly n)
|
||||
let reasonable_param_count = (2..=4).contains(&loop_step.params.len());
|
||||
// P3 minimal/multi/json: typically 2-6 params (i + carriers + len/host)
|
||||
let reasonable_param_count = (2..=6).contains(&loop_step.params.len());
|
||||
|
||||
has_compare && has_select && has_tail_call && reasonable_param_count
|
||||
}
|
||||
|
||||
/// Phase 47-B: P3 if-sum (multi-carrier) shape detector
|
||||
pub(crate) fn is_pattern3_if_sum_multi(module: &JoinModule) -> bool {
|
||||
if !is_pattern3_if_sum_minimal(module) {
|
||||
return false;
|
||||
}
|
||||
module
|
||||
.functions
|
||||
.values()
|
||||
.any(|f| f.name == "pattern3_if_sum_multi_min")
|
||||
}
|
||||
|
||||
/// Phase 47-B: P3 if-sum (JsonParser mini) shape detector
|
||||
pub(crate) fn is_pattern3_if_sum_json(module: &JoinModule) -> bool {
|
||||
if !is_pattern3_if_sum_minimal(module) {
|
||||
return false;
|
||||
}
|
||||
module
|
||||
.functions
|
||||
.values()
|
||||
.any(|f| f.name == "jsonparser_if_sum_min")
|
||||
}
|
||||
|
||||
/// Phase 48-A: Check if module matches Pattern4 continue minimal shape
|
||||
pub(crate) fn is_pattern4_continue_minimal(module: &JoinModule) -> bool {
|
||||
// Structure-based detection (avoid name-based heuristics)
|
||||
|
||||
Reference in New Issue
Block a user