Commit 820ef028

820ef0287db6Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified

Description

Merge pull request #289 from ryanseys/rs-node-shareable-constant

feat(parse): support ShareableConstantNode (# shareable_constant_value: comment)

Details

Commit
820ef0287db6
Parent
9b7a2ad0721a
Merge parent
2f1e785069dc

spinel_parse.cmodifiedView file

@@ -804,6 +804,19 @@
804804 node->location.start - g_parser->start);
805805 exit(1);
806806 }
807+ case PM_SHAREABLE_CONSTANT_NODE: {
808+ /* `# shareable_constant_value: literal` magic comment that wraps
809+ a constant write. Spinel has no Ractor support, so the
810+ shareability state is a no-op. We lower at parse time by
811+ flattening the inner write directly into THIS node slot and
812+ discarding the wrapper. Many later codegen scanner passes
813+ look for ConstantWriteNode at the top level of statements;
814+ lowering here lets all of them work without modification. */
815+ pm_shareable_constant_node_t *n = (pm_shareable_constant_node_t *)node;
816+ /* Re-flatten the inner write at *this* id by rewinding the counter. */
817+ node_counter--;
818+ return flatten(n->write);
819+ }
807820 case PM_SPLAT_NODE: {
808821 pm_splat_node_t *n = (pm_splat_node_t *)node;
809822 N("SplatNode");