yet another string function rename
This commit is contained in:
parent
3e9093af7b
commit
b1300e6e76
2
cc.bqn
2
cc.bqn
@ -22,7 +22,7 @@ Esc←{
|
|||||||
∾(i<≠in) /⟜"\"⊸∾¨ 𝕩 # Insert \
|
∾(i<≠in) /⟜"\"⊸∾¨ 𝕩 # Insert \
|
||||||
}
|
}
|
||||||
|
|
||||||
OStr ← "m_str32(U"""∾Esc∾""")"˙ # A BQN string
|
OStr ← "m_c32vec_0(U"""∾Esc∾""")"˙ # A BQN string
|
||||||
OChr ← {"m_c32(U'"∾(Esc⥊𝕩)∾"')"} # A BQN character
|
OChr ← {"m_c32(U'"∾(Esc⥊𝕩)∾"')"} # A BQN character
|
||||||
ONum ← {s←"-"/˜𝕩<0 ⋄ ∞⊸=∘|◶⟨"m_f64("∾")"∾˜s∾F∘| ⋄ "m_f64("∾s∾"1.0/0.0)"⟩𝕩} # Format number
|
ONum ← {s←"-"/˜𝕩<0 ⋄ ∞⊸=∘|◶⟨"m_f64("∾")"∾˜s∾F∘| ⋄ "m_f64("∾s∾"1.0/0.0)"⟩𝕩} # Format number
|
||||||
OAny ← ≡◶⟨@⊸≤◶ONum‿OChr, OStr, ⊑⟩
|
OAny ← ≡◶⟨@⊸≤◶ONum‿OChr, OStr, ⊑⟩
|
||||||
|
|||||||
@ -226,12 +226,13 @@ HArr_p r = m_harrUp(10); // 10-item array without any set shape. Use the arr_shW
|
|||||||
|
|
||||||
// you can use withFill to add a fill element to a created array (or manually create a fillarr, see src/core/fillarr.h)
|
// you can use withFill to add a fill element to a created array (or manually create a fillarr, see src/core/fillarr.h)
|
||||||
|
|
||||||
B r = m_str32(U"⟨1⋄2⋄3⟩"); // a constant string with unicode chars
|
B r = m_c32vec(U"⟨1⋄2⋄3⟩", 7); // a constant string with unicode chars
|
||||||
B r = m_ascii("hello", 5); // an ASCII string with specified length
|
B r = m_c32vec_0(U"⟨1⋄2⋄3⟩"); // ..or with implicit length
|
||||||
B r = m_ascii0("hello"); // ↑ but read as null-terminated
|
B r = m_c8vec("hello", 5); // a constant ASCII string
|
||||||
#include "utils/utf.h"
|
B r = m_c8vec_0("hello"); // ..or with implicit length
|
||||||
B r = utf8Decode("⟨1⋄2⋄3⟩", 17) // decode UTF-8 from a char*
|
B r = utf8Decode("⟨1⋄2⋄3⟩", 17) // decode UTF-8 from a char*
|
||||||
B r = utf8Decode0("⟨1⋄2⋄3⟩") // ↑ but read as null-terminated
|
B r = utf8Decode_0("⟨1⋄2⋄3⟩") // ..or with implicit length
|
||||||
|
#include "utils/utf.h"
|
||||||
u64 sz = utf8lenB(x); TALLOC(char, buf, sz+1); toUTF8(x, buf); buf[sz]=0; /*use buf as a C-string*/ TFREE(buf);
|
u64 sz = utf8lenB(x); TALLOC(char, buf, sz+1); toUTF8(x, buf); buf[sz]=0; /*use buf as a C-string*/ TFREE(buf);
|
||||||
|
|
||||||
// src/utils/mut.h provides a way to build an array by copying parts of other arrays
|
// src/utils/mut.h provides a way to build an array by copying parts of other arrays
|
||||||
|
|||||||
@ -7,14 +7,14 @@
|
|||||||
B itype_c1(B t, B x) {
|
B itype_c1(B t, B x) {
|
||||||
B r;
|
B r;
|
||||||
if(isVal(x)) {
|
if(isVal(x)) {
|
||||||
r = m_ascii0(type_repr(v(x)->type));
|
r = m_c8vec_0(type_repr(v(x)->type));
|
||||||
} else {
|
} else {
|
||||||
if (isF64(x)) r = m_ascii0("tagged f64");
|
if (isF64(x)) r = m_c8vec_0("tagged f64");
|
||||||
else if (isC32(x)) r = m_ascii0("tagged c32");
|
else if (isC32(x)) r = m_c8vec_0("tagged c32");
|
||||||
else if (isTag(x)) r = m_ascii0("tagged tag");
|
else if (isTag(x)) r = m_c8vec_0("tagged tag");
|
||||||
else if (isVar(x)) r = m_ascii0("tagged var");
|
else if (isVar(x)) r = m_c8vec_0("tagged var");
|
||||||
else if (isExt(x)) r = m_ascii0("tagged extvar");
|
else if (isExt(x)) r = m_c8vec_0("tagged extvar");
|
||||||
else r = m_ascii0("tagged unknown");
|
else r = m_c8vec_0("tagged unknown");
|
||||||
}
|
}
|
||||||
dec(x);
|
dec(x);
|
||||||
return r;
|
return r;
|
||||||
@ -25,7 +25,7 @@ B elType_c1(B t, B x) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
B refc_c1(B t, B x) {
|
B refc_c1(B t, B x) {
|
||||||
B r = isVal(x)? m_i32(v(x)->refc) : m_ascii0("(not heap-allocated)");
|
B r = isVal(x)? m_i32(v(x)->refc) : m_c8vec_0("(not heap-allocated)");
|
||||||
dec(x);
|
dec(x);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -301,10 +301,10 @@ B unshare_c1(B t, B x) {
|
|||||||
static B internalNS;
|
static B internalNS;
|
||||||
B getInternalNS() {
|
B getInternalNS() {
|
||||||
if (internalNS.u == 0) {
|
if (internalNS.u == 0) {
|
||||||
#define F(X) v_##X = m_ascii0(#X);
|
#define F(X) v_##X = m_c8vec_0(#X);
|
||||||
FOR_VARIATION(F)
|
FOR_VARIATION(F)
|
||||||
#undef F
|
#undef F
|
||||||
listVariations_def = m_ascii0("if");
|
listVariations_def = m_c8vec_0("if");
|
||||||
gc_addFn(variation_gcRoot);
|
gc_addFn(variation_gcRoot);
|
||||||
#define F(X) incG(bi_##X),
|
#define F(X) incG(bi_##X),
|
||||||
Body* d = m_nnsDesc("type","eltype","refc","squeeze","ispure","info","listvariations","variation","clearrefs","unshare","deepsqueeze","heapdump","eequal","temp");
|
Body* d = m_nnsDesc("type","eltype","refc","squeeze","ispure","info","listvariations","variation","clearrefs","unshare","deepsqueeze","heapdump","eequal","temp");
|
||||||
|
|||||||
@ -38,6 +38,6 @@ B nativeInvSwap_c1(B t, B x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void inverse_init() {
|
void inverse_init() {
|
||||||
fn_invRegDesc = registerNFn(m_ascii0("(fn_invReg)"), fn_invReg_c1, fn_invReg_c2);
|
fn_invRegDesc = registerNFn(m_c8vec_0("(fn_invReg)"), fn_invReg_c1, fn_invReg_c2);
|
||||||
fn_invSwapDesc = registerNFn(m_ascii0("(fn_invSwap)"), fn_invSwap_c1, fn_invSwap_c2);
|
fn_invSwapDesc = registerNFn(m_c8vec_0("(fn_invSwap)"), fn_invSwap_c1, fn_invSwap_c2);
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ B nsFmt(B x);
|
|||||||
B rtWrap_unwrap(B x);
|
B rtWrap_unwrap(B x);
|
||||||
#endif
|
#endif
|
||||||
B glyph_c1(B t, B x) {
|
B glyph_c1(B t, B x) {
|
||||||
if (!isVal(x)) return m_str32(U"(•Glyph: not given a function)");
|
if (!isVal(x)) return m_c32vec_0(U"(•Glyph: not given a function)");
|
||||||
#ifdef RT_WRAP
|
#ifdef RT_WRAP
|
||||||
x = rtWrap_unwrap(x);
|
x = rtWrap_unwrap(x);
|
||||||
#endif
|
#endif
|
||||||
@ -76,11 +76,11 @@ B glyph_c1(B t, B x) {
|
|||||||
if (ty==t_md1BI) { B r = utf8Decode0(pm1_repr(c(Md1,x)->extra)); decG(x); return r; }
|
if (ty==t_md1BI) { B r = utf8Decode0(pm1_repr(c(Md1,x)->extra)); decG(x); return r; }
|
||||||
if (ty==t_md2BI) { B r = utf8Decode0(pm2_repr(c(Md2,x)->extra)); decG(x); return r; }
|
if (ty==t_md2BI) { B r = utf8Decode0(pm2_repr(c(Md2,x)->extra)); decG(x); return r; }
|
||||||
if (ty==t_nfn) { B r = nfn_name(x); decG(x); return r; }
|
if (ty==t_nfn) { B r = nfn_name(x); decG(x); return r; }
|
||||||
if (ty==t_funBl) { decG(x); return m_ascii0("(function block)"); }
|
if (ty==t_funBl) { decG(x); return m_c8vec_0("(function block)"); }
|
||||||
if (ty==t_md1Bl) { decG(x); return m_ascii0("(1-modifier block)"); }
|
if (ty==t_md1Bl) { decG(x); return m_c8vec_0("(1-modifier block)"); }
|
||||||
if (ty==t_md2Bl) { decG(x); return m_ascii0("(2-modifier block)"); }
|
if (ty==t_md2Bl) { decG(x); return m_c8vec_0("(2-modifier block)"); }
|
||||||
if (ty==t_ns) return nsFmt(x);
|
if (ty==t_ns) return nsFmt(x);
|
||||||
return m_str32(U"(•Glyph: given object with unexpected type)");
|
return m_c32vec_0(U"(•Glyph: given object with unexpected type)");
|
||||||
}
|
}
|
||||||
|
|
||||||
B repr_c1(B t, B x) {
|
B repr_c1(B t, B x) {
|
||||||
@ -536,9 +536,9 @@ static NOINLINE void rand_init() {
|
|||||||
rand_ns = m_nnsDesc("seed1", "seed2", "range", "deal", "subset");
|
rand_ns = m_nnsDesc("seed1", "seed2", "range", "deal", "subset");
|
||||||
NSDesc* d = rand_ns->nsDesc;
|
NSDesc* d = rand_ns->nsDesc;
|
||||||
d->expGIDs[0] = d->expGIDs[1] = -1;
|
d->expGIDs[0] = d->expGIDs[1] = -1;
|
||||||
rand_rangeName = m_ascii0("range"); gc_add(rand_rangeName); rand_rangeDesc = registerNFn(m_ascii0("(rand).Range"), rand_range_c1, rand_range_c2);
|
rand_rangeName = m_c8vec_0("range"); gc_add(rand_rangeName); rand_rangeDesc = registerNFn(m_c8vec_0("(rand).Range"), rand_range_c1, rand_range_c2);
|
||||||
rand_dealName = m_ascii0("deal"); gc_add(rand_dealName); rand_dealDesc = registerNFn(m_ascii0("(rand).Deal"), rand_deal_c1, rand_deal_c2);
|
rand_dealName = m_c8vec_0("deal"); gc_add(rand_dealName); rand_dealDesc = registerNFn(m_c8vec_0("(rand).Deal"), rand_deal_c1, rand_deal_c2);
|
||||||
rand_subsetName = m_ascii0("subset"); gc_add(rand_subsetName); rand_subsetDesc = registerNFn(m_ascii0("(rand).Subset"), c1_bad, rand_subset_c2);
|
rand_subsetName = m_c8vec_0("subset"); gc_add(rand_subsetName); rand_subsetDesc = registerNFn(m_c8vec_0("(rand).Subset"), c1_bad, rand_subset_c2);
|
||||||
}
|
}
|
||||||
B makeRand_c1(B t, B x) {
|
B makeRand_c1(B t, B x) {
|
||||||
if (!isNum(x)) thrM("•MakeRand: 𝕩 must be a number");
|
if (!isNum(x)) thrM("•MakeRand: 𝕩 must be a number");
|
||||||
@ -567,7 +567,7 @@ B reBQN_c1(B t, B x) {
|
|||||||
B prim = ns_getC(x, "primitives");
|
B prim = ns_getC(x, "primitives");
|
||||||
i32 replVal = q_N(repl) || eqStr(repl,U"none")? 0 : eqStr(repl,U"strict")? 1 : eqStr(repl,U"loose")? 2 : 3;
|
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");
|
if (replVal==3) thrM("•ReBQN: Invalid repl value");
|
||||||
Block* initBlock = bqn_comp(m_ascii0("\"(REPL initializer)\""), inc(cdPath), m_f64(0));
|
Block* initBlock = bqn_comp(m_c8vec_0("\"(REPL initializer)\""), inc(cdPath), m_f64(0));
|
||||||
B scVal;
|
B scVal;
|
||||||
if (replVal==0) {
|
if (replVal==0) {
|
||||||
scVal = bi_N;
|
scVal = bi_N;
|
||||||
@ -1246,21 +1246,21 @@ void sysfn_init() {
|
|||||||
#if CATCH_ERRORS
|
#if CATCH_ERRORS
|
||||||
lastErrMsg = bi_N;
|
lastErrMsg = bi_N;
|
||||||
#endif
|
#endif
|
||||||
cdPath = m_ascii(".", 1); gc_add(cdPath); gc_addFn(sys_gcFn);
|
cdPath = m_c8vec(".", 1); gc_add(cdPath); gc_addFn(sys_gcFn);
|
||||||
fCharsDesc = registerNFn(m_ascii0("(file).Chars"), fchars_c1, fchars_c2);
|
fCharsDesc = registerNFn(m_c8vec_0("(file).Chars"), fchars_c1, fchars_c2);
|
||||||
fileAtDesc = registerNFn(m_ascii0("(file).At"), fileAt_c1, fileAt_c2);
|
fileAtDesc = registerNFn(m_c8vec_0("(file).At"), fileAt_c1, fileAt_c2);
|
||||||
fLinesDesc = registerNFn(m_ascii0("(file).Lines"), flines_c1, flines_c2);
|
fLinesDesc = registerNFn(m_c8vec_0("(file).Lines"), flines_c1, flines_c2);
|
||||||
fBytesDesc = registerNFn(m_ascii0("(file).Bytes"), fbytes_c1, fbytes_c2);
|
fBytesDesc = registerNFn(m_c8vec_0("(file).Bytes"), fbytes_c1, fbytes_c2);
|
||||||
fListDesc = registerNFn(m_ascii0("(file).List"), list_c1, c2_bad);
|
fListDesc = registerNFn(m_c8vec_0("(file).List"), list_c1, c2_bad);
|
||||||
fTypeDesc = registerNFn(m_ascii0("(file).Type"), ftype_c1, c2_bad);
|
fTypeDesc = registerNFn(m_c8vec_0("(file).Type"), ftype_c1, c2_bad);
|
||||||
createdirDesc= registerNFn(m_ascii0("(file).CreateDir"), createdir_c1, c2_bad);
|
createdirDesc= registerNFn(m_c8vec_0("(file).CreateDir"), createdir_c1, c2_bad);
|
||||||
renameDesc = registerNFn(m_ascii0("(file).Rename"), c1_bad, rename_c2);
|
renameDesc = registerNFn(m_c8vec_0("(file).Rename"), c1_bad, rename_c2);
|
||||||
removeDesc = registerNFn(m_ascii0("(file).Remove"), remove_c1, c2_bad);
|
removeDesc = registerNFn(m_c8vec_0("(file).Remove"), remove_c1, c2_bad);
|
||||||
fMapBytesDesc= registerNFn(m_ascii0("(file).MapBytes"), mapBytes_c1, c2_bad);
|
fMapBytesDesc= registerNFn(m_c8vec_0("(file).MapBytes"), mapBytes_c1, c2_bad);
|
||||||
fExistsDesc = registerNFn(m_ascii0("(file).Exists"), fexists_c1, c2_bad);
|
fExistsDesc = registerNFn(m_c8vec_0("(file).Exists"), fexists_c1, c2_bad);
|
||||||
reBQNDesc = registerNFn(m_ascii0("(REPL)"), repl_c1, repl_c2);
|
reBQNDesc = registerNFn(m_c8vec_0("(REPL)"), repl_c1, repl_c2);
|
||||||
importDesc = registerNFn(m_str32(U"•Import"), import_c1, import_c2);
|
importDesc = registerNFn(m_c32vec_0(U"•Import"), import_c1, import_c2);
|
||||||
ffiloadDesc = registerNFn(m_str32(U"•FFI"), c1_bad, ffiload_c2);
|
ffiloadDesc = registerNFn(m_c32vec_0(U"•FFI"), c1_bad, ffiload_c2);
|
||||||
}
|
}
|
||||||
void sysfnPost_init() {
|
void sysfnPost_init() {
|
||||||
file_nsGen = m_nnsDesc("path","at","list","bytes","chars","lines","type","exists","name","mapbytes","createdir","rename","remove");
|
file_nsGen = m_nnsDesc("path","at","list","bytes","chars","lines","type","exists","name","mapbytes","createdir","rename","remove");
|
||||||
|
|||||||
@ -17,9 +17,11 @@
|
|||||||
#undef c32
|
#undef c32
|
||||||
|
|
||||||
|
|
||||||
B m_str32(u32* s);
|
B m_c32vec_0(u32* s);
|
||||||
B m_ascii0(char* s);
|
B m_c32vec(u32* s, i64 sz);
|
||||||
B m_ascii(char* s, i64 sz);
|
B m_c8vec_0(char* s);
|
||||||
|
B m_c8vec(char* s, i64 sz);
|
||||||
|
|
||||||
B utf8Decode0(const char* x);
|
B utf8Decode0(const char* x);
|
||||||
B utf8Decode(const char* x, i64 sz);
|
B utf8Decode(const char* x, i64 sz);
|
||||||
B utf8DecodeA(I8Arr* x);
|
B utf8DecodeA(I8Arr* x);
|
||||||
|
|||||||
@ -148,8 +148,8 @@ void derv_init() {
|
|||||||
TIi(t_md1D,identity) = md1D_identity;
|
TIi(t_md1D,identity) = md1D_identity;
|
||||||
}
|
}
|
||||||
void dervPost_init() {
|
void dervPost_init() {
|
||||||
ucwWrapDesc = registerNFn(m_ascii0("(temporary function for ⌾)"), ucwWrap_c1, c2_bad);
|
ucwWrapDesc = registerNFn(m_c8vec_0("(temporary function for ⌾)"), ucwWrap_c1, c2_bad);
|
||||||
uc1WrapDesc = registerNFn(m_ascii0("(temporary function for ⌾)"), uc1Wrap_c1, c2_bad);
|
uc1WrapDesc = registerNFn(m_c8vec_0("(temporary function for ⌾)"), uc1Wrap_c1, c2_bad);
|
||||||
TIi(t_fork,fn_uc1) = fork_uc1; // in post probably to make sure it's not used while not fully initialized or something? idk
|
TIi(t_fork,fn_uc1) = fork_uc1; // in post probably to make sure it's not used while not fully initialized or something? idk
|
||||||
TIi(t_atop,fn_uc1) = atop_uc1;
|
TIi(t_atop,fn_uc1) = atop_uc1;
|
||||||
c(BMd2,bi_atop)->uc1 = atopM2_uc1;
|
c(BMd2,bi_atop)->uc1 = atopM2_uc1;
|
||||||
|
|||||||
@ -156,7 +156,7 @@ void print_fmt(char* p, ...);
|
|||||||
#define AJOIN(X) s = vec_join(s,X) // consumes X
|
#define AJOIN(X) s = vec_join(s,X) // consumes X
|
||||||
#define AOBJ(X) s = vec_addN(s,X) // consumes X
|
#define AOBJ(X) s = vec_addN(s,X) // consumes X
|
||||||
#define ACHR(X) AOBJ(m_c32(X))
|
#define ACHR(X) AOBJ(m_c32(X))
|
||||||
#define A8(X) AJOIN(m_ascii0(X))
|
#define A8(X) AJOIN(m_c8vec_0(X))
|
||||||
#define AU(X) AJOIN(utf8Decode0(X))
|
#define AU(X) AJOIN(utf8Decode0(X))
|
||||||
#define AFMT(...) s = append_fmt(s, __VA_ARGS__)
|
#define AFMT(...) s = append_fmt(s, __VA_ARGS__)
|
||||||
|
|
||||||
|
|||||||
@ -45,16 +45,13 @@ 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
|
#define TP(W,X) W##f64##X
|
||||||
#include "tyarrTemplate.c"
|
#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_caf64(usz sz, f64* a) { f64* rp; B r = m_f64arrv(&rp, sz); memcpy(rp, a, sz*sizeof( f64)); 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_cai32(usz sz, i32* a) { i32* rp; B r = m_i32arrv(&rp, sz); memcpy(rp, a, sz*sizeof( i32)); return r; }
|
||||||
NOINLINE B m_ascii(char* s, i64 sz) { u8* rp; B r = m_c8arrv (&rp, sz); for (u64 i = 0; i < sz; i++) rp[i] = s[i]; return r; }
|
NOINLINE B m_c8vec(char* a, i64 sz) { u8* rp; B r = m_c8arrv (&rp, sz); memcpy(rp, a, sz*sizeof(char)); return r; }
|
||||||
NOINLINE B m_ascii0(char* s) { return m_ascii(s, strlen(s)); }
|
NOINLINE B m_c32vec(u32* s, i64 sz) { u32* rp; B r = m_c32arrv(&rp, sz); memcpy(rp, s, sz*sizeof( u32)); return r; }
|
||||||
NOINLINE B m_str32(u32* s) {
|
NOINLINE B m_c8vec_0(char* s) { return m_c8vec(s, strlen(s)); }
|
||||||
usz sz = 0; while(s[sz]) sz++;
|
NOINLINE B m_c32vec_0(u32* s) { usz sz=0; while(s[sz]) sz++; return m_c32vec(s, sz); }
|
||||||
u32* rp; B r = m_c32arrv(&rp, sz);
|
|
||||||
for (usz i = 0; i < sz; i++) rp[i] = s[i];
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Arr* bitarr_slice(B x, usz s, usz ia) {
|
static Arr* bitarr_slice(B x, usz s, usz ia) {
|
||||||
u64* rp; Arr* r = m_bitarrp(&rp, ia);
|
u64* rp; Arr* r = m_bitarrp(&rp, ia);
|
||||||
|
|||||||
@ -758,8 +758,8 @@ void ffiType_print(FILE* f, B x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ffi_init() {
|
void ffi_init() {
|
||||||
boundFnDesc = registerNFn(m_ascii0("(foreign function)"), boundFn_c1, boundFn_c2);
|
boundFnDesc = registerNFn(m_c8vec_0("(foreign function)"), boundFn_c1, boundFn_c2);
|
||||||
foreignFnDesc = registerNFn(m_ascii0("(foreign function)"), directFn_c1, directFn_c2);
|
foreignFnDesc = registerNFn(m_c8vec_0("(foreign function)"), directFn_c1, directFn_c2);
|
||||||
TIi(t_ffiType,freeO) = ffiType_freeO;
|
TIi(t_ffiType,freeO) = ffiType_freeO;
|
||||||
TIi(t_ffiType,freeF) = ffiType_freeF;
|
TIi(t_ffiType,freeF) = ffiType_freeF;
|
||||||
TIi(t_ffiType,visit) = ffiType_visit;
|
TIi(t_ffiType,visit) = ffiType_visit;
|
||||||
|
|||||||
1
src/h.h
1
src/h.h
@ -344,7 +344,6 @@ B withFill(B x, B f); // consumes both
|
|||||||
|
|
||||||
static B m_unit (B x); // consumes
|
static B m_unit (B x); // consumes
|
||||||
static B m_hunit(B x); // consumes
|
static B m_hunit(B x); // consumes
|
||||||
B m_str32(u32* s); // meant to be used as m_str32(U"{𝕨‿𝕩}"), so doesn't free for you
|
|
||||||
|
|
||||||
B bqn_exec(B str, B path, B args); // consumes all
|
B bqn_exec(B str, B path, B args); // consumes all
|
||||||
B bqn_execFile(B path, B args); // consumes
|
B bqn_execFile(B path, B args); // consumes
|
||||||
|
|||||||
@ -493,22 +493,22 @@ void freeOpt(OptRes o) {
|
|||||||
static void write_asm(u8* p, u64 sz) {
|
static void write_asm(u8* p, u64 sz) {
|
||||||
i32* rp; B r = m_i32arrv(&rp, sz);
|
i32* rp; B r = m_i32arrv(&rp, sz);
|
||||||
for (u64 i = 0; i < sz; i++) rp[i] = p[i];
|
for (u64 i = 0; i < sz; i++) rp[i] = p[i];
|
||||||
path_wBytes(m_ascii0("asm_bin"), r); dec(r);
|
path_wBytes(m_c8vec_0("asm_bin"), r); dec(r);
|
||||||
char off[20]; snprintf(off, 20, "%p", p);
|
char off[20]; snprintf(off, 20, "%p", p);
|
||||||
B o = m_ascii0(off);
|
B o = m_c8vec_0(off);
|
||||||
path_wChars(m_ascii0("asm_off"), o); dec(o);
|
path_wChars(m_c8vec_0("asm_off"), o); dec(o);
|
||||||
B s = emptyCVec();
|
B s = emptyCVec();
|
||||||
#define F(X) AFMT("s/%p$/%p # i_" #X "/;", i_##X, i_##X);
|
#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(LST_0)F(LST_p)F(ARMM)F(ARMO)F(DFND_0)F(DFND_1)F(DFND_2)F(MD1C)F(MD2C)F(MD2R)F(TR2D)F(TR3D)F(TR3O)F(NOVAR)F(EXTO)F(EXTU)F(SETN)F(SETU)F(SETM)F(SETC)F(SETH1)F(SETH2)F(PRED1)F(PRED2)F(SETNi)F(SETUi)F(SETMi)F(SETCi)F(SETNv)F(SETUv)F(SETMv)F(SETCv)F(FLDO)F(VFYM)F(ALIM)F(CHKV)F(FAIL)F(RETD)
|
F(POPS)F(INC)F(FN1C)F(FN1O)F(FN2C)F(FN2O)F(FN1Oi)F(FN2Oi)F(LST_0)F(LST_p)F(ARMM)F(ARMO)F(DFND_0)F(DFND_1)F(DFND_2)F(MD1C)F(MD2C)F(MD2R)F(TR2D)F(TR3D)F(TR3O)F(NOVAR)F(EXTO)F(EXTU)F(SETN)F(SETU)F(SETM)F(SETC)F(SETH1)F(SETH2)F(PRED1)F(PRED2)F(SETNi)F(SETUi)F(SETMi)F(SETCi)F(SETNv)F(SETUv)F(SETMv)F(SETCv)F(FLDO)F(VFYM)F(ALIM)F(CHKV)F(FAIL)F(RETD)
|
||||||
#undef F
|
#undef F
|
||||||
path_wChars(m_ascii0("asm_sed"), s); dec(s);
|
path_wChars(m_c8vec_0("asm_sed"), s); dec(s);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void onJIT(Body* body, u8* binEx, u64 sz) {
|
static void onJIT(Body* body, u8* binEx, u64 sz) {
|
||||||
#if USE_PERF
|
#if USE_PERF
|
||||||
if (!perf_map) {
|
if (!perf_map) {
|
||||||
B s = m_ascii0("/tmp/perf-"); AFMT("%l.map", getpid());
|
B s = m_c8vec_0("/tmp/perf-"); AFMT("%l.map", getpid());
|
||||||
perf_map = file_open(s, "open", "wa");
|
perf_map = file_open(s, "open", "wa");
|
||||||
print(s); printf(": map\n");
|
print(s); printf(": map\n");
|
||||||
dec(s);
|
dec(s);
|
||||||
|
|||||||
@ -114,14 +114,15 @@ Block* load_compObj(B x, B src, B path, Scope* sc) { // consumes x,src
|
|||||||
decG(x);
|
decG(x);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "gen/src"
|
#include "gen/src"
|
||||||
#if RT_SRC
|
#if RT_SRC
|
||||||
Block* load_compImport(char* name, B bc, B objs, B blocks, B bodies, B inds, B src) { // consumes all
|
Block* load_compImport(char* name, 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_ascii0(name), NULL);
|
return compile(bc, objs, blocks, bodies, inds, bi_N, src, m_c8vec_0(name), NULL);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Block* load_compImport(char* name, B bc, B objs, B blocks, B bodies) { // consumes all
|
Block* load_compImport(char* name, B bc, B objs, B blocks, B bodies) { // consumes all
|
||||||
return compile(bc, objs, blocks, bodies, bi_N, bi_N, bi_N, m_ascii0(name), NULL);
|
return compile(bc, objs, blocks, bodies, bi_N, bi_N, bi_N, m_c8vec_0(name), NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -462,7 +463,7 @@ void load_init() { // very last init function
|
|||||||
#include "gen/compiles"
|
#include "gen/compiles"
|
||||||
);
|
);
|
||||||
runtime[n_asrt] = prevAsrt;
|
runtime[n_asrt] = prevAsrt;
|
||||||
load_glyphs = m_hVec3(m_str32(U"+-×÷⋆√⌊⌈|¬∧∨<>≠=≤≥≡≢⊣⊢⥊∾≍⋈↑↓↕«»⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔!"), m_str32(U"˙˜˘¨⌜⁼´˝`"), m_str32(U"∘○⊸⟜⌾⊘◶⎉⚇⍟⎊"));
|
load_glyphs = m_hVec3(m_c32vec_0(U"+-×÷⋆√⌊⌈|¬∧∨<>≠=≤≥≡≢⊣⊢⥊∾≍⋈↑↓↕«»⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔!"), m_c32vec_0(U"˙˜˘¨⌜⁼´˝`"), m_c32vec_0(U"∘○⊸⟜⌾⊘◶⎉⚇⍟⎊"));
|
||||||
load_compgen = evalFunBlock(comp_b, 0); ptr_dec(comp_b);
|
load_compgen = evalFunBlock(comp_b, 0); ptr_dec(comp_b);
|
||||||
load_comp = c1(load_compgen, inc(load_glyphs));
|
load_comp = c1(load_compgen, inc(load_glyphs));
|
||||||
gc_add(load_compgen); gc_add(load_comp); gc_add(load_glyphs);
|
gc_add(load_compgen); gc_add(load_comp); gc_add(load_glyphs);
|
||||||
|
|||||||
10
src/main.c
10
src/main.c
@ -14,7 +14,7 @@ static bool init = false;
|
|||||||
static void repl_init() {
|
static void repl_init() {
|
||||||
if (init) return;
|
if (init) return;
|
||||||
cbqn_init();
|
cbqn_init();
|
||||||
replPath = m_ascii0("."); gc_add(replPath);
|
replPath = m_c8vec_0("."); gc_add(replPath);
|
||||||
Body* body = m_nnsDesc();
|
Body* body = m_nnsDesc();
|
||||||
B ns = m_nns(body);
|
B ns = m_nns(body);
|
||||||
gsc = ptr_inc(c(NS, ns)->sc); gc_add(tag(gsc,OBJ_TAG));
|
gsc = ptr_inc(c(NS, ns)->sc); gc_add(tag(gsc,OBJ_TAG));
|
||||||
@ -341,18 +341,18 @@ 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); }
|
#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 'f': repl_init(); REQARG(f); goto execFile;
|
||||||
case 'e': { repl_init(); REQARG(e);
|
case 'e': { repl_init(); REQARG(e);
|
||||||
dec(gsc_exec_inline(utf8Decode0(argv[i++]), m_ascii0("(-e)"), emptySVec()));
|
dec(gsc_exec_inline(utf8Decode0(argv[i++]), m_c8vec_0("(-e)"), emptySVec()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'L': { repl_init(); break; } // just initialize. mostly for perf testing
|
case 'L': { repl_init(); break; } // just initialize. mostly for perf testing
|
||||||
case 'p': { repl_init(); REQARG(p);
|
case 'p': { repl_init(); REQARG(p);
|
||||||
B r = bqn_fmt(gsc_exec_inline(utf8Decode0(argv[i++]), m_ascii0("(-p)"), emptySVec()));
|
B r = bqn_fmt(gsc_exec_inline(utf8Decode0(argv[i++]), m_c8vec_0("(-p)"), emptySVec()));
|
||||||
printRaw(r); dec(r);
|
printRaw(r); dec(r);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'o': { repl_init(); REQARG(o);
|
case 'o': { repl_init(); REQARG(o);
|
||||||
B r = gsc_exec_inline(utf8Decode0(argv[i++]), m_ascii0("(-o)"), emptySVec());
|
B r = gsc_exec_inline(utf8Decode0(argv[i++]), m_c8vec_0("(-o)"), emptySVec());
|
||||||
printRaw(r); dec(r);
|
printRaw(r); dec(r);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
break;
|
break;
|
||||||
@ -403,7 +403,7 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
B execRes;
|
B execRes;
|
||||||
if (execStdin) {
|
if (execStdin) {
|
||||||
execRes = gsc_exec_inline(utf8DecodeA(stream_bytes(stdin)), m_ascii0("(-)"), args);
|
execRes = gsc_exec_inline(utf8DecodeA(stream_bytes(stdin)), m_c8vec_0("(-)"), args);
|
||||||
} else {
|
} else {
|
||||||
execRes = bqn_execFile(src, args);
|
execRes = bqn_execFile(src, args);
|
||||||
}
|
}
|
||||||
|
|||||||
4
src/ns.c
4
src/ns.c
@ -69,7 +69,7 @@ B ns_getNU(B ns, B name, bool thrEmpty) { VTY(ns, t_ns);
|
|||||||
return bi_N;
|
return bi_N;
|
||||||
}
|
}
|
||||||
B ns_getC(B ns, char* name) {
|
B ns_getC(B ns, char* name) {
|
||||||
B field = m_ascii0(name);
|
B field = m_c8vec_0(name);
|
||||||
B r = ns_getNU(ns, field, false);
|
B r = ns_getNU(ns, field, false);
|
||||||
decG(field);
|
decG(field);
|
||||||
return r;
|
return r;
|
||||||
@ -102,7 +102,7 @@ Body* m_nnsDescF(i32 n, char** names) {
|
|||||||
incBy(emptyi32obj, 3);
|
incBy(emptyi32obj, 3);
|
||||||
|
|
||||||
M_HARR(nl, n)
|
M_HARR(nl, n)
|
||||||
for (usz i = 0; i < n; i++) HARR_ADD(nl, i, m_ascii0(names[i]));
|
for (usz i = 0; i < n; i++) HARR_ADD(nl, i, m_c8vec_0(names[i]));
|
||||||
|
|
||||||
Comp* comp = mm_alloc(sizeof(Comp), t_comp);
|
Comp* comp = mm_alloc(sizeof(Comp), t_comp);
|
||||||
comp->bc = emptyi32obj;
|
comp->bc = emptyi32obj;
|
||||||
|
|||||||
@ -217,7 +217,7 @@ B path_list(B path) {
|
|||||||
B res = emptySVec();
|
B res = emptySVec();
|
||||||
while ((c = readdir(d)) != NULL) {
|
while ((c = readdir(d)) != NULL) {
|
||||||
char* name = c->d_name;
|
char* name = c->d_name;
|
||||||
if (name[0]=='.'? !(name[1]==0 || (name[1]=='.'&&name[2]==0)) : true) res = vec_addN(res, m_ascii0(name));
|
if (name[0]=='.'? !(name[1]==0 || (name[1]=='.'&&name[2]==0)) : true) res = vec_addN(res, m_c8vec_0(name));
|
||||||
}
|
}
|
||||||
closedir(d);
|
closedir(d);
|
||||||
dec(path);
|
dec(path);
|
||||||
|
|||||||
2
src/vm.c
2
src/vm.c
@ -1230,7 +1230,7 @@ void comp_init() {
|
|||||||
TIi(t_funBl,fn_iw) = funBl_iw; TIi(t_md1Bl,m1_iw) = md1Bl_iw; TIi(t_md2Bl,m2_iw) = md2Bl_iw;
|
TIi(t_funBl,fn_iw) = funBl_iw; TIi(t_md1Bl,m1_iw) = md1Bl_iw; TIi(t_md2Bl,m2_iw) = md2Bl_iw;
|
||||||
TIi(t_funBl,fn_ix) = funBl_ix; TIi(t_md1Bl,m1_ix) = md1Bl_ix; TIi(t_md2Bl,m2_ix) = md2Bl_ix;
|
TIi(t_funBl,fn_ix) = funBl_ix; TIi(t_md1Bl,m1_ix) = md1Bl_ix; TIi(t_md2Bl,m2_ix) = md2Bl_ix;
|
||||||
|
|
||||||
oomMessage = m_ascii0("Out of memory"); gc_add(oomMessage);
|
oomMessage = m_c8vec_0("Out of memory"); gc_add(oomMessage);
|
||||||
WrappedObj* arm0 = mm_alloc(sizeof(WrappedObj), t_arrMerge);
|
WrappedObj* arm0 = mm_alloc(sizeof(WrappedObj), t_arrMerge);
|
||||||
arm0->obj = emptyHVec();
|
arm0->obj = emptyHVec();
|
||||||
emptyARMM = tag(arm0, OBJ_TAG);
|
emptyARMM = tag(arm0, OBJ_TAG);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user