Files
hakorune/tools/dev/hako_debug_run.sh
nyash-codex 97a776aac3 feat(phase73): Stage-3 ENV consolidation complete - Shell scripts
Phase 73-B: Unified legacy Stage-3 environment variables in 27 shell scripts:
- Replaced NYASH_PARSER_STAGE3=1 → NYASH_FEATURES=stage3
- Replaced HAKO_PARSER_STAGE3=1 → NYASH_FEATURES=stage3
- Updated all variant patterns (with/without assignments)

Files modified (27 total):
- tools/dev/*.sh (9 files)
- tools/dev_stageb.sh, dump_stageb_min_mir.sh, hakorune_emit_mir.sh
- tools/joinir_ab_test.sh, ny_selfhost_inline.sh
- tools/perf/*.sh, tools/selfhost/*.sh (9 files)
- tools/hako_check/dot_edges_smoke.sh, tools/selfhost_smoke.sh

Complete Phase 73 consolidation count:
- Phase 73-A: 20 test files + 2 special files (stage3 compat)
- Phase 73-B: 27 shell script files
- Total: 49 files with legacy Stage-3 ENV consolidated

Next: Phase 72 (JoinIR EXPERIMENT SSOT consolidation)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 12:38:01 +09:00

103 lines
3.0 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# hako_debug_run.sh — Stable wrapper to run .hako with Stage3
# Usage:
# tools/dev/hako_debug_run.sh [--internal|--delegate] [--core] [--print-env] <file.hako>
# tools/dev/hako_debug_run.sh [--internal|--delegate] -c '<code>'
# Notes:
# - Enables Stage3 + semicolon tolerancesmokes runner と同等)
# - 実行モード:
# --raw (既定): 直実行。inline Ny コンパイラ有効timeoutは延長。include が必要な時はこちら。
# --safe : ランナー経由。inline Ny コンパイラ無効化+ノイズフィルタ。
# --no-compiler : inline Ny コンパイラを明示的に無効化(--raw と併用可)。
# - Uses tools/smokes/v2/lib/test_runner.sh under the hoodsafe モード時)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"
require_env >/dev/null || exit 2
MODE_CODE=0
CODE=""
FILE=""
USE_INTERNAL=0
USE_DELEGATE=0
USE_CORE=0
PRINT_ENV=0
USE_RAW=1
NO_COMPILER=0
while [[ $# -gt 0 ]]; do
case "$1" in
-c|--code)
MODE_CODE=1
CODE="${2:-}"
shift 2
;;
--internal)
USE_INTERNAL=1; shift ;;
--delegate)
USE_DELEGATE=1; shift ;;
--core)
USE_CORE=1; shift ;;
--raw)
USE_RAW=1; shift ;;
--safe)
USE_RAW=0; shift ;;
--no-compiler)
NO_COMPILER=1; shift ;;
--print-env)
PRINT_ENV=1; shift ;;
-h|--help)
echo "Usage: $0 [--internal|--delegate] [--core] [--print-env] <file.hako> | -c '<code>'"; exit 0 ;;
*)
FILE="$1"; shift ;;
esac
done
if [[ "$MODE_CODE" -eq 0 && -z "$FILE" ]]; then
echo "[ERR] No file or -c '<code>' specified" >&2
exit 2
fi
# Base env (Stage-3 + tolerance)
export NYASH_FEATURES=stage3
export NYASH_FEATURES=stage3
export NYASH_PARSER_ALLOW_SEMICOLON=1
export NYASH_ENTRY_ALLOW_TOPLEVEL_MAIN=1
# Compiler policy (default: enabled, longer timeout). Use --no-compiler to disable.
export NYASH_NY_COMPILER_TIMEOUT_MS="${NYASH_NY_COMPILER_TIMEOUT_MS:-8000}"
if [[ "$NO_COMPILER" -eq 1 ]]; then
export NYASH_DISABLE_NY_COMPILER=1
export HAKO_DISABLE_NY_COMPILER=1
fi
if [[ "$USE_INTERNAL" -eq 1 ]]; then export HAKO_MIR_BUILDER_INTERNAL=1; fi
if [[ "$USE_DELEGATE" -eq 1 ]]; then export HAKO_MIR_BUILDER_DELEGATE=1; fi
if [[ "$USE_CORE" -eq 1 ]]; then export NYASH_GATE_C_CORE=1; export HAKO_GATE_C_CORE=1; fi
if [[ "$PRINT_ENV" -eq 1 ]]; then
echo "[ENV] NYASH_BIN=$NYASH_BIN"
env | grep -E '^(NYASH_|HAKO_)' | sort
fi
if [[ "$USE_RAW" -eq 1 ]]; then
# Direct run (inline compiler allowed unless --no-compiler)
if [[ "$MODE_CODE" -eq 1 ]]; then
tmpf="/tmp/hako_debug_run_$$.hako"; printf "%s\n" "$CODE" > "$tmpf"
"$NYASH_BIN" --backend vm "$tmpf"; rc=$?; rm -f "$tmpf"; exit $rc
else
"$NYASH_BIN" --backend vm "$FILE"
fi
else
# Safe run via test runner (inline compiler disabled; noise filtered)
if [[ "$MODE_CODE" -eq 1 ]]; then
run_nyash_vm -c "$CODE"
else
run_nyash_vm "$FILE"
fi
fi