make ⊏ safe
This commit is contained in:
parent
16f379b6c7
commit
4d8375fdfd
@ -102,6 +102,15 @@ B select_c2(B t, B w, B x) {
|
||||
}
|
||||
dec(w); dec(x);
|
||||
return r;
|
||||
} else if (TI(x).elType==el_f64) {
|
||||
f64* rp; B r = m_f64arrc(&rp, w);
|
||||
f64* xp = f64any_ptr(x);
|
||||
for (usz i = 0; i < wia; i++) {
|
||||
usz c = WRAP(wp[i], xia, thrF("⊏: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", wp[i], xia));
|
||||
rp[i] = xp[c];
|
||||
}
|
||||
dec(w); dec(x);
|
||||
return r;
|
||||
} else if (TI(x).elType==el_c32) {
|
||||
u32* rp; B r = m_c32arrc(&rp, w);
|
||||
u32* xp = c32any_ptr(x);
|
||||
@ -111,26 +120,38 @@ B select_c2(B t, B w, B x) {
|
||||
}
|
||||
dec(w); dec(x);
|
||||
return r;
|
||||
} else if (v(x)->type==t_harr) {
|
||||
usz i = 0;
|
||||
B* xp = harr_ptr(x);
|
||||
HArr_p r = m_harrs(wia, &i);
|
||||
for (; i < wia; i++) {
|
||||
usz c = WRAP(wp[i], xia, thrF("⊏: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", wp[i], xia));
|
||||
r.a[i] = inc(xp[c]);
|
||||
}
|
||||
dec(x);
|
||||
return harr_fcd(r, w);
|
||||
} else {
|
||||
HArr_p r = m_harrUc(w);
|
||||
for (usz i = 0; i < wia; i++) {
|
||||
usz i = 0;
|
||||
HArr_p r = m_harrs(wia, &i);
|
||||
for (; i < wia; i++) {
|
||||
usz c = WRAP(wp[i], xia, thrF("⊏: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", wp[i], xia));
|
||||
r.a[i] = xget(x, c);
|
||||
}
|
||||
dec(w); dec(x);
|
||||
return withFill(r.b,xf);
|
||||
dec(x);
|
||||
return withFill(harr_fcd(r,w),xf);
|
||||
}
|
||||
} else {
|
||||
HArr_p r = m_harrUc(w);
|
||||
usz i = 0;
|
||||
HArr_p r = m_harrs(wia, &i);
|
||||
BS2B wgetU = TI(w).getU;
|
||||
for (usz i = 0; i < wia; i++) {
|
||||
for (; i < wia; i++) {
|
||||
B cw = wgetU(w, i);
|
||||
if (!isNum(cw)) { harr_pfree(r.b, i); goto base; }
|
||||
usz c = WRAP(o2i64(cw), xia, thrF("⊏: Indexing out-of-bounds (%R∊𝕨, %s≡≠𝕩)", cw, xia));
|
||||
r.a[i] = xget(x, c);
|
||||
}
|
||||
dec(w); dec(x);
|
||||
return withFill(r.b,xf);
|
||||
dec(x);
|
||||
return withFill(harr_fcd(r,w),xf);
|
||||
}
|
||||
} else {
|
||||
BS2B wgetU = TI(w).getU;
|
||||
|
||||
12
src/h.h
12
src/h.h
@ -23,13 +23,13 @@
|
||||
#define MM 1 // memory manager; 0 - malloc (no GC); 1 - buddy; 2 - 2buddy
|
||||
#define HEAP_MAX ~0ULL // default heap max size
|
||||
|
||||
// #define LOG_GC // log GC stats
|
||||
// #define LOG_GC // log GC stats
|
||||
#define FORMATTER // use self-hosted formatter for output
|
||||
// #define TIME // output runtime of every expression
|
||||
// #define RT_PERF // time runtime primitives
|
||||
// #define RT_VERIFY // compare native and runtime versions of primitives
|
||||
// #define NO_RT // whether to completely disable self-hosted runtime loading
|
||||
// #define PRECOMP // execute just precompiled code at src/gen/interp
|
||||
// #define TIME // output runtime of every expression
|
||||
// #define RT_PERF // time runtime primitives
|
||||
// #define RT_VERIFY // compare native and runtime versions of primitives
|
||||
// #define NO_RT // whether to completely disable self-hosted runtime loading
|
||||
// #define PRECOMP // execute just precompiled code at src/gen/interp
|
||||
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
2
src/vm.c
2
src/vm.c
@ -38,7 +38,7 @@ enum {
|
||||
SYSV = 30, // N; get system function N
|
||||
LOCU = 31, // N0,N1; like LOCO but overrides the slot with bi_optOut
|
||||
EXTO, EXTM, EXTU, // alternate versions of LOC_ for extended variables
|
||||
ADDI, ADDU, // PUSH with required increment & not required increment
|
||||
ADDI, ADDU, // separate PUSH for refcounting needed/not needed (stores the object inline, instead of reading from `objs`)
|
||||
BC_SIZE
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user