Commit b23d6492
b23d6492b25aMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +1 added · ~2 modified
Description
Merge pull request #294 from mame/pr/array-3d-nested
feat(codegen): nested array literals (3D+) via PolyArray-of-PolyArray
Details
- Commit
- b23d6492b25a
- Parent
- fa55c6c0dd16
- Merge parent
- 35ab107f4c5b
lib/sp_runtime.hmodifiedView file
@@ -740,6 +740,7 @@
740740
#define SP_BUILTIN_PROC (-9) /* sp_Proc *, distinct from any tag-based id */741741
#define SP_BUILTIN_RANGE (-10) /* sp_Range *, heap copy of stack-typed sp_Range when crossing into poly */742742
#define SP_BUILTIN_TIME (-11) /* sp_Time *, heap copy of stack-typed sp_Time when crossing into poly */743+
#define SP_BUILTIN_POLY_ARRAY (-12) /* sp_PolyArray *, array of sp_RbVal */743744
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;744745
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; }745746
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; }@@ -797,6 +798,7 @@
797798
}798799
return buf;799800
}801+
static sp_RbVal sp_box_poly_array(void *p) { return sp_box_obj(p, SP_BUILTIN_POLY_ARRAY); }800802
static void sp_poly_puts(sp_RbVal v) {801803
switch (v.tag) {802804
case SP_TAG_INT: printf("%lld\n", (long long)v.v.i); break;spinel_codegen.rbmodifiedView file
Loading diff…
test/array_3d_nested.rbaddedView file
Loading diff…