mirror of
https://github.com/fluffos/fluffos
synced 2026-08-12 18:26:06 -04:00
The compiler front-end's dumps are now JSON-native: each stage has ONE
model and its outputs (human text, --json envelope) are renderings of
it. lpcc ships in the wasm build so the fluffos-vscode extension can
bundle it with zero native setup.
--json stage outputs (one-line {"fluffos_lpcc":1,...} envelopes,
findable in mixed stdout; error_handler_t::replace everywhere since LPC
source bytes are not guaranteed UTF-8):
- tokens: positions, spellings, and token NAMES via lpc_token_name(),
a new public accessor in grammar.y's epilogue over the parser's
file-static yysymbol_name()/YYTRANSLATE table (grammar.autogen.*
regenerated via the pinned copy-back)
- ast: per-node source LINES (absolute compilation-unit lines) plus a
{"stage":"files"} companion envelope with the absolute-line->file
segment table and the string table so (string N) atoms resolve.
dump_tree's ~240-line hand-printed switch is GONE: the --ast text is
render_sexpr() over the same ast_json model (one switch, two
renderings; the rendered form is shape-compatible, one root per line,
function nodes carry their index)
- bytecode (default and -O0, envelope carries optimized:true/false):
the ONE opcode switch in disassemble() emits through a DisSink with
two backends -- text reproduces the legacy dump format (verified
byte-identical across a fixture corpus incl. switch tables and both
optimizer modes), json builds the model natively: per-program
sections (top + inherited), FUNCTIONS table via the shared
fn_table_rows(), instruction rows {a,x,m,o,f,l} with source file:line
NATIVE on every row, structured switch tables (resolved string keys,
case targets, minval), and the line tables. dump_prog_json() exported
via json_fwd
Disassembler fix folded in: loop_cond_number copied its 8-byte LPC_INT
literal (COPY_INT == COPY8) but advanced pc only 4, desyncing the
address stream -- '*** zero opcode ***' garbage and the next function's
listing swallowed. Advance sizeof(LPC_INT); 'bbranch_when_non_zero'
typo -> 'branch back'.
wasm: the emscripten branch builds lpcc-web (main_lpcc.cc as a plain
node CLI with NODERAWFS, so 'node lpcc.js <config> <file>' behaves like
the native binary; the unneeded event2 include is dropped -- mainlib.h
forward-declares init_main's event_base). Added to the wasm build
preset's target list, smoke-tested in the CI wasm job (compile a
testsuite file, expect the --json tokens envelope), and shipped in the
release wasm zip alongside the driver.
Full LPC testsuite passes; all stage outputs verified end-to-end by the
fluffos-vscode Compiler Explorer against fixture corpora.
Claude-Session: https://claude.ai/code/session_01AXqX4Kf55ArA39suS9cdCv
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| ci.yml | ||
| codeql-analysis.yml | ||
| config-docs.yml | ||
| coverity-scan.yml | ||
| docker-publish.yml | ||
| docs-sidebar.yml | ||
| gh-pages.yml | ||
| release.yml | ||