Commit 2516ddf9
2516ddf9d780Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Merge pull request #1345 from matz/emit-symbol-map
Add --emit-symbol-map: export emitted-symbol → Ruby-name map (#1334)
Details
- Commit
- 2516ddf9d780
- Parent
- abc369aebf68
- Merge parent
- 7ae3c4810fed
spinelmodifiedView file
@@ -48,6 +48,7 @@
4848
C_ONLY=04949
EMIT_RBS=05050
EMIT_TYPES=051+
EMIT_SYMBOL_MAP=05152
STDOUT_MODE=05253
RUN_MODE=05354
# #line directives are on by default: they cost nothing at runtime (purely a@@ -140,6 +141,10 @@
140141
# diagnostics as JSON (for the ruby-lsp addon). Needs node141142
# positions, so it turns on SPINEL_DEBUG below.142143
EMIT_TYPES=1; DEBUG=1; shift ;;144+
--emit-symbol-map) # Dump emitted-symbol -> Ruby-name map as JSON (#1334).145+
# Runs codegen (the mangling lives there) but writes no146+
# binary. DEBUG on so node positions (file/line) are stamped.147+
EMIT_SYMBOL_MAP=1; DEBUG=1; shift ;;143148
-S) STDOUT_MODE=1; shift ;;144149
-E) RUN_MODE=1; shift ;;145150
*.rb)@@ -367,6 +372,28 @@
367372
exit 0368373
fi369374
375+
# --emit-symbol-map needs codegen (the C name-mangling lives there) but emits376+
# no binary: run codegen with SPINEL_EMIT_SYMBOL_MAP set, route the C output377+
# to a temp, and stop.378+
if [ "$EMIT_SYMBOL_MAP" -eq 1 ]; then379+
SYM_OUT="${OUTPUT:-$BASENAME.symbols.json}"380+
export SPINEL_EMIT_SYMBOL_MAP="$SYM_OUT"381+
SYM_C_TMP="$(mktemp /tmp/spinel_symc.XXXXXX)"382+
if [ -x "$CODEGEN_BIN" ]; then383+
"$CODEGEN_BIN" "$AST_TMP" "$IR_TMP" "$SYM_C_TMP"384+
else385+
ruby "$CODEGEN_RB" "$AST_TMP" "$IR_TMP" "$SYM_C_TMP"386+
fi387+
cg_rc=$?388+
rm -f "$SYM_C_TMP"389+
if [ $cg_rc -ne 0 ]; then390+
echo "spinel: codegen failed" >&2391+
exit 1392+
fi393+
echo "Wrote $SYM_OUT" >&2394+
exit 0395+
fi396+
370397
# Step 3: Codegen371398
if [ $STDOUT_MODE -eq 1 ]; then372399
if [ -x "$CODEGEN_BIN" ]; thenspinel_codegen.rbmodifiedView file
Loading diff…