use str8l more
This commit is contained in:
parent
83011df536
commit
93f362c4f2
@ -7,18 +7,18 @@ B itype_c1(B t, B x) {
|
||||
if(isVal(x)) {
|
||||
r = m_str8l(format_type(v(x)->type));
|
||||
} else {
|
||||
if (isF64(x)) r = m_str32(U"tagged f64");
|
||||
else if (isC32(x)) r = m_str32(U"tagged c32");
|
||||
else if (isTag(x)) r = m_str32(U"tagged tag");
|
||||
else if (isVar(x)) r = m_str32(U"tagged var");
|
||||
else if (isExt(x)) r = m_str32(U"tagged extvar");
|
||||
else r = m_str32(U"tagged unknown");
|
||||
if (isF64(x)) r = m_str8l("tagged f64");
|
||||
else if (isC32(x)) r = m_str8l("tagged c32");
|
||||
else if (isTag(x)) r = m_str8l("tagged tag");
|
||||
else if (isVar(x)) r = m_str8l("tagged var");
|
||||
else if (isExt(x)) r = m_str8l("tagged extvar");
|
||||
else r = m_str8l("tagged unknown");
|
||||
}
|
||||
dec(x);
|
||||
return r;
|
||||
}
|
||||
B refc_c1(B t, B x) {
|
||||
B r = isVal(x)? m_i32(v(x)->refc) : m_str32(U"(not heap-allocated)");
|
||||
B r = isVal(x)? m_i32(v(x)->refc) : m_str8l("(not heap-allocated)");
|
||||
dec(x);
|
||||
return r;
|
||||
}
|
||||
@ -255,7 +255,7 @@ B getInternalNS() {
|
||||
#define F(X) v_##X = m_str8l(#X);
|
||||
FOR_VARIATION(F)
|
||||
#undef F
|
||||
listVariations_def = m_str32(U"if");
|
||||
listVariations_def = m_str8l("if");
|
||||
gc_addFn(variation_root);
|
||||
#define F(X) inc(bi_##X),
|
||||
B fn = bqn_exec(m_str32(U"{⟨ Type, Refc, Squeeze, IsPure, Info, ListVariations, Variation, ClearRefs, Unshare⟩⇐𝕩}"), emptyCVec(), emptySVec());
|
||||
|
||||
@ -402,12 +402,12 @@ B rand_subset_c2(B t, B w, B x) {
|
||||
|
||||
static NOINLINE void rand_init() {
|
||||
rand_ns = bqn_exec(m_str32(U"{a←𝕨⋄b←𝕩⋄range⇐0⋄deal⇐0⋄subset⇐0}"), emptyCVec(), emptySVec()); gc_add(rand_ns);
|
||||
rand_rangeName = m_str32(U"range"); gc_add(rand_rangeName); rand_rangeDesc = registerNFn(m_str32(U"(rand).Range"), rand_range_c1, rand_range_c2);
|
||||
rand_dealName = m_str32(U"deal"); gc_add(rand_dealName); rand_dealDesc = registerNFn(m_str32(U"(rand).Deal"), rand_deal_c1, rand_deal_c2);
|
||||
rand_subsetName = m_str32(U"subset"); gc_add(rand_subsetName); rand_subsetDesc = registerNFn(m_str32(U"(rand).Subset"), c1_bad, rand_subset_c2);
|
||||
rand_rangeName = m_str8l("range"); gc_add(rand_rangeName); rand_rangeDesc = registerNFn(m_str8l("(rand).Range"), rand_range_c1, rand_range_c2);
|
||||
rand_dealName = m_str8l("deal"); gc_add(rand_dealName); rand_dealDesc = registerNFn(m_str8l("(rand).Deal"), rand_deal_c1, rand_deal_c2);
|
||||
rand_subsetName = m_str8l("subset"); gc_add(rand_subsetName); rand_subsetDesc = registerNFn(m_str8l("(rand).Subset"), c1_bad, rand_subset_c2);
|
||||
B tmp = c2(rand_ns, m_f64(0), m_f64(0));
|
||||
rand_a = ns_pos(tmp, m_str32(U"a"));
|
||||
rand_b = ns_pos(tmp, m_str32(U"b"));
|
||||
rand_a = ns_pos(tmp, m_str8l("a"));
|
||||
rand_b = ns_pos(tmp, m_str8l("b"));
|
||||
dec(tmp);
|
||||
}
|
||||
B makeRand_c1(B t, B x) {
|
||||
@ -435,12 +435,12 @@ extern B replPath; // defined in main.c
|
||||
static NFnDesc* reBQNDesc;
|
||||
B reBQN_c1(B t, B x) {
|
||||
if (!isNsp(x)) thrM("•ReBQN: Argument must be a namespace");
|
||||
B replStr = m_str32(U"repl");
|
||||
B replStr = m_str8l("repl");
|
||||
B repl = ns_getNU(x, replStr, false); dec(replStr);
|
||||
i32 replVal = q_N(repl) || eqStr(repl,U"none")? 0 : eqStr(repl,U"strict")? 1 : eqStr(repl,U"loose")? 2 : 3;
|
||||
if (replVal==3) thrM("•ReBQN: Invalid repl value");
|
||||
dec(x);
|
||||
Block* initBlock = bqn_comp(m_str32(U"\"(REPL initializer)\""), inc(replPath), m_f64(0));
|
||||
Block* initBlock = bqn_comp(m_str8l("\"(REPL initializer)\""), inc(replPath), m_f64(0));
|
||||
B scVal;
|
||||
if (replVal==0) {
|
||||
scVal = bi_N;
|
||||
@ -726,12 +726,12 @@ B sys_c1(B t, B x) {
|
||||
}
|
||||
|
||||
void sysfn_init() {
|
||||
fCharsDesc = registerNFn(m_str32(U"(file).Chars"), fchars_c1, fchars_c2);
|
||||
fileAtDesc = registerNFn(m_str32(U"(file).At"), fileAt_c1, c2_bad);
|
||||
fLinesDesc = registerNFn(m_str32(U"(file).Lines"), flines_c1, flines_c2);
|
||||
fBytesDesc = registerNFn(m_str32(U"(file).Bytes"), fbytes_c1, fbytes_c2);
|
||||
fCharsDesc = registerNFn(m_str8l("(file).Chars"), fchars_c1, fchars_c2);
|
||||
fileAtDesc = registerNFn(m_str8l("(file).At"), fileAt_c1, c2_bad);
|
||||
fLinesDesc = registerNFn(m_str8l("(file).Lines"), flines_c1, flines_c2);
|
||||
fBytesDesc = registerNFn(m_str8l("(file).Bytes"), fbytes_c1, fbytes_c2);
|
||||
importDesc = registerNFn(m_str32(U"•Import"), import_c1, import_c2);
|
||||
reBQNDesc = registerNFn(m_str32(U"(REPL)"), repl_c1, repl_c2);
|
||||
reBQNDesc = registerNFn(m_str8l("(REPL)"), repl_c1, repl_c2);
|
||||
listDesc = registerNFn(m_str32(U"•file.List"), list_c1, c2_bad);
|
||||
}
|
||||
void sysfnPost_init() {
|
||||
|
||||
@ -24,9 +24,9 @@ B m_c8(u8 x) { return m_c32(x); } B m_c16(u16 x) { return m_c32(x); }
|
||||
#define TP(W,X) W##f64##X
|
||||
#include "tyarrTemplate.c"
|
||||
|
||||
NOINLINE B m_caf64(usz sz, f64* a) { f64* rp; B r = m_f64arrv(&rp, sz); for (usz i = 0; i < sz; i++) rp[i] = a[i]; return r; }
|
||||
NOINLINE B m_cai32(usz sz, i32* a) { i32* rp; B r = m_i32arrv(&rp, sz); for (usz i = 0; i < sz; i++) rp[i] = a[i]; return r; }
|
||||
NOINLINE B m_str8(usz sz, char* s) { u32* rp; B r = m_c32arrv(&rp, sz); for (u64 i = 0; i < sz; i++) rp[i] = (u32)s[i]; return r; }
|
||||
NOINLINE B m_caf64(usz sz, f64* a) { f64* rp; B r = m_f64arrv(&rp, sz); for (usz i = 0; i < sz; i++) rp[i] = a[i]; return r; }
|
||||
NOINLINE B m_cai32(usz sz, i32* a) { i32* rp; B r = m_i32arrv(&rp, sz); for (usz i = 0; i < sz; i++) rp[i] = a[i]; return r; }
|
||||
NOINLINE B m_str8(usz sz, char* s) { u8* rp; B r = m_c8arrv (&rp, sz); for (u64 i = 0; i < sz; i++) rp[i] = s[i]; return r; }
|
||||
NOINLINE B m_str8l(char* s) { return m_str8(strlen(s), s); }
|
||||
NOINLINE B m_str32(u32* s) {
|
||||
usz sz = 0; while(s[sz]) sz++;
|
||||
|
||||
@ -435,22 +435,22 @@ static u32 readBytes4(u8* d) {
|
||||
static void write_asm(u8* p, u64 sz) {
|
||||
i32* rp; B r = m_i32arrv(&rp, sz);
|
||||
for (u64 i = 0; i < sz; i++) rp[i] = p[i];
|
||||
file_wBytes(m_str32(U"asm_bin"), r); dec(r);
|
||||
file_wBytes(m_str8l("asm_bin"), r); dec(r);
|
||||
char off[20]; snprintf(off, 20, "%p", p);
|
||||
B o = m_str8l(off);
|
||||
file_wChars(m_str32(U"asm_off"), o); dec(o);
|
||||
file_wChars(m_str8l("asm_off"), o); dec(o);
|
||||
B s = emptyCVec();
|
||||
#define F(X) AFMT("s/%p$/%p # i_" #X "/;", i_##X, i_##X);
|
||||
F(POPS) F(INC) F(FN1C) F(FN1O) F(FN2C) F(FN2O) F(FN1Oi) F(FN2Oi) F(ARR_0) F(ARR_p) F(DFND_0) F(DFND_1) F(DFND_2) F(MD1C) F(MD2C) F(MD2R) F(TR2D) F(TR3D) F(TR3O) F(EXTO) F(EXTU) F(SETN) F(SETU) F(SETM) F(FLDO) F(ALIM) F(RETD) F(SETNi) F(SETUi) F(SETMi)
|
||||
#undef F
|
||||
file_wChars(m_str32(U"asm_sed"), s); dec(s);
|
||||
file_wChars(m_str8l("asm_sed"), s); dec(s);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void onJIT(Body* body, u8* binEx, u64 sz) {
|
||||
#if USE_PERF
|
||||
if (!perf_map) {
|
||||
B s = m_str32(U"/tmp/perf-"); AFMT("%l.map", getpid());
|
||||
B s = m_str8l("/tmp/perf-"); AFMT("%l.map", getpid());
|
||||
perf_map = file_open(s, "open", "wa");
|
||||
print(s); printf(": map\n");
|
||||
dec(s);
|
||||
|
||||
@ -114,7 +114,7 @@ Block* load_compObj(B x, B src, B path, Scope* sc) { // consumes x,src
|
||||
#include "gen/src"
|
||||
#if RT_SRC
|
||||
Block* load_compImport(B bc, B objs, B blocks, B bodies, B inds, B src) { // consumes all
|
||||
return compile(bc, objs, blocks, bodies, inds, bi_N, src, m_str32(U"(precompiled)"), NULL);
|
||||
return compile(bc, objs, blocks, bodies, inds, bi_N, src, m_str8l("(precompiled)"), NULL);
|
||||
}
|
||||
#else
|
||||
Block* load_compImport(B bc, B objs, B blocks, B bodies) { // consumes all
|
||||
|
||||
10
src/main.c
10
src/main.c
@ -10,8 +10,8 @@ static bool init = false;
|
||||
static void repl_init() {
|
||||
if (init) return;
|
||||
cbqn_init();
|
||||
replPath = m_str32(U"."); gc_add(replPath);
|
||||
Block* initBlock = bqn_comp(m_str32(U"\"(REPL initializer)\""), inc(replPath), m_f64(0));
|
||||
replPath = m_str8l("."); gc_add(replPath);
|
||||
Block* initBlock = bqn_comp(m_str8l("\"(REPL initializer)\""), inc(replPath), m_f64(0));
|
||||
gsc = m_scope(initBlock->bodies[0], NULL, 0, 0, NULL); gc_add(tag(gsc,OBJ_TAG));
|
||||
ptr_dec(initBlock);
|
||||
init = true;
|
||||
@ -85,17 +85,17 @@ int main(int argc, char* argv[]) {
|
||||
#define REQARG(X) if(*carg) { fprintf(stderr, "%s: -%s must end the option\n", argv[0], #X); exit(1); } if (i==argc) { fprintf(stderr, "%s: -%s requires an argument\n", argv[0], #X); exit(1); }
|
||||
case 'f': repl_init(); REQARG(f); goto execFile;
|
||||
case 'e': { repl_init(); REQARG(e);
|
||||
dec(gsc_exec_inline(fromUTF8l(argv[i++]), m_str32(U"(-e)"), emptySVec()));
|
||||
dec(gsc_exec_inline(fromUTF8l(argv[i++]), m_str8l("(-e)"), emptySVec()));
|
||||
break;
|
||||
}
|
||||
case 'p': { repl_init(); REQARG(p);
|
||||
B r = gsc_exec_inline(fromUTF8l(argv[i++]), m_str32(U"(-p)"), emptySVec());
|
||||
B r = gsc_exec_inline(fromUTF8l(argv[i++]), m_str8l("(-p)"), emptySVec());
|
||||
print(r); dec(r);
|
||||
printf("\n");
|
||||
break;
|
||||
}
|
||||
case 'o': { repl_init(); REQARG(o);
|
||||
B r = gsc_exec_inline(fromUTF8l(argv[i++]), m_str32(U"(-o)"), emptySVec());
|
||||
B r = gsc_exec_inline(fromUTF8l(argv[i++]), m_str8l("(-o)"), emptySVec());
|
||||
printRaw(r); dec(r);
|
||||
printf("\n");
|
||||
break;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user