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 + 1
1606316063 end
1606416064 end
16065+ # ptr_array RHS (e.g., `A, B = [1,6].map { (0..n).map { ... } }`
16066+ # whose outer map returns int_array_ptr_array). Each target
16067+ # is a class-typed (here IntArray*) element of the PtrArray.
16068+ if is_ptr_array_type(rhs_t) == 1
16069+ elem_pt = ptr_array_elem_type(rhs_t)
16070+ tmp_n = new_temp
16071+ emit(" sp_PtrArray *" + tmp_n + " = " + compile_expr(val_id) + ";")
16072+ ti3 = 0
16073+ while ti3 < targets.length
16074+ tid = targets[ti3]
16075+ if @nd_type[tid] == "ConstantTargetNode"
16076+ cn = @nd_name[tid]
16077+ if scope_n != ""
16078+ cn = scope_n + "_" + cn
16079+ end
16080+ emit(" cst_" + cn + " = (" + c_type(elem_pt) + ")sp_PtrArray_get(" + tmp_n + ", " + ti3.to_s + ");")
16081+ end
16082+ ti3 = ti3 + 1
16083+ end
16084+ end
1606516085 end
1606616086 @current_lexical_scope = old_scope
1606716087 mci = mci + 1