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
47 lines
1.0 KiB
Plaintext
47 lines
1.0 KiB
Plaintext
// Nyash small benchmarks - reduced iterations for quick testing
|
|
// How to run:
|
|
// - Interpreter: ./target/release/hakorune examples/ny_bench_small.hako
|
|
// - VM: ./target/release/hakorune --backend vm examples/ny_bench_small.hako
|
|
// - VM+JIT (fast path!): NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 ./target/release/hakorune --backend vm examples/ny_bench_small.hako
|
|
|
|
local ITER
|
|
ITER = 1000 // reduced for interpreter testing
|
|
|
|
print("\n=== Nyash Small Benchmarks (ITER=" + ITER + ") ===")
|
|
|
|
// 1) Simple arithmetic loop: sum 0..ITER-1
|
|
local i, sum
|
|
i = 0
|
|
sum = 0
|
|
loop(i < ITER) {
|
|
sum = sum + i
|
|
i = i + 1
|
|
}
|
|
print("[arith_loop] sum = " + sum)
|
|
|
|
// 2) Array push loop: push integers 0..ITER-1
|
|
local arr
|
|
arr = new ArrayBox()
|
|
i = 0
|
|
loop(i < ITER) {
|
|
arr.push(i)
|
|
i = i + 1
|
|
}
|
|
print("[array_push] length = " + arr.length())
|
|
|
|
// 3) Mixed arithmetic: simple_add repeated
|
|
local a, b, z
|
|
a = 1
|
|
b = 2
|
|
i = 0
|
|
loop(i < ITER) {
|
|
z = a + b
|
|
a = a + 1
|
|
b = b + 1
|
|
i = i + 1
|
|
}
|
|
print("[simple_add_loop] final z = " + z)
|
|
|
|
print("\nDone.")
|
|
return 0
|