Commit 1755124b
1755124b4204Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
Merge pull request #275 from ryanseys/rs-node-implicit
feat(parse): support ImplicitNode top-level via parser-side unwrap
Details
- Commit
- 1755124b4204
- Parent
- 41a5e7c4e96b
- Merge parent
- c7e7e24ea718
spinel_parse.cmodifiedView file
@@ -468,14 +468,10 @@
468468
N("AssocNode");469469
R("key", n->key);470470
/* Hash shorthand `{ x: }` lowers to an AssocNode whose value is a471-
PM_IMPLICIT_NODE wrapping the actual LocalVariableReadNode (or472-
MethodCallNode for an undeclared name). Unwrap one level here so473-
the codegen never sees the implicit wrapper. */474-
pm_node_t *val = n->value;475-
if (val && PM_NODE_TYPE_P(val, PM_IMPLICIT_NODE)) {476-
val = ((pm_implicit_node_t *)val)->value;477-
}478-
R("value", val);471+
PM_IMPLICIT_NODE. The top-level PM_IMPLICIT_NODE case below472+
handles the unwrap by recursing into n->value at the same id473+
slot, so the codegen never sees the implicit wrapper here. */474+
R("value", n->value);479475
break;480476
}481477
case PM_KEYWORD_HASH_NODE: {@@ -766,6 +762,16 @@
766762
N("SourceEncodingNode");767763
break;768764
}765+
case PM_IMPLICIT_NODE: {766+
/* Wraps an implicit value reference, e.g. the value side of a767+
hash-shorthand `{x:}`. Lowers to its inner value at the same768+
id slot so the codegen never sees the implicit wrapper. Covers769+
PM_IMPLICIT_NODE in any context (AssocNode value, kwarg770+
shorthand inside KeywordHashNode, future Prism evolutions). */771+
pm_implicit_node_t *n = (pm_implicit_node_t *)node;772+
node_counter--;773+
return flatten(n->value);774+
}769775
case PM_SPLAT_NODE: {770776
pm_splat_node_t *n = (pm_splat_node_t *)node;771777
N("SplatNode");