feat(joinir): Phase 213-2 Step 2-2 & 2-3 Data structure extensions

Extended PatternPipelineContext and CarrierUpdateInfo for Pattern 3 AST-based generalization.

Changes:
1. PatternPipelineContext:
   - Added loop_condition: Option<ASTNode>
   - Added loop_body: Option<Vec<ASTNode>>
   - Added loop_update_summary: Option<LoopUpdateSummary>
   - Updated build_pattern_context() for Pattern 3

2. CarrierUpdateInfo:
   - Added then_expr: Option<ASTNode>
   - Added else_expr: Option<ASTNode>
   - Updated analyze_loop_updates() with None defaults

Status: Phase 213-2 Steps 2-2 & 2-3 complete
Next: Create Pattern3IfAnalyzer to extract if statement and populate update summary
This commit is contained in:
nyash-codex
2025-12-10 00:01:53 +09:00
parent 577b5b01d5
commit d7805e5974
138 changed files with 3529 additions and 378 deletions

View File

@ -12,7 +12,7 @@
**場所**: `chip8_nyash/chip8_emulator.hako`
**特徴**: 完全なゲーム機エミュレータ、グラフィック表示対応
```bash
./target/release/nyash apps/chip8_nyash/chip8_emulator.hako
./target/release/hakorune apps/chip8_nyash/chip8_emulator.hako
```
### 📝 エディタ・開発ツール
@ -21,7 +21,7 @@
**場所**: `kilo_nyash/enhanced_kilo_editor.hako`
**特徴**: テキストエディタkilo改良版、実用的なファイル編集機能
```bash
./target/release/nyash apps/kilo_nyash/enhanced_kilo_editor.hako
./target/release/hakorune apps/kilo_nyash/enhanced_kilo_editor.hako
```
### 🌐 ネットワークアプリ
@ -30,7 +30,7 @@
**場所**: `tinyproxy_nyash/proxy_server.hako`
**特徴**: HTTPプロキシサーバー、Netプラグイン活用
```bash
./target/release/nyash apps/tinyproxy_nyash/proxy_server.hako
./target/release/hakorune apps/tinyproxy_nyash/proxy_server.hako
```
### 🛠️ ユーティリティ・ベンチマーク

View File

@ -3,7 +3,10 @@
set -e
NYASH=${NYASH:-"../../target/release/nyash"}
NYASH=${NYASH:-"../../target/release/hakorune"}
if [ ! -x "$NYASH" ] && [ -x "../../target/release/nyash" ]; then
NYASH="../../target/release/nyash"
fi
SCRIPT="main.hako"
echo "=== ny-echo Test Suite ==="
@ -82,4 +85,4 @@ fi
rm -f out*.txt vm_out.txt jit_out.txt
echo ""
echo "=== All tests passed! ==="
echo "=== All tests passed! ==="

View File

@ -0,0 +1,41 @@
// Phase 210: Pattern 1 (SimpleWhile) test - match literal implementation
// Tests: Simple loop without break/continue, early return only
// Target: _match_literal pattern from JsonParser
//
// Expected behavior:
// Compare "hello" with "hello" character by character
// If all match, return 1
// If any mismatch, return 0 (early return)
//
// Expected result: 1 (match success)
static box Main {
main() {
local s
s = "hello"
local literal
literal = "hello"
local pos
pos = 0
local len
len = 5
local i
i = 0
loop(i < len) {
// Character-by-character comparison
// Note: Using string equality instead of substring for simplicity
// Real _match_literal uses substring(pos+i, pos+i+1)
// Simplified: just check if we reach the end
// (full substring comparison would require StringBox.substring)
if i >= len {
return 0
}
i = i + 1
}
// If we exit loop normally, all characters matched
return 1
}
}

View File

@ -0,0 +1,52 @@
// Phase 212: Pattern 1 + Pattern 3 (IfPHI) test - if-sum implementation
// Tests: Loop with conditional update inside if block
// Target: selfhost if-sum pattern (e.g., FuncScannerBox._sum_def_count)
//
// Expected behavior:
// Array [null-equivalent, "a", "b"] → sum counts non-empty strings
// Empty string "" treated as null-equivalent → skip
// "a", "b" are valid → sum = 2
//
// Expected result: 2 (count of valid items)
static box IfSumTest {
sum_def_count(defs) {
local sum
sum = 0
local i
i = 0
local len
len = 3
loop(i < len) {
// ArrayBox.get equivalent (simplified: use index directly)
// In real code: local item = defs.get(i)
// For Phase 212: simulate with positional check
// Simulate: [empty, "a", "b"]
// i=0 → empty (skip)
// i=1 → "a" (count)
// i=2 → "b" (count)
if i > 0 {
// Conditional update: sum = sum + 1
sum = sum + 1
print(sum) // ← Force if to stay in MIR
} else {
print(0) // ← Ensure else branch exists
}
i = i + 1
}
return sum
}
main() {
// Array: [empty, "a", "b"] → sum=2
// (simplified without actual ArrayBox for Phase 212)
local result
result = IfSumTest.sum_def_count(0) // dummy arg
return result
}
}