Commit 3cafbe02
3cafbe024df9Merged
Yusuke Endoh <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
fix(codegen): multi-write const targets from ptr_array RHS
A, B = [1,6].map { (0..n).map { ... } } lands a ptr_array
value (each element a typed inner array). The constant-multi-
write codegen had branches for ArrayNode literal RHS and
int_array RHS but no ptr_array branch — every target stayed
unset.
Add a ptr_array RHS branch that materializes the recv into a
sp_PtrArray temp, then writes each ConstantTargetNode with a
cast through the recorded element type
((sp_<elem> *)sp_PtrArray_get(tmp, i)).
Stacks on the multi-write-constants infrastructure (#213-style collection passes).
Details
- Commit
- 3cafbe024df9
- Parent
- 676669bd66be
spinel_codegen.rbmodifiedView file
@@ -16062,6 +16062,26 @@
1606216062
ti3 = ti3 + 11606316063
end1606416064
end16065+
# ptr_array RHS (e.g., `A, B = [1,6].map { (0..n).map { ... } }`16066+
# whose outer map returns int_array_ptr_array). Each target16067+
# is a class-typed (here IntArray*) element of the PtrArray.16068+
if is_ptr_array_type(rhs_t) == 116069+
elem_pt = ptr_array_elem_type(rhs_t)16070+
tmp_n = new_temp16071+
emit(" sp_PtrArray *" + tmp_n + " = " + compile_expr(val_id) + ";")16072+
ti3 = 016073+
while ti3 < targets.length16074+
tid = targets[ti3]16075+
if @nd_type[tid] == "ConstantTargetNode"16076+
cn = @nd_name[tid]16077+
if scope_n != ""16078+
cn = scope_n + "_" + cn16079+
end16080+
emit(" cst_" + cn + " = (" + c_type(elem_pt) + ")sp_PtrArray_get(" + tmp_n + ", " + ti3.to_s + ");")16081+
end16082+
ti3 = ti3 + 116083+
end16084+
end1606516085
end1606616086
@current_lexical_scope = old_scope1606716087
mci = mci + 1test/multi_write_map_block.rbaddedView file
Loading diff…
test/multi_write_map_block.rb.expectedaddedView file
Loading diff…