move fmtF to •Glyph

This commit is contained in:
dzaima 2021-08-04 22:06:33 +03:00
parent 65fe3d9aa2
commit 2ab2f35a34
5 changed files with 29 additions and 33 deletions

View File

@ -85,33 +85,6 @@ B ltack_c2(B t, B w, B x) { dec(x); return w; }
B rtack_c1(B t, B x) { return x; }
B rtack_c2(B t, B w, B x) { dec(w); return x; }
B nsFmt(B x);
#ifdef RT_WRAP
B rtWrap_unwrap(B x);
#endif
B fmtF_c1(B t, B x) {
if (!isVal(x)) return m_str32(U"(fmtF: not given a function)");
#ifdef RT_WRAP
x = rtWrap_unwrap(x);
#endif
u8 fl = v(x)->flags;
if (fl==0 || fl>rtLen) {
u8 ty = v(x)->type;
if (ty==t_funBI) { B r = fromUTF8l(format_pf (c(Fun,x)->extra)); dec(x); return r; }
if (ty==t_md1BI) { B r = fromUTF8l(format_pm1(c(Md1,x)->extra)); dec(x); return r; }
if (ty==t_md2BI) { B r = fromUTF8l(format_pm2(c(Md2,x)->extra)); dec(x); return r; }
if (ty==t_nfn) { B r = nfn_name(x); dec(x); return r; }
if (ty==t_fun_block) { dec(x); return m_str8l("(function block)"); }
if (ty==t_md1_block) { dec(x); return m_str8l("(1-modifier block)"); }
if (ty==t_md2_block) { dec(x); return m_str8l("(2-modifier block)"); }
if (ty==t_ns) return nsFmt(x);
return m_str32(U"(fmtF: not given a runtime primitive)");
}
dec(x);
return m_c32(U"+-×÷⋆√⌊⌈|¬∧∨<>≠=≤≥≡≢⊣⊢⥊∾≍↑↓↕«»⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔!˙˜˘¨⌜⁼´˝`∘○⊸⟜⌾⊘◶⎉⚇⍟⎊"[fl-1]);
}
B fne_c1(B t, B x) {
if (isArr(x)) {
ur xr = rnk(x);

View File

@ -34,8 +34,30 @@ B primInd_c1(B t, B x) {
return m_i32(rtLen);
}
B nsFmt(B x);
#ifdef RT_WRAP
B rtWrap_unwrap(B x);
#endif
B glyph_c1(B t, B x) {
return x;
if (!isVal(x)) return m_str32(U"(•Glyph: not given a function)");
#ifdef RT_WRAP
x = rtWrap_unwrap(x);
#endif
u8 fl = v(x)->flags;
if (fl==0 || fl>rtLen) {
u8 ty = v(x)->type;
if (ty==t_funBI) { B r = fromUTF8l(format_pf (c(Fun,x)->extra)); dec(x); return r; }
if (ty==t_md1BI) { B r = fromUTF8l(format_pm1(c(Md1,x)->extra)); dec(x); return r; }
if (ty==t_md2BI) { B r = fromUTF8l(format_pm2(c(Md2,x)->extra)); dec(x); return r; }
if (ty==t_nfn) { B r = nfn_name(x); dec(x); return r; }
if (ty==t_fun_block) { dec(x); return m_str8l("(function block)"); }
if (ty==t_md1_block) { dec(x); return m_str8l("(1-modifier block)"); }
if (ty==t_md2_block) { dec(x); return m_str8l("(2-modifier block)"); }
if (ty==t_ns) return nsFmt(x);
return m_str32(U"(•Glyph: given object with unexpected type)");
}
dec(x);
return m_c32(U"+-×÷⋆√⌊⌈|¬∧∨<>≠=≤≥≡≢⊣⊢⥊∾≍↑↓↕«»⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔!˙˜˘¨⌜⁼´˝`∘○⊸⟜⌾⊘◶⎉⚇⍟⎊"[fl-1]);
}
B repr_c1(B t, B x) {
@ -480,6 +502,7 @@ B sys_c1(B t, B x) {
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"glyph")) r.a[i] = inc(bi_glyph);
else if (eqStr(c, U"makerand")) r.a[i] = inc(bi_makeRand);
else if (eqStr(c, U"fchars")) r.a[i] = m_nfn(fCharsDesc, path_dir(inc(comp_currPath)));
else if (eqStr(c, U"fbytes")) r.a[i] = m_nfn(fBytesDesc, path_dir(inc(comp_currPath)));

View File

@ -335,7 +335,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_fmtF), inc(bi_repr)}));
B fmtR = c1(fmtM, m_caB(4, (B[]){inc(bi_type), inc(bi_decp), inc(bi_glyph), inc(bi_repr)}));
BS2B fget = TI(fmtR,get);
load_fmt = fget(fmtR, 0); gc_add(load_fmt);
load_repr = fget(fmtR, 1); gc_add(load_repr);

View File

@ -234,19 +234,19 @@ void rtWrap_print() {
#ifdef RT_PERF
WFun* cf = lastWF;
while (cf) {
printRaw(c1(bi_fmtF, tag(cf,FUN_TAG)));
printRaw(c1(bi_glyph, tag(cf,FUN_TAG)));
printf(": m=%d %.3fms | d=%d %.3fms\n", cf->c1a, cf->c1t/1e6, cf->c2a, cf->c2t/1e6);
cf = cf->prev;
}
WMd1* cm1 = lastWM1;
while (cm1) {
printRaw(c1(bi_fmtF, tag(cm1,MD1_TAG)));
printRaw(c1(bi_glyph, tag(cm1,MD1_TAG)));
printf(": m=%d %.3fms | d=%d %.3fms\n", cm1->c1a, cm1->c1t/1e6, cm1->c2a, cm1->c2t/1e6);
cm1 = cm1->prev;
}
WMd2* cm2 = lastWM2;
while (cm2) {
printRaw(c1(bi_fmtF, tag(cm2,MD2_TAG)));
printRaw(c1(bi_glyph, tag(cm2,MD2_TAG)));
printf(": m=%d %.3fms | d=%d %.3fms\n", cm2->c1a, cm2->c1t/1e6, cm2->c2a, cm2->c2t/1e6);
cm2 = cm2->prev;
}

View File

@ -3,7 +3,7 @@
#define FOR_PFN(A,M,D) \
/* arith.c*/A(add,"+") A(sub,"-") A(mul,"×") A(div,"÷") A(pow,"") A(root,"") A(floor,"") A(ceil,"") A(stile,"|") A(eq,"=") \
/* arith.c*/A(ne,"") D(le,"") D(ge,"") A(lt,"<") A(gt,">") A(and,"") A(or,"") A(not,"¬") A(log,"⋆⁼") \
/* fns.c*/A(ud,"") A(fne,"") A(feq,"") A(ltack,"") A(rtack,"") M(fmtF,"•FmtF") A(indexOf,"") A(memberOf,"") A(find,"") A(count,"") \
/* fns.c*/A(ud,"") A(fne,"") A(feq,"") A(ltack,"") A(rtack,"") A(indexOf,"") A(memberOf,"") A(find,"") A(count,"") \
/* sfns.c*/A(shape,"") A(pick,"") A(pair,"{𝕨‿𝕩}") A(select,"") A(slash,"/") A(join,"") A(couple,"") A(shiftb,"»") A(shifta,"«") A(take,"") A(drop,"") A(group,"") A(reverse,"") \
/* sort.c*/A(gradeUp,"") A(gradeDown,"") \
/* everything before the definition of •Type is defined to be pure, and everything after is not */ \