From 7f9773f971409fb0e94a46db688712ccf89b98ad Mon Sep 17 00:00:00 2001 From: dzaima Date: Sun, 1 May 2022 00:41:43 +0300 Subject: [PATCH] =?UTF-8?q?unified=20int=20&=20char=20cases=20for=20?= =?UTF-8?q?=E2=8D=89=20&=20=E2=8C=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/sfns.c | 44 ++++++++++++++++++++++++-------------------- src/core/arrFns.h | 16 ++++++++-------- src/core/stuff.c | 4 ++-- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/src/builtins/sfns.c b/src/builtins/sfns.c index 15348109..955df44e 100644 --- a/src/builtins/sfns.c +++ b/src/builtins/sfns.c @@ -445,8 +445,8 @@ B slash_c2(B t, B w, B x) { goto bit_ret; } #if SINGELI - case el_c8: case el_i8: { i8* xp=tyany_ptr(x); i8* rp=m_tyarrvO(&r,1,wsum,el2t(xe), 8); bmipopc_2slash8 (wp, xp, rp, wia); goto bit_ret; } - case el_c16:case el_i16: { i16* xp=tyany_ptr(x); i16* rp=m_tyarrvO(&r,2,wsum,el2t(xe), 16); bmipopc_2slash16(wp, xp, rp, wia); goto bit_ret; } + case el_i8: case el_c8: { i8* xp=tyany_ptr(x); i8* rp=m_tyarrvO(&r,1,wsum,el2t(xe), 8); bmipopc_2slash8 (wp, xp, rp, wia); goto bit_ret; } + case el_i16:case el_c16: { i16* xp=tyany_ptr(x); i16* rp=m_tyarrvO(&r,2,wsum,el2t(xe), 16); bmipopc_2slash16(wp, xp, rp, wia); goto bit_ret; } #endif } #endif @@ -1068,16 +1068,22 @@ B reverse_c1(B t, B x) { B xf = getFillQ(x); u8 xe = TI(x,elType); usz xia = a(x)->ia; - if (rnk(x)==1 && xea : c(TyArr,x)->a; } -#define M_TYARR(OVER, MID) { \ +#define M_TYARR(OVER, MID, RV) { \ Arr* r = m_arr(TYARR_SZW(w, ia) OVER, type, ia); \ - MID \ - *rp = taga(r); \ - return ((TyArr*)r)->a; \ + MID \ + *rp = RV; \ + return ((TyArr*)r)->a; \ } // width in bytes for m_tyarr*; overalloc is a byte count -static void* m_tyarrp (B* rp, usz w, usz ia, u8 type ) M_TYARR( , ) -static void* m_tyarrpO(B* rp, usz w, usz ia, u8 type, usz over) M_TYARR(+over, ) -static void* m_tyarrv (B* rp, usz w, usz ia, u8 type ) M_TYARR( , arr_shVec((Arr*)r);) -static void* m_tyarrvO(B* rp, usz w, usz ia, u8 type, usz over) M_TYARR(+over, arr_shVec((Arr*)r);) +static void* m_tyarrp (Arr** rp, usz w, usz ia, u8 type ) M_TYARR( , , r) +static void* m_tyarrpO(Arr** rp, usz w, usz ia, u8 type, usz over) M_TYARR(+over, , r) +static void* m_tyarrv (B* rp, usz w, usz ia, u8 type ) M_TYARR( , arr_shVec((Arr*)r);, taga(r)) +static void* m_tyarrvO(B* rp, usz w, usz ia, u8 type, usz over) M_TYARR(+over, arr_shVec((Arr*)r);, taga(r)) extern u8 elType2type[]; #define el2t(X) elType2type[X] // TODO maybe reorganize array types such that this can just be addition? \ No newline at end of file diff --git a/src/core/stuff.c b/src/core/stuff.c index 425f689c..f823bb0e 100644 --- a/src/core/stuff.c +++ b/src/core/stuff.c @@ -162,7 +162,7 @@ NOINLINE void fprintRaw(FILE* f, B x) { if (isAtm(x)) { if (isF64(x)) { NUM_FMT_BUF(buf, x.f); fprintf(f, "%s", buf); } else if (isC32(x)) fprintUTF8(f, (u32)x.u); - else thrM("bad printRaw argument: atom arguments should be either numerical or characters"); + else thrM("•Out: Unexpected argument type"); } else { usz ia = a(x)->ia; SGetU(x) @@ -171,7 +171,7 @@ NOINLINE void fprintRaw(FILE* f, B x) { #if !CATCH_ERRORS if (c.u==0 || noFill(c)) { fprintf(f, " "); continue; } #endif - if (!isC32(c)) thrM("bad printRaw argument: expected all character items"); + if (!isC32(c)) thrM("•Out: Unexpected element in argument"); fprintUTF8(f, (u32)c.u); } }