feat: specialize constant matches in generic procedures

Reuse checked match selection for generic constant subjects and explicit match $(). Preserve owned captures, runtime scope and control transfers; keep ordinary calls, mutable subjects and potential runtime defaults unprobed. Update README and TODO checkpoint boundaries.

Verified: bro build; bro test (250 passed); python3 tests/native.py (555 interpreter/native comparisons at -O0/-O2, allocator, LLVM and CLI checks); direct interpreter/native constant-match smoke (42).
This commit is contained in:
2026-10-27 12:53:19 +01:00
parent 8d1a98f982
commit c3e10b3bed
5 changed files with 345 additions and 10 deletions
+14 -1
View File
@@ -125,6 +125,19 @@ recompiles_specialized_calls_without_borrowing_previous_ir test {
` .empty: return bool,
` }
`}
`read_selected proc($choice Choice, value i16) i16 {
` match choice {
` .payload |detail|: {
` copied :: detail
` if (copied.text.len != 2) return -1
` return match detail.values[1] {
` 2: match true { true: value + detail.values[1], false: value.missing },
` else: value.missing,
` }
` }
` .empty: return value.missing,
` }
`}
`main proc() i16 {
` if $(i16 != i16) { return $(i8(128)) }
` values :: $(data())
@@ -143,7 +156,7 @@ recompiles_specialized_calls_without_borrowing_previous_ir test {
` .failed |detail|: detail.code + i16(detail.text.len),
` }
` if (error_code != 7) return 0
` return identity(same.values[0]) + same.values[$(usize(1))] + same.bias
` return read_selected(packet.choices[0], identity(same.values[0]) + same.values[$(usize(1))] + same.bias - 2)
`}
,
)