Commit f0684077

f068407724a9Merged

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

Description

Merge pull request #315 from dak2/feat/hash-dig

feat(codegen): Hash#dig across hash variants

Details

Commit
f068407724a9
Parent
1a954abe2238
Merge parent
5c19d067935f

lib/sp_runtime.hmodifiedView file

@@ -765,6 +765,15 @@
765765 #define SP_BUILTIN_RANGE (-10) /* sp_Range *, heap copy of stack-typed sp_Range when crossing into poly */
766766 #define SP_BUILTIN_TIME (-11) /* sp_Time *, heap copy of stack-typed sp_Time when crossing into poly */
767767 #define SP_BUILTIN_POLY_ARRAY (-12) /* sp_PolyArray *, array of sp_RbVal */
768+/* Hash variant cls_ids — boxed into the cls_id of a poly slot so
769+ Hash#dig can recover the concrete hash type at runtime. */
770+#define SP_BUILTIN_STR_INT_HASH (-13)
771+#define SP_BUILTIN_STR_STR_HASH (-14)
772+#define SP_BUILTIN_INT_STR_HASH (-15)
773+#define SP_BUILTIN_SYM_INT_HASH (-16)
774+#define SP_BUILTIN_SYM_STR_HASH (-17)
775+#define SP_BUILTIN_STR_POLY_HASH (-18)
776+#define SP_BUILTIN_SYM_POLY_HASH (-19)
768777 typedef struct { int tag; int cls_id; union { mrb_int i; const char *s; mrb_float f; mrb_bool b; void *p; } v; } sp_RbVal;
769778 static sp_RbVal sp_box_int(mrb_int v) { sp_RbVal r; r.tag = SP_TAG_INT; r.cls_id = 0; r.v.i = v; return r; }
770779 static sp_RbVal sp_box_str(const char *v) { sp_RbVal r; r.tag = SP_TAG_STR; r.cls_id = 0; r.v.s = v; return r; }