Commit 2f1e7850
2f1e785069dcMerged
Ryan Seys <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
feat(parse): support ShareableConstantNode (# shareable_constant_value: comment)
Adds parser case that lowers ShareableConstantNode to its inner ConstantWriteNode by rewinding node_counter and re-flattening at the same slot. The wrapper carries no semantic information Spinel needs (no Ractor runtime), and 12+ codegen scanner passes look for ConstantWriteNode at top-level of statement lists; parser-side lowering lets them all work unchanged.
This is the same trick the existing PM_IT_LOCAL_VARIABLE_READ_NODE
arm uses to rename it to _1.
Test: test/shareable_constant.rb (verifies the wrapped const write still produces working const reads/methods). Bootstrap: gen2.c == gen3.c.
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 2f1e785069dc
- Parent
- 40403f434501
spinel_parse.cmodifiedView file
node->location.start - g_parser->start); exit(1); } case PM_SHAREABLE_CONSTANT_NODE: { /* `# shareable_constant_value: literal` magic comment that wraps a constant write. Spinel has no Ractor support, so the shareability state is a no-op. We lower at parse time by flattening the inner write directly into THIS node slot and discarding the wrapper. Many later codegen scanner passes look for ConstantWriteNode at the top level of statements; lowering here lets all of them work without modification. */ pm_shareable_constant_node_t *n = (pm_shareable_constant_node_t *)node; /* Re-flatten the inner write at *this* id by rewinding the counter. */ node_counter--; return flatten(n->write); } case PM_SPLAT_NODE: { pm_splat_node_t *n = (pm_splat_node_t *)node; N("SplatNode");