all native builtins
This commit is contained in:
parent
b656c9aa44
commit
14d298231f
@ -18,13 +18,13 @@
|
||||
/* arithm.c*/M(sin,"•math.Sin") M(cos,"•math.Cos") M(tan,"•math.Tan") M(asin,"•math.Asin") M(acos,"•math.Acos") M(atan,"•math.Atan")
|
||||
|
||||
#define FOR_PM1(A,M,D) \
|
||||
/*md1.c*/A(tbl,"⌜") A(each,"¨") A(fold,"´") A(scan,"`") A(const,"˙") A(swap,"˜") A(cell,"˘") \
|
||||
/*md1.c*/A(tbl,"⌜") A(each,"¨") A(fold,"´") A(scan,"`") A(const,"˙") A(swap,"˜") A(cell,"˘") A(insert,"˝") \
|
||||
/*inverse.c*/A(undo,"⁼") \
|
||||
/* everything before the definition of •_timed is defined to be pure, and everything after is not */ \
|
||||
/*md1.c*/A(timed,"•_timed")
|
||||
|
||||
#define FOR_PM2(A,M,D) \
|
||||
/*md2.c*/A(val,"⊘") A(repeat,"⍟") A(rank,"⎉") A(fillBy,"•_fillBy_") A(catch,"⎊") \
|
||||
/*md2.c*/A(val,"⊘") A(repeat,"⍟") A(rank,"⎉") A(depth,"⚇") A(fillBy,"•_fillBy_") A(catch,"⎊") \
|
||||
/*md2.c*/A(atop,"∘") A(over,"○") A(before,"⊸") A(after,"⟜") A(cond,"◶") A(under,"⌾") \
|
||||
/* everything before the definition of •_while_ is defined to be pure, and everything after is not */ \
|
||||
/*md2.c*/A(while,"•_while_")
|
||||
@ -35,8 +35,8 @@ enum PrimNumbers {
|
||||
/* ⊣⊢⥊∾≍⋈↑↓↕« */ n_ltack , n_rtack , n_shape , n_join , n_couple , n_pair , n_take , n_drop , n_ud , n_shifta,
|
||||
/* »⌽⍉/⍋⍒⊏⊑⊐⊒ */ n_shiftb , n_reverse, n_transp, n_slash, n_gradeUp, n_gradeDown, n_select, n_pick , n_indexOf, n_count,
|
||||
/* ∊⍷⊔!˙˜˘¨⌜⁼ */ n_memberOf, n_find , n_group , n_asrt , n_const , n_swap , n_cell , n_each , n_tbl , n_undo,
|
||||
/* ´˝`∘○⊸⟜⌾⊘◶ */ n_fold , n_reduce , n_scan , n_atop , n_over , n_before , n_after , n_under, n_val , n_cond,
|
||||
/* ⎉⚇⍟⎊ */ n_rank , n_depth2 , n_repeat, n_catch
|
||||
/* ´˝`∘○⊸⟜⌾⊘◶ */ n_fold , n_insert , n_scan , n_atop , n_over , n_before , n_after , n_under, n_val , n_cond,
|
||||
/* ⎉⚇⍟⎊ */ n_rank , n_depth , n_repeat, n_catch
|
||||
};
|
||||
extern B rt_invFnReg, rt_invFnSwap;
|
||||
extern BB2B rt_invFnRegFn;
|
||||
|
||||
@ -340,6 +340,20 @@ B timed_c1(Md1D* d, B x) { B f = d->f;
|
||||
}
|
||||
|
||||
|
||||
static B m1c1(B t, B f, B x) { // consumes x
|
||||
B fn = m1_d(inc(t), inc(f));
|
||||
B r = c1(fn, x);
|
||||
dec(fn);
|
||||
return r;
|
||||
}
|
||||
static B m1c2(B t, B f, B w, B x) { // consumes w,x
|
||||
B fn = m1_d(inc(t), inc(f));
|
||||
B r = c2(fn, w, x);
|
||||
dec(fn);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
extern B rt_cell;
|
||||
B cell_c1(Md1D* d, B x) { B f = d->f;
|
||||
if (isAtm(x) || rnk(x)==0) {
|
||||
@ -372,12 +386,12 @@ B cell_c2(Md1D* d, B w, B x) { B f = d->f;
|
||||
B r = c2(f, w, x);
|
||||
return isAtm(r)? m_atomUnit(r) : r;
|
||||
}
|
||||
B fn = m1_d(inc(rt_cell), inc(f)); // TODO
|
||||
B r = c2(fn, w, x);
|
||||
dec(fn);
|
||||
return r;
|
||||
return m1c2(rt_cell, f, w, x);
|
||||
}
|
||||
|
||||
extern B rt_insert;
|
||||
B insert_c1(Md1D* d, B x) { return m1c1(rt_insert, d->f, x); }
|
||||
B insert_c2(Md1D* d, B w, B x) { return m1c2(rt_insert, d->f, w, x); }
|
||||
|
||||
|
||||
static void print_md1BI(B x) { printf("%s", pm1_repr(c(Md1,x)->extra)); }
|
||||
|
||||
@ -177,13 +177,13 @@ B while_c2(Md2D* d, B w, B x) { B f=d->f; B g=d->g;
|
||||
return x;
|
||||
}
|
||||
|
||||
B m1c(B t, B f, B g, B x) { // consumes x
|
||||
static B m2c1(B t, B f, B g, B x) { // consumes x
|
||||
B fn = m2_d(inc(t), inc(f), inc(g));
|
||||
B r = c1(fn, x);
|
||||
dec(fn);
|
||||
return r;
|
||||
}
|
||||
B m2c(B t, B f, B g, B w, B x) { // consumes w,x
|
||||
static B m2c2(B t, B f, B g, B w, B x) { // consumes w,x
|
||||
B fn = m2_d(inc(t), inc(f), inc(g));
|
||||
B r = c2(fn, w, x);
|
||||
dec(fn);
|
||||
@ -249,9 +249,17 @@ B rank_c1(Md2D* d, B x) { B f = d->f; B g = d->g;
|
||||
}
|
||||
extern B rt_rank;
|
||||
B rank_c2(Md2D* d, B w, B x) { B f = d->f; B g = d->g; // TODO
|
||||
return m2c(rt_rank, f, g, w, x);
|
||||
return m2c2(rt_rank, f, g, w, x);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
extern B rt_depth;
|
||||
B depth_c1(Md2D* d, B x) { return m2c1(rt_depth, d->f, d->g, x); }
|
||||
B depth_c2(Md2D* d, B w, B x) { return m2c2(rt_depth, d->f, d->g, w, x); }
|
||||
|
||||
|
||||
static void print_md2BI(B x) { printf("%s", pm2_repr(c(Md1,x)->extra)); }
|
||||
void md2_init() {
|
||||
TIi(t_md2BI,print) = print_md2BI;
|
||||
|
||||
12
src/load.c
12
src/load.c
@ -102,7 +102,7 @@ B comp_currArgs;
|
||||
B comp_currSrc;
|
||||
B comp_currRe;
|
||||
|
||||
B rt_merge, rt_undo, rt_select, rt_slash, rt_join, rt_ud, rt_pick,rt_take, rt_drop,
|
||||
B rt_merge, rt_undo, rt_select, rt_slash, rt_join, rt_ud, rt_pick, rt_take, rt_drop, rt_insert, rt_depth,
|
||||
rt_group, rt_under, rt_reverse, rt_indexOf, rt_count, rt_memberOf, rt_find, rt_cell, rt_rank, rt_transp;
|
||||
Block* load_compObj(B x, B src, B path, Scope* sc) { // consumes x,src
|
||||
SGet(x)
|
||||
@ -322,8 +322,8 @@ void load_init() { // very last init function
|
||||
/* ⊣⊢⥊∾≍⋈↑↓↕« */ bi_ltack , bi_rtack , bi_shape , bi_join , bi_couple , bi_pair , bi_take , bi_drop , bi_ud , bi_shifta,
|
||||
/* »⌽⍉/⍋⍒⊏⊑⊐⊒ */ bi_shiftb , bi_reverse, bi_transp, bi_slash, bi_gradeUp, bi_gradeDown, bi_select, bi_pick , bi_indexOf, bi_count,
|
||||
/* ∊⍷⊔!˙˜˘¨⌜⁼ */ bi_memberOf, bi_find , bi_group , bi_asrt , bi_const , bi_swap , bi_cell , bi_each , bi_tbl , bi_undo,
|
||||
/* ´˝`∘○⊸⟜⌾⊘◶ */ bi_fold , bi_N , bi_scan , bi_atop , bi_over , bi_before , bi_after , bi_under, bi_val , bi_cond,
|
||||
/* ⎉⚇⍟⎊ */ bi_rank , bi_N , bi_repeat, bi_catch
|
||||
/* ´˝`∘○⊸⟜⌾⊘◶ */ bi_fold , bi_insert , bi_scan , bi_atop , bi_over , bi_before , bi_after , bi_under, bi_val , bi_cond,
|
||||
/* ⎉⚇⍟⎊ */ bi_rank , bi_depth , bi_repeat, bi_catch
|
||||
|
||||
};
|
||||
bool rtComplete[] = {
|
||||
@ -332,8 +332,8 @@ void load_init() { // very last init function
|
||||
/* ⊣⊢⥊∾≍⋈↑↓↕« */ 1,1,1,1,1,1,1,1,1,1,
|
||||
/* »⌽⍉/⍋⍒⊏⊑⊐⊒ */ 1,1,1,1,1,1,1,1,1,1,
|
||||
/* ∊⍷⊔!˙˜˘¨⌜⁼ */ 1,1,1,1,1,1,1,1,1,1,
|
||||
/* ´˝`∘○⊸⟜⌾⊘◶ */ 1,0,1,1,1,1,1,1,1,1,
|
||||
/* ⎉⚇⍟⎊ */ 1,0,1,1
|
||||
/* ´˝`∘○⊸⟜⌾⊘◶ */ 1,1,1,1,1,1,1,1,1,1,
|
||||
/* ⎉⚇⍟⎊ */ 1,1,1,1
|
||||
};
|
||||
assert(sizeof(fruntime)/sizeof(B) == rtLen);
|
||||
for (u64 i = 0; i < rtLen; i++) inc(fruntime[i]);
|
||||
@ -392,6 +392,8 @@ void load_init() { // very last init function
|
||||
rt_cell = Get(rtObjRaw, n_cell ); gc_add(rt_cell);
|
||||
rt_rank = Get(rtObjRaw, n_rank ); gc_add(rt_rank);
|
||||
rt_transp = Get(rtObjRaw, n_transp ); gc_add(rt_transp);
|
||||
rt_depth = Get(rtObjRaw, n_depth ); gc_add(rt_depth);
|
||||
rt_insert = Get(rtObjRaw, n_insert ); gc_add(rt_insert);
|
||||
|
||||
for (usz i = 0; i < rtLen; i++) {
|
||||
#ifdef RT_WRAP
|
||||
|
||||
Loading…
Reference in New Issue
Block a user