Commit 0c73e84f
0c73e84ffa0eMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
spinelc: --emit-symbol-map (emitted C symbol -> Ruby name JSON)
Restores the legacy backend's symbol-map dump in the C driver. Gated on
SPINEL_EMIT_SYMBOL_MAP (set by spinel --emit-symbol-map), codegen walks
the analyzed scopes after analyze_program and writes
{"symbols":[{"c","ruby","kind","file","line"}, ...]}
then short-circuits codegen (no binary). The C symbol comes from
emit_method_cname so it matches what codegen actually emits -- note the C
path mangles singleton methods as sp_<Class>_s_<m> (not the legacy
_cls_). Ruby names are name / Class#m / Class.m; file/line come
from the def node and are null unless positions were stamped. The driver
sets SPINEL_DEBUG so they are.
make check: 846 pass, 0 fail.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 0c73e84ffa0e
- Parent
- f14172a22bcf
spinelmodifiedView file
# Options:# -o FILE Output file (binary, or C when combined with -c)# -c Generate C source only, don't compile# --emit-symbol-map Dump emitted-symbol -> Ruby-name map as JSON, no binary# -S Print generated C to stdout# -E Run the compiled binary instead of saving it; the# first .rb file ends spinel-flag parsing, and the restC_ONLY=0STDOUT_MODE=0RUN_MODE=0EMIT_SYMBOL_MAP=0OPT_LEVEL="2"CC_CMD="cc"EXTRA_FLAGS="" EVAL_USED=1 shift ;; -c) C_ONLY=1; shift ;; --emit-symbol-map) # Dump emitted-C-symbol -> Ruby-name map as JSON # (-> app.symbols.json). Analyze-only; writes no binary. EMIT_SYMBOL_MAP=1; shift ;; -S) STDOUT_MODE=1; shift ;; -E) RUN_MODE=1; shift ;; *.rb) echo "Options:" >&2 echo " -o FILE Output file" >&2 echo " -c C source only (don't compile)" >&2 echo " --emit-symbol-map Dump emitted-symbol -> Ruby-name map as JSON, no binary" >&2 echo " -S Print C to stdout" >&2 echo " -E Run the compiled binary; leftover args become its ARGV" >&2 echo " -O LEVEL Optimization level (default: 2)" >&2 export SPINEL_LINE_MAP=1fi# --emit-symbol-map: analyze-only. spinelc writes the JSON itself (driven by# SPINEL_EMIT_SYMBOL_MAP) and emits an empty translation unit; SPINEL_DEBUG# makes the parser stamp node positions so each symbol carries its file/line.if [ "$EMIT_SYMBOL_MAP" -eq 1 ]; then SYM_OUT="${OUTPUT:-$BASENAME.symbols.json}" export SPINEL_DEBUG=1 export SPINEL_EMIT_SYMBOL_MAP="$SYM_OUT" if ! "$SPINELC" "$SOURCE" >/dev/null; then echo "spinel: emit-symbol-map failed" >&2 exit 1 fi echo "Wrote $SYM_OUT" >&2 exit 0fi# Step 1: Compile (parse + analyze + codegen) — spinelc emits C.if [ "$STDOUT_MODE" -eq 1 ]; then "$SPINELC" "$SOURCE"src/codegen.cmodifiedView file
Loading diff…