Making typed .^ a little less fake.

This commit is contained in:
C. Guy Yarvin 2016-02-02 11:52:10 -08:00
parent 55d1d29b56
commit 4b92cd2685
8 changed files with 68 additions and 35 deletions

View File

@ -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_mick(u3_noun);
u3_noun u3we_mink(u3_noun);
u3_noun u3we_mule(u3_noun);
u3_noun u3we_repg(u3_noun);

View File

@ -146,7 +146,8 @@
} jed;
struct { // namespace
u3_noun flu; // (list $+(* (unit))), inward
u3_noun flu; // (list $+(* (unit))), old
u3_noun sea; // (list $+(* (unit))), new
} ski;
struct { // trace stack

View File

@ -72,6 +72,7 @@
*/
u3_noun
u3m_soft_run(u3_noun fly,
u3_noun sea,
u3_funq fun_f,
u3_noun aga,
u3_noun agb);
@ -79,7 +80,7 @@
/* u3m_soft_esc(): namespace lookup to (unit ,*).
*/
u3_noun
u3m_soft_esc(u3_noun sam);
u3m_soft_esc(u3_noun ref, u3_noun sam);
/* u3m_mark(): mark all nouns in the road.
*/

View File

@ -19,26 +19,26 @@
u3_noun
u3n_kick_on(u3_noun gat);
/* u3n_nock_un(): produce .*(bus fol), as ++toon.
*/
u3_noun
u3n_nock_un(u3_noun bus, u3_noun fol);
/* u3n_slam_un(): produce (gat sam), as ++toon.
*/
u3_noun
u3n_slam_un(u3_noun gat, u3_noun sam);
/* u3n_nock_in(): produce .*(bus fol), as ++toon, in namespace.
*/
u3_noun
u3n_nock_in(u3_noun fly, u3_noun bus, u3_noun fol);
/* u3n_nock_it(): produce .*(bus fol), as ++toon, in namespace.
*/
u3_noun
u3n_nock_it(u3_noun sea, u3_noun bus, u3_noun fol);
/* u3n_slam_in(): produce (gat sam), as ++toon, in namespace.
*/
u3_noun
u3n_slam_in(u3_noun fly, u3_noun gat, u3_noun sam);
/* u3n_slam_it(): produce (gat sam), as ++toon, in namespace.
*/
u3_noun
u3n_slam_it(u3_noun sea, u3_noun gat, u3_noun sam);
/* u3n_nock_an(): as slam_in(), but with empty fly.
*/
u3_noun

View File

@ -24,3 +24,24 @@
return som;
}
}
u3_noun
u3we_mick(u3_noun cor)
{
u3_noun bus, fol, sea;
if ( c3n == u3r_mean(cor, u3x_sam_4, &bus,
u3x_sam_5, &fol,
u3x_sam_3, &sea,
0) )
{
return u3m_bail(c3__exit);
}
else {
u3_noun som;
som = u3n_nock_it(u3k(sea), u3k(bus), u3k(fol));
return som;
}
}

View File

@ -124,6 +124,7 @@ static u3j_harm _mood__hoon_mat_a[] = {{".2", u3we_mat}, {}};
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_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}, {}};
@ -485,6 +486,7 @@ static u3j_core _mood__hoon_d[] =
{ "lore", _mood__hoon_lore_a },
{ "loss", _mood__hoon_loss_a },
{ "mink", _mood__hoon_mink_a },
{ "mick", _mood__hoon_mick_a },
{ "mule", _mood__hoon_mule_a },
{ "repg", _mood__hoon_repg_a },
{ "rexp", _mood__hoon_rexp_a },

View File

@ -470,6 +470,7 @@ u3m_mark(void)
tot_w += u3h_mark(u3R->jed.har_p);
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->bug.tax);
tot_w += u3a_mark_noun(u3R->bug.mer);
tot_w += u3a_mark_noun(u3R->pro.don);
@ -969,6 +970,7 @@ u3m_soft_nock(u3_noun bus, u3_noun fol)
*/
u3_noun
u3m_soft_run(u3_noun fly,
u3_noun sea,
u3_funq fun_f,
u3_noun aga,
u3_noun agb)
@ -983,6 +985,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->pro.don = u3to(u3_road, u3R->par_p)->pro.don;
u3R->bug.tax = 0;
}
@ -1045,6 +1048,7 @@ u3m_soft_run(u3_noun fly,
*/
{
u3z(fly);
u3z(sea);
u3z(aga);
u3z(agb);
}
@ -1057,14 +1061,16 @@ u3m_soft_run(u3_noun fly,
/* u3m_soft_esc(): namespace lookup. Produces direct result.
*/
u3_noun
u3m_soft_esc(u3_noun sam)
u3m_soft_esc(u3_noun ref, u3_noun sam)
{
u3_noun why, fly, pro;
u3_noun why, fly, sea, pro;
/* Assert preconditions.
*/
{
c3_assert(0 != u3R->ski.flu);
c3_assert(0 != u3R->ski.sea);
sea = u3h(u3R->ski.sea);
fly = u3h(u3R->ski.flu);
}
@ -1076,6 +1082,7 @@ u3m_soft_esc(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->pro.don = u3to(u3_road, u3R->par_p)->pro.don;
u3R->bug.tax = 0;
}
@ -1083,7 +1090,11 @@ u3m_soft_esc(u3_noun sam)
/* Trap for exceptions.
*/
if ( 0 == (why = (u3_noun)_setjmp(u3R->esc.buf)) ) {
pro = u3n_slam_on(fly, sam);
if ( 0 == sea ) {
pro = u3n_slam_on(fly, sam);
} else {
pro = u3n_slam_on(sea, u3nc(ref, sam));
}
/* Fall back to the old road, leaving temporary memory intact.
*/
@ -1100,6 +1111,7 @@ u3m_soft_esc(u3_noun sam)
/* Release the sample.
*/
u3z(ref);
u3z(sam);
/* Return the product.

View File

@ -350,8 +350,7 @@ _n_nock_on(u3_noun bus, u3_noun fol)
u3_noun val;
u3t_off(noc_o);
u3z(ref);
val = u3m_soft_esc(u3k(gof));
val = u3m_soft_esc(ref, u3k(gof));
u3t_on(noc_o);
if ( !_(u3du(val)) ) {
@ -374,7 +373,7 @@ _n_nock_on(u3_noun bus, u3_noun fol)
u3_noun val;
u3t_off(noc_o);
val = u3m_soft_esc(u3k(gof));
val = u3m_soft_esc(0, u3k(gof));
u3t_on(noc_o);
if ( !_(u3du(val)) ) {
@ -440,24 +439,12 @@ u3n_slam_on(u3_noun gat, u3_noun sam)
return u3n_kick_on(cor);
}
/* u3n_nock_un(): produce .*(bus fol), as ++toon.
/* u3n_nock_it(): produce .*(bus fol), as ++toon, in namespace.
*/
u3_noun
u3n_nock_un(u3_noun bus, u3_noun fol)
u3n_nock_it(u3_noun sea, u3_noun bus, u3_noun fol)
{
u3_noun fly = u3nt(u3nt(11, 0, 6), 0, 0); // |=(a=* .^(a))
return u3n_nock_in(fly, bus, fol);
}
/* u3n_slam_un(): produce (gat sam), as ++toon.
*/
u3_noun
u3n_slam_un(u3_noun gat, u3_noun sam)
{
u3_noun fly = u3nt(u3nt(11, 0, 6), 0, 0); // |=(a=* .^(a))
return u3n_slam_in(fly, gat, sam);
return u3m_soft_run(0, sea, u3n_nock_on, bus, fol);
}
/* u3n_nock_in(): produce .*(bus fol), as ++toon, in namespace.
@ -465,7 +452,15 @@ u3n_slam_un(u3_noun gat, u3_noun sam)
u3_noun
u3n_nock_in(u3_noun fly, u3_noun bus, u3_noun fol)
{
return u3m_soft_run(fly, u3n_nock_on, bus, fol);
return u3m_soft_run(fly, 0, u3n_nock_on, bus, fol);
}
/* u3n_slam_it(): produce (gat sam), as ++toon, in namespace.
*/
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);
}
/* u3n_slam_in(): produce (gat sam), as ++toon, in namespace.
@ -473,7 +468,7 @@ u3n_nock_in(u3_noun fly, u3_noun bus, u3_noun fol)
u3_noun
u3n_slam_in(u3_noun fly, u3_noun gat, u3_noun sam)
{
return u3m_soft_run(fly, u3n_slam_on, gat, sam);
return u3m_soft_run(fly, 0, u3n_slam_on, gat, sam);
}
/* u3n_nock_an(): as slam_in(), but with empty fly.