Commit 62575f90
62575f90e417Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
spinelc: --emit-types (position-keyed types + diagnostics JSON)
Restores the legacy backend's ruby-lsp export in the C driver. Gated on
SPINEL_EMIT_TYPES (set by spinel --emit-types), codegen emits
{"types":[{file,line,col,type,rbs}...], "diagnostics":[{file,line,col,severity,message}...]}
after analyze_program, then short-circuits codegen. types lists every
node with a concrete inferred type keyed by its parser-stamped position
(SPINEL_DEBUG, which the driver enables); type is the legacy tag
(objects spelled obj_) and rbs its RBS form. diagnostics warns
once per method whose signature widened to the boxed poly slow path --
detected directly off each Scope (its def_node gives the position), so the
C path skips the legacy body-id matching dance.
make check: 846 pass, 0 fail.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 62575f90e417
- Parent
- 0041e8f094af
spinelmodifiedView file
# -o FILE Output file (binary, or C when combined with -c)# -c Generate C source only, don't compile# --emit-rbs Dump inferred type signatures as RBS (-> app.rbs), no binary# --emit-types Dump per-position inferred types + diagnostics as JSON, no binary# --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; theSTDOUT_MODE=0RUN_MODE=0EMIT_RBS=0EMIT_TYPES=0EMIT_SYMBOL_MAP=0OPT_LEVEL="2"CC_CMD="cc" --emit-rbs) # Dump inferred type signatures as RBS (-> app.rbs). # Analyze-only; writes no binary. EMIT_RBS=1; shift ;; --emit-types) # Dump per-position inferred types + degrade diagnostics as # JSON (for the ruby-lsp addon). Analyze-only; writes no binary. EMIT_TYPES=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 ;; echo " -o FILE Output file" >&2 echo " -c C source only (don't compile)" >&2 echo " --emit-rbs Dump inferred type signatures as RBS (-> app.rbs), no binary" >&2 echo " --emit-types Dump per-position inferred types + diagnostics as JSON" >&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 exit 0fi# --emit-types: analyze-only. Per-node types are keyed by source position, so# SPINEL_DEBUG makes the parser stamp node line/col/file. spinelc writes the# JSON (driven by SPINEL_EMIT_TYPES) and emits an empty translation unit.if [ "$EMIT_TYPES" -eq 1 ]; then TYPES_OUT="${OUTPUT:-$BASENAME.types.json}" export SPINEL_DEBUG=1 export SPINEL_EMIT_TYPES="$TYPES_OUT" if ! "$SPINELC" "$SOURCE" >/dev/null; then echo "spinel: emit-types failed" >&2 exit 1 fi echo "Wrote $TYPES_OUT" >&2 exit 0fi# --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.src/codegen.cmodifiedView file
Loading diff…