Commit 3b53a628
3b53a628b217Merged
Ori Pekelman <[email protected]> · 5 months ago · 5 files · ~5 modified
Description
Add spinel --emit-types: position-keyed inferred types + degrade diagnostics
Part 2 of the typing arc — the data backend for the ruby-lsp addon. Emits
JSON: every node with a concrete inferred type keyed by source position
(1-based line / 0-based col, matching Prism's node.location), plus a focused
list of degrade diagnostics — methods whose signature widened to the boxed
poly slow path, positioned at the def.
- spinel_parse.c: emit node_col alongside node_line/node_file (Prism's line/column helper; column is concatenation-stable across require splicing).
- compiler_helpers.rb: load node_col into a dedicated @nd_col slot.
- spinel_analyze.rb: emit_types_json — per-node {file,line,col,type,rbs} from @nd_inferred_type + the position slots; diagnostics by matching each DefNode to its method via body-node id (the degrade lives in the signature tables, not the per-node cache, which holds context-specialised concrete types). Hand-rolled JSON (self-hosted subset has no stdlib json). Gated by SPINEL_EMIT_TYPES; positions need SPINEL_DEBUG, which the wrapper turns on.
- spinel:
--emit-typesanalyze-only mode -> app.types.json.
Verified: types JSON is valid, positions line up with Prism node starts, a
param that widens across call sites yields one diagnostic at its def, clean
programs yield none. Normal compile unaffected. ori fork (feat/typing).
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- 3b53a628b217
- Parent
- 40eca6faf074
compiler_helpers.rbmodifiedView file
@nd_value.push(0) @nd_line.push(0) # keep the source-map arrays parallel with the rest, so a @nd_file.push(0) # dynamically-allocated node can't drift them out of sync @nd_col.push(0) # (and the self-host inferencer needs the literal push here) @nd_content.push("") @nd_flags.push(0) @nd_operator.push("") @nd_value = Array.new(n, 0) @nd_line = Array.new(n, 0) @nd_file = Array.new(n, 0) @nd_col = Array.new(n, 0) @nd_content = Array.new(n, "") @nd_flags = Array.new(n, 0) @nd_operator = Array.new(n, "") if field == "node_file" @nd_file[nid] = val end # Debug/types export: 0-based source column for hover position keys. if field == "node_col" @nd_col[nid] = val end end # Debug multi-file map: record a FILE <id> <path> table entry emitted byspinelmodifiedView file
Loading diff…
spinel_analyze.rbmodifiedView file
Loading diff…
spinel_codegen.rbmodifiedView file
Loading diff…
spinel_parse.cmodifiedView file
Loading diff…