incG
This commit is contained in:
parent
0969acef35
commit
cd5f50e3eb
@ -25,7 +25,7 @@ B fillBy_c2(Md2D* d, B w, B x) {
|
||||
B r = c2(d->f, w,x);
|
||||
if(isAtm(r) || noFill(xf)) { dec(xf); dec(wf); return r; }
|
||||
if (CATCH) { dec(catchMessage); return r; }
|
||||
if (noFill(wf)) wf = inc(bi_asrt);
|
||||
if (noFill(wf)) wf = incG(bi_asrt);
|
||||
B fill = asFill(c2(d->g, wf, xf));
|
||||
popCatch();
|
||||
return withFill(r, fill);
|
||||
@ -81,7 +81,7 @@ B repeat_replace(B g, B* q) { // doesn't consume
|
||||
q[0] = inc(x); \
|
||||
if (min) { \
|
||||
B x2 = inc(x); \
|
||||
B fi = m1_d(inc(rt_undo), inc(f)); \
|
||||
B fi = m1_d(incG(rt_undo), inc(f)); \
|
||||
for (i64 i = 0; i < min; i++) q[-1-i] = inc(x2 = CN(fi, __VA_ARGS__ x2)); \
|
||||
dec(x2); \
|
||||
dec(fi); \
|
||||
@ -122,7 +122,7 @@ B cond_c2(Md2D* d, B w, B x) { B g=d->g;
|
||||
extern B rt_under, bi_before;
|
||||
B under_c1(Md2D* d, B x) { B f=d->f; B g=d->g;
|
||||
if (!isVal(g)) { // ugh idk
|
||||
B fn = m2_d(inc(rt_under), inc(f), inc(g));
|
||||
B fn = m2_d(incG(rt_under), inc(f), inc(g));
|
||||
B r = c1(fn, x);
|
||||
dec(fn);
|
||||
return r;
|
||||
@ -131,12 +131,12 @@ B under_c1(Md2D* d, B x) { B f=d->f; B g=d->g;
|
||||
}
|
||||
B under_c2(Md2D* d, B w, B x) { B f=d->f; B g=d->g;
|
||||
if (!isVal(g)) {
|
||||
B fn = m2_d(inc(rt_under), inc(f), inc(g));
|
||||
B fn = m2_d(incG(rt_under), inc(f), inc(g));
|
||||
B r = c2(fn, w, x);
|
||||
dec(fn);
|
||||
return r;
|
||||
}
|
||||
B f2 = m2_d(inc(bi_before), c1(g, w), inc(f));
|
||||
B f2 = m2_d(incG(bi_before), c1(g, w), inc(f));
|
||||
B r = TI(g,fn_uc1)(g, f2, x);
|
||||
dec(f2);
|
||||
return r;
|
||||
|
||||
@ -637,7 +637,7 @@ B couple_c1(B t, B x) {
|
||||
if (isAtm(x)) return unitV1(x);
|
||||
usz rr = rnk(x);
|
||||
usz ia = a(x)->ia;
|
||||
Arr* r = TI(x,slice)(inc(x),0, ia);
|
||||
Arr* r = TI(x,slice)(incG(x),0, ia);
|
||||
usz* sh = arr_shAlloc(r, rr+1);
|
||||
if (sh) { sh[0] = 1; memcpy(sh+1, a(x)->sh, rr*sizeof(usz)); }
|
||||
dec(x);
|
||||
|
||||
@ -414,9 +414,9 @@ B makeRand_c1(B t, B x) {
|
||||
if (!isNum(x)) thrM("•MakeRand: 𝕩 must be a number");
|
||||
if (rand_ns.u==0) rand_init();
|
||||
B r = c2(rand_ns, b(x.u>>32), b(x.u&0xFFFFFFFF));
|
||||
ns_set(r, rand_rangeName, m_nfn(rand_rangeDesc, inc(r)));
|
||||
ns_set(r, rand_dealName, m_nfn(rand_dealDesc, inc(r)));
|
||||
ns_set(r, rand_subsetName, m_nfn(rand_subsetDesc, inc(r)));
|
||||
ns_set(r, rand_rangeName, m_nfn(rand_rangeDesc, incG(r)));
|
||||
ns_set(r, rand_dealName, m_nfn(rand_dealDesc, incG(r)));
|
||||
ns_set(r, rand_subsetName, m_nfn(rand_subsetDesc, incG(r)));
|
||||
return r;
|
||||
}
|
||||
static B randNS;
|
||||
@ -429,7 +429,7 @@ B getRandNS() {
|
||||
#endif
|
||||
gc_add(randNS);
|
||||
}
|
||||
return inc(randNS);
|
||||
return incG(randNS);
|
||||
}
|
||||
extern B replPath; // defined in main.c
|
||||
static NFnDesc* reBQNDesc;
|
||||
@ -675,10 +675,10 @@ B sys_c1(B t, B x) {
|
||||
#define REQ_PATH ({ if(!path.u) path = path_abs(path_dir(inc(comp_currPath))); path; })
|
||||
for (; i < a(x)->ia; i++) {
|
||||
B c = GetU(x,i);
|
||||
if (eqStr(c, U"out")) r.a[i] = inc(bi_out);
|
||||
else if (eqStr(c, U"show")) r.a[i] = inc(bi_show);
|
||||
else if (eqStr(c, U"exit")) r.a[i] = inc(bi_exit);
|
||||
else if (eqStr(c, U"getline")) r.a[i] = inc(bi_getLine);
|
||||
if (eqStr(c, U"out")) r.a[i] = incG(bi_out);
|
||||
else if (eqStr(c, U"show")) r.a[i] = incG(bi_show);
|
||||
else if (eqStr(c, U"exit")) r.a[i] = incG(bi_exit);
|
||||
else if (eqStr(c, U"getline")) r.a[i] = incG(bi_getLine);
|
||||
else if (eqStr(c, U"file")) {
|
||||
if(!fileNS.u) {
|
||||
REQ_PATH;
|
||||
@ -691,24 +691,24 @@ B sys_c1(B t, B x) {
|
||||
}
|
||||
else if (eqStr(c, U"internal")) r.a[i] = getInternalNS();
|
||||
else if (eqStr(c, U"math")) r.a[i] = getMathNS();
|
||||
else if (eqStr(c, U"type")) r.a[i] = inc(bi_type);
|
||||
else if (eqStr(c, U"sh")) r.a[i] = inc(bi_sh);
|
||||
else if (eqStr(c, U"decompose")) r.a[i] = inc(bi_decp);
|
||||
else if (eqStr(c, U"primind")) r.a[i] = inc(bi_primInd);
|
||||
else if (eqStr(c, U"bqn")) r.a[i] = inc(bi_bqn);
|
||||
else if (eqStr(c, U"cmp")) r.a[i] = inc(bi_cmp);
|
||||
else if (eqStr(c, U"unixtime")) r.a[i] = inc(bi_unixTime);
|
||||
else if (eqStr(c, U"monotime")) r.a[i] = inc(bi_monoTime);
|
||||
else if (eqStr(c, U"timed")) r.a[i] = inc(bi_timed);
|
||||
else if (eqStr(c, U"delay")) r.a[i] = inc(bi_delay);
|
||||
else if (eqStr(c, U"hash")) r.a[i] = inc(bi_hash);
|
||||
else if (eqStr(c, U"repr")) r.a[i] = inc(bi_repr);
|
||||
else if (eqStr(c, U"fmt")) r.a[i] = inc(bi_fmt);
|
||||
else if (eqStr(c, U"glyph")) r.a[i] = inc(bi_glyph);
|
||||
else if (eqStr(c, U"makerand")) r.a[i] = inc(bi_makeRand);
|
||||
else if (eqStr(c, U"type")) r.a[i] = incG(bi_type);
|
||||
else if (eqStr(c, U"sh")) r.a[i] = incG(bi_sh);
|
||||
else if (eqStr(c, U"decompose")) r.a[i] = incG(bi_decp);
|
||||
else if (eqStr(c, U"primind")) r.a[i] = incG(bi_primInd);
|
||||
else if (eqStr(c, U"bqn")) r.a[i] = incG(bi_bqn);
|
||||
else if (eqStr(c, U"cmp")) r.a[i] = incG(bi_cmp);
|
||||
else if (eqStr(c, U"unixtime")) r.a[i] = incG(bi_unixTime);
|
||||
else if (eqStr(c, U"monotime")) r.a[i] = incG(bi_monoTime);
|
||||
else if (eqStr(c, U"timed")) r.a[i] = incG(bi_timed);
|
||||
else if (eqStr(c, U"delay")) r.a[i] = incG(bi_delay);
|
||||
else if (eqStr(c, U"hash")) r.a[i] = incG(bi_hash);
|
||||
else if (eqStr(c, U"repr")) r.a[i] = incG(bi_repr);
|
||||
else if (eqStr(c, U"fmt")) r.a[i] = incG(bi_fmt);
|
||||
else if (eqStr(c, U"glyph")) r.a[i] = incG(bi_glyph);
|
||||
else if (eqStr(c, U"makerand")) r.a[i] = incG(bi_makeRand);
|
||||
else if (eqStr(c, U"rand")) r.a[i] = getRandNS();
|
||||
else if (eqStr(c, U"rebqn")) r.a[i] = inc(bi_reBQN);
|
||||
else if (eqStr(c, U"fromutf8")) r.a[i] = inc(bi_fromUtf8);
|
||||
else if (eqStr(c, U"rebqn")) r.a[i] = incG(bi_reBQN);
|
||||
else if (eqStr(c, U"fromutf8")) r.a[i] = incG(bi_fromUtf8);
|
||||
else if (eqStr(c, U"path")) r.a[i] = inc(REQ_PATH);
|
||||
else if (eqStr(c, U"fchars")) r.a[i] = m_nfn(fCharsDesc, inc(REQ_PATH));
|
||||
else if (eqStr(c, U"fbytes")) r.a[i] = m_nfn(fBytesDesc, inc(REQ_PATH));
|
||||
|
||||
12
src/h.h
12
src/h.h
@ -255,10 +255,10 @@ static const B bi_okHdr = b((u64)0x7FF2000000000002ull); // tag(2, TAG_TAG);
|
||||
static const B bi_optOut = b((u64)0x7FF2000000000003ull); // tag(3, TAG_TAG);
|
||||
static const B bi_noFill = b((u64)0x7FF2000000000005ull); // tag(5, TAG_TAG);
|
||||
extern B bi_emptyHVec, bi_emptyIVec, bi_emptyCVec, bi_emptySVec;
|
||||
#define emptyHVec() ({ B t = bi_emptyHVec; ptr_inc(v(t)); t; })
|
||||
#define emptyIVec() ({ B t = bi_emptyIVec; ptr_inc(v(t)); t; })
|
||||
#define emptyCVec() ({ B t = bi_emptyCVec; ptr_inc(v(t)); t; })
|
||||
#define emptySVec() ({ B t = bi_emptySVec; ptr_inc(v(t)); t; })
|
||||
#define emptyHVec() incG(bi_emptyHVec)
|
||||
#define emptyIVec() incG(bi_emptyIVec)
|
||||
#define emptyCVec() incG(bi_emptyCVec)
|
||||
#define emptySVec() incG(bi_emptySVec)
|
||||
static void* mm_alloc(usz sz, u8 type);
|
||||
static void mm_free(Value* x);
|
||||
static u64 mm_size(Value* x);
|
||||
@ -465,6 +465,10 @@ static B inc(B x) {
|
||||
if (isVal(VALIDATE(x))) v(x)->refc++;
|
||||
return x;
|
||||
}
|
||||
static B incG(B x) { // inc for guaranteed heap objects
|
||||
v(VALIDATE(x))->refc++;
|
||||
return x;
|
||||
}
|
||||
static B incBy(B x, i64 am) { // am mustn't be negative!
|
||||
if (isVal(VALIDATE(x))) v(x)->refc+= am;
|
||||
return x;
|
||||
|
||||
12
src/load.c
12
src/load.c
@ -107,7 +107,7 @@ Block* load_compObj(B x, B src, B path, Scope* sc) { // consumes x,src
|
||||
usz xia = a(x)->ia;
|
||||
if (xia!=6 & xia!=4) thrM("load_compObj: bad item count");
|
||||
Block* r = xia==6? compile(Get(x,0),Get(x,1),Get(x,2),Get(x,3),Get(x,4),Get(x,5), src, inc(path), sc)
|
||||
: compile(Get(x,0),Get(x,1),Get(x,2),Get(x,3),bi_N, bi_N, src, inc(path), sc);
|
||||
: compile(Get(x,0),Get(x,1),Get(x,2),Get(x,3),bi_N, bi_N, src, inc(path), sc);
|
||||
dec(x);
|
||||
return r;
|
||||
}
|
||||
@ -146,7 +146,7 @@ NOINLINE Block* bqn_comp(B str, B path, B args) { // consumes all
|
||||
B prevArgs = comp_currArgs ; comp_currArgs = args;
|
||||
B prevSrc = comp_currSrc ; comp_currSrc = str;
|
||||
i64 prevEnvPos = comp_currEnvPos; comp_currEnvPos = envCurr-envStart;
|
||||
Block* r = load_compObj(c2(load_comp, inc(load_compArg), inc(str)), str, path, NULL);
|
||||
Block* r = load_compObj(c2(load_comp, incG(load_compArg), inc(str)), str, path, NULL);
|
||||
dec(path); dec(args);
|
||||
comp_currPath = prevPath;
|
||||
comp_currArgs = prevArgs;
|
||||
@ -178,7 +178,7 @@ NOINLINE Block* bqn_compSc(B str, B path, B args, Scope* sc, bool repl) { // con
|
||||
csc = csc->psc;
|
||||
depth++;
|
||||
}
|
||||
Block* r = load_compObj(c2(load_comp, m_v4(inc(load_rtObj), inc(bi_sys), vName, vDepth), inc(str)), str, path, sc);
|
||||
Block* r = load_compObj(c2(load_comp, m_v4(incG(load_rtObj), incG(bi_sys), vName, vDepth), inc(str)), str, path, sc);
|
||||
dec(path); dec(args);
|
||||
comp_currPath = prevPath;
|
||||
comp_currArgs = prevArgs;
|
||||
@ -303,9 +303,9 @@ void load_init() { // very last init function
|
||||
dec(rtObjRaw);
|
||||
B* runtime = runtimeH.a;
|
||||
B rtObj = runtimeH.b;
|
||||
dec(c1(rtFinish, m_v2(inc(bi_decp), inc(bi_primInd)))); dec(rtFinish);
|
||||
dec(c1(rtFinish, m_v2(incG(bi_decp), incG(bi_primInd)))); dec(rtFinish);
|
||||
load_rtObj = FAKE_RUNTIME? frtObj : rtObj;
|
||||
load_compArg = m_v2(load_rtObj, inc(bi_sys)); gc_add(FAKE_RUNTIME? rtObj : frtObj);
|
||||
load_compArg = m_v2(load_rtObj, incG(bi_sys)); gc_add(FAKE_RUNTIME? rtObj : frtObj);
|
||||
gc_add(load_compArg);
|
||||
#else
|
||||
B* runtime = fruntime;
|
||||
@ -346,7 +346,7 @@ void load_init() { // very last init function
|
||||
#include "gen/formatter"
|
||||
);
|
||||
B fmtM = m_funBlock(fmt_b, 0); ptr_dec(fmt_b);
|
||||
B fmtR = c1(fmtM, m_caB(4, (B[]){inc(bi_type), inc(bi_decp), inc(bi_glyph), inc(bi_repr)}));
|
||||
B fmtR = c1(fmtM, m_caB(4, (B[]){incG(bi_type), incG(bi_decp), incG(bi_glyph), incG(bi_repr)}));
|
||||
SGet(fmtR)
|
||||
load_fmt = Get(fmtR, 0); gc_add(load_fmt);
|
||||
load_repr = Get(fmtR, 1); gc_add(load_repr);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user