From b26fd406363b87c99886cb661bec1ed3d7e780a1 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Wed, 3 Feb 2016 13:33:43 -0800 Subject: [PATCH] More typed .^. --- include/jets/w.h | 1 + include/noun/allocate.h | 1 + include/noun/manage.h | 1 + include/noun/nock.h | 10 ++++++++ jets/e/mink.c | 21 +++++++++++++++ jets/f/ut_mint.c | 2 +- jets/tree.c | 2 ++ noun/manage.c | 30 +++++++++++++++++++--- noun/nock.c | 57 ++++++++++++++++++++--------------------- 9 files changed, 91 insertions(+), 34 deletions(-) diff --git a/include/jets/w.h b/include/jets/w.h index 0fab2fa72..8c8ffe2d7 100644 --- a/include/jets/w.h +++ b/include/jets/w.h @@ -102,6 +102,7 @@ u3_noun u3we_rub(u3_noun); u3_noun u3we_lore(u3_noun); u3_noun u3we_loss(u3_noun); + u3_noun u3we_micq(u3_noun); u3_noun u3we_mick(u3_noun); u3_noun u3we_mink(u3_noun); u3_noun u3we_mule(u3_noun); diff --git a/include/noun/allocate.h b/include/noun/allocate.h index 7d7d29314..ed716b373 100644 --- a/include/noun/allocate.h +++ b/include/noun/allocate.h @@ -148,6 +148,7 @@ struct { // namespace u3_noun flu; // (list $+(* (unit))), old u3_noun sea; // (list $+(* (unit))), new + u3_noun gul; // (list $+(* (unit (unit)))) now } ski; struct { // trace stack diff --git a/include/noun/manage.h b/include/noun/manage.h index 4cc95b7f0..a5decfe2c 100644 --- a/include/noun/manage.h +++ b/include/noun/manage.h @@ -73,6 +73,7 @@ u3_noun u3m_soft_run(u3_noun fly, u3_noun sea, + u3_noun gul, u3_funq fun_f, u3_noun aga, u3_noun agb); diff --git a/include/noun/nock.h b/include/noun/nock.h index 89d49c2fa..2234778d9 100644 --- a/include/noun/nock.h +++ b/include/noun/nock.h @@ -29,6 +29,11 @@ u3_noun u3n_nock_it(u3_noun sea, u3_noun bus, u3_noun fol); + /* u3n_nock_et(): produce .*(bus fol), as ++toon, in namespace. + */ + u3_noun + u3n_nock_et(u3_noun gul, u3_noun bus, u3_noun fol); + /* u3n_slam_in(): produce (gat sam), as ++toon, in namespace. */ u3_noun @@ -39,6 +44,11 @@ u3_noun u3n_slam_it(u3_noun sea, u3_noun gat, u3_noun sam); + /* u3n_slam_et(): produce (gat sam), as ++toon, in namespace. + */ + u3_noun + u3n_slam_it(u3_noun gul, u3_noun gat, u3_noun sam); + /* u3n_nock_an(): as slam_in(), but with empty fly. */ u3_noun diff --git a/jets/e/mink.c b/jets/e/mink.c index 082363308..1c9e7057d 100644 --- a/jets/e/mink.c +++ b/jets/e/mink.c @@ -45,3 +45,24 @@ return som; } } + + u3_noun + u3we_micq(u3_noun cor) + { + u3_noun bus, fol, gul; + + if ( c3n == u3r_mean(cor, u3x_sam_4, &bus, + u3x_sam_5, &fol, + u3x_sam_3, &gul, + 0) ) + { + return u3m_bail(c3__exit); + } + else { + u3_noun som; + + som = u3n_nock_et(u3k(gul), u3k(bus), u3k(fol)); + + return som; + } + } diff --git a/jets/f/ut_mint.c b/jets/f/ut_mint.c index 2354e476b..6e37e6fbf 100644 --- a/jets/f/ut_mint.c +++ b/jets/f/ut_mint.c @@ -502,7 +502,7 @@ u3_noun viz = _mint_in(van, sut, c3__noun, q_gen); ret = u3nc(u3k(u3h(nef)), - u3nt(12, u3nc(1, u3k(u3h(nef))), u3k(u3t(viz)))); + u3nt(11, u3nc(1, u3nc(151, u3k(u3h(nef)))), u3k(u3t(viz)))); u3z(viz); u3z(nef); diff --git a/jets/tree.c b/jets/tree.c index 7a8f3f57d..a5393f5b7 100644 --- a/jets/tree.c +++ b/jets/tree.c @@ -125,6 +125,7 @@ static u3j_harm _mood__hoon_rub_a[] = {{".2", u3we_rub}, {}}; static u3j_harm _mood__hoon_lore_a[] = {{".2", u3we_lore}, {}}; static u3j_harm _mood__hoon_loss_a[] = {{".2", u3we_loss}, {}}; static u3j_harm _mood__hoon_mick_a[] = {{".2", u3we_mick}, {}}; +static u3j_harm _mood__hoon_micq_a[] = {{".2", u3we_micq}, {}}; static u3j_harm _mood__hoon_mink_a[] = {{".2", u3we_mink}, {}}; static u3j_harm _mood__hoon_mule_a[] = {{".2", u3we_mule}, {}}; static u3j_harm _mood__hoon_repg_a[] = {{".2", u3we_repg}, {}}; @@ -487,6 +488,7 @@ static u3j_core _mood__hoon_d[] = { "loss", _mood__hoon_loss_a }, { "mink", _mood__hoon_mink_a }, { "mick", _mood__hoon_mick_a }, + { "micq", _mood__hoon_micq_a }, { "mule", _mood__hoon_mule_a }, { "repg", _mood__hoon_repg_a }, { "rexp", _mood__hoon_rexp_a }, diff --git a/noun/manage.c b/noun/manage.c index 6140cdd94..5dc57459c 100644 --- a/noun/manage.c +++ b/noun/manage.c @@ -471,6 +471,7 @@ u3m_mark(void) tot_w += u3a_mark_noun(u3R->jed.das); tot_w += u3a_mark_noun(u3R->ski.flu); tot_w += u3a_mark_noun(u3R->ski.sea); + tot_w += u3a_mark_noun(u3R->ski.gul); tot_w += u3a_mark_noun(u3R->bug.tax); tot_w += u3a_mark_noun(u3R->bug.mer); tot_w += u3a_mark_noun(u3R->pro.don); @@ -971,6 +972,7 @@ u3m_soft_nock(u3_noun bus, u3_noun fol) u3_noun u3m_soft_run(u3_noun fly, u3_noun sea, + u3_noun gul, u3_funq fun_f, u3_noun aga, u3_noun agb) @@ -986,6 +988,7 @@ u3m_soft_run(u3_noun fly, { u3R->ski.flu = u3nc(fly, u3to(u3_road, u3R->par_p)->ski.flu); u3R->ski.sea = u3nc(sea, u3to(u3_road, u3R->par_p)->ski.sea); + u3R->ski.gul = u3nc(gul, u3to(u3_road, u3R->par_p)->ski.gul); u3R->pro.don = u3to(u3_road, u3R->par_p)->pro.don; u3R->bug.tax = 0; } @@ -1049,6 +1052,7 @@ u3m_soft_run(u3_noun fly, { u3z(fly); u3z(sea); + u3z(gul); u3z(aga); u3z(agb); } @@ -1063,13 +1067,15 @@ u3m_soft_run(u3_noun fly, u3_noun u3m_soft_esc(u3_noun ref, u3_noun sam) { - u3_noun why, fly, sea, pro; + u3_noun why, fly, sea, gul, pro; /* Assert preconditions. */ { c3_assert(0 != u3R->ski.flu); c3_assert(0 != u3R->ski.sea); + c3_assert(0 != u3R->ski.gul); + gul = u3h(u3R->ski.gul); sea = u3h(u3R->ski.sea); fly = u3h(u3R->ski.flu); } @@ -1083,6 +1089,7 @@ u3m_soft_esc(u3_noun ref, u3_noun sam) { u3R->ski.flu = u3t(u3to(u3_road, u3R->par_p)->ski.flu); u3R->ski.sea = u3t(u3to(u3_road, u3R->par_p)->ski.sea); + u3R->ski.gul = u3t(u3to(u3_road, u3R->par_p)->ski.gul); u3R->pro.don = u3to(u3_road, u3R->par_p)->pro.don; u3R->bug.tax = 0; } @@ -1090,10 +1097,24 @@ u3m_soft_esc(u3_noun ref, u3_noun sam) /* Trap for exceptions. */ if ( 0 == (why = (u3_noun)_setjmp(u3R->esc.buf)) ) { - if ( 0 == sea ) { + if ( 0 != fly ) { + // fprintf(stderr, "fly escape\r\n"); pro = u3n_slam_on(fly, sam); - } else { + if ( u3_nul != pro ) { + pro = u3nc(u3_nul, pro); + } + } else if ( 0 != sea ) { + // fprintf(stderr, "sea escape\r\n"); pro = u3n_slam_on(sea, u3nc(ref, sam)); + if ( u3_nul != pro ) { + pro = u3nc(u3_nul, pro); + } + } else if ( 0 != gul ) { + // fprintf(stderr, "gul escape\r\n"); + pro = u3n_slam_on(gul, u3nc(ref, sam)); + } + else { + return u3m_bail(c3__oops); } /* Fall back to the old road, leaving temporary memory intact. @@ -1109,7 +1130,8 @@ u3m_soft_esc(u3_noun ref, u3_noun sam) u3m_bail(u3nc(4, u3m_love(why))); } - /* Release the sample. + /* Release the sample. Note that we used it above, but in a junior + ** road, so its refcount is intact. */ u3z(ref); u3z(sam); diff --git a/noun/nock.c b/noun/nock.c index 05b5e7d65..3fa0387d6 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -356,41 +356,24 @@ _n_nock_on(u3_noun bus, u3_noun fol) if ( !_(u3du(val)) ) { u3m_bail(u3nt(1, gof, 0)); } + if ( !_(u3du(u3t(val))) ) { + // + // replace with proper error stack push + // + u3m_p("lost", gof); + return u3m_bail(c3__exit); + } else { u3_noun pro; u3z(gof); u3z(fol); - pro = u3k(u3t(val)); + pro = u3k(u3t(u3t(val))); u3z(val); return pro; } } - - case 12: { - u3_noun gof = _n_nock_on(bus, u3k(u3t(gal))); - u3_noun val; - - u3t_off(noc_o); - val = u3m_soft_esc(0, u3k(gof)); - u3t_on(noc_o); - - if ( !_(u3du(val)) ) { - u3m_bail(u3nt(1, gof, 0)); - } - else { - u3_noun pro; - - u3z(gof); - u3z(fol); - pro = u3k(u3t(val)); - u3z(val); - - return pro; - } - } - c3_assert(!"not reached"); } } @@ -444,7 +427,15 @@ u3n_slam_on(u3_noun gat, u3_noun sam) u3_noun u3n_nock_it(u3_noun sea, u3_noun bus, u3_noun fol) { - return u3m_soft_run(0, sea, u3n_nock_on, bus, fol); + return u3m_soft_run(0, sea, 0, u3n_nock_on, bus, fol); +} + +/* u3n_nock_et(): produce .*(bus fol), as ++toon, in namespace. +*/ +u3_noun +u3n_nock_et(u3_noun gul, u3_noun bus, u3_noun fol) +{ + return u3m_soft_run(0, 0, gul, u3n_nock_on, bus, fol); } /* u3n_nock_in(): produce .*(bus fol), as ++toon, in namespace. @@ -452,7 +443,7 @@ u3n_nock_it(u3_noun sea, u3_noun bus, u3_noun fol) u3_noun u3n_nock_in(u3_noun fly, u3_noun bus, u3_noun fol) { - return u3m_soft_run(fly, 0, u3n_nock_on, bus, fol); + return u3m_soft_run(fly, 0, 0, u3n_nock_on, bus, fol); } /* u3n_slam_it(): produce (gat sam), as ++toon, in namespace. @@ -460,7 +451,15 @@ u3n_nock_in(u3_noun fly, u3_noun bus, u3_noun fol) u3_noun u3n_slam_it(u3_noun sea, u3_noun gat, u3_noun sam) { - return u3m_soft_run(0, sea, u3n_slam_on, gat, sam); + return u3m_soft_run(0, sea, 0, u3n_slam_on, gat, sam); +} + +/* u3n_slam_et(): produce (gat sam), as ++toon, in namespace. +*/ +u3_noun +u3n_slam_et(u3_noun gul, u3_noun gat, u3_noun sam) +{ + return u3m_soft_run(0, 0, gul, u3n_slam_on, gat, sam); } /* u3n_slam_in(): produce (gat sam), as ++toon, in namespace. @@ -468,7 +467,7 @@ u3n_slam_it(u3_noun sea, u3_noun gat, u3_noun sam) u3_noun u3n_slam_in(u3_noun fly, u3_noun gat, u3_noun sam) { - return u3m_soft_run(fly, 0, u3n_slam_on, gat, sam); + return u3m_soft_run(fly, 0, 0, u3n_slam_on, gat, sam); } /* u3n_nock_an(): as slam_in(), but with empty fly.