Commit d6902a38
d6902a38958aMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
Merge pull request #217 from mame/pr/multi-write-ivar-widening
fix(codegen): scan multi-write ivar targets for type widening
Details
- Commit
- d6902a38958a
- Parent
- 531adf9ba0fe
- Merge parent
- 70c17fd90948
spinel_codegen.rbmodifiedView file
@@ -8447,6 +8447,30 @@
84478447
end84488448
end84498449
end8450+
# Multi-write to ivars: `@a, @b = pulse_0, pulse_1`. Mirrors the8451+
# single-write branch above so each ivar's type is widened from8452+
# the corresponding RHS slot. Without this the multi-write left8453+
# the ivars at their initial "int" guess and the struct came out8454+
# with mrb_int fields that the assigning method then tried to8455+
# overwrite with pointer values.8456+
if @nd_type[nid] == "MultiWriteNode"8457+
if @current_class_idx >= 08458+
targets_mw = parse_id_list(@nd_targets[nid])8459+
val_mw = @nd_expression[nid]8460+
ti_mw = 08461+
while ti_mw < targets_mw.length8462+
tid_mw = targets_mw[ti_mw]8463+
if @nd_type[tid_mw] == "InstanceVariableTargetNode"8464+
iname_mw = @nd_name[tid_mw]8465+
at_mw = scan_ivars_multi_target_type(val_mw, ti_mw)8466+
if at_mw != "int" && at_mw != "nil"8467+
update_ivar_type(@current_class_idx, iname_mw, at_mw)8468+
end8469+
end8470+
ti_mw = ti_mw + 18471+
end8472+
end8473+
end84508474
if @nd_type[nid] == "CallNode"84518475
mname = @nd_name[nid]84528476
recv = @nd_receiver[nid]test/multi_write_ivar_widening.rbaddedView file
Loading diff…
test/multi_write_ivar_widening.rb.expectedaddedView file
Loading diff…