shrub/gen164/6/ut_sift.c

134 lines
3.3 KiB
C
Raw Normal View History

2014-01-05 06:05:33 +04:00
/* j/6/sift.c
**
** This file is in the public domain.
*/
#include "all.h"
#include "../pit.h"
/* boilerplate
*/
u2_ho_jet
2014-01-05 06:05:33 +04:00
j2_mcj(Pt6, ut, sift)[];
u2_noun // transfer
2014-08-21 01:18:34 +04:00
j2_mc(Pt6, ut, sift)(
2014-01-05 06:05:33 +04:00
u2_noun cor) // retain
{
u2_noun sut, ref, van;
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_mean(cor, u2_cv_sam, &ref,
u2_cv_con, &van,
2014-01-05 06:05:33 +04:00
0)) ||
2014-08-21 01:18:34 +04:00
(u2_none == (sut = u2_cr_at(u2_cv_sam, van))) )
2014-01-05 06:05:33 +04:00
{
2014-08-21 01:18:34 +04:00
return u2_cm_bail(c3__fail);
2014-01-05 06:05:33 +04:00
} else {
2014-08-21 01:18:34 +04:00
return j2_mcy(Pt6, ut, sift)(van, sut, ref);
2014-01-05 06:05:33 +04:00
}
}
u2_weak // transfer
2014-08-21 01:18:34 +04:00
j2_mci(Pt6, ut, sift)(
2014-01-05 06:05:33 +04:00
u2_noun van, // retain
u2_noun sut, // retain
2014-01-05 06:05:33 +04:00
u2_noun ref) // retain
{
2014-08-21 01:24:29 +04:00
u2_weak hoc = u2_cj_look(u2k(van), "sift");
2014-01-05 06:05:33 +04:00
if ( u2_none == hoc ) {
c3_assert(!"register sift");
return u2_none;
} else {
2014-08-21 01:18:34 +04:00
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);
2014-01-05 06:05:33 +04:00
if ( (u2_none == j2_mcj(Pt6, ut, sift)[0].xip) ) {
2014-08-21 01:24:29 +04:00
u2_noun xip = u2_cj_find(u2k(cor));
2014-01-05 06:05:33 +04:00
// c3_assert(u2_none != xip);
j2_mcj(Pt6, ut, sift)[0].xip = xip;
}
2014-08-21 01:18:34 +04:00
u2z(gat);
2014-01-05 06:05:33 +04:00
return cor;
}
}
u2_noun // transfer
2014-08-21 01:18:34 +04:00
j2_mcy(Pt6, ut, sift)(
2014-01-05 06:05:33 +04:00
u2_noun van, // retain
u2_noun sut, // retain
u2_noun ref) // retain
{
2014-01-05 07:18:06 +04:00
return u2k(ref);
2014-01-05 06:05:33 +04:00
#if 0
u2_ho_jet *jet_j = &j2_mcj(Pt6, ut, sift)[0];
if ( (jet_j->sat_s & u2_jet_live) && !(jet_j->sat_s & u2_jet_test) ) {
if ( !(jet_j->sat_s & u2_jet_memo) ) {
2014-08-21 01:18:34 +04:00
return j2_mcx(Pt6, ut, sift)(van, sut, ref);
2014-01-05 06:05:33 +04:00
}
else {
c3_m fun_m = c3__sift;
2014-08-26 20:12:45 +04:00
u2_noun pro = u2_cz_find_3(fun_m, sut, ref);
2014-01-05 06:05:33 +04:00
if ( u2_none != pro ) {
return pro;
}
else {
2014-08-21 01:18:34 +04:00
pro = j2_mcx(Pt6, ut, sift)(van, sut, ref);
2014-01-05 06:05:33 +04:00
2014-08-26 20:12:45 +04:00
return u2_cz_save_3(fun_m, sut, ref, pro);
2014-01-05 06:05:33 +04:00
}
}
return pro;
} else
2014-01-05 06:05:33 +04:00
#else
{
u2_noun cor, pro;
2014-08-21 01:18:34 +04:00
cor = j2_mci(Pt6, ut, sift)(van, sut, ref);
2014-01-05 06:05:33 +04:00
2014-08-21 01:18:34 +04:00
pro = u2_cn_nock_on(u2k(cor), u2k(u2h(cor)));
if ( u2_none == pro ) return u2_cm_bail(c3__fail);
2014-01-05 06:05:33 +04:00
2014-08-21 01:18:34 +04:00
u2z(cor);
2014-01-05 06:05:33 +04:00
return pro;
#endif
}
}
u2_weak
2014-08-21 01:18:34 +04:00
j2_mck(Pt6, ut, sift)(
2014-01-05 06:05:33 +04:00
u2_noun cor)
{
u2_noun sut, ref, van;
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_mean(cor, u2_cv_sam, &ref,
u2_cv_con, &van,
2014-01-05 06:05:33 +04:00
0)) ||
2014-08-21 01:18:34 +04:00
(u2_none == (sut = u2_cr_at(u2_cv_sam, van))) )
2014-01-05 06:05:33 +04:00
{
return u2_none;
} else {
2014-08-21 01:18:34 +04:00
return u2nc
(u2k(sut), u2k(ref));
2014-01-05 06:05:33 +04:00
}
}
/* structures
*/
u2_ho_jet
2014-01-05 06:05:33 +04:00
j2_mcj(Pt6, ut, sift)[] = {
{ ".2", c3__hevy,
j2_mc(Pt6, ut, sift),
2014-01-05 06:05:33 +04:00
Tier6_b_memo,
u2_none, u2_none,
j2_mck(Pt6, ut, sift), c3__sift
},
{ }
};