urbit/gen164/6/ut_fink.c

117 lines
3.2 KiB
C
Raw Normal View History

2013-09-29 00:21:18 +04:00
/* j/6/fink.c
**
** This file is in the public domain.
*/
#include "all.h"
#include "../pit.h"
/* logic
*/
u2_noun // transfer
2014-08-21 01:18:34 +04:00
j2_mcx(Pt6, ut, fink)(
2013-09-29 00:21:18 +04:00
u2_noun van, // retain
u2_noun sut, // retain
u2_noun dep, // retain
u2_noun way, // retain
u2_noun cog) // retain
{
2014-08-21 01:18:34 +04:00
// u2_noun dun = j2_mcy(Pt6, ut, dunq)(van, "type", sut);
u2_noun nuc = (u2_blip == cog)
2013-09-29 00:21:18 +04:00
? j2_mcy(Pt6, ut, shew)
2014-08-21 01:18:34 +04:00
(van,
u2nc
(u2nc('c', u2_ci_string("find-limb")),
2013-09-29 00:21:18 +04:00
'$'))
: j2_mcy(Pt6, ut, shep)
2014-08-21 01:18:34 +04:00
(van, "find-limb", 'a', u2k(cog));
2013-09-29 00:21:18 +04:00
u2_noun pro;
2014-08-21 01:18:34 +04:00
// u2_ct_push(u2nc(c3__mean, dun));
u2_ct_push(u2nc(c3__mean, nuc));
2013-09-29 00:21:18 +04:00
{
2014-08-21 01:18:34 +04:00
u2_noun hoq = j2_mcy(Pt6, ut, find)(van, sut, dep, way, cog);
u2_noun fin = u2t(hoq);
2013-09-29 00:21:18 +04:00
if ( u2_nul == fin ) {
2014-08-21 01:18:34 +04:00
return u2_cm_error("find-none");
2013-09-29 00:21:18 +04:00
}
else {
2014-08-21 01:18:34 +04:00
pro = u2k(u2t(fin));
u2z(hoq);
2013-09-29 00:21:18 +04:00
}
}
2014-08-21 01:18:34 +04:00
u2_ct_drop();
// u2_ct_drop();
2013-09-29 00:21:18 +04:00
return pro;
}
/* boilerplate
*/
u2_ho_jet
2013-09-29 00:21:18 +04:00
j2_mcj(Pt6, ut, fink)[];
u2_noun // transfer
2014-08-28 23:40:40 +04:00
j2_mc(Pt6, ut, fink)(u2_noun cor) // retain
2013-09-29 00:21:18 +04:00
{
u2_noun sut, dep, way, cog, van;
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_mean(cor, u2_cv_sam_2, &dep,
u2_cv_sam_6, &way,
u2_cv_sam_7, &cog,
u2_cv_con, &van,
2013-09-29 00:21:18 +04:00
0)) ||
2014-08-21 01:18:34 +04:00
(u2_none == (sut = u2_cr_at(u2_cv_sam, van))) )
2013-09-29 00:21:18 +04:00
{
2014-08-21 01:18:34 +04:00
return u2_cm_bail(c3__fail);
2013-09-29 00:21:18 +04:00
} else {
2014-08-21 01:18:34 +04:00
return j2_mcx(Pt6, ut, fink)(van, sut, dep, way, cog);
2013-09-29 00:21:18 +04:00
}
}
u2_noun // transfer
2014-08-21 01:18:34 +04:00
j2_mcy(Pt6, ut, fink)(
2013-09-29 00:21:18 +04:00
u2_noun van, // retain
u2_noun sut, // retain
u2_noun dep,
u2_noun way, // retain
u2_noun cog) // retain
{
2014-08-28 23:40:40 +04:00
return j2_mcx(Pt6, ut, fink)(van, sut, dep, way, cog);
2013-09-29 00:21:18 +04:00
}
u2_weak
2014-08-28 23:40:40 +04:00
j2_mck(Pt6, ut, fink)(u2_noun cor)
2013-09-29 00:21:18 +04:00
{
u2_noun sut, dep, way, cog, van;
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_mean(cor, u2_cv_sam_2, &dep,
u2_cv_sam_6, &way,
u2_cv_sam_7, &cog,
u2_cv_con, &van,
2013-09-29 00:21:18 +04:00
0)) ||
2014-08-21 01:18:34 +04:00
(u2_none == (sut = u2_cr_at(u2_cv_sam, van))) )
2013-09-29 00:21:18 +04:00
{
return u2_none;
} else {
2014-08-21 01:18:34 +04:00
return u2nq
(u2k(sut),
u2k(dep),
u2k(way),
u2k(cog));
2013-09-29 00:21:18 +04:00
}
}
/* structures
*/
u2_ho_jet
2013-09-29 00:21:18 +04:00
j2_mcj(Pt6, ut, fink)[] = {
{ ".2", c3__hevy,
j2_mc(Pt6, ut, fink),
2013-09-29 00:21:18 +04:00
Tier6_b,
u2_none, u2_none,
j2_mck(Pt6, ut, fink), c3__fink,
},
{ }
};