urbit/gen164/6/ut_tock.c

116 lines
3.7 KiB
C
Raw Normal View History

2013-09-29 00:21:18 +04:00
/* j/6/tock.c
**
** This file is in the public domain.
*/
#include "all.h"
#include "../pit.h"
/* internals
*/
static u2_noun // transfer
2014-08-21 01:18:34 +04:00
_tock_in(
2013-09-29 00:21:18 +04:00
u2_noun van, // retain
u2_noun sut, // retain
u2_noun peh, // retain
u2_noun mur, // retain
u2_noun men) // retain
{
2014-08-21 01:18:34 +04:00
if ( u2_no == u2du(men) ) {
return u2nc(u2_nul, u2_nul);
}
2013-09-29 00:21:18 +04:00
else {
2014-08-21 01:18:34 +04:00
u2_noun i_men = u2h(men);
u2_noun pi_men = u2h(i_men);
u2_noun qi_men = u2t(i_men);
u2_noun t_men = u2t(men);
2014-09-03 07:36:29 +04:00
u2_noun geq = u2_cqfu_tack(van, pi_men, peh, mur);
2014-08-21 01:18:34 +04:00
u2_noun p_geq = u2h(geq);
u2_noun q_geq = u2t(geq);
u2_noun mox = _tock_in(van, sut, peh, mur, t_men);
u2_noun p_mox = u2h(mox);
u2_noun q_mox = u2t(mox);
2013-09-29 00:21:18 +04:00
u2_noun ret;
2014-08-21 01:18:34 +04:00
ret = u2nc(
( (u2_nul == p_mox)
2014-08-21 01:18:34 +04:00
? u2nc(u2_nul, u2k(p_geq))
: (u2_no == u2_cr_sing(p_geq, u2t(p_mox)))
? u2_cm_bail(c3__exit)
: u2k(p_mox) ),
u2nc(u2nc(u2k(q_geq),
u2k(qi_men)),
u2k(q_mox)));
u2z(mox);
u2z(geq);
2013-09-29 00:21:18 +04:00
return ret;
}
}
2013-09-29 00:21:18 +04:00
/* functions
*/
u2_noun // transfer
2014-08-21 01:18:34 +04:00
j2_mcx(Pt6, ut, tock)(
2013-09-29 00:21:18 +04:00
u2_noun van, // retain
u2_noun sut, // retain
u2_noun peh, // retain
u2_noun mur, // retain
u2_noun men) // retain
{
2014-08-21 01:18:34 +04:00
u2_noun wib = _tock_in(van, sut, peh, mur, men);
u2_noun p_wib = u2h(wib);
u2_noun q_wib = u2t(wib);
2013-09-29 00:21:18 +04:00
if ( u2_nul == p_wib ) {
2014-08-21 01:18:34 +04:00
return u2_cm_bail(c3__exit);
2013-09-29 00:21:18 +04:00
} else {
2014-08-21 01:18:34 +04:00
u2_noun ret = u2nc(u2k(u2t(p_wib)),
u2k(q_wib));
2013-09-29 00:21:18 +04:00
2014-08-21 01:18:34 +04:00
u2z(wib);
2013-09-29 00:21:18 +04:00
return ret;
}
}
/* boilerplate
*/
u2_ho_jet
2013-09-29 00:21:18 +04:00
j2_mcj(Pt6, ut, tock)[];
u2_noun // transfer
2014-08-21 01:18:34 +04:00
j2_mc(Pt6, ut, tock)(
2013-09-29 00:21:18 +04:00
u2_noun cor) // retain
{
u2_noun van, sut, peh, mur, men;
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_mean(cor, u2_cv_sam_2, &peh,
2013-09-29 00:21:18 +04:00
u2_cv_sam_6, &mur,
u2_cv_sam_7, &men,
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, tock)(van, sut, peh, mur, men);
2013-09-29 00:21:18 +04:00
}
}
u2_noun // transfer
2014-09-03 07:36:29 +04:00
u2_cqfu_tock(u2_noun van, // retain
2013-09-29 00:21:18 +04:00
u2_noun sut, // retain
u2_noun peh, // retain
u2_noun mur, // retain
u2_noun men) // retain
{
2014-08-28 23:40:40 +04:00
return j2_mcx(Pt6, ut, tock)(van, sut, peh, mur, men);
2013-09-29 00:21:18 +04:00
}
/* structures
*/
u2_ho_jet
2013-09-29 00:21:18 +04:00
j2_mcj(Pt6, ut, tock)[] = {
{ ".2", c3__hevy, j2_mc(Pt6, ut, tock), Tier6_c, u2_none, u2_none },
{ }
};