name normalization for •ns.Get & •ns.Has
also fix •ns.Has error message & rename some function declarations
This commit is contained in:
parent
0b32ef96ce
commit
ca0c100b73
@ -66,8 +66,8 @@ bool isPervasiveDyExt(B x) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
B slash_c2(B f, B w, B x);
|
B slash_c2(B t, B w, B x);
|
||||||
B shape_c2(B f, B w, B x);
|
B shape_c2(B t, B w, B x);
|
||||||
B tbl_c2(Md1D* d, B w, B x) { B f = d->f;
|
B tbl_c2(Md1D* d, B w, B x) { B f = d->f;
|
||||||
if (isAtm(w)) w = m_atomUnit(w);
|
if (isAtm(w)) w = m_atomUnit(w);
|
||||||
if (isAtm(x)) x = m_atomUnit(x);
|
if (isAtm(x)) x = m_atomUnit(x);
|
||||||
|
|||||||
@ -55,7 +55,7 @@ static B scan_and(B x, u64 ia) { // consumes x
|
|||||||
decG(x); return FL_SET(r, fl_dsc|fl_squoze);
|
decG(x); return FL_SET(r, fl_dsc|fl_squoze);
|
||||||
}
|
}
|
||||||
|
|
||||||
B slash_c1(B f, B x);
|
B slash_c1(B t, B x);
|
||||||
B scan_add_bool(B x, u64 ia) { // consumes x
|
B scan_add_bool(B x, u64 ia) { // consumes x
|
||||||
u64* xp = bitarr_ptr(x);
|
u64* xp = bitarr_ptr(x);
|
||||||
u64 xs = bit_sum(xp, ia);
|
u64 xs = bit_sum(xp, ia);
|
||||||
|
|||||||
@ -1110,6 +1110,26 @@ B getTermNS(void) {
|
|||||||
return incG(termNS);
|
return incG(termNS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool name_isUpper(u32 c) { return (c>='A' & c<='Z') || (c>=U'À' && c<=U'Þ'); }
|
||||||
|
B slash_c2(B, B, B);
|
||||||
|
B ne_c2(B, B, B);
|
||||||
|
static NOINLINE B name_normalize(B x) {
|
||||||
|
usz ia = IA(x); SGetU(x)
|
||||||
|
for (ux i = 0; i < ia; i++) {
|
||||||
|
u32 c0 = o2cG(GetU(x, i));
|
||||||
|
if (name_isUpper(c0) || c0=='_') {
|
||||||
|
u32* rp; B r = m_c32arrv(&rp, ia);
|
||||||
|
COPY_TO(rp, el_c32, 0, x, 0, i);
|
||||||
|
while (i < ia) {
|
||||||
|
u32 c = o2cG(GetU(x, i));
|
||||||
|
rp[i] = name_isUpper(c)? c+32 : c;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return C2(slash, C2(ne, x, m_c32('_')), r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
B nKeys_c1(B t, B x) {
|
B nKeys_c1(B t, B x) {
|
||||||
if (!isNsp(x)) thrM("•ns.Keys: 𝕩 must be a namespace");
|
if (!isNsp(x)) thrM("•ns.Keys: 𝕩 must be a namespace");
|
||||||
@ -1129,13 +1149,15 @@ B nKeys_c1(B t, B x) {
|
|||||||
B nGet_c2(B t, B w, B x) {
|
B nGet_c2(B t, B w, B x) {
|
||||||
if (!isNsp(w)) thrM("•ns.Has: 𝕨 must be a namespace");
|
if (!isNsp(w)) thrM("•ns.Has: 𝕨 must be a namespace");
|
||||||
vfyStr(x, "•ns.Get", "𝕩");
|
vfyStr(x, "•ns.Get", "𝕩");
|
||||||
|
x = name_normalize(x);
|
||||||
B r = ns_getNU(w, x, true);
|
B r = ns_getNU(w, x, true);
|
||||||
decG(w); decG(x);
|
decG(w); decG(x);
|
||||||
return inc(r);
|
return inc(r);
|
||||||
}
|
}
|
||||||
B nHas_c2(B t, B w, B x) {
|
B nHas_c2(B t, B w, B x) {
|
||||||
if (!isNsp(w)) thrM("•ns.Has: 𝕨 must be a namespace");
|
if (!isNsp(w)) thrM("•ns.Has: 𝕨 must be a namespace");
|
||||||
vfyStr(x, "•ns.Get", "𝕩");
|
vfyStr(x, "•ns.Has", "𝕩");
|
||||||
|
x = name_normalize(x);
|
||||||
B r = ns_getNU(w, x, false);
|
B r = ns_getNU(w, x, false);
|
||||||
decG(w); decG(x);
|
decG(w); decG(x);
|
||||||
return m_i32(!q_N(r));
|
return m_i32(!q_N(r));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user