Commit 3d2e8d1d

3d2e8d1d8754Merged

Ryan Seys <[email protected]> · 6 months ago · 4 files · +2 added · ~2 modified

Description

feat(parse,codegen): support GlobalVariableTargetNode ($a, $b = 1, 2)

Adds parser case (just emits name) and an arm in emit_multi_write_target alongside the existing LocalVariable and InstanceVariable cases. The new arm emits the same g_ = val shape that GlobalVariableWriteNode uses, so swap ($a, $b = $b, $a) and arbitrary multi-assign just work via the existing MultiWriteNode codegen.

Test: test/global_var_target.rb (basic + swap). Bootstrap: gen2.c == gen3.c.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Details

Commit
3d2e8d1d8754
Parent
135e1a3a3938

spinel_codegen.rbmodifiedView file

@@ -25339,6 +25339,12 @@
2533925339 end
2534025340 end
2534125341 end
25342+ if @nd_type[tid] == "GlobalVariableTargetNode"
25343+ # Multi-assign LHS: `$a, $b = 1, 2`. Same storage path as
25344+ # GlobalVariableWriteNode but without an embedded expression --
25345+ # the value is supplied by the caller.
25346+ emit(" " + sanitize_gvar(@nd_name[tid]) + " = " + value_expr + ";")
25347+ end
2534225348 end
2534325349
2534425350 # Handle `a, *b = rhs` / `*a, b = rhs` / `a, *b, c = rhs`.