Commit eab5b038

eab5b038c08bMerged

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

Description

style: strip issue-number suffixes from identifiers and comments

Issue numbers in code (local variables like cls_idx_404, owner_419, ovr_422) and in comments (Issue #404 Phase 3:, (see #305), etc.) are noise for future readers: the code describes what it does, and historical "this fix tied to issue N" provenance lives in the git log / issue tracker, not the source file.

Bulk replace:

  • <name>_<3-digit-issue-num>[<suffix>] -> <name>[<suffix>] in spinel_analyze.rb, spinel_codegen.rb, lib/sp_runtime.h.
  • Issue #N: / (issue #N) / Ref #N / (#N) etc. in comments dropped.

One scope collision repaired by hand: compile_object_method_expr had both a mrb_int owner_419 (cls_cmethod_owner result) and a string owner (find_method_owner result) in different branches. The bulk rename collapsed both to owner, which the analyser couldn't reconcile. Renamed the int variant to owner_idx so the two names stay distinct.

Bootstrap 4-way fixpoint OK; optcarrot checksum 59662 unchanged; 386 tests pass. The change is mechanical -- no behaviour change.

Details

Commit
eab5b038c08b
Parent
c85fd4a6f4c4

lib/sp_runtime.hmodifiedView file

@@ -99,7 +99,7 @@
9999 typedef struct{mrb_int first;mrb_int last;}sp_Range;
100100 static sp_Range sp_range_new(mrb_int f,mrb_int l){sp_Range r;r.first=f;r.last=l;return r;}
101101
102-/* ---- Class object (issue #404 Phase 1) ----
102+/* ---- Class object ----
103103 Value-type Class reference: a single class id that indexes into
104104 the per-program sp_class_names[] table emitted by codegen. Lets
105105 `c = Foo` produce a runtime value (`(sp_Class){<id>}`) instead of
@@ -124,7 +124,7 @@
124124 /* sp_Time keeps Time.now / Time.at as value-typed structs. d78149b's
125125 sub-second precision is preserved by inlining tv_sec + tv_nsec/1e9
126126 at every Time#to_f / Time#- call site (see spinel_codegen.rb).
127- Issue #418: `is_utc` distinguishes UTC-coerced times (set by
127+ `is_utc` distinguishes UTC-coerced times (set by
128128 `Time#utc`) from local-zone times — a presentation-only flag,
129129 the underlying epoch is the same instant either way. iso8601 /
130130 strftime check the flag at format time. C99 compound literals
@@ -169,7 +169,7 @@
169169 h->next = sp_str_heap;
170170 h->size = total;
171171 sp_str_heap = h;
172- /* Don't fold string-heap pressure into sp_gc_bytes (issue #99): the
172+ /* Don't fold string-heap pressure into sp_gc_bytes : the
173173 threshold heuristic in sp_gc_alloc is keyed on heap survivors, and
174174 the str-heap mark-sweep that runs alongside (sp_str_sweep,
175175 called from sp_gc_collect) doesn't add surviving strings back into
@@ -212,7 +212,7 @@
212212 static inline int sp_utf8_encode(uint32_t cp,char*out){if(cp<0x80){out[0]=(char)cp;return 1;}if(cp<0x800){out[0]=(char)(0xC0|(cp>>6));out[1]=(char)(0x80|(cp&0x3F));return 2;}if(cp<0x10000){out[0]=(char)(0xE0|(cp>>12));out[1]=(char)(0x80|((cp>>6)&0x3F));out[2]=(char)(0x80|(cp&0x3F));return 3;}out[0]=(char)(0xF0|(cp>>18));out[1]=(char)(0x80|((cp>>12)&0x3F));out[2]=(char)(0x80|((cp>>6)&0x3F));out[3]=(char)(0x80|(cp&0x3F));return 4;}
213213 static mrb_int sp_str_length(const char*s){mrb_int n=0;while(*s){s+=sp_utf8_advance(s);n++;}return n;}
214214 static mrb_int sp_str_ord(const char*s){if(!*s)return 0;uint32_t cp;sp_utf8_decode(s,&cp);return(mrb_int)cp;}
215-/* NULL-safe string equality. Issue #129: ENV[] returns NULL for unset vars
215+/* NULL-safe string equality. ENV[] returns NULL for unset vars
216216 (the dispatch is `sp_str_dup_external(getenv(...))`, which propagates
217217 NULL), so emitted strcmp(...) on the result of `ENV["X"] == "1"` would
218218 dereference NULL on either side. nil-vs-string equality is false in
@@ -247,8 +247,8 @@
247247 }
248248 }
249249
250-/* Issue #414: Time#strftime — format the time per `fmt` using libc
251- strftime. The is_utc flag (#418) selects gmtime vs localtime so a
250+/* Time#strftime — format the time per `fmt` using libc
251+ strftime. The is_utc flag selects gmtime vs localtime so a
252252 `Time.now.utc.strftime("%H")` runs against the UTC broken-down
253253 value. Returns a freshly-allocated string (sp_str_dup_external'd
254254 into the str heap so GC tracks it). The 256-byte buffer is enough
@@ -265,7 +265,7 @@
265265 return sp_str_dup_external(buf);
266266 }
267267
268-/* Issue #414: Time#iso8601 — RFC 3339 style. Format the date+time
268+/* Time#iso8601 — RFC 3339 style. Format the date+time
269269 prefix with strftime, then compute the UTC offset manually via
270270 `mktime(gmtime(s)) - s` rather than relying on strftime's %z,
271271 because MSVCRT's %z emits the timezone *name* rather than ±HHMM,
@@ -276,7 +276,7 @@
276276 Sub-second precision is intentionally omitted: CRuby's iso8601
277277 also drops it unless the caller passes a precision arg, which
278278 Phase 1 doesn't support.
279- Issue #418: when is_utc is set, format against gmtime and emit the
279+ when is_utc is set, format against gmtime and emit the
280280 trailing "Z" suffix CRuby uses for UTC iso8601. */
281281 static const char *sp_time_iso8601(sp_Time t) {
282282 char buf[64];
@@ -315,7 +315,7 @@
315315 return sp_str_dup_external(buf);
316316 }
317317
318-/* Issue #418: Time#utc — same instant, presentation flag flipped to
318+/* Time#utc — same instant, presentation flag flipped to
319319 UTC. iso8601 / strftime check is_utc at format time. CRuby's Time
320320 internally tracks a similar "gmt" flag; the value-typed sp_Time
321321 stores it inline. */
@@ -723,7 +723,7 @@
723723 static const char*sp_PtrArray_inspect(sp_PtrArray*a){sp_String*s=sp_String_new("[");for(mrb_int i=0;i<a->len;i++){if(i>0)sp_String_append(s,", ");sp_String_append(s,"#<Object>");}sp_String_append(s,"]");return s->data;}
724724 /* Nested-array inspect: when codegen knows the ptr_array's element
725725 type is one of the four built-in T_array shapes, recurse into the
726- matching primitive inspect (issue #169). */
726+ matching primitive inspect . */
727727 static const char*sp_IntArrayPtrArray_inspect(sp_PtrArray*a){sp_String*s=sp_String_new("[");for(mrb_int i=0;i<a->len;i++){if(i>0)sp_String_append(s,", ");sp_String_append(s,sp_IntArray_inspect((sp_IntArray*)a->data[i]));}sp_String_append(s,"]");return s->data;}
728728 static const char*sp_FloatArrayPtrArray_inspect(sp_PtrArray*a){sp_String*s=sp_String_new("[");for(mrb_int i=0;i<a->len;i++){if(i>0)sp_String_append(s,", ");sp_String_append(s,sp_FloatArray_inspect((sp_FloatArray*)a->data[i]));}sp_String_append(s,"]");return s->data;}
729729 static const char*sp_StrArrayPtrArray_inspect(sp_PtrArray*a){sp_String*s=sp_String_new("[");for(mrb_int i=0;i<a->len;i++){if(i>0)sp_String_append(s,", ");sp_String_append(s,sp_StrArray_inspect((sp_StrArray*)a->data[i]));}sp_String_append(s,"]");return s->data;}
@@ -901,14 +901,14 @@
901901
902902 /* NaN-boxed polymorphic value */
903903 typedef uint64_t sp_RbValue;
904-#define SP_TAG_INT 0
905-#define SP_TAG_STR 1
906-#define SP_TAG_FLT 2
904+#define SP_TAG_INT 0
905+#define SP_TAG_STR 1
906+#define SP_TAG_FLT 2
907907 #define SP_TAG_BOOL 3
908-#define SP_TAG_NIL 4
909-#define SP_TAG_OBJ 5
910-#define SP_TAG_SYM 6
911-/* Issue #404 Phase 3: Class values boxed into a poly slot (e.g.
908+#define SP_TAG_NIL 4
909+#define SP_TAG_OBJ 5
910+#define SP_TAG_SYM 6
911+/* Class values boxed into a poly slot (e.g.
912912 as ancestors-array elements). cls_id of the sp_RbVal carries
913913 the boxed sp_Class's cls_id directly so unboxing is just a
914914 field read. */
@@ -919,22 +919,22 @@
919919 table as before. The element-type tag and the array cls_id are
920920 paired by `array_cls_id = -element_tag - 1`. */
921921 #define SP_BUILTIN_ARRAY_OF(tag) (-(tag) - 1)
922-#define SP_BUILTIN_INT_ARRAY SP_BUILTIN_ARRAY_OF(SP_TAG_INT) /* -1 */
923-#define SP_BUILTIN_STR_ARRAY SP_BUILTIN_ARRAY_OF(SP_TAG_STR) /* -2 */
924-#define SP_BUILTIN_FLT_ARRAY SP_BUILTIN_ARRAY_OF(SP_TAG_FLT) /* -3 */
925-#define SP_BUILTIN_PTR_ARRAY SP_BUILTIN_ARRAY_OF(SP_TAG_OBJ) /* -6 */
926-#define SP_BUILTIN_SYM_ARRAY SP_BUILTIN_ARRAY_OF(SP_TAG_SYM) /* -7 */
927-#define SP_BUILTIN_PROC (-9) /* sp_Proc *, distinct from any tag-based id */
928-#define SP_BUILTIN_RANGE (-10) /* sp_Range *, heap copy of stack-typed sp_Range when crossing into poly */
929-#define SP_BUILTIN_TIME (-11) /* sp_Time *, heap copy of stack-typed sp_Time when crossing into poly */
930-#define SP_BUILTIN_POLY_ARRAY (-12) /* sp_PolyArray *, array of sp_RbVal */
922+#define SP_BUILTIN_INT_ARRAY SP_BUILTIN_ARRAY_OF(SP_TAG_INT) /* -1 */
923+#define SP_BUILTIN_STR_ARRAY SP_BUILTIN_ARRAY_OF(SP_TAG_STR) /* -2 */
924+#define SP_BUILTIN_FLT_ARRAY SP_BUILTIN_ARRAY_OF(SP_TAG_FLT) /* -3 */
925+#define SP_BUILTIN_PTR_ARRAY SP_BUILTIN_ARRAY_OF(SP_TAG_OBJ) /* -6 */
926+#define SP_BUILTIN_SYM_ARRAY SP_BUILTIN_ARRAY_OF(SP_TAG_SYM) /* -7 */
927+#define SP_BUILTIN_PROC (-9) /* sp_Proc *, distinct from any tag-based id */
928+#define SP_BUILTIN_RANGE (-10) /* sp_Range *, heap copy of stack-typed sp_Range when crossing into poly */
929+#define SP_BUILTIN_TIME (-11) /* sp_Time *, heap copy of stack-typed sp_Time when crossing into poly */
930+#define SP_BUILTIN_POLY_ARRAY (-12) /* sp_PolyArray *, array of sp_RbVal */
931931 /* Hash variant cls_ids — boxed into the cls_id of a poly slot so
932932 Hash#dig can recover the concrete hash type at runtime. */
933-#define SP_BUILTIN_STR_INT_HASH (-13)
934-#define SP_BUILTIN_STR_STR_HASH (-14)
935-#define SP_BUILTIN_INT_STR_HASH (-15)
936-#define SP_BUILTIN_SYM_INT_HASH (-16)
937-#define SP_BUILTIN_SYM_STR_HASH (-17)
933+#define SP_BUILTIN_STR_INT_HASH (-13)
934+#define SP_BUILTIN_STR_STR_HASH (-14)
935+#define SP_BUILTIN_INT_STR_HASH (-15)
936+#define SP_BUILTIN_SYM_INT_HASH (-16)
937+#define SP_BUILTIN_SYM_STR_HASH (-17)
938938 #define SP_BUILTIN_STR_POLY_HASH (-18)
939939 #define SP_BUILTIN_SYM_POLY_HASH (-19)
940940 #define SP_BUILTIN_POLY_POLY_HASH (-20)
@@ -946,11 +946,11 @@
946946 static sp_RbVal sp_box_nil(void) { sp_RbVal r; r.tag = SP_TAG_NIL; r.cls_id = 0; r.v.i = 0; return r; }
947947 static sp_RbVal sp_box_obj(void *p, int cls_id) { sp_RbVal r; r.tag = SP_TAG_OBJ; r.cls_id = cls_id; r.v.p = p; return r; }
948948 static sp_RbVal sp_box_sym(sp_sym v) { sp_RbVal r; r.tag = SP_TAG_SYM; r.cls_id = 0; r.v.i = (mrb_int)v; return r; }
949-/* Issue #404 Phase 3: box a sp_Class into a poly slot. */
949+/* box a sp_Class into a poly slot. */
950950 static sp_RbVal sp_box_class(sp_Class c) { sp_RbVal r; r.tag = SP_TAG_CLASS; r.cls_id = (int)c.cls_id; r.v.i = c.cls_id; return r; }
951951
952-/* Issue #404 Phase 3 Tier 4: every non-value-type sp_<C> starts
953- with `mrb_int cls_id` (#422). Read it back from a void* when
952+/* every non-value-type sp_<C> starts
953+ with `mrb_int cls_id`. Read it back from a void* when
954954 the static type at the call site has lost the cls_id (e.g.
955955 sp_PtrArray_get returning void*). NULL-safe via the guard
956956 on p; expects p to actually point at a user-class struct
@@ -1036,7 +1036,7 @@
10361036 }
10371037 static mrb_bool sp_poly_nil_p(sp_RbVal v) { return v.tag == SP_TAG_NIL; }
10381038 static mrb_bool sp_poly_truthy(sp_RbVal v) { return !(v.tag == SP_TAG_NIL || (v.tag == SP_TAG_BOOL && !v.v.b)); }
1039-/* Issue #404 Phase 3: forward-declare the program-emitted class
1039+/* forward-declare the program-emitted class
10401040 name lookup so sp_poly_to_s's SP_TAG_CLASS arm resolves.
10411041 The codegen emits a 1-line stub when no class const is used,
10421042 or the real body when @needs_class_table fires. The forward
@@ -1196,7 +1196,7 @@
11961196 static mrb_int sp_StrPolyHash_length(sp_StrPolyHash*h){return h->len;}
11971197 static sp_StrArray*sp_StrPolyHash_keys(sp_StrPolyHash*h){sp_StrArray*a=sp_StrArray_new();for(mrb_int i=0;i<h->len;i++)sp_StrArray_push(a,h->order[i]);return a;}
11981198 static sp_PolyArray*sp_StrPolyHash_values(sp_StrPolyHash*h){sp_PolyArray*a=sp_PolyArray_new();for(mrb_int i=0;i<h->len;i++)sp_PolyArray_push(a,sp_StrPolyHash_get(h,h->order[i]));return a;}
1199-/* Issue #426: Hash#merge for str_poly_hash. Same shape as the
1199+/* Hash#merge for str_poly_hash. Same shape as the
12001200 StrIntHash / SymPolyHash siblings -- copy recv's entries into a
12011201 fresh hash, then overlay other's. */
12021202 static sp_StrPolyHash*sp_StrPolyHash_merge(sp_StrPolyHash*a,sp_StrPolyHash*b){sp_StrPolyHash*r=sp_StrPolyHash_new();for(mrb_int i=0;i<a->len;i++)sp_StrPolyHash_set(r,a->order[i],sp_StrPolyHash_get(a,a->order[i]));for(mrb_int i=0;i<b->len;i++)sp_StrPolyHash_set(r,b->order[i],sp_StrPolyHash_get(b,b->order[i]));return r;}
@@ -1452,7 +1452,7 @@
14521452 static sp_Val *sp_lam_bool(mrb_bool b) { sp_Val *v = (sp_Val *)sp_lam_alloc(sizeof(sp_Val)); v->tag = SP_BOOL2; v->u.bval = b; return v; }
14531453 static sp_Val sp_lam_nil_val = { .tag = SP_NIL2 };
14541454 static sp_Val *sp_lam_call(sp_Val *f, sp_Val *arg) { return f->u.proc.fn(f, arg); }
1455-/* Multi-arg lambda dispatch (issue #400). The fn pointer is stored
1455+/* Multi-arg lambda dispatch . The fn pointer is stored
14561456 typed as `sp_fn_t` (1-arg) so re-cast at the call site to the
14571457 right arity. The generated lambda body is declared with the
14581458 matching arity so the actual ABI matches. */