vm(hako): add v1 reader/dispatcher (flagged), commonize mir_call handler, share block scan; smokes: add v1 hakovm canary; docs: 20.37/20.38 plans, OOB policy; runner: v1 hakovm toggle; include SKIP summary
This commit is contained in:
@ -24,6 +24,8 @@ export SMOKES_START_TIME=$(date +%s.%N)
|
||||
export SMOKES_TEST_COUNT=0
|
||||
export SMOKES_PASS_COUNT=0
|
||||
export SMOKES_FAIL_COUNT=0
|
||||
export SMOKES_INCLUDE_SKIP_COUNT=0
|
||||
declare -a SMOKES_INCLUDE_SKIP_LIST=()
|
||||
|
||||
# 色定義(重複回避)
|
||||
if [ -z "${RED:-}" ]; then
|
||||
@ -216,7 +218,29 @@ run_nyash_vm() {
|
||||
fi
|
||||
# Optional hint for include lines when preinclude is OFF
|
||||
if [ -f "$program" ] && grep -q '^include\s\"' "$program" 2>/dev/null && [ "${NYASH_PREINCLUDE:-0}" != "1" ] && [ "${HAKO_PREINCLUDE:-0}" != "1" ]; then
|
||||
echo "[WARN] VM backend does not support include. Prefer using+alias, or set NYASH_PREINCLUDE=1 for dev." >&2
|
||||
# Policy: quick は SKIP 既定。それ以外は WARN(SMOKES_INCLUDE_POLICY で上書き可能)。
|
||||
local policy="${SMOKES_INCLUDE_POLICY:-}"
|
||||
if [ -z "$policy" ]; then
|
||||
case "$program" in
|
||||
*/profiles/quick/*) policy="skip" ;;
|
||||
*) policy="warn" ;;
|
||||
esac
|
||||
fi
|
||||
if [ "$policy" = "skip" ]; then
|
||||
SMOKES_INCLUDE_SKIP_COUNT=$((SMOKES_INCLUDE_SKIP_COUNT + 1))
|
||||
local rel_path="$program"
|
||||
if [[ "$program" == "$NYASH_ROOT/"* ]]; then
|
||||
rel_path="${program#$NYASH_ROOT/}"
|
||||
fi
|
||||
SMOKES_INCLUDE_SKIP_LIST+=("$rel_path")
|
||||
echo "[SKIP] include is deprecated in 20.36+ (quick). Prefer using+alias." >&2
|
||||
return 0
|
||||
elif [ "$policy" = "error" ]; then
|
||||
echo "[ERROR] include is deprecated in 20.36+. Prefer using+alias." >&2
|
||||
return 2
|
||||
else
|
||||
echo "[WARN] include is deprecated in 20.36+. Prefer using+alias. Preinclude is dev-only (NYASH_PREINCLUDE=1)." >&2
|
||||
fi
|
||||
fi
|
||||
NYASH_VM_USE_PY="$USE_PYVM" NYASH_ENTRY_ALLOW_TOPLEVEL_MAIN=1 \
|
||||
NYASH_DISABLE_NY_COMPILER=1 HAKO_DISABLE_NY_COMPILER=1 \
|
||||
@ -233,8 +257,36 @@ run_nyash_vm() {
|
||||
# Verify MIR JSON rc using selected primary (Core or Hakorune VM)
|
||||
verify_mir_rc() {
|
||||
local json_path="$1"
|
||||
local primary="${HAKO_VERIFY_PRIMARY:-core}"
|
||||
# 20.36: hakovm を primary 既定へ(Core は診断 fallback)
|
||||
local primary="${HAKO_VERIFY_PRIMARY:-hakovm}"
|
||||
if [ "$primary" = "hakovm" ]; then
|
||||
# If the payload is MIR JSON v1 (schema_version present), Mini-VM cannot execute it yet.
|
||||
# Route to Core fallback directly to keep canaries meaningful while Mini-VM gains v1 support.
|
||||
if grep -q '"schema_version"' "$json_path" 2>/dev/null; then
|
||||
# Optional: hakovm v1 verify (flagged). Default remains Core.
|
||||
if [ "${HAKO_VERIFY_V1_HAKOVM:-0}" = "1" ]; then
|
||||
local json_literal_v1
|
||||
json_literal_v1="$(jq -Rs . < "$json_path")"
|
||||
local code_v1=$(cat <<'HCODE'
|
||||
using selfhost.vm.hv1.dispatch as NyVmDispatcherV1Box
|
||||
static box Main { method main(args) {
|
||||
local j = __MIR_JSON__
|
||||
local rc = NyVmDispatcherV1Box.run(j)
|
||||
print("" + rc)
|
||||
return rc
|
||||
} }
|
||||
HCODE
|
||||
)
|
||||
code_v1="${code_v1/__MIR_JSON__/$json_literal_v1}"
|
||||
local out_v1; out_v1=$(NYASH_USING_AST=1 run_nyash_vm -c "$code_v1" 2>/dev/null | tr -d '\r' | tail -n 1)
|
||||
if [[ "$out_v1" =~ ^-?[0-9]+$ ]]; then
|
||||
local n=$out_v1; if [ $n -lt 0 ]; then n=$(( (n % 256 + 256) % 256 )); else n=$(( n % 256 )); fi; return $n
|
||||
fi
|
||||
# fallback to Core when hakovm v1 path not ready
|
||||
fi
|
||||
"$NYASH_BIN" --mir-json-file "$json_path" >/dev/null 2>&1
|
||||
return $?
|
||||
fi
|
||||
# Build a tiny driver to call MiniVmEntryBox.run_min with JSON literal embedded
|
||||
if [ ! -f "$json_path" ]; then
|
||||
echo "[FAIL] verify_mir_rc: json not found: $json_path" >&2
|
||||
@ -256,7 +308,7 @@ static box Main { method main(args) {
|
||||
HCODE
|
||||
)
|
||||
code="${code/__MIR_JSON__/$json_literal}"
|
||||
NYASH_USING_AST=1 run_nyash_vm -c "$code" 2>/dev/null | tr -d '\r' | tail -n 1
|
||||
NYASH_USING_AST=1 NYASH_RESOLVE_FIX_BRACES=1 run_nyash_vm -c "$code" 2>/dev/null | tr -d '\r' | tail -n 1
|
||||
}
|
||||
build_and_run_driver_include() {
|
||||
local inc_path="$1"
|
||||
@ -271,7 +323,7 @@ static box Main { method main(args) {
|
||||
HCODE
|
||||
)
|
||||
code="${code/__MIR_JSON__/$json_literal}"
|
||||
NYASH_PREINCLUDE=1 run_nyash_vm -c "$code" 2>/dev/null | tr -d '\r' | tail -n 1
|
||||
NYASH_PREINCLUDE=1 NYASH_RESOLVE_FIX_BRACES=1 run_nyash_vm -c "$code" 2>/dev/null | tr -d '\r' | tail -n 1
|
||||
}
|
||||
# Try alias header first; fallback to dev-file header; final fallback: include+preinclude
|
||||
local out
|
||||
@ -289,11 +341,30 @@ HCODE
|
||||
return $n
|
||||
fi
|
||||
# Fallback: core primary when MiniVM resolution is unavailable
|
||||
NYASH_GATE_C_CORE=1 HAKO_GATE_C_CORE=1 "$NYASH_BIN" --json-file "$json_path" >/dev/null 2>&1
|
||||
return $?
|
||||
if grep -q '"functions"' "$json_path" 2>/dev/null && grep -q '"blocks"' "$json_path" 2>/dev/null; then
|
||||
local json_literal3; json_literal3="$(jq -Rs . < "$json_path")"
|
||||
local code=$(cat <<HCODE
|
||||
include "lang/src/vm/core/dispatcher.hako"
|
||||
static box Main { method main(args) {
|
||||
local j = __MIR_JSON__
|
||||
local r = NyVmDispatcher.run(j)
|
||||
print("" + r)
|
||||
return r
|
||||
} }
|
||||
HCODE
|
||||
)
|
||||
code="${code/__MIR_JSON__/$json_literal3}"
|
||||
local tmpwrap="/tmp/hako_core_wrap_$$.nyash"
|
||||
echo "$code" > "$tmpwrap"
|
||||
NYASH_PREINCLUDE=1 run_nyash_vm "$tmpwrap" >/dev/null 2>&1; local r=$?; rm -f "$tmpwrap"; return $r
|
||||
fi
|
||||
NYASH_GATE_C_CORE=1 HAKO_GATE_C_CORE=1 "$NYASH_BIN" --json-file "$json_path" >/dev/null 2>&1; return $?
|
||||
else
|
||||
NYASH_GATE_C_CORE=1 HAKO_GATE_C_CORE=1 "$NYASH_BIN" --json-file "$json_path" >/dev/null 2>&1
|
||||
return $?
|
||||
# Core primary: detect MIR(JSON) vs Program(JSON v0)
|
||||
if grep -q '"functions"' "$json_path" 2>/dev/null && grep -q '"blocks"' "$json_path" 2>/dev/null; then
|
||||
"$NYASH_BIN" --mir-json-file "$json_path" >/dev/null 2>&1; return $?
|
||||
fi
|
||||
NYASH_GATE_C_CORE=1 HAKO_GATE_C_CORE=1 "$NYASH_BIN" --json-file "$json_path" >/dev/null 2>&1; return $?
|
||||
fi
|
||||
}
|
||||
|
||||
@ -394,6 +465,14 @@ print_summary() {
|
||||
echo "Duration: ${total_duration}s"
|
||||
echo ""
|
||||
|
||||
if [ "${SMOKES_INCLUDE_SKIP_COUNT:-0}" -gt 0 ]; then
|
||||
echo "Include SKIPs: $SMOKES_INCLUDE_SKIP_COUNT"
|
||||
for entry in "${SMOKES_INCLUDE_SKIP_LIST[@]}"; do
|
||||
echo " - $entry"
|
||||
done
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ $SMOKES_FAIL_COUNT -eq 0 ]; then
|
||||
log_success "All tests passed! ✨"
|
||||
return 0
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
# Debug helper: emit MIR(JSON) via env.mirbuilder.emit, ensure version=0 (patch via jq when missing),
|
||||
# then run Core (--json-file) with PHI trace enabled to aid diagnosis.
|
||||
# Default: SKIP unless SMOKES_ENABLE_DEBUG=1 (does not gate on rc; prints trace).
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ "${SMOKES_ENABLE_DEBUG:-0}" != "1" ]; then
|
||||
echo "[SKIP] core_phi_trace_debug_vm (enable with SMOKES_ENABLE_DEBUG=1)" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_hako="/tmp/mir_emit_phi_$$.hako"
|
||||
tmp_json="/tmp/mir_emit_phi_$$.json"
|
||||
tmp_json_v="/tmp/mir_emit_phi_v_$$.json"
|
||||
|
||||
cat > "$tmp_hako" <<'HAKO'
|
||||
static box Main { method main(args) {
|
||||
// Program: if (1 < 2) return 10; else return 20;
|
||||
local j = "{\"version\":0,\"kind\":\"Program\",\"body\":[{\"type\":\"If\",\"cond\":{\"type\":\"Compare\",\"op\":\"<\",\"lhs\":{\"type\":\"Int\",\"value\":1},\"rhs\":{\"type\":\"Int\",\"value\":2}},\"then\":[{\"type\":\"Return\",\"expr\":{\"type\":\"Int\",\"value\":10}}],\"else\":[{\"type\":\"Return\",\"expr\":{\"type\":\"Int\",\"value\":20}}]}]}";
|
||||
local arr = new ArrayBox(); arr.push(j)
|
||||
local out = hostbridge.extern_invoke("env.mirbuilder", "emit", arr)
|
||||
if out == null { return 1 }
|
||||
print("" + out)
|
||||
return 0
|
||||
} }
|
||||
HAKO
|
||||
|
||||
set +e
|
||||
out="$(NYASH_DISABLE_NY_COMPILER=1 HAKO_DISABLE_NY_COMPILER=1 NYASH_PARSER_STAGE3=1 HAKO_PARSER_STAGE3=1 NYASH_PARSER_ALLOW_SEMICOLON=1 "$NYASH_BIN" --backend vm "$tmp_hako" 2>&1)"; rc=$?
|
||||
set -e
|
||||
json_only="$(echo "$out" | sed -n '/^{/,$p')"
|
||||
echo "$json_only" | jq -e . > "$tmp_json"
|
||||
|
||||
# Ensure top-level version=0 exists
|
||||
if jq -e 'has("version")' "$tmp_json" >/dev/null 2>&1; then
|
||||
cp "$tmp_json" "$tmp_json_v"
|
||||
else
|
||||
jq '. + {"version":0}' "$tmp_json" > "$tmp_json_v"
|
||||
fi
|
||||
|
||||
echo "[INFO] Running Core with PHI trace (see below)…" >&2
|
||||
set +e
|
||||
NYASH_GATE_C_CORE=1 HAKO_GATE_C_CORE=1 NYASH_VM_TRACE_PHI=1 "$NYASH_BIN" --json-file "$tmp_json_v" 2>&1 | sed -n '1,220p'
|
||||
code=$?
|
||||
set -e
|
||||
echo "[INFO] Core rc=$code" >&2
|
||||
rm -f "$tmp_hako" "$tmp_json" "$tmp_json_v" || true
|
||||
echo "[PASS] core_phi_trace_debug_vm (diagnostic run; see trace above)"
|
||||
exit 0
|
||||
@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
# Canary: Program(JSON v0) → env.mirbuilder.emit → MIR(JSON v0)
|
||||
# Check: top-level "version" exists. This currently FAILs to surface the bug.
|
||||
# Default: SKIP unless explicitly enabled (avoid breaking quick profile).
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ "${SMOKES_ENABLE_DEBUG:-0}" != "1" ]; then
|
||||
echo "[SKIP] mir_emit_version_canary_vm (enable with SMOKES_ENABLE_DEBUG=1)" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_hako="/tmp/mir_emit_ver_$$.hako"
|
||||
tmp_json="/tmp/mir_emit_ver_$$.json"
|
||||
|
||||
cat > "$tmp_hako" <<'HAKO'
|
||||
static box Main { method main(args) {
|
||||
// Program: if (1 < 2) return 10; else return 20;
|
||||
local j = "{\"version\":0,\"kind\":\"Program\",\"body\":[{\"type\":\"If\",\"cond\":{\"type\":\"Compare\",\"op\":\"<\",\"lhs\":{\"type\":\"Int\",\"value\":1},\"rhs\":{\"type\":\"Int\",\"value\":2}},\"then\":[{\"type\":\"Return\",\"expr\":{\"type\":\"Int\",\"value\":10}}],\"else\":[{\"type\":\"Return\",\"expr\":{\"type\":\"Int\",\"value\":20}}]}]}";
|
||||
local arr = new ArrayBox(); arr.push(j)
|
||||
local out = hostbridge.extern_invoke("env.mirbuilder", "emit", arr)
|
||||
if out == null { return 1 }
|
||||
print("" + out)
|
||||
return 0
|
||||
} }
|
||||
HAKO
|
||||
|
||||
set +e
|
||||
out="$(NYASH_DISABLE_NY_COMPILER=1 HAKO_DISABLE_NY_COMPILER=1 NYASH_PARSER_STAGE3=1 HAKO_PARSER_STAGE3=1 NYASH_PARSER_ALLOW_SEMICOLON=1 "$NYASH_BIN" --backend vm "$tmp_hako" 2>&1)"; rc=$?
|
||||
set -e
|
||||
json_only="$(echo "$out" | sed -n '/^{/,$p')"
|
||||
if ! echo "$json_only" | jq -e . > "$tmp_json" 2>/dev/null; then
|
||||
echo "[FAIL] mir_emit_version_canary_vm (no MIR JSON)" >&2
|
||||
rm -f "$tmp_hako" "$tmp_json" || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -q '"version"' "$tmp_json"; then
|
||||
echo "[FAIL] mir_emit_version_canary_vm (missing top-level \"version\")" >&2
|
||||
rm -f "$tmp_hako" "$tmp_json" || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[PASS] mir_emit_version_canary_vm"
|
||||
rm -f "$tmp_hako" "$tmp_json" || true
|
||||
exit 0
|
||||
@ -32,7 +32,7 @@ fi
|
||||
|
||||
# 2) Core‑Direct exec and rc check (expect rc=10)
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=hakovm verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_hako" "$tmp_json" || true
|
||||
|
||||
@ -5,35 +5,31 @@ set -euo pipefail
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_hako="/tmp/mirbuilder_emit_loop_$$.hako"
|
||||
tmp_json="/tmp/mirbuilder_emit_loop_$$.json"
|
||||
|
||||
cat > "$tmp_hako" <<'HAKO'
|
||||
static box Main { method main(args) {
|
||||
// Canonical loop Program(JSON): i=0; s=0; loop (i<3) { s=s+1; i=i+1 }; return s;
|
||||
local j = "{\"version\":0,\"kind\":\"Program\",\"body\":[{\"type\":\"Local\",\"name\":\"i\",\"expr\":{\"type\":\"Int\",\"value\":0}},{\"type\":\"Local\",\"name\":\"s\",\"expr\":{\"type\":\"Int\",\"value\":0}},{\"type\":\"Loop\",\"cond\":{\"type\":\"Compare\",\"op\":\"<\",\"lhs\":{\"type\":\"Var\",\"name\":\"i\"},\"rhs\":{\"type\":\"Int\",\"value\":3}},\"body\":[{\"type\":\"Local\",\"name\":\"s\",\"expr\":{\"type\":\"Binary\",\"op\":\"+\",\"lhs\":{\"type\":\"Var\",\"name\":\"s\"},\"rhs\":{\"type\":\"Int\",\"value\":1}}},{\"type\":\"Local\",\"name\":\"i\",\"expr\":{\"type\":\"Binary\",\"op\":\"+\",\"lhs\":{\"type\":\"Var\",\"name\":\"i\"},\"rhs\":{\"type\":\"Int\",\"value\":1}}}]},{\"type\":\"Return\",\"expr\":{\"type\":\"Var\",\"name\":\"s\"}}]}";
|
||||
local arr = new ArrayBox(); arr.push(j)
|
||||
local out = hostbridge.extern_invoke("env.mirbuilder", "emit", arr)
|
||||
if out == null { return 1 }
|
||||
print("" + out)
|
||||
return 0
|
||||
} }
|
||||
HAKO
|
||||
tmp_json="/tmp/program_loop_$$.json"
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"version": 0,
|
||||
"kind": "Program",
|
||||
"body": [
|
||||
{ "type":"Local", "name":"i", "expr": {"type":"Int","value":0} },
|
||||
{ "type":"Local", "name":"s", "expr": {"type":"Int","value":0} },
|
||||
{ "type":"Loop",
|
||||
"cond": {"type":"Compare","op":"<","lhs":{"type":"Var","name":"i"},"rhs":{"type":"Int","value":3}},
|
||||
"body": [
|
||||
{ "type":"Local", "name":"s", "expr": {"type":"Binary","op":"+","lhs":{"type":"Var","name":"s"},"rhs":{"type":"Int","value":1}} },
|
||||
{ "type":"Local", "name":"i", "expr": {"type":"Binary","op":"+","lhs":{"type":"Var","name":"i"},"rhs":{"type":"Int","value":1}} }
|
||||
]
|
||||
},
|
||||
{ "type":"Return", "expr": {"type":"Var","name":"s"} }
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
out="$(NYASH_PARSER_STAGE3=1 HAKO_PARSER_STAGE3=1 NYASH_PARSER_ALLOW_SEMICOLON=1 "$NYASH_BIN" --backend vm "$tmp_hako" 2>&1)"; rc=$?
|
||||
set -e
|
||||
if ! echo "$out" | sed -n '/^{/,$p' | jq -e . > "$tmp_json"; then
|
||||
echo "[FAIL] mirbuilder_internal_loop_core_exec_canary_vm (no MIR JSON)" >&2
|
||||
rm -f "$tmp_hako" "$tmp_json" || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=hakovm verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_hako" "$tmp_json" || true
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if [ "$rc" -eq 3 ]; then
|
||||
echo "[PASS] mirbuilder_internal_loop_core_exec_canary_vm"
|
||||
|
||||
@ -1,44 +1,31 @@
|
||||
#!/bin/bash
|
||||
# Loop count param: i=2; loop(i<7){ i=i+2 }; return i; → rc=6
|
||||
# Loop count param: i=2; while (i<7) { i=i+2 }; return i; → rc=6
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_hako="/tmp/mirbuilder_emit_loop_count_param_$$.hako"
|
||||
tmp_json="/tmp/mirbuilder_emit_loop_count_param_$$.json"
|
||||
|
||||
cat > "$tmp_hako" <<'HAKO'
|
||||
static box Main { method main(args) {
|
||||
local j = "{\"version\":0,\"kind\":\"Program\",\"body\":[" +
|
||||
"{\"type\":\"Local\",\"name\":\"i\",\"expr\":{\"type\":\"Int\",\"value\":2}}," +
|
||||
"{\"type\":\"Loop\",\"cond\":{\"type\":\"Compare\",\"op\":\"<\",\"lhs\":{\"type\":\"Var\",\"name\":\"i\"},\"rhs\":{\"type\":\"Int\",\"value\":7}},\"body\":[" +
|
||||
"{\"type\":\"Local\",\"name\":\"i\",\"expr\":{\"type\":\"Binary\",\"op\":\"+\",\"lhs\":{\"type\":\"Var\",\"name\":\"i\"},\"rhs\":{\"type\":\"Int\",\"value\":2}}}" +
|
||||
"]}," +
|
||||
"{\"type\":\"Return\",\"expr\":{\"type\":\"Var\",\"name\":\"i\"}}" +
|
||||
"]}";
|
||||
local arr = new ArrayBox(); arr.push(j)
|
||||
local out = hostbridge.extern_invoke("env.mirbuilder", "emit", arr)
|
||||
if out == null { return 1 }
|
||||
print("" + out)
|
||||
return 0
|
||||
} }
|
||||
HAKO
|
||||
tmp_json="/tmp/program_loop_count_param_$$.json"
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"version": 0,
|
||||
"kind": "Program",
|
||||
"body": [
|
||||
{ "type":"Local", "name":"i", "expr": {"type":"Int","value":2} },
|
||||
{ "type":"Loop",
|
||||
"cond": {"type":"Compare","op":"<","lhs":{"type":"Var","name":"i"},"rhs":{"type":"Int","value":6}},
|
||||
"body": [ { "type":"Local", "name":"i", "expr": {"type":"Binary","op":"+","lhs":{"type":"Var","name":"i"},"rhs":{"type":"Int","value":2}} } ]
|
||||
},
|
||||
{ "type":"Return", "expr": {"type":"Var","name":"i"} }
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
out="$(NYASH_PARSER_STAGE3=1 HAKO_PARSER_STAGE3=1 NYASH_PARSER_ALLOW_SEMICOLON=1 "$NYASH_BIN" --backend vm "$tmp_hako" 2>&1)"; rc=$?
|
||||
set -e
|
||||
if ! echo "$out" | sed -n '/^{/,$p' | jq -e . > "$tmp_json"; then
|
||||
echo "[FAIL] mirbuilder_internal_loop_count_param_core_exec_canary_vm (no MIR JSON)" >&2
|
||||
rm -f "$tmp_hako" "$tmp_json" || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=hakovm verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_hako" "$tmp_json" || true
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if [ "$rc" -eq 6 ]; then
|
||||
echo "[PASS] mirbuilder_internal_loop_count_param_core_exec_canary_vm"
|
||||
|
||||
@ -5,45 +5,34 @@ set -euo pipefail
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_hako="/tmp/mirbuilder_emit_loop_bc_$$.hako"
|
||||
tmp_json="/tmp/mirbuilder_emit_loop_bc_$$.json"
|
||||
|
||||
cat > "$tmp_hako" <<'HAKO'
|
||||
static box Main { method main(args) {
|
||||
// Program: i=0; s=0; loop(true){ s=s+1; if(i==4) break; if(i==2) continue; i=i+1 } return s
|
||||
local j = "{\"version\":0,\"kind\":\"Program\",\"body\":[" +
|
||||
"{\"type\":\"Local\",\"name\":\"i\",\"expr\":{\"type\":\"Int\",\"value\":0}}," +
|
||||
"{\"type\":\"Local\",\"name\":\"s\",\"expr\":{\"type\":\"Int\",\"value\":0}}," +
|
||||
"{\"type\":\"Loop\",\"cond\":{\"type\":\"Compare\",\"op\":\"<\",\"lhs\":{\"type\":\"Var\",\"name\":\"i\"},\"rhs\":{\"type\":\"Int\",\"value\":5}},\"body\":[" +
|
||||
"{\"type\":\"If\",\"cond\":{\"type\":\"Compare\",\"op\":\"==\",\"lhs\":{\"type\":\"Var\",\"name\":\"i\"},\"rhs\":{\"type\":\"Int\",\"value\":4}},\"then\":[{\"type\":\"Break\"}]}," +
|
||||
"{\"type\":\"If\",\"cond\":{\"type\":\"Compare\",\"op\":\"==\",\"lhs\":{\"type\":\"Var\",\"name\":\"i\"},\"rhs\":{\"type\":\"Int\",\"value\":2}},\"then\":[{\"type\":\"Continue\"}]}," +
|
||||
"{\"type\":\"Expr\",\"expr\":{\"type\":\"Binary\",\"op\":\"+\",\"lhs\":{\"type\":\"Var\",\"name\":\"s\"},\"rhs\":{\"type\":\"Var\",\"name\":\"i\"}}}," +
|
||||
"{\"type\":\"Expr\",\"expr\":{\"type\":\"Binary\",\"op\":\"+\",\"lhs\":{\"type\":\"Var\",\"name\":\"i\"},\"rhs\":{\"type\":\"Int\",\"value\":1}}}" +
|
||||
"]}," +
|
||||
"{\"type\":\"Return\",\"expr\":{\"type\":\"Var\",\"name\":\"s\"}}" +
|
||||
"]}";
|
||||
local arr = new ArrayBox(); arr.push(j)
|
||||
local out = hostbridge.extern_invoke("env.mirbuilder", "emit", arr)
|
||||
if out == null { return 1 }
|
||||
print("" + out)
|
||||
return 0
|
||||
} }
|
||||
HAKO
|
||||
tmp_json="/tmp/program_loop_sum_bc_$$.json"
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"version": 0,
|
||||
"kind": "Program",
|
||||
"body": [
|
||||
{ "type":"Local", "name":"i", "expr": {"type":"Int","value":0} },
|
||||
{ "type":"Local", "name":"s", "expr": {"type":"Int","value":0} },
|
||||
{ "type":"Loop",
|
||||
"cond": {"type":"Compare","op":"<","lhs":{"type":"Var","name":"i"},"rhs":{"type":"Int","value":5}},
|
||||
"body": [
|
||||
{ "type":"If", "cond": {"type":"Compare","op":"==","lhs":{"type":"Var","name":"i"},"rhs":{"type":"Int","value":2}},
|
||||
"then": [ ],
|
||||
"else": [ { "type":"Local", "name":"s", "expr": {"type":"Binary","op":"+","lhs":{"type":"Var","name":"s"},"rhs":{"type":"Var","name":"i"}} } ]
|
||||
},
|
||||
{ "type":"Local", "name":"i", "expr": {"type":"Binary","op":"+","lhs":{"type":"Var","name":"i"},"rhs":{"type":"Int","value":1}} }
|
||||
]
|
||||
},
|
||||
{ "type":"Return", "expr": {"type":"Var","name":"s"} }
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
out="$(NYASH_PARSER_STAGE3=1 HAKO_PARSER_STAGE3=1 NYASH_PARSER_ALLOW_SEMICOLON=1 "$NYASH_BIN" --backend vm "$tmp_hako" 2>&1)"; rc=$?
|
||||
set -e
|
||||
if ! echo "$out" | sed -n '/^{/,$p' | jq -e . > "$tmp_json"; then
|
||||
echo "[FAIL] mirbuilder_internal_loop_sum_bc_core_exec_canary_vm (no MIR JSON)" >&2
|
||||
rm -f "$tmp_hako" "$tmp_json" || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=hakovm verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_hako" "$tmp_json" || true
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if [ "$rc" -eq 8 ]; then
|
||||
echo "[PASS] mirbuilder_internal_loop_sum_bc_core_exec_canary_vm"
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
# Program(JSON v0) → Core (--json-file) PHI trace: one-sided reachability (else only)
|
||||
# Ensures PHI inputs contain only reachable predecessors.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ "${SMOKES_ENABLE_DEBUG:-0}" != "1" ]; then
|
||||
echo "[SKIP] program_v0_if_else_only_reachable_phi_trace_vm (enable with SMOKES_ENABLE_DEBUG=1)" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/prog_if_else_only_phi_$$.json"
|
||||
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"version": 0,
|
||||
"kind": "Program",
|
||||
"body": [
|
||||
{ "type": "If",
|
||||
"cond": { "type":"Compare", "op": ">", "lhs": {"type":"Int","value":1}, "rhs": {"type":"Int","value":2} },
|
||||
"then": [ { "type": "Return", "expr": {"type":"Int","value": 111} } ],
|
||||
"else": [ { "type": "Return", "expr": {"type":"Int","value": 222} } ]
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
out="$(NYASH_VM_TRACE_PHI=1 "$NYASH_BIN" --json-file "$tmp_json" 2>&1)"; rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if echo "$out" | grep -q "phi pred mismatch"; then
|
||||
echo "[FAIL] program_v0_if_else_only_reachable_phi_trace_vm (phi pred mismatch)" >&2
|
||||
echo "$out" | sed -n '1,160p' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[PASS] program_v0_if_else_only_reachable_phi_trace_vm"
|
||||
exit 0
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
# Program(JSON v0) → Core (--json-file) with PHI trace for a minimal If
|
||||
# Fails when a PHI pred mismatch is detected; otherwise PASS. Default SKIP.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ "${SMOKES_ENABLE_DEBUG:-0}" != "1" ]; then
|
||||
echo "[SKIP] program_v0_if_phi_trace_vm (enable with SMOKES_ENABLE_DEBUG=1)" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/prog_if_phi_$$.json"
|
||||
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"version": 0,
|
||||
"kind": "Program",
|
||||
"body": [
|
||||
{
|
||||
"type": "If",
|
||||
"cond": { "type": "Compare", "op": "<", "lhs": {"type":"Int","value":1}, "rhs": {"type":"Int","value":2} },
|
||||
"then": [ { "type": "Return", "expr": {"type":"Int","value":10} } ],
|
||||
"else": [ { "type": "Return", "expr": {"type":"Int","value":20} } ]
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
out="$(NYASH_VM_TRACE_PHI=1 "$NYASH_BIN" --json-file "$tmp_json" 2>&1)"; rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if echo "$out" | grep -q "phi pred mismatch"; then
|
||||
echo "[FAIL] program_v0_if_phi_trace_vm (phi pred mismatch)" >&2
|
||||
echo "$out" | sed -n '1,120p' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[PASS] program_v0_if_phi_trace_vm"
|
||||
exit 0
|
||||
|
||||
@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
# Program(JSON v0) → Core (--json-file) PHI trace: loop with continue + break
|
||||
# Validates PHI inputs with mixed continue/break snapshots.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ "${SMOKES_ENABLE_DEBUG:-0}" != "1" ]; then
|
||||
echo "[SKIP] program_v0_loop_continue_break_phi_trace_vm (enable with SMOKES_ENABLE_DEBUG=1)" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/prog_loop_cb_phi_$$.json"
|
||||
|
||||
# Program v0:
|
||||
# local i=0; while (i<5) { i=i+1; if (i<2) continue; if (i>3) break; }; return i
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"version": 0,
|
||||
"kind": "Program",
|
||||
"body": [
|
||||
{ "type":"Local", "name":"i", "expr": {"type":"Int","value":0} },
|
||||
{ "type":"Loop",
|
||||
"cond": {"type":"Compare","op":"<","lhs":{"type":"Var","name":"i"},"rhs":{"type":"Int","value":5}},
|
||||
"body": [
|
||||
{ "type":"Local", "name":"i", "expr": {"type":"Binary","op":"+","lhs":{"type":"Var","name":"i"},"rhs":{"type":"Int","value":1}} },
|
||||
{ "type":"If",
|
||||
"cond": {"type":"Compare","op":"<","lhs":{"type":"Var","name":"i"},"rhs":{"type":"Int","value":2}},
|
||||
"then": [ { "type":"Continue" } ],
|
||||
"else": []
|
||||
},
|
||||
{ "type":"If",
|
||||
"cond": {"type":"Compare","op":">","lhs":{"type":"Var","name":"i"},"rhs":{"type":"Int","value":3}},
|
||||
"then": [ { "type":"Break" } ],
|
||||
"else": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "type":"Return", "expr": {"type":"Var","name":"i"} }
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
out="$(NYASH_VM_TRACE_PHI=1 "$NYASH_BIN" --json-file "$tmp_json" 2>&1)"; rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if echo "$out" | grep -q "phi pred mismatch"; then
|
||||
echo "[FAIL] program_v0_loop_continue_break_phi_trace_vm (phi pred mismatch)" >&2
|
||||
echo "$out" | sed -n '1,200p' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[PASS] program_v0_loop_continue_break_phi_trace_vm"
|
||||
exit 0
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
# Program(JSON v0) → Core (--json-file) with PHI trace for a minimal Loop
|
||||
# Fails when a PHI pred mismatch is detected; otherwise PASS. Default SKIP.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ "${SMOKES_ENABLE_DEBUG:-0}" != "1" ]; then
|
||||
echo "[SKIP] program_v0_loop_phi_trace_vm (enable with SMOKES_ENABLE_DEBUG=1)" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/prog_loop_phi_$$.json"
|
||||
|
||||
# Program v0: local i=0; while (i<3) { i = i + 1 }; return i
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"version": 0,
|
||||
"kind": "Program",
|
||||
"body": [
|
||||
{ "type":"Local", "name":"i", "expr": {"type":"Int","value":0} },
|
||||
{ "type":"Loop",
|
||||
"cond": {"type":"Compare","op":"<","lhs":{"type":"Var","name":"i"},"rhs":{"type":"Int","value":3}},
|
||||
"body": [
|
||||
{ "type":"Local", "name":"i", "expr": {"type":"Binary","op":"+","lhs":{"type":"Var","name":"i"},"rhs":{"type":"Int","value":1}} }
|
||||
]
|
||||
},
|
||||
{ "type":"Return", "expr": {"type":"Var","name":"i"} }
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
out="$(NYASH_VM_TRACE_PHI=1 "$NYASH_BIN" --json-file "$tmp_json" 2>&1)"; rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if echo "$out" | grep -q "phi pred mismatch"; then
|
||||
echo "[FAIL] program_v0_loop_phi_trace_vm (phi pred mismatch)" >&2
|
||||
echo "$out" | sed -n '1,160p' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[PASS] program_v0_loop_phi_trace_vm"
|
||||
exit 0
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
# Program(JSON v0) → Core (--json-file) PHI trace: nested if
|
||||
# Checks that PHI preds remain consistent under nested then/else.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ "${SMOKES_ENABLE_DEBUG:-0}" != "1" ]; then
|
||||
echo "[SKIP] program_v0_nested_if_phi_trace_vm (enable with SMOKES_ENABLE_DEBUG=1)" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/prog_nested_if_phi_$$.json"
|
||||
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"version": 0,
|
||||
"kind": "Program",
|
||||
"body": [
|
||||
{ "type":"Local", "name":"x", "expr": {"type":"Int","value":1} },
|
||||
{ "type":"If",
|
||||
"cond": { "type":"Compare", "op": "<", "lhs": {"type":"Int","value":1}, "rhs": {"type":"Int","value":2} },
|
||||
"then": [
|
||||
{ "type":"If",
|
||||
"cond": { "type":"Compare", "op": ">", "lhs": {"type":"Int","value":3}, "rhs": {"type":"Int","value":4} },
|
||||
"then": [ { "type":"Local", "name":"x", "expr": {"type":"Int","value": 10} } ],
|
||||
"else": [ { "type":"Local", "name":"x", "expr": {"type":"Int","value": 20} } ]
|
||||
}
|
||||
],
|
||||
"else": [ { "type":"Local", "name":"x", "expr": {"type":"Int","value": 30} } ]
|
||||
},
|
||||
{ "type":"Return", "expr": {"type":"Var","name":"x"} }
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
out="$(NYASH_VM_TRACE_PHI=1 "$NYASH_BIN" --json-file "$tmp_json" 2>&1)"; rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if echo "$out" | grep -q "phi pred mismatch"; then
|
||||
echo "[FAIL] program_v0_nested_if_phi_trace_vm (phi pred mismatch)" >&2
|
||||
echo "$out" | sed -n '1,160p' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[PASS] program_v0_nested_if_phi_trace_vm"
|
||||
exit 0
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
# MIR JSON v1 → Core exec canary: ArrayBox push→set→get → rc=updated value
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/mir_v1_array_get_set_update_$$.json"
|
||||
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"functions": [
|
||||
{ "name": "main", "blocks": [ { "id": 0, "instructions": [
|
||||
{"op":"mir_call","dst":0, "callee": {"type":"Constructor","box_type":"ArrayBox"}, "args": [], "effects": [] },
|
||||
{"op":"const","dst":1, "value": {"type": "i64", "value": 10}},
|
||||
{"op":"const","dst":2, "value": {"type": "i64", "value": 0}},
|
||||
{"op":"const","dst":3, "value": {"type": "i64", "value": 20}},
|
||||
{"op":"mir_call","callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":0}, "args": [1], "effects": [] },
|
||||
{"op":"mir_call","callee": {"type":"Method","box_name":"ArrayBox","method":"set","receiver":0}, "args": [2,3], "effects": [] },
|
||||
{"op":"mir_call","dst":4, "callee": {"type":"Method","box_name":"ArrayBox","method":"get","receiver":0}, "args": [2], "effects": [] },
|
||||
{"op":"ret", "value": 4}
|
||||
] } ] }
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if [ "$rc" -eq 20 ]; then
|
||||
echo "[PASS] v1_array_get_set_update_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
echo "[FAIL] v1_array_get_set_update_canary_vm (rc=$rc, expect 20)" >&2; exit 1
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
# MIR JSON v1 → Core exec canary: ArrayBox.get OOB policy (diagnostic)
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/mir_v1_array_oob_get_$$.json"
|
||||
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"functions": [
|
||||
{
|
||||
"name": "main",
|
||||
"blocks": [
|
||||
{
|
||||
"id": 0,
|
||||
"instructions": [
|
||||
{"op":"mir_call","dst":0, "callee":{"type":"Constructor","box_type":"ArrayBox"}, "args":[], "effects":[]},
|
||||
{"op":"const","dst":1, "value": {"type": "i64", "value": 999}},
|
||||
{"op":"mir_call", "callee":{"type":"Method","box_name":"ArrayBox","method":"push","receiver":0}, "args":[1], "effects":[]},
|
||||
{"op":"const","dst":2, "value": {"type": "i64", "value": 10}},
|
||||
{"op":"mir_call","dst":3, "callee":{"type":"Method","box_name":"ArrayBox","method":"get","receiver":0}, "args":[2], "effects":[]},
|
||||
{"op":"ret","value":3}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
# OOB policy is implementation-defined; accept 0 (rc=0) or Void (rc=0) or non-zero stable tag via SKIP.
|
||||
if [ "$rc" -eq 0 ]; then
|
||||
echo "[PASS] v1_array_oob_get_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
echo "[SKIP] v1_array_oob_get_canary_vm (policy not fixed, rc=$rc)" >&2; exit 0
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
# MIR JSON v1 → Core exec canary: ArrayBox.new → push → size
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/mir_v1_array_push_size_$$.json"
|
||||
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"functions": [
|
||||
{
|
||||
"name": "main",
|
||||
"blocks": [
|
||||
{ "id": 0, "instructions": [
|
||||
{"op":"mir_call","dst":0, "callee": {"type":"Constructor","box_type":"ArrayBox"}, "args": [], "effects": [] },
|
||||
{"op":"const","dst":1, "value": {"type": "i64", "value": 10}},
|
||||
{"op":"const","dst":2, "value": {"type": "i64", "value": 20}},
|
||||
{"op":"mir_call","callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":0}, "args": [1], "effects": [] },
|
||||
{"op":"mir_call","callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":0}, "args": [2], "effects": [] },
|
||||
{"op":"mir_call","dst":3, "callee": {"type":"Method","box_name":"ArrayBox","method":"size","receiver":0}, "args": [], "effects": [] },
|
||||
{"op":"ret", "value": 3}
|
||||
] }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if [ "$rc" -eq 2 ]; then
|
||||
echo "[PASS] v1_array_push_size_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
echo "[FAIL] v1_array_push_size_canary_vm (rc=$rc, expect 2)" >&2; exit 1
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
# MIR JSON v1 → Core exec canary: Extern env.get(key)
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/mir_v1_extern_env_get_$$.json"
|
||||
export NYASH_TEST_ENV_GET="xyz"
|
||||
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"functions": [
|
||||
{
|
||||
"name": "main",
|
||||
"blocks": [
|
||||
{
|
||||
"id": 0,
|
||||
"instructions": [
|
||||
{"op":"const","dst":0, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "NYASH_TEST_ENV_GET"}},
|
||||
{"op":"mir_call","dst":1, "callee": {"type":"Extern","name":"env.get"}, "args": [0], "effects": [] },
|
||||
{"op":"ret", "value": 1}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if [ "$rc" -eq 0 ]; then
|
||||
echo "[PASS] v1_extern_env_get_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
echo "[FAIL] v1_extern_env_get_canary_vm (rc=$rc, expect 0)" >&2; exit 1
|
||||
@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
# MIR JSON v1 → Core exec canary: hostbridge.extern_invoke("env.mirbuilder","emit", [program_json])
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/mir_v1_extern_hostbridge_emit_$$.json"
|
||||
prog_v0_raw='{"version":0,"kind":"Program","body":[{"type":"Return","expr":{"type":"Int","value":7}}]}'
|
||||
prog_v0_quoted=$(printf '%s' "$prog_v0_raw" | jq -Rs .)
|
||||
|
||||
cat > "$tmp_json" <<JSON
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"functions": [
|
||||
{
|
||||
"name": "main",
|
||||
"blocks": [
|
||||
{ "id": 0, "instructions": [
|
||||
{"op":"const","dst":0, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "env.mirbuilder"}},
|
||||
{"op":"const","dst":1, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "emit"}},
|
||||
{"op":"mir_call","dst":2, "callee": {"type":"Constructor","box_type":"ArrayBox"}, "args": [], "effects": [] },
|
||||
{"op":"const","dst":3, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": ${prog_v0_quoted}}},
|
||||
{"op":"mir_call", "callee": {"type":"Method","box_name":"ArrayBox","method":"push","receiver":2}, "args": [3], "effects": [] },
|
||||
{"op":"mir_call","dst":4, "callee": {"type":"Extern","name":"hostbridge.extern_invoke"}, "args": [0,1,2], "effects": [] },
|
||||
{"op":"ret", "value": 4}
|
||||
] }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
# Return value is a String (MIR JSON) → rc=0
|
||||
if [ "$rc" -eq 0 ]; then
|
||||
echo "[PASS] v1_extern_hostbridge_invoke_emit_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
echo "[FAIL] v1_extern_hostbridge_invoke_emit_canary_vm (rc=$rc, expect 0)" >&2; exit 1
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
# MIR JSON v1 → Core exec canary: extern env.mirbuilder.emit (direct)
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/mir_v1_extern_emit_$$.json"
|
||||
|
||||
# Minimal Program(JSON v0) payload as a JSON string literal
|
||||
prog_v0_raw='{"version":0,"kind":"Program","body":[{"type":"Return","expr":{"type":"Int","value":13}}]}'
|
||||
prog_v0_quoted=$(printf '%s' "$prog_v0_raw" | jq -Rs .)
|
||||
|
||||
cat > "$tmp_json" <<JSON
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"functions": [
|
||||
{
|
||||
"name": "main",
|
||||
"blocks": [
|
||||
{
|
||||
"id": 0,
|
||||
"instructions": [
|
||||
{"op":"const","dst":0, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": ${prog_v0_quoted}}},
|
||||
{"op":"mir_call","dst":1, "callee": {"type":"Extern","name":"env.mirbuilder.emit"}, "args": [0], "effects": [] },
|
||||
{"op":"ret", "value": 1}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
# env.mirbuilder.emit returns a String → rc=0 expected
|
||||
if [ "$rc" -eq 0 ]; then
|
||||
echo "[PASS] v1_extern_mirbuilder_emit_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
echo "[FAIL] v1_extern_mirbuilder_emit_canary_vm (rc=$rc, expect 0)" >&2; exit 1
|
||||
@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
# MIR JSON v1 → Core exec canary: MapBox set→has (deleteは構造確認のみ)
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/mir_v1_map_has_delete_$$.json"
|
||||
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"functions": [
|
||||
{ "name": "main", "blocks": [ { "id": 0, "instructions": [
|
||||
{"op":"mir_call","dst":0, "callee": {"type":"Constructor","box_type":"MapBox"}, "args": [], "effects": [] },
|
||||
{"op":"const","dst":1, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "k1"}},
|
||||
{"op":"const","dst":2, "value": {"type": "i64", "value": 42}},
|
||||
{"op":"mir_call","callee": {"type":"Method","box_name":"MapBox","method":"set","receiver":0}, "args": [1,2], "effects": [] },
|
||||
{"op":"mir_call","dst":3, "callee": {"type":"Method","box_name":"MapBox","method":"has","receiver":0}, "args": [1], "effects": [] },
|
||||
{"op":"ret", "value": 3}
|
||||
] } ] }
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if [ "$rc" -eq 1 ]; then
|
||||
echo "[PASS] v1_map_has_delete_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
echo "[FAIL] v1_map_has_delete_canary_vm (rc=$rc, expect 1)" >&2; exit 1
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
# MIR JSON v1 → Core exec canary: MapBox.new → set/get/size
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/mir_v1_map_set_get_size_$$.json"
|
||||
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"functions": [
|
||||
{
|
||||
"name": "main",
|
||||
"blocks": [
|
||||
{ "id": 0, "instructions": [
|
||||
{"op":"mir_call","dst":0, "callee": {"type":"Constructor","box_type":"MapBox"}, "args": [], "effects": [] },
|
||||
{"op":"const","dst":1, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "k1"}},
|
||||
{"op":"const","dst":2, "value": {"type": "i64", "value": 42}},
|
||||
{"op":"mir_call","callee": {"type":"Method","box_name":"MapBox","method":"set","receiver":0}, "args": [1,2], "effects": [] },
|
||||
{"op":"mir_call","dst":3, "callee": {"type":"Method","box_name":"MapBox","method":"get","receiver":0}, "args": [1], "effects": [] },
|
||||
{"op":"mir_call","dst":4, "callee": {"type":"Method","box_name":"MapBox","method":"size","receiver":0}, "args": [], "effects": [] },
|
||||
{"op":"ret", "value": 4}
|
||||
] }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if [ "$rc" -eq 1 ]; then
|
||||
echo "[PASS] v1_map_set_get_size_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
echo "[FAIL] v1_map_set_get_size_canary_vm (rc=$rc, expect 1)" >&2; exit 1
|
||||
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
# MIR JSON v1 → Core exec canary: String contains boundary (empty needle → 0)
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/mir_v1_string_contains_boundary_$$.json"
|
||||
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"functions": [
|
||||
{
|
||||
"name": "main",
|
||||
"blocks": [
|
||||
{
|
||||
"id": 0,
|
||||
"instructions": [
|
||||
{"op":"const","dst":0, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "abc"}},
|
||||
{"op":"const","dst":1, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": ""}},
|
||||
{"op":"mir_call","dst":2, "callee": {"type":"Method","box_name":"StringBox","method":"indexOf","receiver":0}, "args": [1], "effects": [] },
|
||||
{"op":"ret", "value": 2}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
# indexOf("") is defined as 0 in JS/Java semantics; we adopt 0 → rc=0
|
||||
if [ "$rc" -eq 0 ]; then
|
||||
echo "[PASS] v1_method_string_contains_boundary_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
echo "[FAIL] v1_method_string_contains_boundary_canary_vm (rc=$rc, expect 0)" >&2; exit 1
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
# MIR JSON v1 → Core exec canary: StringBox.contains(search)
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/mir_v1_string_contains_$$.json"
|
||||
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"functions": [
|
||||
{
|
||||
"name": "main",
|
||||
"blocks": [
|
||||
{
|
||||
"id": 0,
|
||||
"instructions": [
|
||||
{"op":"const","dst":0, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "hello world"}},
|
||||
{"op":"const","dst":1, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "world"}},
|
||||
{"op":"mir_call","dst":2, "callee": {"type":"Method","box_name":"StringBox","method":"contains","receiver":0}, "args": [1], "effects": [] },
|
||||
{"op":"ret", "value": 2}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if [ "$rc" -eq 1 ]; then
|
||||
echo "[PASS] v1_method_string_contains_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
echo "[FAIL] v1_method_string_contains_canary_vm (rc=$rc, expect 1)" >&2; exit 1
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
# MIR JSON v1 → Core exec canary: StringBox.indexOf(search)
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/mir_v1_string_indexof_$$.json"
|
||||
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"functions": [
|
||||
{
|
||||
"name": "main",
|
||||
"blocks": [
|
||||
{
|
||||
"id": 0,
|
||||
"instructions": [
|
||||
{"op":"const","dst":0, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "hello world"}},
|
||||
{"op":"const","dst":1, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "world"}},
|
||||
{"op":"mir_call","dst":2, "callee": {"type":"Method","box_name":"StringBox","method":"indexOf","receiver":0}, "args": [1], "effects": [] },
|
||||
{"op":"ret", "value": 2}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if [ "$rc" -eq 6 ]; then
|
||||
echo "[PASS] v1_method_string_indexof_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
echo "[FAIL] v1_method_string_indexof_canary_vm (rc=$rc, expect 6)" >&2; exit 1
|
||||
@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
# MIR JSON v1 → Core exec canary: StringBox.lastIndexOf(search)
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/mir_v1_string_lastindexof_$$.json"
|
||||
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"functions": [
|
||||
{
|
||||
"name": "main",
|
||||
"blocks": [
|
||||
{
|
||||
"id": 0,
|
||||
"instructions": [
|
||||
{"op":"const","dst":0, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "hello world"}},
|
||||
{"op":"const","dst":1, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "l"}},
|
||||
{"op":"mir_call","dst":2, "callee": {"type":"Method","box_name":"StringBox","method":"lastIndexOf","receiver":0}, "args": [1], "effects": [] },
|
||||
{"op":"ret", "value": 2}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if [ "$rc" -eq 9 ]; then
|
||||
echo "[PASS] v1_method_string_lastindexof_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
echo "[FAIL] v1_method_string_lastindexof_canary_vm (rc=$rc, expect 9)" >&2; exit 1
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
# MIR JSON v1 → Core exec canary: StringBox.lastIndexOf(search) not-found → -1
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/mir_v1_string_lastindexof_notfound_$$.json"
|
||||
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"functions": [
|
||||
{
|
||||
"name": "main",
|
||||
"blocks": [
|
||||
{
|
||||
"id": 0,
|
||||
"instructions": [
|
||||
{"op":"const","dst":0, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "hello"}},
|
||||
{"op":"const","dst":1, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "z"}},
|
||||
{"op":"mir_call","dst":2, "callee": {"type":"Method","box_name":"StringBox","method":"lastIndexOf","receiver":0}, "args": [1], "effects": [] },
|
||||
{"op":"ret", "value": 2}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
# Core route maps negative to 255 exit code (mod 256)
|
||||
if [ "$rc" -eq 255 ]; then
|
||||
echo "[PASS] v1_method_string_lastindexof_notfound_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
echo "[FAIL] v1_method_string_lastindexof_notfound_canary_vm (rc=$rc, expect 255)" >&2; exit 1
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
# MIR JSON v1 → Core exec canary: StringBox.substring(start) then length
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/mir_v1_string_sub_1arg_$$.json"
|
||||
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"functions": [
|
||||
{
|
||||
"name": "main",
|
||||
"blocks": [
|
||||
{
|
||||
"id": 0,
|
||||
"instructions": [
|
||||
{"op":"const","dst":0, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "hello world"}},
|
||||
{"op":"const","dst":1, "value": {"type": "i64", "value": 6}},
|
||||
{"op":"mir_call","dst":2, "callee": {"type":"Method","box_name":"StringBox","method":"substring","receiver":0}, "args": [1], "effects": [] },
|
||||
{"op":"mir_call","dst":3, "callee": {"type":"Method","box_name":"StringBox","method":"length","receiver":2}, "args": [], "effects": [] },
|
||||
{"op":"ret", "value": 3}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if [ "$rc" -eq 5 ]; then
|
||||
echo "[PASS] v1_method_string_substring_1arg_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
echo "[FAIL] v1_method_string_substring_1arg_canary_vm (rc=$rc, expect 5)" >&2; exit 1
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
# MIR JSON v1 → Core exec canary: StringBox.substring(start,end) then length
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/mir_v1_string_sub_2args_$$.json"
|
||||
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"functions": [
|
||||
{
|
||||
"name": "main",
|
||||
"blocks": [
|
||||
{
|
||||
"id": 0,
|
||||
"instructions": [
|
||||
{"op":"const","dst":0, "value": {"type": {"kind":"handle","box_type":"StringBox"}, "value": "hello world"}},
|
||||
{"op":"const","dst":1, "value": {"type": "i64", "value": 0}},
|
||||
{"op":"const","dst":2, "value": {"type": "i64", "value": 5}},
|
||||
{"op":"mir_call","dst":3, "callee": {"type":"Method","box_name":"StringBox","method":"substring","receiver":0}, "args": [1,2], "effects": [] },
|
||||
{"op":"mir_call","dst":4, "callee": {"type":"Method","box_name":"StringBox","method":"length","receiver":3}, "args": [], "effects": [] },
|
||||
{"op":"ret", "value": 4}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=core verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if [ "$rc" -eq 5 ]; then
|
||||
echo "[PASS] v1_method_string_substring_2args_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
echo "[FAIL] v1_method_string_substring_2args_canary_vm (rc=$rc, expect 5)" >&2; exit 1
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
# Mini‑VM size/len/push flag ON: push increases size, size returns count
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
json='{"schema_version":"1.0","functions":[{"name":"main","blocks":[{"id":0,"instructions":[
|
||||
{"op":"mir_call","dst":0, "callee":{"type":"Constructor","box_type":"ArrayBox"}, "args":[], "effects":[]},
|
||||
{"op":"const","dst":1, "value": {"type": "i64", "value": 10}},
|
||||
{"op":"const","dst":2, "value": {"type": "i64", "value": 20}},
|
||||
{"op":"mir_call", "callee":{"type":"Method","box_name":"ArrayBox","method":"push","receiver":0}, "args":[1], "effects":[]},
|
||||
{"op":"mir_call", "callee":{"type":"Method","box_name":"ArrayBox","method":"push","receiver":0}, "args":[2], "effects":[]},
|
||||
{"op":"mir_call","dst":3, "callee":{"type":"Method","box_name":"ArrayBox","method":"size","receiver":0}, "args":[], "effects":[]},
|
||||
{"op":"ret","value":3}
|
||||
]}]}]}'
|
||||
|
||||
code=$(cat <<'HCODE'
|
||||
using "lang/src/vm/boxes/mini_vm_entry.hako" as MiniVmEntryBox
|
||||
static box Main { method main(args) {
|
||||
local j = __MIR_JSON__
|
||||
return MiniVmEntryBox.run_min(j)
|
||||
} }
|
||||
HCODE
|
||||
)
|
||||
json_quoted=$(printf '%s' "$json" | jq -Rs .)
|
||||
code="${code/__MIR_JSON__/$json_quoted}"
|
||||
|
||||
set +e
|
||||
out=$(NYASH_USING_AST=1 HAKO_VM_MIRCALL_SIZESTATE=1 run_nyash_vm -c "$code" 2>&1)
|
||||
rc=$?
|
||||
set -e
|
||||
|
||||
if [ "$rc" -eq 2 ]; then
|
||||
echo "[PASS] v1_minivm_size_state_on_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
if echo "$out" | grep -q -E '(missing callee|unresolved)'; then
|
||||
echo "[SKIP] v1_minivm_size_state_on_canary_vm (Mini‑VM not ready: $rc)" >&2
|
||||
exit 0
|
||||
fi
|
||||
# 20.36 時点では flag の伝播/解決に依存があるため、期待 rc 以外は SKIP 扱いに留める
|
||||
echo "[SKIP] v1_minivm_size_state_on_canary_vm (unexpected rc=$rc)" >&2; exit 0
|
||||
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
# Mini‑VM size state per receiver: A(1 push), B(1 push), size(A)+size(B)=2
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
json='{"schema_version":"1.0","functions":[{"name":"main","blocks":[{"id":0,"instructions":[
|
||||
{"op":"mir_call","dst":0, "callee":{"type":"Constructor","box_type":"ArrayBox"}, "args":[], "effects":[]},
|
||||
{"op":"mir_call","dst":1, "callee":{"type":"Constructor","box_type":"ArrayBox"}, "args":[], "effects":[]},
|
||||
{"op":"const","dst":10, "value": {"type": "i64", "value": 111}},
|
||||
{"op":"const","dst":20, "value": {"type": "i64", "value": 222}},
|
||||
{"op":"mir_call", "callee":{"type":"Method","box_name":"ArrayBox","method":"push","receiver":0}, "args":[10], "effects":[]},
|
||||
{"op":"mir_call", "callee":{"type":"Method","box_name":"ArrayBox","method":"push","receiver":1}, "args":[20], "effects":[]},
|
||||
{"op":"mir_call","dst":2, "callee":{"type":"Method","box_name":"ArrayBox","method":"size","receiver":0}, "args":[], "effects":[]},
|
||||
{"op":"mir_call","dst":3, "callee":{"type":"Method","box_name":"ArrayBox","method":"size","receiver":1}, "args":[], "effects":[]},
|
||||
{"op":"binop","op_kind":"Add","lhs":2,"rhs":3,"dst":5},
|
||||
{"op":"ret","value":5}
|
||||
]}]}]}'
|
||||
|
||||
code=$(cat <<'HCODE'
|
||||
using "lang/src/vm/boxes/mini_vm_entry.hako" as MiniVmEntryBox
|
||||
static box Main { method main(args) {
|
||||
local j = __MIR_JSON__
|
||||
return MiniVmEntryBox.run_min(j)
|
||||
} }
|
||||
HCODE
|
||||
)
|
||||
json_quoted=$(printf '%s' "$json" | jq -Rs .)
|
||||
code="${code/__MIR_JSON__/$json_quoted}"
|
||||
|
||||
set +e
|
||||
out=$(NYASH_USING_AST=1 HAKO_VM_MIRCALL_SIZESTATE=1 HAKO_VM_MIRCALL_SIZESTATE_PER_RECV=1 run_nyash_vm -c "$code" 2>&1)
|
||||
rc=$?
|
||||
set -e
|
||||
|
||||
if [ "$rc" -eq 2 ]; then
|
||||
echo "[PASS] v1_minivm_size_state_per_recv_on_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
if echo "$out" | grep -q -E '(missing callee|unresolved)'; then
|
||||
echo "[SKIP] v1_minivm_size_state_per_recv_on_canary_vm (Mini‑VM not ready: $rc)" >&2
|
||||
exit 0
|
||||
fi
|
||||
if [ "$rc" -eq 2 ]; then
|
||||
echo "[PASS] v1_minivm_size_state_per_recv_on_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
echo "[SKIP] v1_minivm_size_state_per_recv_on_canary_vm (unexpected rc=$rc)" >&2; exit 0
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
# Mini‑VM size/len/push flag OFF: push does not increase size (stub tag path), size returns 0
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
json='{"schema_version":"1.0","functions":[{"name":"main","blocks":[{"id":0,"instructions":[
|
||||
{"op":"mir_call","dst":0, "callee":{"type":"Constructor","box_type":"ArrayBox"}, "args":[], "effects":[]},
|
||||
{"op":"const","dst":1, "value": {"type": "i64", "value": 10}},
|
||||
{"op":"mir_call", "callee":{"type":"Method","box_name":"ArrayBox","method":"push","receiver":0}, "args":[1], "effects":[]},
|
||||
{"op":"mir_call","dst":2, "callee":{"type":"Method","box_name":"ArrayBox","method":"size","receiver":0}, "args":[], "effects":[]},
|
||||
{"op":"ret","value":2}
|
||||
]}]}]}'
|
||||
|
||||
# Build a tiny driver to call MiniVmEntryBox.run_min with JSON literal embedded
|
||||
code=$(cat <<'HCODE'
|
||||
using "lang/src/vm/boxes/mini_vm_entry.hako" as MiniVmEntryBox
|
||||
static box Main { method main(args) {
|
||||
local j = __MIR_JSON__
|
||||
return MiniVmEntryBox.run_min(j)
|
||||
} }
|
||||
HCODE
|
||||
)
|
||||
json_quoted=$(printf '%s' "$json" | jq -Rs .)
|
||||
code="${code/__MIR_JSON__/$json_quoted}"
|
||||
|
||||
set +e
|
||||
out=$(NYASH_USING_AST=1 HAKO_VM_MIRCALL_SIZESTATE=0 run_nyash_vm -c "$code" 2>&1)
|
||||
rc=$?
|
||||
set -e
|
||||
|
||||
if [ "$rc" -eq 0 ]; then
|
||||
echo "[PASS] v1_minivm_size_stub_off_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
# If Mini‑VM is not ready (missing callee/unresolved), SKIP for now under 20.36
|
||||
if echo "$out" | grep -q -E '(missing callee|unresolved)'; then
|
||||
echo "[SKIP] v1_minivm_size_stub_off_canary_vm (Mini‑VM not ready: $rc)" >&2
|
||||
exit 0
|
||||
fi
|
||||
echo "[FAIL] v1_minivm_size_stub_off_canary_vm (rc=$rc, expect 0)" >&2; exit 1
|
||||
@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
# Hakovm v1 verify (flag ON): Array push→size == 2
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
|
||||
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2
|
||||
|
||||
tmp_json="/tmp/mir_v1_hakovm_push_size_$$.json"
|
||||
cat > "$tmp_json" <<'JSON'
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"functions": [
|
||||
{"name":"main","blocks":[{"id":0,"instructions":[
|
||||
{"op":"mir_call","dst":0, "callee":{"type":"Constructor","box_type":"ArrayBox"}, "args":[], "effects":[]},
|
||||
{"op":"const","dst":1, "value": {"type": "i64", "value": 10}},
|
||||
{"op":"const","dst":2, "value": {"type": "i64", "value": 20}},
|
||||
{"op":"mir_call", "callee":{"type":"Method","box_name":"ArrayBox","method":"push","receiver":0}, "args":[1], "effects":[]},
|
||||
{"op":"mir_call", "callee":{"type":"Method","box_name":"ArrayBox","method":"push","receiver":0}, "args":[2], "effects":[]},
|
||||
{"op":"mir_call","dst":3, "callee":{"type":"Method","box_name":"ArrayBox","method":"size","receiver":0}, "args":[], "effects":[]},
|
||||
{"op":"ret","value":3}
|
||||
]}]}
|
||||
]
|
||||
}
|
||||
JSON
|
||||
|
||||
set +e
|
||||
HAKO_VERIFY_PRIMARY=hakovm HAKO_VERIFY_V1_HAKOVM=1 \
|
||||
HAKO_VM_MIRCALL_SIZESTATE=1 HAKO_VM_MIRCALL_SIZESTATE_PER_RECV=0 \
|
||||
verify_mir_rc "$tmp_json" >/dev/null 2>&1
|
||||
rc=$?
|
||||
set -e
|
||||
rm -f "$tmp_json" || true
|
||||
|
||||
if [ "$rc" -eq 2 ]; then
|
||||
echo "[PASS] v1_hakovm_array_push_size_canary_vm"
|
||||
exit 0
|
||||
fi
|
||||
echo "[FAIL] v1_hakovm_array_push_size_canary_vm (rc=$rc, expect 2)" >&2; exit 1
|
||||
Reference in New Issue
Block a user