slice checking macro refactor
This commit is contained in:
parent
ba1b853936
commit
229a32237a
@ -14,11 +14,11 @@ static B* arrV_bptr(Arr* x) {
|
|||||||
if (PTY(x)==t_fillslice) return ((FillSlice*)x)->a;
|
if (PTY(x)==t_fillslice) return ((FillSlice*)x)->a;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
static void* tyarr_ptr(B x) { assert(IS_ARR(TY(x))); return c(TyArr,x)->a; }
|
static void* tyarr_ptr(B x) { assert(IS_ANY_ARR(TY(x)) && !IS_SLICE(TY(x))); return c(TyArr,x)->a; }
|
||||||
static void* tyslice_ptr(B x) { assert(IS_SLICE(TY(x))); return c(TySlice,x)->a; }
|
static void* tyslice_ptr(B x) { assert(IS_ANY_ARR(TY(x)) && IS_SLICE(TY(x))); return c(TySlice,x)->a; }
|
||||||
static void* tyany_ptr(B x) { assert(IS_ARR(TY(x)) || IS_SLICE(TY(x)));
|
static void* tyany_ptr(B x) {
|
||||||
u8 t = TY(x);
|
assert(IS_ANY_ARR(TY(x)));
|
||||||
return IS_SLICE(t)? c(TySlice,x)->a : c(TyArr,x)->a;
|
return IS_SLICE(TY(x))? c(TySlice,x)->a : c(TyArr,x)->a;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define M_TYARR(WM, OVER, MID, RV, PRE) { PRE \
|
#define M_TYARR(WM, OVER, MID, RV, PRE) { PRE \
|
||||||
|
|||||||
4
src/h.h
4
src/h.h
@ -293,8 +293,8 @@ enum Type {
|
|||||||
#undef F
|
#undef F
|
||||||
t_COUNT
|
t_COUNT
|
||||||
};
|
};
|
||||||
#define IS_SLICE(T) ((T)>=t_hslice & (T)<=t_f64slice)
|
#define IS_ANY_ARR(T) ((T)>=t_hslice & (T)<=t_bitarr)
|
||||||
#define IS_ARR(T) ((T)>=t_harr & (T)<=t_bitarr)
|
#define IS_SLICE(T) ((T)<=t_f64slice)
|
||||||
#define TO_SLICE(T) ((T) + t_hslice - t_harr) // Assumes T!=t_bitarr
|
#define TO_SLICE(T) ((T) + t_hslice - t_harr) // Assumes T!=t_bitarr
|
||||||
|
|
||||||
enum ElType { // a⌈b shall return the type that can store both, if possible
|
enum ElType { // a⌈b shall return the type that can store both, if possible
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user