Commit 497d6970

497d69700e72Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 5 files · +4 added · ~1 modified

Description

Merge pull request #323 from ryanseys/fix/divmod-tuple-inspect

fix(codegen): inspect tuple:int,int / tuple:int,float for p

Details

Commit
497d69700e72
Parent
760bc936cd54
Merge parent
bfe58c281865

spinel_codegen.rbmodifiedView file

@@ -31811,6 +31811,20 @@
3181131811 @needs_int_array = 1
3181231812 return "sp_SymArrayPtrArray_inspect(" + val + ")"
3181331813 end
31814+ # Tuples produced by methods that return Ruby Arrays of fixed
31815+ # arity (Integer#divmod, Array#minmax, etc.). Without an inspect
31816+ # path here, `p arr.minmax` would fall through to printf("%lld",...)
31817+ # and emit the struct pointer. Format as Ruby's "[a, b]" so the
31818+ # output round-trips with CRuby.
31819+ if at == "tuple:int,int"
31820+ return "sp_sprintf(\"[%lld, %lld]\", (long long)" + val + "->_0, (long long)" + val + "->_1)"
31821+ end
31822+ if at == "tuple:int,float"
31823+ return "sp_sprintf(\"[%lld, %s]\", (long long)" + val + "->_0, sp_float_inspect(" + val + "->_1))"
31824+ end
31825+ if at == "tuple:float,float"
31826+ return "sp_sprintf(\"[%s, %s]\", sp_float_inspect(" + val + "->_0), sp_float_inspect(" + val + "->_1))"
31827+ end
3181431828 ""
3181531829 end
3181631830