Jet dispatcher compiles and links.

This commit is contained in:
C. Guy Yarvin 2014-09-01 17:10:04 -07:00
parent d7018b3310
commit a6ea515d2a
11 changed files with 580 additions and 258 deletions

View File

@ -328,7 +328,7 @@ $(BIN)/vere: $(LIBCRE) $(VERE_OFILES) $(LIBUV) $(LIBRE2) $(LIBED25519) $(BPT_O)
meme: $(BIN)/meme
MEME_OFILES=f/meme.o $(J164_OFILES) $(CRE2_OFILES)
MEME_OFILES=f/meme.o f/zock.o $(J164_OFILES) $(CRE2_OFILES)
$(BIN)/meme: $(MEME_OFILES) $(LIBED25519)
$(CLD) -g $(CLDOSFLAGS) -o $(BIN)/meme $(MEME_OFILES) $(LIBRE2) $(LIBED25519) -lgmp

View File

@ -3431,7 +3431,7 @@ u2_cz_find(u2_mote fun, u2_noun one)
u2_noun key = u2nc(fun, u2k(one));
u2_noun val;
val = u2_ch_get(u2R->cax.sav, key);
val = u2_ch_get(u2R->cax.har_u, key);
u2z(key);
return val;
}
@ -3441,7 +3441,7 @@ u2_cz_find_2(u2_mote fun, u2_noun one, u2_noun two)
u2_noun key = u2nt(fun, u2k(one), u2k(two));
u2_noun val;
val = u2_ch_get(u2R->cax.sav, key);
val = u2_ch_get(u2R->cax.har_u, key);
u2z(key);
return val;
}
@ -3451,7 +3451,7 @@ u2_cz_find_3(u2_mote fun, u2_noun one, u2_noun two, u2_noun tri)
u2_noun key = u2nq(fun, u2k(one), u2k(two), u2k(tri));
u2_noun val;
val = u2_ch_get(u2R->cax.sav, key);
val = u2_ch_get(u2R->cax.har_u, key);
u2z(key);
return val;
}
@ -3461,7 +3461,7 @@ u2_cz_find_4(u2_mote fun, u2_noun one, u2_noun two, u2_noun tri, u2_noun qua)
u2_noun key = u2nc(fun, u2nq(u2k(one), u2k(two), u2k(tri), u2k(qua)));
u2_noun val;
val = u2_ch_get(u2R->cax.sav, key);
val = u2_ch_get(u2R->cax.har_u, key);
u2z(key);
return val;
}
@ -3473,7 +3473,7 @@ u2_cz_save(u2_mote fun, u2_noun one, u2_noun val)
{
u2_noun key = u2nc(fun, u2k(one));
u2_ch_put(u2R->cax.sav, key, u2k(val));
u2_ch_put(u2R->cax.har_u, key, u2k(val));
u2z(key);
return val;
}
@ -3482,7 +3482,7 @@ u2_cz_save_2(u2_mote fun, u2_noun one, u2_noun two, u2_noun val)
{
u2_noun key = u2nt(fun, u2k(one), u2k(two));
u2_ch_put(u2R->cax.sav, key, u2k(val));
u2_ch_put(u2R->cax.har_u, key, u2k(val));
u2z(key);
return val;
}
@ -3491,7 +3491,7 @@ u2_cz_save_3(u2_mote fun, u2_noun one, u2_noun two, u2_noun tri, u2_noun val)
{
u2_noun key = u2nq(fun, u2k(one), u2k(two), u2k(tri));
u2_ch_put(u2R->cax.sav, key, u2k(val));
u2_ch_put(u2R->cax.har_u, key, u2k(val));
u2z(key);
return val;
}
@ -3505,7 +3505,7 @@ u2_cz_save_4(u2_mote fun,
{
u2_noun key = u2nc(fun, u2nq(u2k(one), u2k(two), u2k(tri), u2k(qua)));
u2_ch_put(u2R->cax.sav, key, u2k(val));
u2_ch_put(u2R->cax.har_u, key, u2k(val));
u2z(key);
return val;
}
@ -3516,13 +3516,13 @@ u2_noun
u2_cz_uniq(u2_noun som)
{
u2_noun key = u2nc(c3__uniq, u2k(som));
u2_noun val = u2_ch_get(u2R->cax.sav, key);
u2_noun val = u2_ch_get(u2R->cax.har_u, key);
if ( u2_none != val ) {
u2z(key); u2z(som); return val;
}
else {
u2_ch_put(u2R->cax.sav, key, u2k(som));
u2_ch_put(u2R->cax.har_u, key, u2k(som));
return som;
}
}
@ -3532,6 +3532,7 @@ u2_cz_uniq(u2_noun som)
void
u2_ct_push(u2_noun mon)
{
u2R->bug.tax = u2nc(mon, u2R->bug.tax);
}
/* u2_ct_mean(): push `[%mean roc]` on trace stack.
@ -3539,17 +3540,30 @@ u2_ct_push(u2_noun mon)
void
u2_ct_mean(u2_noun roc)
{
u2R->bug.tax = u2nc(u2nc(c3__mean, roc), u2R->bug.tax);
}
/* u2_ct_drop(): drop from meaning stack.
*/
void
u2_ct_drop(void);
u2_ct_drop(void)
{
c3_assert(u2_so(u2du(u2R->bug.tax)));
{
u2_noun tax = u2R->bug.tax;
u2R->bug.tax = u2k(u2t(tax));
u2z(tax);
}
}
/* u2_ct_slog(): print directly.
*/
void
u2_ct_slog(u2_noun hod);
u2_ct_slog(u2_noun hod)
{
u2z(hod);
}
/* _cn_hint(): process hint.
*/
@ -3608,28 +3622,6 @@ _cn_hint(u2_noun zep,
case c3__fast: {
u2_noun pro = u2_cn_nock_on(bus, nex);
/* XX: translate hod to old clue form.
*/
{
u2_noun p_hod, q_hod, r_hod;
if ( u2_no == u2_cr_trel(hod, &p_hod, &q_hod, &r_hod) ) {
u2z(hod);
return pro;
}
else {
u2_noun xod;
if ( u2_yes == u2du(q_hod) &&
(1 == u2h(q_hod)) &&
(0 == u2t(q_hod)) ) {
q_hod = 0;
}
xod = u2nt(u2k(q_hod), u2k(p_hod), u2k(r_hod));
u2z(hod);
hod = xod;
}
}
return u2_cj_mine(hod, pro);
}
@ -3804,28 +3796,26 @@ u2_cn_nock_on(u2_noun bus, u2_noun fol)
u2_noun b_gal, c_gal;
u2_cx_cell(gal, &b_gal, &c_gal);
if ( u2_no == u2_cr_ud(b_gal) ) {
return u2_cm_bail(c3__exit);
}
else {
{
u2_noun seb = u2_cn_nock_on(bus, u2k(c_gal));
u2_weak xip;
xip = u2_cj_find(u2k(seb));
if ( u2_none != xip ) {
u2_noun pro = u2_cj_kick(xip, seb, b_gal);
u2_noun pro = u2_cj_kick(seb, b_gal);
if ( u2_none != pro ) {
u2_ca_lose(fol);
return pro;
}
else {
u2_noun nex = u2k(u2at(b_gal, seb));
if ( u2_no == u2_cr_ud(b_gal) ) {
return u2_cm_bail(c3__exit);
}
else {
u2_noun nex = u2k(u2at(b_gal, seb));
u2_ca_lose(fol);
bus = seb;
fol = nex;
continue;
u2_ca_lose(fol);
bus = seb;
fol = nex;
continue;
}
}
}
}
@ -3874,14 +3864,7 @@ u2_cn_nock_on(u2_noun bus, u2_noun fol)
u2_noun
u2_cn_kick_on(u2_noun gat)
{
u2_noun xip;
if ( u2_none != (xip = u2_cj_find(gat)) ) {
return u2_cj_kick(xip, gat, 2);
}
else {
return u2_cn_nock_on(gat, u2k(u2h(gat)));
}
return u2_cj_kink(gat, 2);
}
/* u2_cn_slam_on(): produce (gat sam).

425
f/zock.c
View File

@ -4,4 +4,429 @@
*/
#include "f/meme.h"
/* u2_cj_boot(): initialize jet system.
*/
/* _cj_count(): count and link dashboard entries.
*/
static c3_w
_cj_count(u2_cs_core* par_u, u2_cs_core* dev_u)
{
c3_w len_l = 0;
c3_w i_w;
for ( i_w = 0; 0 != dev_u[len_l].cos_c; i_w++ ) {
u2_cs_core* kid_u = &dev_u[i_w];
kid_u->par_u = par_u;
len_l = _cj_count(kid_u, kid_u->dev_u);
}
return 1 + len_l;
}
/* _cj_install(): install dashboard entries.
*/
static c3_w
_cj_install(u2_cs_core* ray_u, c3_w jax_l, u2_cs_core* dev_u)
{
c3_w i_w;
for ( i_w = 0; 0 != dev_u[i_w].cos_c; i_w++ ) {
u2_cs_core* kid_u = &dev_u[i_w];
kid_u->jax_l = jax_l;
ray_u[jax_l++] = *kid_u;
jax_l = _cj_install(ray_u, jax_l, kid_u->dev_u);
}
return jax_l;
}
/* u2_cj_boot(): initialize jet system.
*/
void
u2_cj_boot(void)
{
u2D.len_l =_cj_count(0, u2D.dev_u);
u2D.ray_u = (u2_cs_core*) malloc(u2D.len_l * sizeof(u2_cs_core));
memset(u2D.ray_u, 0, (u2D.len_l * sizeof(u2_cs_core)));
_cj_install(u2D.ray_u, 1, u2D.dev_u);
}
/* _cj_insert(): append copy of core driver to jet table.
*/
static c3_l
_cj_insert(u2_cs_core* cop_u)
{
c3_l jax_l = u2D.len_l;
u2D.len_l += 1;
u2D.ray_u = realloc(u2D.ray_u, u2D.len_l * sizeof(u2_cs_core));
memcpy(&u2D.ray_u[jax_l], cop_u, sizeof(u2_cs_core));
cop_u->jax_l = jax_l;
return jax_l;
}
/* u2_cj_find(): search for jet. `cor` is RETAINED.
*/
c3_l
u2_cj_find(u2_noun bat)
{
u2_weak jax = u2_ch_get(u2R->jed.har_u, bat);
if ( u2_none == jax ) {
return 0;
} else {
c3_assert(u2_co_is_cat(jax));
return (c3_l)jax;
}
}
/* _cj_kick_a(): try to kick by jet. If no kick, produce u2_none.
**
** `cor` is RETAINED iff there is no kick, TRANSFERRED if one.
*/
static u2_weak
_cj_kick_a(u2_noun cor, u2_cs_hood* hud_u, c3_l axe_l)
{
u2_cs_harm* ham_u;
if ( axe_l >= hud_u->len_w ) {
return u2_none;
}
if ( !(ham_u = hud_u->ray_u[axe_l]) ) {
return u2_none;
}
if ( 0 == ham_u->fun_f ) {
return u2_none;
}
// XX: support tot and ice flags, and validator
//
{
u2_weak pro = ham_u->fun_f(cor);
if ( u2_none != pro ) {
return pro;
}
}
return u2_none;
}
/* _cj_kick_b(): try to kick by jet. If no kick, produce u2_none.
**
** `cor` is RETAINED iff there is no kick, TRANSFERRED if one.
*/
static u2_weak
_cj_kick_b(u2_noun cor, c3_l jax_l, c3_l axe_l)
{
c3_l mug_l = u2_cr_mug(u2h(cor));
u2_cs_core* cop_u = &u2D.ray_u[jax_l];
u2_cs_hood* hud_u = cop_u->hud_u;
while ( 1 ) {
if ( 0 == hud_u ) { break; }
if ( mug_l != hud_u->mug_l ) { hud_u = hud_u->nex_u; continue; }
return _cj_kick_a(cor, hud_u, axe_l);
}
return u2_none;
}
/* u2_cj_hook(): execute hook from core, or fail.
*/
u2_noun
u2_cj_hook(u2_noun cor,
const c3_c* tam_c)
{
u2_noun bat = u2h(cor);
c3_l jax_l = u2_cj_find(bat);
if ( 0 == jax_l ) { return 0; }
else {
u2_cs_core* cop_u = &u2D.ray_u[jax_l];
u2_cs_hood* hud_u = cop_u->hud_u;
c3_l mug_l = u2_cr_mug(bat);
while ( 1 ) {
if ( 0 == hud_u ) { break; }
if ( mug_l != hud_u->mug_l ) { hud_u = hud_u->nex_u; continue; }
{
u2_cs_hook* huk_u = hud_u->huk_u;
while ( huk_u ) {
if ( !strcmp(huk_u->nam_c, tam_c) ) {
u2_noun pro = _cj_kick_a(cor, hud_u, huk_u->axe_l);
if ( u2_none != pro ) {
return pro;
}
else return u2_cn_nock_on(cor, u2nq(9, huk_u->axe_l, 0, 1));
}
huk_u = huk_u->nex_u;
}
}
}
}
u2z(cor);
return u2_cm_bail(c3__fail);
}
/* u2_cj_kick(): try to kick by jet. If no kick, produce u2_none.
**
** `axe` is RETAINED by the caller; `cor` is RETAINED iff there
** is no kick, TRANSFERRED if one.
*/
u2_weak
u2_cj_kick(u2_noun cor, u2_noun axe)
{
c3_l axe_l, jax_l;
if ( u2_ne(u2_co_is_cat(axe)) ) {
return u2_none;
}
axe_l = axe;
if ( 0 == (jax_l = u2_cj_find(u2h(cor))) ) {
return u2_none;
}
return _cj_kick_b(cor, jax_l, axe_l);
}
/* u2_cj_kink(): kick either by jet or by nock.
*/
u2_noun
u2_cj_kink(u2_noun cor,
u2_noun axe)
{
u2_weak pro = u2_cj_kick(cor, axe);
if ( u2_none != pro ) {
return pro;
} else {
return u2_cn_nock_on(cor, u2nq(9, axe, 0, 1));
}
}
/* _cj_axis(): axis from formula, or 0. `fol` is RETAINED.
*/
static c3_l
_cj_axis(u2_noun fol)
{
u2_noun p_fol, q_fol, r_fol;
if ( u2_ne(u2_cr_trel(fol, &p_fol, &q_fol, &r_fol)) )
{ fprintf(stderr, "axis: bad a\r\n"); return 0; }
if ( 9 != p_fol )
{ fprintf(stderr, "axis: bad b\r\n"); return 0; }
if ( u2_ne(u2_co_is_cat(q_fol)) )
{ fprintf(stderr, "axis: bad c\r\n"); return 0; }
if ( u2_ne(u2du(r_fol)) || (0 != u2h(r_fol)) || (1 != u2t(r_fol)) )
{ fprintf(stderr, "axis: bad d\r\n"); return 0; }
return q_fol;
}
/* _cj_activate(): activate jets in `cop` for `hud`.
*/
static void
_cj_activate(u2_cs_core* cop_u, u2_cs_hood* hud_u)
{
c3_l max_l = 0;
/* Check for mismatched duplicates - very unlikely.
*/
{
u2_cs_hood* duh_u = cop_u->hud_u;
while ( duh_u ) {
if ( duh_u->mug_l == hud_u->mug_l ) {
fprintf(stderr, "jets: mug collision!\r\n");
return;
}
duh_u = duh_u->nex_u;
}
}
/* Compute axes of all correctly declared jets.
*/
{
c3_l i_l = 0;
while ( 1 ) {
u2_cs_harm* jet_u = &cop_u->arm_u[i_l];
if ( 0 == jet_u->fcs_c ) {
break;
}
else {
c3_l axe_l = 0;
if ( '.' == *(jet_u->fcs_c) ) {
c3_d axe_d = 0;
if ( (1 != sscanf(jet_u->fcs_c+1, "%llu", &axe_d)) ||
axe_d >> 32ULL ||
((1 << 31) & (axe_l = (c3_w)axe_d)) ||
(axe_l < 2) )
{
fprintf(stderr, "jets: activate: bad fcs %s\r\n", jet_u->fcs_c);
}
}
else {
u2_cs_hook* huk_u = hud_u->huk_u;
while ( huk_u ) {
if ( !strcmp(huk_u->nam_c, jet_u->fcs_c) ) {
axe_l = huk_u->axe_l;
break;
}
huk_u = huk_u->nex_u;
}
}
max_l = c3_max(max_l, axe_l);
jet_u->axe_l = axe_l;
}
i_l++;
}
}
/* Allocate jet table for this battery.
*/
{
c3_w i_l;
if ( !max_l ) {
hud_u->len_w = 0;
}
else {
hud_u->len_w = (max_l + 1);
hud_u->ray_u = malloc(hud_u->len_w * (sizeof(u2_cs_harm *)));
for ( i_l = 0; i_l < hud_u->len_w; i_l++ ) {
hud_u->ray_u[i_l] = 0;
}
}
}
/* Fill jet table.
*/
{
c3_l i_l = 0;
while ( 1 ) {
u2_cs_harm* jet_u = &cop_u->arm_u[i_l];
if ( jet_u->axe_l ) {
hud_u->ray_u[jet_u->axe_l] = jet_u;
}
}
}
/* Link in new battery record.
*/
{
hud_u->nex_u = cop_u->hud_u;
cop_u->hud_u = hud_u;
}
}
/* u2_cj_mine(): register core for jets.
*/
u2_noun
u2_cj_mine(u2_noun clu,
u2_noun cor)
{
if ( u2_none != u2_ch_get(u2R->jed.har_u, u2h(cor)) ) {
u2z(clu);
return cor;
}
else {
u2_noun p_clu, q_clu, r_clu;
u2_cs_hook* huk_u;
u2_cs_hood* hud_u;
c3_l axe_l, par_l;
u2_noun nam;
u2_noun pab;
if ( u2_no == u2_cr_trel(clu, &p_clu, &q_clu, &r_clu) )
{ fprintf(stderr, "mine: bad z\r\n"); u2z(clu); return cor; }
if ( u2_ne(u2ud(nam = p_clu)) )
{ fprintf(stderr, "mine: bad a\r\n"); u2z(clu); return cor; }
if ( u2_ne(u2du(q_clu)) )
{ fprintf(stderr, "mine: bad b\r\n"); u2z(clu); return cor; }
if ( (0 != u2h(q_clu)) )
{ fprintf(stderr, "mine: bad c\r\n"); u2z(clu); return cor; }
if ( u2_ne(u2_co_is_cat(axe_l = u2t(q_clu))) )
{ fprintf(stderr, "mine: bad d\r\n"); u2z(clu); return cor; }
if ( (u2_none == (pab = u2_cr_at(axe_l, cor))) )
{ fprintf(stderr, "mine: bad e\r\n"); u2z(clu); return cor; }
if ( (0 == (par_l = u2_cj_find(pab))) )
{ fprintf(stderr, "mine: bad f\r\n"); u2z(clu); return cor; }
huk_u = 0;
while ( 0 != r_clu ) {
u2_noun ir_clu, tr_clu, pir_clu, qir_clu;
u2_cs_hook* kuh_u;
c3_l kax_l;
if ( u2_no == u2_cr_cell(clu, &ir_clu, &tr_clu) )
{ fprintf(stderr, "mine: bad g\r\n"); u2z(clu); return cor; }
if ( u2_no == u2_cr_cell(ir_clu, &pir_clu, &qir_clu) )
{ fprintf(stderr, "mine: bad h\r\n"); u2z(clu); return cor; }
if ( u2_ne(u2ud(pir_clu)) )
{ fprintf(stderr, "mine: bad i\r\n"); u2z(clu); return cor; }
if ( 0 == (kax_l = _cj_axis(qir_clu)) )
{ fprintf(stderr, "mine: bad j\r\n"); u2z(clu); return cor; }
kuh_u = malloc(sizeof(u2_cs_hook));
kuh_u->nam_c = u2_cr_string(pir_clu);
kuh_u->axe_l = kax_l;
kuh_u->nex_u = huk_u;
huk_u = kuh_u;
}
hud_u = malloc(sizeof(u2_cs_hood));
hud_u->mug_l = u2_cr_mug(u2h(cor));
hud_u->len_w = 0;
hud_u->ray_u = 0;
hud_u->huk_u = huk_u;
hud_u->nex_u = 0;
// Find the child, if possible, in the parent. Otherwise,
// register it to avoid slow repeated search.
//
{
u2_cs_core* par_u = &u2D.ray_u[par_l];
c3_l jax_l = 0;
c3_w i_l = 0;
while ( 1 ) {
u2_cs_core* cop_u = &par_u->dev_u[i_l];
if ( 0 == cop_u->cos_c ) { break; }
if ( u2_so(u2_cr_sing_c(cop_u->cos_c, nam)) ) {
jax_l = cop_u->jax_l;
c3_assert(0 != jax_l);
break;
}
i_l++;
}
if ( 0 == jax_l ) {
u2_cs_core fak_u;
memset(&fak_u, 0, sizeof(u2_cs_core));
fak_u.cos_c = u2_cr_string(nam);
fak_u.par_u = par_u;
jax_l =_cj_insert(&fak_u);
}
u2_ch_put(u2R->jed.har_u, u2h(cor), jax_l);
u2z(clu);
_cj_activate(&u2D.ray_u[jax_l], hud_u);
return cor;
}
}
}

View File

@ -8,66 +8,35 @@
/* ~(. al gen)
*/
static u2_noun
_al_core(
u2_noun van,
_al_core(u2_noun van,
u2_noun gen)
{
u2_noun ter = u2_cr_at(u2_cv_con_3, van);
u2_weak hoc = u2_cj_look(ter, "al");
if ( u2_none == hoc ) {
return u2_cm_bail(c3__fail);
}
else {
u2_noun gat = u2_cn_nock_on(u2k(ter), u2k(hoc));
u2_noun cor = u2_ci_molt(u2k(gat),
u2_cv_sam, u2k(gen),
0);
u2z(hoc);
u2z(gat);
return cor;
}
u2_noun gat = u2_cj_hook(u2k(ter), "al");
return u2_ci_molt(gat, u2_cv_sam, u2k(gen), 0);
}
/* ~(bunt al gen)
*/
u2_noun // transfer
j2_mcy(Pt6, al, bunt)(
u2_noun van, // retain
j2_mcy(Pt6, al, bunt)(u2_noun van, // retain
u2_noun gen) // retain
{
u2_noun cor = _al_core(van, gen);
u2_weak hoc = u2_cj_look(u2k(cor), "bunt");
if ( u2_none == hoc ) {
return u2_cm_bail(c3__fail);
} else {
u2_noun pro = u2_cn_nock_on(cor, u2k(hoc));
u2z(hoc);
return pro;
}
return u2_cj_hook(cor, "bunt");
}
/* ~(whip al gen)
*/
u2_noun // transfer
j2_mcy(Pt6, al, whip)(
u2_noun van, // retain
j2_mcy(Pt6, al, whip)(u2_noun van, // retain
u2_noun gen, // retain
u2_noun axe) //
{
u2_noun cor = _al_core(van, gen);
u2_weak hoc = u2_cj_look(u2k(cor), "whip");
u2_noun gat = u2_cj_hook(u2k(cor), "whip");
if ( u2_none == hoc ) {
return u2_cm_bail(c3__fail);
} else {
u2_noun gat = u2_cn_nock_on(cor, u2k(hoc));
u2_noun pro = u2_cn_slam_on(u2k(gat), u2k(axe));
u2z(hoc);
return pro;
}
return u2_cn_slam_on(gat, u2k(axe));
}

View File

@ -38,31 +38,18 @@
};
static u2_weak
_open_in(
u2_noun ter,
u2_noun gen);
_open_in(u2_noun ter, u2_noun gen);
/* ~(. al gen)
*/
static u2_noun
_al_core(
u2_noun ter,
u2_noun gen)
_al_core(u2_noun van,
u2_noun gen)
{
u2_weak hoc = u2_cj_look(u2k(ter), "al");
if ( u2_none == hoc ) {
return u2_cm_bail(c3__fail);
}
else {
u2_noun gat = u2_cn_nock_on(u2k(ter), u2k(hoc));
u2_noun cor = u2_ci_molt(u2k(gat),
u2_cv_sam, u2k(gen),
0);
u2z(hoc);
u2z(gat);
return cor;
}
u2_noun ter = u2_cr_at(u2_cv_con_3, van);
u2_noun gat = u2_cj_hook(u2k(ter), "al");
return u2_ci_molt(gat, u2_cv_sam, u2k(gen), 0);
}
/** open cases
@ -1041,44 +1028,23 @@
/* boilerplate
*/
u2_noun // transfer
j2_mbi(Pt6, ap)(
u2_noun ter, // retain
j2_mbi(Pt6, ap)(u2_noun ter, // retain
u2_noun gen) // retain
{
u2_weak hoc = u2_cj_look(u2k(ter), "ap");
if ( u2_none == hoc ) {
return u2_cm_bail(c3__fail);
} else {
u2_noun gat = u2_cn_nock_on(u2k(ter), u2k(hoc));
u2_noun cor = u2_ci_molt(u2k(gat),
u2_cv_sam, u2k(gen),
0);
u2z(hoc);
u2z(gat);
return cor;
}
{
u2_noun gat = u2_cj_hook(u2k(ter), "ap");
return u2_ci_molt(gat, u2_cv_sam, u2k(gen), 0);
}
/* open
*/
static u2_noun
_ap_open_n(
u2_noun ter,
_ap_open_n(u2_noun ter,
u2_noun gen)
{
u2_noun cor = j2_mbi(Pt6, ap)(ter, gen);
u2_weak hoc = u2_cj_look(u2k(cor), "open");
if ( u2_none == hoc ) {
return u2_cm_bail(c3__fail);
} else {
u2_noun pro = u2_cn_nock_on(cor, u2k(hoc));
u2z(hoc);
return pro;
}
return u2_cj_hook(cor, "open");
}
static u2_noun // transfer
_ap_open_l(

View File

@ -5,29 +5,13 @@
#include "all.h"
#include "../pit.h"
u2_weak // transfer
j2_mci(Pt6, ut, gain)(u2_noun van, // retain
u2_noun sut, // retain
u2_noun gen) // retain
{
u2_weak hoc = u2_cj_look(u2k(van), "gain");
if ( u2_none == hoc ) {
c3_assert(!"register gain");
return u2_none;
} else {
u2_weak von = u2_ci_molt(u2k(van), u2_cv_sam, u2k(sut), 0);
u2_weak gat = u2_cn_nock_on(von, hoc);
u2_weak cor = u2_ci_molt(gat, u2_cv_sam, u2k(gen), 0);
return cor;
}
}
u2_noun // transfer
j2_mcy(Pt6, ut, gain)(u2_noun van, // retain
u2_noun sut, // retain
u2_noun gen) // retain
{
return u2_cn_kick_on(j2_mci(Pt6, ut, gain)(van, sut, gen));
u2_noun von = u2_ci_molt(u2k(van), u2_cv_sam, u2k(sut), 0);
u2_noun gat = u2_cj_hook(u2k(von), "gain");
return u2_cn_kick_on(u2_ci_molt(gat, u2_cv_sam, u2k(gen), 0));
}

View File

@ -5,31 +5,13 @@
#include "all.h"
#include "../pit.h"
u2_weak // transfer
j2_mci(Pt6, ut, lose)(u2_noun van, // retain
u2_noun sut, // retain
u2_noun gen) // retain
{
u2_weak hoc = u2_cj_look(u2k(van), "lose");
if ( u2_none == hoc ) {
c3_assert(!"register lose");
return u2_none;
} else {
u2_weak von = u2_ci_molt(u2k(van), u2_cv_sam, u2k(sut), 0);
u2_weak gat = u2_cn_nock_on(von, hoc);
u2_weak cor = u2_ci_molt(gat, u2_cv_sam, u2k(gen), 0);
return cor;
}
}
u2_noun // transfer
j2_mcy(Pt6, ut, lose)(u2_noun van, // retain
u2_noun sut, // retain
u2_noun gen) // retain
{
u2_noun cor = j2_mci(Pt6, ut, lose)(van, sut, gen);
u2_noun von = u2_ci_molt(u2k(van), u2_cv_sam, u2k(sut), 0);
u2_noun gat = u2_cj_hook(u2k(von), "lose");
return u2_cn_kick_on(cor);
return u2_cn_kick_on(u2_ci_molt(gat, u2_cv_sam, u2k(gen), 0));
}

View File

@ -27,33 +27,6 @@
}
}
u2_weak // transfer
j2_mci(Pt6, ut, sift)(
u2_noun van, // retain
u2_noun sut, // retain
u2_noun ref) // retain
{
u2_weak hoc = u2_cj_look(u2k(van), "sift");
if ( u2_none == hoc ) {
c3_assert(!"register sift");
return u2_none;
} else {
u2_weak von = u2_ci_molt(u2k(van), u2_cv_sam, u2k(sut), 0);
u2_weak gat = u2_cn_nock_on(von, hoc);
u2_weak cor = u2_ci_molt(u2k(gat), u2_cv_sam, u2k(ref), 0);
if ( (u2_none == j2_mcj(Pt6, ut, sift)[0].xip) ) {
u2_noun xip = u2_cj_find(u2k(cor));
// c3_assert(u2_none != xip);
j2_mcj(Pt6, ut, sift)[0].xip = xip;
}
u2z(gat);
return cor;
}
}
u2_noun // transfer
j2_mcy(Pt6, ut, sift)(u2_noun van, // retain
u2_noun sut, // retain

View File

@ -5,32 +5,15 @@
#include "all.h"
#include "../pit.h"
u2_weak // transfer
j2_mci(Pt6, ut, tack)(u2_noun van, // retain
u2_noun sut, // retain
u2_noun peh, // retain
u2_noun mur) // retain
{
u2_weak hoc = u2_cj_look(u2k(van), "tack");
if ( u2_none == hoc ) {
c3_assert(!"register tack");
return u2_none;
} else {
u2_weak von = u2_ci_molt(u2k(van), u2_cv_sam, u2k(sut), 0);
u2_weak gat = u2_cn_nock_on(von, hoc);
u2_weak cor = u2_ci_molt(gat, u2_cv_sam_2, u2k(peh),
u2_cv_sam_3, u2k(mur),
0);
return cor;
}
}
u2_noun // transfer
j2_mcy(Pt6, ut, tack)(u2_noun van, // retain
u2_noun sut, // retain
u2_noun peh, // retain
u2_noun mur) // retain
{
return u2_cn_kick_on(j2_mci(Pt6, ut, tack)(van, sut, peh, mur));
u2_noun von = u2_ci_molt(u2k(van), u2_cv_sam, u2k(sut), 0);
u2_noun gat = u2_cj_hook(u2k(von), "tack");
return u2_cn_kick_on
(u2_ci_molt(gat, u2_cv_sam_2, u2k(peh), u2_cv_sam_3, u2k(mur), 0));
}

View File

@ -17,6 +17,7 @@
typedef uint8_t c3_b; // bit
typedef uint8_t c3_t; // boolean
typedef uint8_t c3_o; // loobean
typedef uint8_t c3_g; // 32-bit log - 0-31 bits
typedef uint32_t c3_l; // little; 31-bit unsigned integer
typedef uint32_t c3_m; // mote; also c3_l; LSB first a-z 4-char string.

View File

@ -316,6 +316,59 @@
# define u2_cc_minimum (1 + c3_wiseof(u2_cs_fbox))
/* u2_cs_hook: core map from hint.
*/
typedef struct _u2_cs_hook {
c3_c* nam_c;
c3_l axe_l;
struct _u2_cs_hook* nex_u;
} u2_cs_hook;
/* u2_cs_hood: battery as instance of core.
*/
typedef struct _u2_cs_hood {
c3_l mug_l; // battery mug
c3_w len_w; // dynamic array length
struct _u2_cs_harm** ray_u; // dynamic array by axis
struct _u2_cs_hook* huk_u; // hooks if any
struct _u2_cs_hood* nex_u; // next in this core
} u2_cs_hood;
/* u2_cs_harm: jet arm.
*/
typedef struct _u2_cs_harm {
c3_c* fcs_c; // `.axe` or name
u2_noun (*fun_f)(u2_noun); // 0 or compute function / semitransfer
u2_bean (*val_f)(u2_noun); // 0 or validate function - retain
c3_o ice; // perfect (don't test)
c3_o tot; // total (never punts)
c3_d paw_d; // jammed part memo formula, as c3_d
c3_l axe_l; // computed/discovered axis
} u2_cs_harm;
/* u2_cs_core: driver definition.
*/
typedef struct _u2_cs_core {
c3_c* cos_c; // control string
struct _u2_cs_harm* arm_u; // blank-terminated static list
struct _u2_cs_core* dev_u; // blank-terminated static list
struct _u2_cs_core* par_u; // parent pointer
struct _u2_cs_hood* hud_u; // dynamic instance list
c3_l jax_l; // index in global dashboard
} u2_cs_core;
/* u2_cs_dash, u2_Dash, u2D: jet dashboard singleton
*/
typedef struct _u2_cs_dash {
u2_cs_core* dev_u; // null-terminated static list
c3_l len_l; // dynamic array length
u2_cs_core* ray_u; // dynamic array by axis
} u2_cs_dash;
c3_global u2_cs_dash u2_Dash;
# define u2D u2_Dash
/* u2_cs_road: contiguous allocation and execution context.
**
** A road is a normal heap-stack system, except that the heap
@ -415,7 +468,7 @@
} all;
struct { // jet dashboard
u2_noun dax; // (map ,* (list chub))
u2_ch_root* har_u; // jet index by
} jed;
struct { // namespace
@ -435,7 +488,7 @@
} pro;
struct { // memoization
u2_ch_root* sav; // (map (pair term noun) noun)
u2_ch_root* har_u; // (map (pair term noun) noun)
} cax;
} u2_cs_road;
typedef u2_cs_road u2_road;
@ -1238,41 +1291,44 @@
u2_ch_free(u2_ch_root* har_u);
/** Jet firing. (Change retain protocols!)
/** Jets.
**/
/* u2_cj_boot(): initialize jet system.
*/
void
u2_cj_boot(void);
/* u2_cj_hook():
**
** Execute hook from core.
** Execute hook from core.
*/
u2_noun
u2_cj_hook(u2_noun cor,
const c3_c* tam_c);
/* u2_cj_look():
/* u2_cj_find(): battery to driver number, or 0.
**
** Produce hook formula from core, or u2_none.
** `bat` is RETAINED by the caller.
*/
u2_noun
u2_cj_look(u2_noun cor,
const c3_c* tam_c);
c3_l
u2_cj_find(u2_noun bat);
/* u2_cj_find(): find chip by core, or none.
/* u2_cj_kick(): try to kick by jet. If no kick, produce u2_none.
**
** `cor` is RETAINED by the caller.
** `axe` is RETAINED by the caller; `cor` is RETAINED iff there
** is no kick, TRANSFERRED if one.
*/
u2_weak
u2_cj_find(u2_noun cor);
u2_cj_kick(u2_noun cor,
u2_noun axe);
/* u2_cj_kick(): kick jet by discovered chip.
**
** `axe` is RETAINED by the caller.
/* u2_cj_kink(): kick either by jet or by nock.
*/
u2_noun
u2_cj_kick(u2_noun xip,
u2_noun cor,
u2_atom axe);
/* u2_cj_mine(): register jet.
u2_cj_kink(u2_noun cor,
u2_noun axe);
/* u2_cj_mine(): register core for jets.
*/
u2_noun
u2_cj_mine(u2_noun clu,