Commit a9ca40b3
a9ca40b38368Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified
Description
Merge pull request #162 from mame/pr/unbox-poly-int-array-literal
fix(codegen): unbox poly elements when emitting an IntArray literal
Details
- Commit
- a9ca40b38368
- Parent
- d3a530b4042d
- Merge parent
- 98bf255871b4
spinel_codegen.rbmodifiedView file
@@ -20296,7 +20296,17 @@
2029620296
emit(" sp_IntArray *" + tmp + " = sp_IntArray_new();")2029720297
k = 02029820298
while k < elems.length20299-
emit(" sp_IntArray_push(" + tmp + ", " + compile_expr(elems[k]) + ");")20299+
ev = compile_expr(elems[k])20300+
et = infer_type(elems[k])20301+
# Unbox poly values when pushing into a (concrete) IntArray.20302+
# An ArrayNode literal whose elements are poly (e.g.20303+
# `[addr]` where addr's recorded type is sp_RbVal) needs the20304+
# int payload extracted via `.v.i`. Without this, the C20305+
# compiler rejects the push with "incompatible type".20306+
if et == "poly"20307+
ev = "(" + ev + ").v.i"20308+
end20309+
emit(" sp_IntArray_push(" + tmp + ", " + ev + ");")2030020310
k = k + 12030120311
end2030220312
tmptest/array_lit_unbox_poly.rbaddedView file
Loading diff…