Commit adb76fd2

adb76fd253fdMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

chore(codegen): tighten poly_dispatch_return_type per Gemini review

Two stylistic cleanups suggested in Gemini's review of #56:

  • flatten the nested if/else in poly_dispatch_return_type to a single if/elsif (reads top-to-bottom, no negative path)
  • replace the if/end fallback at the tail with the ternary that is the prevailing style in spinel_codegen.rb (e.g. line 8028 gc_linkage = @needs_bigint == 1 ? "" : "static ")
  • same ternary applied to the is_poly_ret flag in compile_poly_method_call

Skipped Gemini's other two suggestions:

  • using String#empty? instead of s == "": spinel_codegen.rb consistently uses the == "" form; staying with the project's existing idiom rather than mixing styles.
  • building arg_strs via arr_exprs = [] + push + join: the empty [] literal infers as int_array in spinel's self-hosted type inference, so pushing strings would be a type error and break the bootstrap. The string-concat form mame chose is the safe self-host idiom here.

No behaviour change. Bootstrap fixed-point clean; 106 tests + 56 benches green.

Refs #56.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Details

Commit
adb76fd253fd
Parent
0f0c9dc05076

spinel_codegen.rbmodifiedView file

@@ -15707,18 +15707,13 @@
1570715707 rt = cls_method_return(ci, mname)
1570815708 if common == ""
1570915709 common = rt
15710- else
15711- if common != rt
15712- return "poly"
15713- end
15710+ elsif common != rt
15711+ return "poly"
1571415712 end
1571515713 end
1571615714 ci = ci + 1
1571715715 end
15718- if common == ""
15719- return "int"
15720- end
15721- common
15716+ common == "" ? "int" : common
1572215717 end
1572315718
1572415719 def compile_poly_method_call(nid, rc, mname)
@@ -15734,10 +15729,7 @@
1573415729 # disagree on that type, the result is sp_RbVal and each branch
1573515730 # boxes its concrete return value.
1573615731 ret_type = poly_dispatch_return_type(mname)
15737- is_poly_ret = 0
15738- if ret_type == "poly"
15739- is_poly_ret = 1
15740- end
15732+ is_poly_ret = ret_type == "poly" ? 1 : 0
1574115733 ret_ct = c_type(ret_type)
1574215734 ret_def = c_default_val(ret_type)
1574315735 # Stash the receiver in a temp so we don't re-evaluate the