Commit 0041e8f0
0041e8f094afMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
spinelc: --emit-rbs (inferred type signatures as RBS)
Restores the legacy backend's RBS dump in the C driver. Gated on
SPINEL_EMIT_RBS (set by spinel --emit-rbs), codegen walks the analyzed
scopes/classes after analyze_program and writes a .rbs: top-level methods
wrapped in class Object, then a class C < Parent block per user class
with its @ivar: Type declarations and instance / self. method
signatures, then short-circuits codegen (no binary).
ty_to_rbs_into maps the TyKind lattice to RBS (containers recurse via
ty_array_elem / ty_hash_key/val; the boxed poly family and unknowns become
untyped), and a method whose params/return widened to untyped gets the
legacy "# spinel: widened to untyped (slow path)" comment.
make check: 846 pass, 0 fail.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 0041e8f094af
- Parent
- 0c73e84ffa0e
spinelmodifiedView file
# Options:# -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-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; theC_ONLY=0STDOUT_MODE=0RUN_MODE=0EMIT_RBS=0EMIT_SYMBOL_MAP=0OPT_LEVEL="2"CC_CMD="cc" EVAL_USED=1 shift ;; -c) C_ONLY=1; shift ;; --emit-rbs) # Dump inferred type signatures as RBS (-> app.rbs). # Analyze-only; writes no binary. EMIT_RBS=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 "Options:" >&2 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-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 export SPINEL_LINE_MAP=1fi# --emit-rbs: analyze-only. spinelc writes the .rbs itself (driven by# SPINEL_EMIT_RBS) and emits an empty translation unit. No source positions# needed, so the parser stays in its normal (fast) mode.if [ "$EMIT_RBS" -eq 1 ]; then RBS_OUT="${OUTPUT:-$BASENAME.rbs}" export SPINEL_EMIT_RBS="$RBS_OUT" if ! "$SPINELC" "$SOURCE" >/dev/null; then echo "spinel: emit-rbs failed" >&2 exit 1 fi echo "Wrote $RBS_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…