updated formatter
This commit is contained in:
parent
23af3f56e9
commit
dd865697ef
2
src/h.h
2
src/h.h
@ -263,6 +263,8 @@ B m_str32(u32* s); // meant to be used as m_str32(U"{𝕨‿𝕩}"), so doesn't
|
|||||||
|
|
||||||
B bqn_exec(B str, B path, B args); // consumes both
|
B bqn_exec(B str, B path, B args); // consumes both
|
||||||
B bqn_execFile(B path, B args); // consumes
|
B bqn_execFile(B path, B args); // consumes
|
||||||
|
B bqn_fmt(B x); // consumes
|
||||||
|
B bqn_repr(B x); // consumes
|
||||||
|
|
||||||
NOINLINE NORETURN void thr(B b);
|
NOINLINE NORETURN void thr(B b);
|
||||||
NOINLINE NORETURN void thrM(char* s);
|
NOINLINE NORETURN void thrM(char* s);
|
||||||
|
|||||||
12
src/load.c
12
src/load.c
@ -23,10 +23,13 @@ B load_comp;
|
|||||||
B load_compArg;
|
B load_compArg;
|
||||||
|
|
||||||
#ifdef FORMATTER
|
#ifdef FORMATTER
|
||||||
B load_fmt;
|
B load_fmt, load_repr;
|
||||||
B bqn_fmt(B x) { // consumes
|
B bqn_fmt(B x) { // consumes
|
||||||
return c1(load_fmt, x);
|
return c1(load_fmt, x);
|
||||||
}
|
}
|
||||||
|
B bqn_repr(B x) { // consumes
|
||||||
|
return c1(load_repr, x);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void load_gcFn() {
|
void load_gcFn() {
|
||||||
@ -170,8 +173,11 @@ static inline void load_init() {
|
|||||||
#include "formatter"
|
#include "formatter"
|
||||||
);
|
);
|
||||||
B fmtM = m_funBlock(fmt_b, 0); ptr_dec(fmt_b);
|
B fmtM = m_funBlock(fmt_b, 0); ptr_dec(fmt_b);
|
||||||
load_fmt = TI(fmtM).m1_d(fmtM, m_caB(4, (B[]){inc(bi_type), inc(bi_decp), inc(bi_fmtF), inc(bi_fmtN)}));
|
B fmtR = c1(fmtM, m_caB(4, (B[]){inc(bi_type), inc(bi_decp), inc(bi_fmtF), inc(bi_repr)}));
|
||||||
gc_add(load_fmt);
|
BS2B fget = TI(fmtR).get;
|
||||||
|
load_fmt = fget(fmtR, 0); gc_add(load_fmt);
|
||||||
|
load_repr = fget(fmtR, 1); gc_add(load_repr);
|
||||||
|
dec(fmtR);
|
||||||
#endif
|
#endif
|
||||||
gc_enable();
|
gc_enable();
|
||||||
#endif // NO_COMP
|
#endif // NO_COMP
|
||||||
|
|||||||
@ -34,10 +34,11 @@ B glyph_c1(B t, B x) {
|
|||||||
|
|
||||||
B repr_c1(B t, B x) {
|
B repr_c1(B t, B x) {
|
||||||
#define BL 100
|
#define BL 100
|
||||||
char buf[BL];
|
if (isF64(x)) {
|
||||||
if (isF64(x)) snprintf(buf, BL, "%g", x.f);
|
char buf[BL];
|
||||||
else snprintf(buf, BL, "(fmtN: not given a number?)");
|
snprintf(buf, BL, "%g", x.f);
|
||||||
return m_str8(strlen(buf), buf);
|
return m_str8(strlen(buf), buf);
|
||||||
|
} else return bqn_repr(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
B fill_c1(B t, B x) {
|
B fill_c1(B t, B x) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user