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 end
84488448 end
84498449 end
8450+ # Multi-write to ivars: `@a, @b = pulse_0, pulse_1`. Mirrors the
8451+ # single-write branch above so each ivar's type is widened from
8452+ # the corresponding RHS slot. Without this the multi-write left
8453+ # the ivars at their initial "int" guess and the struct came out
8454+ # with mrb_int fields that the assigning method then tried to
8455+ # overwrite with pointer values.
8456+ if @nd_type[nid] == "MultiWriteNode"
8457+ if @current_class_idx >= 0
8458+ targets_mw = parse_id_list(@nd_targets[nid])
8459+ val_mw = @nd_expression[nid]
8460+ ti_mw = 0
8461+ while ti_mw < targets_mw.length
8462+ 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+ end
8469+ end
8470+ ti_mw = ti_mw + 1
8471+ end
8472+ end
8473+ end
84508474 if @nd_type[nid] == "CallNode"
84518475 mname = @nd_name[nid]
84528476 recv = @nd_receiver[nid]