Commit fdc93fde
fdc93fdef75aMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Merge pull request #1276 from OriPekelman/pr/emit-rbs
Add spinel --emit-rbs: export whole-program inferred types as RBS
Details
- Commit
- fdc93fdef75a
- Parent
- 507158f61403
- Merge parent
- 5a899bc3c3f8
spinelmodifiedView file
@@ -43,6 +43,7 @@
4343
SOURCE=""4444
OUTPUT=""4545
C_ONLY=046+
EMIT_RBS=04647
STDOUT_MODE=04748
RUN_MODE=04849
OPT_LEVEL="2"@@ -107,6 +108,8 @@
107108
EVAL_USED=1108109
shift ;;109110
-c) C_ONLY=1; shift ;;111+
--emit-rbs) # Analyze-only: dump inferred signatures as RBS, no binary.112+
EMIT_RBS=1; shift ;;110113
-S) STDOUT_MODE=1; shift ;;111114
-E) RUN_MODE=1; shift ;;112115
*.rb)@@ -145,6 +148,23 @@
145148
fi146149
fi147150
151+
# --emit-rbs is analyze-only (stops before codegen), so the binary/C-output152+
# modes would be silently ignored alongside it — reject the conflict up front.153+
if [ "$EMIT_RBS" -eq 1 ]; then154+
if [ "$RUN_MODE" -eq 1 ]; then155+
echo "spinel: --emit-rbs cannot be combined with -E (run)" >&2156+
exit 2157+
fi158+
if [ "$C_ONLY" -eq 1 ]; then159+
echo "spinel: --emit-rbs cannot be combined with -c (C source only)" >&2160+
exit 2161+
fi162+
if [ "$STDOUT_MODE" -eq 1 ]; then163+
echo "spinel: --emit-rbs cannot be combined with -S (stdout)" >&2164+
exit 2165+
fi166+
fi167+
148168
# `-e` mode: write the accumulated inline script to a temp file and149169
# treat it as the source. Default output name is `a` since the150170
# inline form has no .rb basename to derive from. If both -e and a@@ -173,6 +193,7 @@
173193
echo "Options:" >&2174194
echo " -o FILE Output file" >&2175195
echo " -c C source only (don't compile)" >&2196+
echo " --emit-rbs Dump inferred type signatures as RBS (-> app.rbs), no binary" >&2176197
echo " -S Print C to stdout" >&2177198
echo " -E Run the compiled binary; leftover args become its ARGV" >&2178199
echo " -O LEVEL Optimization level (default: 2)" >&2@@ -239,6 +260,12 @@
239260
# int locals as bigint when mode == promote. Raise / wrap modes240261
# only care about the cc-time preprocessor switch added below.241262
export SPINEL_INT_OVERFLOW="$INT_OVERFLOW"263+
# RBS export mode: tell the analyzer to also dump inferred signatures.264+
# (Conflicting-mode checks are done up front with the other mode-conflict guards.)265+
if [ "$EMIT_RBS" -eq 1 ]; then266+
RBS_OUT="${OUTPUT:-$BASENAME.rbs}"267+
export SPINEL_EMIT_RBS="$RBS_OUT"268+
fi242269
if [ -x "$ANALYZE_BIN" ]; then243270
"$ANALYZE_BIN" "$AST_TMP" "$IR_TMP" $SEED_TMP244271
else@@ -249,6 +276,12 @@
249276
exit 1250277
fi251278
279+
# --emit-rbs is analyze-only: the signatures are written, stop before codegen.280+
if [ "$EMIT_RBS" -eq 1 ]; then281+
echo "Wrote $RBS_OUT" >&2282+
exit 0283+
fi284+
252285
# Step 3: Codegen253286
if [ $STDOUT_MODE -eq 1 ]; then254287
if [ -x "$CODEGEN_BIN" ]; thenspinel_analyze.rbmodifiedView file
Loading diff…