diff --git a/include/noun/jets.h b/include/noun/jets.h index 9b6d1f6d3..0c6a5727f 100644 --- a/include/noun/jets.h +++ b/include/noun/jets.h @@ -139,6 +139,11 @@ c3_o u3j_fine(u3_noun cor, u3j_fink* fin_u); + /* u3j_cast(): create u3j_fink from core and location. + */ + u3j_fink* + u3j_cast(u3_noun cor, u3_noun loc); + /* u3j_nail(): resolve hot state for location and axis. RETAIN. ** return value indicates presence of driver. **/ diff --git a/noun/jets.c b/noun/jets.c index ace1b904a..f9001eb27 100644 --- a/noun/jets.c +++ b/noun/jets.c @@ -271,6 +271,54 @@ u3j_spot(u3_noun cor) } } +static u3j_fink* +_cj_cast(u3_noun cor, u3_noun loc) +{ + c3_w i_w = 0; + u3_noun j, par, bat, dyn, pax, + rev = u3_nul, + pat = u3h(loc); + u3j_fink* fin_u; + + while ( c3n == u3h(pat) ) { + bat = u3h(cor); + dyn = u3t(pat); + pax = u3h(dyn); + loc = u3t(dyn); + pat = u3h(loc); + rev = u3nc(u3nc(u3k(bat), u3k(pax)), rev); + cor = u3r_at(pax, cor); + ++i_w; + } + + fin_u = u3a_walloc(c3_wiseof(u3j_fink) + + (i_w * c3_wiseof(u3j_fist))); + fin_u->len_w = i_w; + fin_u->sat = u3k(cor); + for ( j = rev; i_w-- > 0; j = u3t(j) ) { + u3j_fist* fis_u = &(fin_u->fis_u[i_w]); + par = u3h(j); + fis_u->bat = u3k(u3h(par)); + fis_u->pax = u3k(u3t(par)); + } + u3z(rev); + c3_assert( u3_nul == j ); + + return fin_u; +} + +/* u3j_cast(): create u3j_fink from core and location. + */ +u3j_fink* +u3j_cast(u3_noun cor, u3_noun loc) +{ + u3j_fink* fin_u; + u3t_on(glu_o); + fin_u = _cj_cast(cor, loc); + u3t_off(glu_o); + return fin_u; +} + static c3_o _cj_fine(u3_noun cor, u3j_fink* fin_u) { diff --git a/noun/nock.c b/noun/nock.c index 54c9c02de..a2eba5471 100644 --- a/noun/nock.c +++ b/noun/nock.c @@ -527,42 +527,6 @@ _n_nock_on(u3_noun bus, u3_noun fol) #define SLIS 71 #define SAVE 72 -static u3j_fink* -_n_cast(u3_noun cor, u3_noun loc) -{ - c3_w i_w = 0; - u3_noun j, par, bat, dyn, pax, - rev = u3_nul, - pat = u3h(loc); - u3j_fink* fin_u; - - while ( c3n == u3h(pat) ) { - bat = u3h(cor); - dyn = u3t(pat); - pax = u3h(dyn); - loc = u3t(dyn); - pat = u3h(loc); - rev = u3nc(u3nc(u3k(bat), u3k(pax)), rev); - cor = u3r_at(pax, cor); - ++i_w; - } - - fin_u = u3a_walloc(c3_wiseof(u3j_fink) + - (i_w * c3_wiseof(u3j_fist))); - fin_u->len_w = i_w; - fin_u->sat = u3k(cor); - for ( j = rev; i_w-- > 0; j = u3t(j) ) { - u3j_fist* fis_u = &(fin_u->fis_u[i_w]); - par = u3h(j); - fis_u->bat = u3k(u3h(par)); - fis_u->pax = u3k(u3t(par)); - } - u3z(rev); - c3_assert( u3_nul == j ); - - return fin_u; -} - static c3_w _n_fink_mark(u3j_fink* fin_u) { @@ -622,7 +586,7 @@ _n_mine(u3j_rite* rit_u, u3_noun clu, u3_noun cor) c3_o own_o = rit_u->own_o; rit_u->own_o = c3y; rit_u->clu = u3k(clu); - rit_u->fin_u = _n_cast(cor, loc); + rit_u->fin_u = u3j_cast(cor, loc); u3z(loc); if ( !non_t && (c3y == own_o) ) { @@ -1667,7 +1631,7 @@ _n_kick(u3_noun cor, u3j_site* sit_u) } sit_u->loc = loc; - sit_u->fin_u = _n_cast(cor, loc); + sit_u->fin_u = u3j_cast(cor, loc); sit_u->fon_o = c3y; if ( c3y == (sit_u->jet_o = u3j_nail(loc, sit_u->axe,