Better wiring for find testing.

This commit is contained in:
C. Guy Yarvin 2016-01-21 11:13:27 -08:00
parent 70976954a1
commit 7b75e647da
6 changed files with 102 additions and 4 deletions

View File

@ -396,6 +396,7 @@
# define c3__flot c3_s4('f','l','o','t')
# define c3__flow c3_s4('f','l','o','w')
# define c3__fon c3_s3('f','o','n')
# define c3__fond c3_s4('f','o','n','d')
# define c3__for c3_s3('f','o','r')
# define c3__forb c3_s4('f','o','r','b')
# define c3__fore c3_s4('f','o','r','e')

View File

@ -203,7 +203,7 @@
u3_noun u3qfu_dung(u3_noun, u3_noun cap, u3_noun);
u3_noun u3qfu_dunq(u3_noun, const c3_c*, u3_noun);
void u3qfu_dump(u3_noun, const c3_c*, u3_noun);
u3_noun u3qfu_find(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qfu_fond(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qfu_finc(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qfu_fink(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qfu_fire(u3_noun, u3_noun, u3_noun);

View File

@ -221,6 +221,7 @@
u3_noun u3wfu_cull(u3_noun);
u3_noun u3wfu_duck(u3_noun);
u3_noun u3wfu_find(u3_noun);
u3_noun u3wfu_fond(u3_noun);
u3_noun u3wfu_fink(u3_noun);
u3_noun u3wfu_fire(u3_noun);
u3_noun u3wfu_firm(u3_noun);

View File

@ -41,6 +41,37 @@
0));
}
static u3_noun
u3qfu_funk(u3_noun van,
u3_noun sut,
u3_noun tor)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "funk");
return u3n_kick_on(u3i_molt(gat,
u3x_sam,
u3k(tor),
0));
}
static u3_noun
u3qfu_fund(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun hyp)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "fund");
return u3n_kick_on(u3i_molt(gat,
u3x_sam_2,
u3k(way),
u3x_sam_3,
u3k(hyp),
0));
}
static u3_noun
u3qfu_perk(u3_noun van,
u3_noun sut,
@ -686,6 +717,33 @@
}
}
extern void
u3_lo_tank(c3_l tab_l, u3_noun tac);
static u3_noun
_cqfu_fond(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun hyp)
{
u3_noun old = u3qfu_fund(van, sut, way, hyp);
u3_noun new = _find_pony(van, sut, way, hyp);
if ( c3n == u3r_sing(old, new) ) {
u3_noun olf = u3qfu_funk(van, sut, old);
u3_noun nef = u3qfu_funk(van, sut, new);
u3qfu_dump(van, "sut", sut);
u3qfu_dump(van, "hyp", hyp);
fprintf(stderr, "old:\r\n");
u3_lo_tank(1, olf);
fprintf(stderr, "new:\r\n");
u3_lo_tank(1, nef);
}
return _find_pony(van, sut, way, hyp);
}
u3_noun
_cqfu_find(u3_noun van,
u3_noun sut,
@ -757,3 +815,41 @@
return u3z_save_3(fun_m, sut, way, hyp, pro);
}
}
/* boilerplate
*/
u3_noun
u3wfu_fond(u3_noun cor)
{
u3_noun sut, way, hyp, van;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &way,
u3x_sam_3, &hyp,
u3x_con, &van,
0)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqfu_fond(van, sut, way, hyp);
}
}
u3_noun
u3qfu_fond(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun hyp)
{
c3_m fun_m = c3__fond + !!u3r_at(u3qfu_van_vet, van);
u3_noun pro = u3z_find_3(fun_m, sut, way, hyp);
if ( u3_none != pro ) {
return pro;
}
else {
pro = _cqfu_fond(van, sut, way, hyp);
return u3z_save_3(fun_m, sut, way, hyp, pro);
}
}

View File

@ -348,7 +348,7 @@ static u3j_harm _mood__hoon__ut_burn_a[] = {{".2", u3wfu_burn}, {}};
static u3j_harm _mood__hoon__ut_conk_a[] = {{".2", u3wfu_conk}, {}};
static u3j_harm _mood__hoon__ut_crop_a[] = {{".2", u3wfu_crop}, {}};
// static u3j_harm _mood__hoon__ut_fire_a[] = {{".2", u3wfu_fire}, {}};
static u3j_harm _mood__hoon__ut_find_a[] = {{".2", u3wfu_find, c3n}, {}};
// static u3j_harm _mood__hoon__ut_fond_a[] = {{".2", u3wfu_fond, c3n}, {}};
static u3j_harm _mood__hoon__ut_fish_a[] = {{".2", u3wfu_fish}, {}};
static u3j_harm _mood__hoon__ut_fuse_a[] = {{".2", u3wfu_fuse}, {}};
static u3j_harm _mood__hoon__ut_mint_a[] = {{".2", u3wfu_mint}, {}};
@ -366,7 +366,7 @@ static u3j_core _mood__hoon__ut_d[] =
{ "burn", _mood__hoon__ut_burn_a },
{ "conk", _mood__hoon__ut_conk_a },
{ "crop", _mood__hoon__ut_crop_a },
{ "find", _mood__hoon__ut_find_a },
{ "fond", _mood__hoon__ut_fond_a },
// { "fire", _mood__hoon__ut_fire_a },
{ "fish", _mood__hoon__ut_fish_a },
{ "fuse", _mood__hoon__ut_fuse_a },