Commit 158d3531

158d35311abaMerged

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

Description

refactor: drop issue-number suffixes from local identifiers

Five groups of locals across spinel_analyze.rb and spinel_codegen.rb carried the issue number that introduced them (236, 239, 286, 304, 314) as a numeric suffix on every shadow-avoidance variable. The suffix was a tag for the introducing commit, not a semantic label, and the rule against session-only numbers in code applies.

Renamed by behavioral role per block:

  • codegen.rb chained-ivar empty-{} consensus path: ctor236 → typed_ctor (and friends).
  • codegen.rb class-method-default-padding path: cmidx239 / kk239 / arg_count239 / args_id239 / def_id239 → unsuffixed locals.
  • analyze.rb inherited-method widening: cls_ci_286 / cls_owner_286 / midx_286 / owner_286 / args_id_286 / arg_ids_286 / ptypes_286 / kk_286 / at_286 → inh_ prefix.
  • analyze.rb module-class-method widening: mfn239 / mi239 / args_id239 / arg_ids239 / pnames239 / ptypes239 → mod_ prefix.
  • analyze.rb module-singleton-accessor.method widening: every *304 → mua prefix.
  • analyze.rb value-type exclusion via poly-arg-passed: type_str314 → obj_type_str.

No behavior change; full test suite (411 tests) green and the i450 real-blog archive still compiles cleanly.

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

Details

Commit
158d35311aba
Parent
af0dc6e8e641

spinel_analyze.rbmodifiedView file

@@ -9935,33 +9935,33 @@
99359935 # finds the ancestor that actually defines the method, then
99369936 # we update *that* class's @cls_meth_ptypes.
99379937 if @current_class_idx >= 0
9938- cls_ci_286 = @current_class_idx
9939- cls_owner_286 = cls_ci_286
9940- midx_286 = cls_find_method_direct(cls_ci_286, mname)
9941- if midx_286 < 0
9942- owner_286 = find_method_owner(cls_ci_286, mname)
9943- if owner_286 != "" && owner_286 != @cls_names[cls_ci_286]
9944- cls_owner_286 = find_class_idx(owner_286)
9945- if cls_owner_286 >= 0
9946- midx_286 = cls_find_method_direct(cls_owner_286, mname)
9947- end
9948- end
9949- end
9950- if midx_286 >= 0
9951- args_id_286 = @nd_arguments[nid]
9952- if args_id_286 >= 0
9953- arg_ids_286 = get_args(args_id_286)
9954- ptypes_286 = cls_meth_ptypes_get(cls_owner_286, midx_286)
9955- if ptypes_286.length > 0
9956- kk_286 = 0
9957- while kk_286 < arg_ids_286.length
9958- at_286 = infer_type(arg_ids_286[kk_286])
9959- if kk_286 < ptypes_286.length
9960- ptypes_286[kk_286] = unify_call_types(ptypes_286[kk_286], at_286, arg_ids_286[kk_286])
9938+ inh_ci = @current_class_idx
9939+ inh_owner_ci = inh_ci
9940+ inh_midx = cls_find_method_direct(inh_ci, mname)
9941+ if inh_midx < 0
9942+ inh_owner_name = find_method_owner(inh_ci, mname)
9943+ if inh_owner_name != "" && inh_owner_name != @cls_names[inh_ci]
9944+ inh_owner_ci = find_class_idx(inh_owner_name)
9945+ if inh_owner_ci >= 0
9946+ inh_midx = cls_find_method_direct(inh_owner_ci, mname)
9947+ end
9948+ end
9949+ end
9950+ if inh_midx >= 0
9951+ inh_args_id = @nd_arguments[nid]
9952+ if inh_args_id >= 0
9953+ inh_arg_ids = get_args(inh_args_id)
9954+ inh_ptypes = cls_meth_ptypes_get(inh_owner_ci, inh_midx)
9955+ if inh_ptypes.length > 0
9956+ inh_k = 0
9957+ while inh_k < inh_arg_ids.length
9958+ inh_at = infer_type(inh_arg_ids[inh_k])
9959+ if inh_k < inh_ptypes.length
9960+ inh_ptypes[inh_k] = unify_call_types(inh_ptypes[inh_k], inh_at, inh_arg_ids[inh_k])
99619961 end
9962- kk_286 = kk_286 + 1
9962+ inh_k = inh_k + 1
99639963 end
9964- cls_meth_ptypes_put(cls_owner_286, midx_286, ptypes_286)
9964+ cls_meth_ptypes_put(inh_owner_ci, inh_midx, inh_ptypes)
99659965 end
99669966 end
99679967 end
@@ -10230,16 +10230,16 @@
1023010230 # teaches the synthetic function to accept the actual
1023110231 # arg type instead of the default `mrb_int`.
1023210232 if module_name_exists(rcname) == 1
10233- mfn239 = rcname + "_cls_" + @nd_name[nid]
10234- mi239 = find_method_idx(mfn239)
10235- if mi239 >= 0
10236- args_id239 = @nd_arguments[nid]
10237- if args_id239 >= 0
10238- arg_ids239 = get_args(args_id239)
10239- pnames239 = @meth_param_names[mi239].split(",")
10240- ptypes239 = @meth_param_types[mi239].split(",")
10241- widen_ptypes_from_args(arg_ids239, pnames239, ptypes239)
10242- @meth_param_types[mi239] = ptypes239.join(",")
10233+ mod_mfn = rcname + "_cls_" + @nd_name[nid]
10234+ mod_mi = find_method_idx(mod_mfn)
10235+ if mod_mi >= 0
10236+ mod_args_id = @nd_arguments[nid]
10237+ if mod_args_id >= 0
10238+ mod_arg_ids = get_args(mod_args_id)
10239+ mod_pnames = @meth_param_names[mod_mi].split(",")
10240+ mod_ptypes = @meth_param_types[mod_mi].split(",")
10241+ widen_ptypes_from_args(mod_arg_ids, mod_pnames, mod_ptypes)
10242+ @meth_param_types[mod_mi] = mod_ptypes.join(",")
1024310243 end
1024410244 end
1024510245 end
@@ -10255,42 +10255,42 @@
1025510255 # ternary arms type-mismatch when the caller passes a poly
1025610256 # value but the targets' params are still mrb_int.
1025710257 if @nd_type[nid] == "CallNode" && @nd_receiver[nid] >= 0
10258- outer_recv_304 = @nd_receiver[nid]
10259- if @nd_type[outer_recv_304] == "CallNode"
10260- inner_recv_304 = @nd_receiver[outer_recv_304]
10261- inner_mname_304 = @nd_name[outer_recv_304]
10262- if inner_recv_304 >= 0 && @nd_type[inner_recv_304] == "ConstantReadNode"
10263- mod_name_304 = @nd_name[inner_recv_304]
10264- if module_name_exists(mod_name_304) == 1
10265- rconsts_304 = module_acc_resolved(mod_name_304, inner_mname_304)
10266- if rconsts_304 != "" && rconsts_304 != "?"
10267- cands_304 = rconsts_304.split(";")
10268- outer_mname_304 = @nd_name[nid]
10269- args_id_304 = @nd_arguments[nid]
10270- if args_id_304 >= 0
10271- arg_ids_304 = get_args(args_id_304)
10272- cands_304.each { |cn_304|
10273- cci_304 = find_class_idx(cn_304)
10274- if cci_304 >= 0
10275- cmnames_304 = @cls_cmeth_names[cci_304].split(";")
10276- cmpall_304 = @cls_cmeth_ptypes[cci_304].split("|")
10277- cmidx_304 = 0
10278- while cmidx_304 < cmnames_304.length
10279- if cmnames_304[cmidx_304] == outer_mname_304 && cmidx_304 < cmpall_304.length
10280- cmpt_304 = cmpall_304[cmidx_304].split(",")
10281- kk_304 = 0
10282- while kk_304 < arg_ids_304.length
10283- at_304 = infer_type(arg_ids_304[kk_304])
10284- if kk_304 < cmpt_304.length
10285- cmpt_304[kk_304] = unify_call_types(cmpt_304[kk_304], at_304, arg_ids_304[kk_304])
10258+ mua_outer_recv = @nd_receiver[nid]
10259+ if @nd_type[mua_outer_recv] == "CallNode"
10260+ mua_inner_recv = @nd_receiver[mua_outer_recv]
10261+ mua_inner_mname = @nd_name[mua_outer_recv]
10262+ if mua_inner_recv >= 0 && @nd_type[mua_inner_recv] == "ConstantReadNode"
10263+ mua_mod_name = @nd_name[mua_inner_recv]
10264+ if module_name_exists(mua_mod_name) == 1
10265+ mua_rconsts = module_acc_resolved(mua_mod_name, mua_inner_mname)
10266+ if mua_rconsts != "" && mua_rconsts != "?"
10267+ mua_cands = mua_rconsts.split(";")
10268+ mua_outer_mname = @nd_name[nid]
10269+ mua_args_id = @nd_arguments[nid]
10270+ if mua_args_id >= 0
10271+ mua_arg_ids = get_args(mua_args_id)
10272+ mua_cands.each { |mua_cn|
10273+ mua_cci = find_class_idx(mua_cn)
10274+ if mua_cci >= 0
10275+ mua_cmnames = @cls_cmeth_names[mua_cci].split(";")
10276+ mua_cmpall = @cls_cmeth_ptypes[mua_cci].split("|")
10277+ mua_cmidx = 0
10278+ while mua_cmidx < mua_cmnames.length
10279+ if mua_cmnames[mua_cmidx] == mua_outer_mname && mua_cmidx < mua_cmpall.length
10280+ mua_cmpt = mua_cmpall[mua_cmidx].split(",")
10281+ mua_k = 0
10282+ while mua_k < mua_arg_ids.length
10283+ mua_at = infer_type(mua_arg_ids[mua_k])
10284+ if mua_k < mua_cmpt.length
10285+ mua_cmpt[mua_k] = unify_call_types(mua_cmpt[mua_k], mua_at, mua_arg_ids[mua_k])
1028610286 end
10287- kk_304 = kk_304 + 1
10287+ mua_k = mua_k + 1
1028810288 end
10289- cmpall_304[cmidx_304] = cmpt_304.join(",")
10290- @cls_cmeth_ptypes[cci_304] = cmpall_304.join("|")
10289+ mua_cmpall[mua_cmidx] = mua_cmpt.join(",")
10290+ @cls_cmeth_ptypes[mua_cci] = mua_cmpall.join("|")
1029110291 @cls_cmeth_ptypes_version = @cls_cmeth_ptypes_version + 1
1029210292 end
10293- cmidx_304 = cmidx_304 + 1
10293+ mua_cmidx = mua_cmidx + 1
1029410294 end
1029510295 end
1029610296 # When the candidate is a module (not a class),
@@ -10300,14 +10300,14 @@
1030010300 # method widening branch above so a
1030110301 # `Mod.accessor.method(args)` call site widens
1030210302 # the synthetic top-level function's params.
10303- if module_name_exists(cn_304) == 1
10304- mfn_304m = cn_304 + "_cls_" + outer_mname_304
10305- mi_304m = find_method_idx(mfn_304m)
10306- if mi_304m >= 0
10307- pnames_304m = @meth_param_names[mi_304m].split(",")
10308- ptypes_304m = @meth_param_types[mi_304m].split(",")
10309- widen_ptypes_from_args(arg_ids_304, pnames_304m, ptypes_304m)
10310- @meth_param_types[mi_304m] = ptypes_304m.join(",")
10303+ if module_name_exists(mua_cn) == 1
10304+ mua_mod_mfn = mua_cn + "_cls_" + mua_outer_mname
10305+ mua_mod_mi = find_method_idx(mua_mod_mfn)
10306+ if mua_mod_mi >= 0
10307+ mua_mod_pnames = @meth_param_names[mua_mod_mi].split(",")
10308+ mua_mod_ptypes = @meth_param_types[mua_mod_mi].split(",")
10309+ widen_ptypes_from_args(mua_arg_ids, mua_mod_pnames, mua_mod_ptypes)
10310+ @meth_param_types[mua_mod_mi] = mua_mod_ptypes.join(",")
1031110311 end
1031210312 end
1031310313 }
@@ -17072,10 +17072,10 @@
1707217072 # the call site boxes a value-type instance and
1707317073 # mismatches sp_box_obj's `void *` slot.
1707417074 if all_val == 1
17075- type_str314 = "obj_" + @cls_names[i]
17075+ obj_type_str = "obj_" + @cls_names[i]
1707617076 pai = 0
1707717077 while pai < @poly_arg_passed_types.length
17078- if @poly_arg_passed_types[pai] == type_str314
17078+ if @poly_arg_passed_types[pai] == obj_type_str
1707917079 all_val = 0
1708017080 end
1708117081 pai = pai + 1