Commit b764f192
b764f192c6f8Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 8 files · +6 added · ~2 modified
Description
Split the 19k-line code generator into six stage files
codegen.c had grown to 19.4k lines / 240 functions. It is now split by emission stage, sharing the former file-statics through codegen_internal.h:
- codegen_util.c buffers, escaping, C type names, regex registry, globals
- codegen_fold.c enumerable fusion (emit_*_expr), arg filling, dispatch
- codegen_call.c emit_call, array mutation, index writes, inlining, loops
- codegen_expr.c interpolation + expression emission
- codegen_stmt.c output calls, assignment, control flow, pattern match, rescue, the statement switches
- codegen.c boxing, scope/method/class/proc/fiber emission, driver
Cross-file functions and globals lost their static linkage and are declared in
the internal header; single-file helpers stay static. Two split hazards fixed
in the process: static Buf *g_pre landing in the header gave every unit its
own prelude buffer (state forked silently), and the one-line multi-declaration
static ... g_re_src; static ... g_re_flg; ... left the regex-literal registry
half per-unit, so the driver emitted no sp_re_pat_N definitions.
No behavior change: 845 pass / 0 fail / 0 error before and after.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- b764f192c6f8
- Parent
- 22d92395b987
MakefilemodifiedView file
# The binary emits C; the test harness invokes cc to link libspinel_rt.a.SPINELC = build/spinelc$(EXE)SPINELC_HDRS = src/node_table.h src/codegen.h src/types.h src/compiler.h src/analyze.hSPINELC_HDRS = src/node_table.h src/codegen.h src/codegen_internal.h src/types.h src/compiler.h src/analyze.hSPINELC_OBJ = build/csrc/node_table.o build/csrc/types.o build/csrc/compiler.o \ build/csrc/analyze.o build/csrc/codegen.o build/csrc/main.o build/csrc/analyze.o build/csrc/codegen.o build/csrc/codegen_util.o \ build/csrc/codegen_fold.o build/csrc/codegen_call.o \ build/csrc/codegen_expr.o build/csrc/codegen_stmt.o build/csrc/main.obuild/csrc: @mkdir -p build/csrcsrc/codegen.cmodifiedView file
Loading diff…
src/codegen_call.caddedView file
Loading diff…
src/codegen_expr.caddedView file
Loading diff…
src/codegen_fold.caddedView file
Loading diff…
src/codegen_internal.haddedView file
Loading diff…
src/codegen_stmt.caddedView file
Loading diff…
src/codegen_util.caddedView file
Loading diff…