basic namespace formatting
This commit is contained in:
parent
2710786bf0
commit
65fe3d9aa2
@ -85,6 +85,7 @@ 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
|
||||
@ -103,6 +104,7 @@ B fmtF_c1(B t, B x) {
|
||||
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);
|
||||
|
||||
20
src/ns.c
20
src/ns.c
@ -1,5 +1,6 @@
|
||||
#include "core.h"
|
||||
#include "ns.h"
|
||||
#include "utils/mut.h"
|
||||
|
||||
void m_nsDesc(Body* body, bool imm, u8 ty, B nameList, B varIDs, B exported) { // consumes nameList
|
||||
if (!isArr(varIDs) || !isArr(exported)) thrM("Bad namespace description information");
|
||||
@ -133,6 +134,25 @@ static void ns_print(B x) {
|
||||
}
|
||||
putchar('}');
|
||||
}
|
||||
B nsFmt(B x) { // consumes
|
||||
B s = emptyCVec();
|
||||
ACHR('{');
|
||||
NSDesc* desc = c(NS,x)->desc;
|
||||
i32 am = desc->varAm;
|
||||
BS2B getNameU = TI(desc->nameList,getU);
|
||||
bool first = true;
|
||||
for (i32 i = 0; i < am; i++) {
|
||||
i32 id = desc->expIDs[i];
|
||||
if (id>=0) {
|
||||
if (first) first=false;
|
||||
else ACHR(U'‿');
|
||||
AFMT("%R", getNameU(desc->nameList, id));
|
||||
}
|
||||
}
|
||||
AU("⇐}");
|
||||
dec(x);
|
||||
return s;
|
||||
}
|
||||
|
||||
DEF_FREE(nsDesc) { decR(((NSDesc*)x)->nameList); }
|
||||
static void nsDesc_visit(Value* x) { mm_visit(((NSDesc*)x)->nameList); }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user