fix no fill case in ⥊ and namespace destructuring in header
This commit is contained in:
parent
750207f1f8
commit
8f8828c671
@ -147,6 +147,7 @@ B shape_c2(B t, B w, B x) {
|
||||
i64 div = nia/xia;
|
||||
i64 mod = nia%xia;
|
||||
for (i64 i = 0; i < div; i++) mut_copyG(m, i*xia, x, 0, xia);
|
||||
if (fill && mod && noFill(xf)) thrM("⥊: 𝕩 had no fill element");
|
||||
if (fill) mut_fill(m, div*xia, xf, mod);
|
||||
else mut_copyG(m, div*xia, x, 0, mod);
|
||||
dec(x);
|
||||
|
||||
20
src/ns.c
20
src/ns.c
@ -58,6 +58,26 @@ B ns_getU(B ns, B cNL, i32 nameID) { VTY(ns, t_ns);
|
||||
}
|
||||
thrM("No key found");
|
||||
}
|
||||
B ns_qgetU(B ns, B cNL, i32 nameID) { VTY(ns, t_ns); // TODO somehow merge impl with ns_getU
|
||||
NS* n = c(NS, ns);
|
||||
NSDesc* d = n->desc;
|
||||
i32 dVarAm = d->varAm;
|
||||
assert((u64)nameID < a(cNL)->ia && nameID>=0);
|
||||
B dNL = d->nameList;
|
||||
if (cNL.u != dNL.u) {
|
||||
B cName = TI(cNL,getU)(cNL, nameID);
|
||||
BS2B dNLgetU = TI(dNL,getU);
|
||||
for (i32 i = 0; i < dVarAm; i++) {
|
||||
i32 dID = d->expIDs[i];
|
||||
if (dID>=0 && equal(dNLgetU(dNL, dID), cName)) return n->sc->vars[i];
|
||||
}
|
||||
} else {
|
||||
for (i32 i = 0; i < dVarAm; i++) {
|
||||
if (d->expIDs[i]==nameID) return n->sc->vars[i];
|
||||
}
|
||||
}
|
||||
return bi_N;
|
||||
}
|
||||
B ns_getNU(B ns, B name) { VTY(ns, t_ns);
|
||||
NS* n = c(NS, ns);
|
||||
NSDesc* d = n->desc;
|
||||
|
||||
1
src/ns.h
1
src/ns.h
@ -17,6 +17,7 @@ typedef struct NS {
|
||||
void m_nsDesc(Body* body, bool imm, u8 ty, B nameList, B varIDs, B exported); // consumes nameList
|
||||
B m_ns(Scope* sc, NSDesc* desc); // consumes both
|
||||
B ns_getU(B ns, B nameList, i32 nameID); // doesn't consume anything, doesn't increment result
|
||||
B ns_qgetU(B ns, B nameList, i32 nameID); // ns_getU but return bi_N on fail
|
||||
B ns_getNU(B ns, B name); // doesn't consume anything, doesn't increment result
|
||||
void ns_set(B ns, B name, B val); // consumes val
|
||||
i32 ns_pos(B ns, B name); // consumes name; returns an index in sc->vars for any variable, exported or local
|
||||
|
||||
6
src/vm.c
6
src/vm.c
@ -478,12 +478,14 @@ NOINLINE bool v_sethR(Scope* pscs[], B s, B x) {
|
||||
if (isVar(c)) {
|
||||
Scope* sc = pscs[(u16)(c.u>>32)];
|
||||
i32 nameID = sc->body->varIDs[(u32)c.u];
|
||||
if (!v_seth(pscs, c, ns_getU(x, sc->body->nsDesc->nameList, nameID))) return false;
|
||||
B g = ns_qgetU(x, sc->body->nsDesc->nameList, nameID);
|
||||
if (q_N(g) || !v_seth(pscs, c, g)) return false;
|
||||
} else if (isObj(c) && v(c)->type==t_fldAlias) {
|
||||
assert(v(c)->type == t_fldAlias);
|
||||
Scope* sc = pscs[0];
|
||||
FldAlias* cf = c(FldAlias,c);
|
||||
if (!v_seth(pscs, cf->obj, ns_getU(x, sc->body->nsDesc->nameList, cf->p))) return false;
|
||||
B g = ns_qgetU(x, sc->body->nsDesc->nameList, cf->p);
|
||||
if (q_N(g) || !v_seth(pscs, cf->obj, g)) return false;
|
||||
} else return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user