2013-09-29 00:21:18 +04:00
|
|
|
/* j/6/ut_rest.c
|
|
|
|
**
|
|
|
|
** This file is in the public domain.
|
|
|
|
*/
|
|
|
|
#include "all.h"
|
|
|
|
#include "../pit.h"
|
|
|
|
|
|
|
|
/* logic
|
|
|
|
*/
|
2014-04-22 05:22:11 +04:00
|
|
|
static u2_noun
|
2014-08-21 01:18:34 +04:00
|
|
|
_rest_in_list(
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun van, // retain
|
|
|
|
u2_noun leg) // retain
|
|
|
|
{
|
|
|
|
if ( u2_nul == leg ) {
|
|
|
|
return u2_nul;
|
|
|
|
} else {
|
2014-08-21 01:18:34 +04:00
|
|
|
u2_noun i_leg = u2h(leg);
|
|
|
|
u2_noun t_leg = u2t(leg);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
return u2nc
|
|
|
|
(j2_mcy(Pt6, ut, play)(van, u2h(i_leg), u2t(i_leg)),
|
|
|
|
_rest_in_list(van, t_leg));
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static u2_noun
|
2014-08-21 01:18:34 +04:00
|
|
|
_rest_in_stil(
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun van,
|
|
|
|
u2_noun gar)
|
|
|
|
{
|
2014-08-21 01:18:34 +04:00
|
|
|
u2_noun gun = j2_mcc(Pt4, in, gas)(u2_nul, gar);
|
|
|
|
u2_noun nog = j2_mcc(Pt4, in, tap)(gun, u2_nul);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
u2z(gun);
|
2013-09-29 00:21:18 +04:00
|
|
|
return nog;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u2_noun // produce
|
2014-08-21 01:18:34 +04:00
|
|
|
_rest_in_fork(
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun nog, // retain
|
|
|
|
u2_noun fub) // retain
|
|
|
|
{
|
2014-08-21 01:18:34 +04:00
|
|
|
if ( u2_no == u2du(nog) ) {
|
2013-09-29 00:21:18 +04:00
|
|
|
return fub;
|
|
|
|
} else {
|
|
|
|
u2_noun buf = _rest_in_fork
|
2014-08-21 01:18:34 +04:00
|
|
|
(
|
|
|
|
u2t(nog),
|
|
|
|
j2_mby(Pt6, fork)(u2h(nog), fub));
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
u2z(fub);
|
2013-09-29 00:21:18 +04:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static u2_noun // produce
|
2014-08-21 01:18:34 +04:00
|
|
|
_rest_in(
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun van, // retain
|
|
|
|
u2_noun leg) // retain
|
|
|
|
{
|
2014-08-21 01:18:34 +04:00
|
|
|
u2_noun gar = _rest_in_list(van, leg);
|
|
|
|
u2_noun nog = _rest_in_stil(van, gar);
|
|
|
|
u2_noun fub = _rest_in_fork(nog, c3__void);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
u2z(gar);
|
|
|
|
u2z(nog);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
return fub;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u2_bean
|
2014-08-21 01:18:34 +04:00
|
|
|
_rest_hit_fan(
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun fan, // retain
|
|
|
|
u2_noun leg) // retain
|
|
|
|
{
|
|
|
|
if ( u2_nul == leg ) {
|
|
|
|
return u2_no;
|
|
|
|
} else {
|
2014-08-21 01:18:34 +04:00
|
|
|
return u2_or(j2_mcc(Pt4, in, has)(fan, u2h(leg)),
|
|
|
|
_rest_hit_fan(fan, u2t(leg)));
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u2_noun // produce
|
2014-08-21 01:18:34 +04:00
|
|
|
j2_mcx(Pt6, ut, rest)(
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun van, // retain
|
|
|
|
u2_noun sut, // retain
|
|
|
|
u2_noun leg) // retain
|
|
|
|
{
|
2014-08-21 01:18:34 +04:00
|
|
|
u2_noun fan = u2_cr_at(j2_ut_van_fan, van);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
if ( u2_yes == _rest_hit_fan(fan, leg) ) {
|
|
|
|
return u2_cm_error("rest-loop");
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-08-21 01:18:34 +04:00
|
|
|
u2_noun naf = j2_mcc(Pt4, in, gas)(fan, leg);
|
|
|
|
u2_noun nav = u2_ci_molt(u2k(van), j2_ut_van_fan, naf, 0);
|
|
|
|
u2_noun mez = _rest_in(nav, leg);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
u2z(naf);
|
|
|
|
u2z(nav);
|
2013-09-29 00:21:18 +04:00
|
|
|
return mez;
|
|
|
|
}
|
2014-04-22 05:22:11 +04:00
|
|
|
}
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
/* boilerplate
|
|
|
|
*/
|
2014-04-22 05:22:11 +04:00
|
|
|
u2_ho_jet
|
2013-09-29 00:21:18 +04:00
|
|
|
j2_mcj(Pt6, ut, rest)[];
|
|
|
|
|
|
|
|
u2_noun // transfer
|
2014-08-21 01:18:34 +04:00
|
|
|
j2_mc(Pt6, ut, rest)(
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun cor) // retain
|
|
|
|
{
|
|
|
|
u2_noun sut, leg, van;
|
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
if ( (u2_no == u2_cr_mean(cor, u2_cv_sam, &leg, u2_cv_con, &van, 0)) ||
|
|
|
|
(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, rest)(van, sut, leg);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u2_noun // transfer
|
2014-08-28 23:40:40 +04:00
|
|
|
j2_mcy(Pt6, ut, rest)(u2_noun van, // retain
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun sut, // retain
|
|
|
|
u2_noun leg) // retain
|
|
|
|
{
|
2014-08-28 23:40:40 +04:00
|
|
|
c3_m fun_m = c3__rest;
|
|
|
|
u2_noun pro = u2_cz_find_2(fun_m, sut, leg);
|
|
|
|
|
|
|
|
if ( u2_none != pro ) {
|
|
|
|
return pro;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-08-28 23:40:40 +04:00
|
|
|
pro = j2_mcx(Pt6, ut, rest)(van, sut, leg);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-28 23:40:40 +04:00
|
|
|
return u2_cz_save_2(fun_m, sut, leg, pro);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u2_weak
|
2014-08-28 23:40:40 +04:00
|
|
|
j2_mck(Pt6, ut, rest)(u2_noun cor)
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
|
|
|
u2_noun sut, leg, van;
|
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
if ( (u2_no == u2_cr_mean(cor, u2_cv_sam, &leg, u2_cv_con, &van, 0)) ||
|
|
|
|
(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 u2nc(u2k(sut), u2k(leg));
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* structures
|
|
|
|
*/
|
2014-04-22 05:22:11 +04:00
|
|
|
u2_ho_jet
|
2013-09-29 00:21:18 +04:00
|
|
|
j2_mcj(Pt6, ut, rest)[] = {
|
2014-04-22 05:22:11 +04:00
|
|
|
{ ".2", c3__hevy,
|
|
|
|
j2_mc(Pt6, ut, rest),
|
2013-09-29 00:21:18 +04:00
|
|
|
Tier6_b_memo,
|
|
|
|
u2_none, u2_none,
|
|
|
|
j2_mck(Pt6, ut, rest), c3__rest,
|
|
|
|
},
|
|
|
|
{ }
|
|
|
|
};
|