shrub/gen164/6/ut_firm.c

148 lines
3.9 KiB
C
Raw Normal View History

2013-09-29 00:21:18 +04:00
/* j/6/firm.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, firm)(
2013-09-29 00:21:18 +04:00
u2_noun van, // retain
u2_noun sut, // retain
u2_noun dib) // retain
{
2013-12-26 21:12:07 +04:00
u2_noun p_sut, q_sut;
2013-09-29 00:21:18 +04:00
2014-08-21 01:18:34 +04:00
if ( u2_no == u2du(sut) ) switch ( sut ) {
default: return u2_cm_bail(c3__fail);
2013-09-29 00:21:18 +04:00
case c3__noun:
2013-09-29 00:21:18 +04:00
{
return u2_yes;
}
case c3__void:
{
return u2_no;
}
}
2014-08-21 01:18:34 +04:00
else switch ( u2h(sut) ) {
default: return u2_cm_bail(c3__fail);
2013-09-29 00:21:18 +04:00
2014-08-21 01:18:34 +04:00
case c3__atom: p_sut = u2t(sut);
2013-09-29 00:21:18 +04:00
{
2014-08-21 01:18:34 +04:00
return u2ud(dib);
2013-09-29 00:21:18 +04:00
}
2014-08-21 01:18:34 +04:00
case c3__bull: u2_cx_cell(u2t(sut), &p_sut, &q_sut);
2013-12-26 21:12:07 +04:00
{
2014-08-21 01:18:34 +04:00
u2_weak nun = u2_cr_at(u2h(u2t(u2t(p_sut))), dib);
2014-01-04 06:59:56 +04:00
if ( u2_none == nun ) {
return u2_no;
} else {
2014-08-21 01:18:34 +04:00
return u2_and(j2_mcx(Pt6, ut, firm)(van, q_sut, dib),
j2_mcx(Pt6, ut, firm)(van, u2t(u2t(u2t(p_sut))),
2014-01-04 06:59:56 +04:00
nun));
}
2013-12-26 21:12:07 +04:00
}
2014-08-21 01:18:34 +04:00
case c3__cell: u2_cx_cell(u2t(sut), &p_sut, &q_sut);
2013-09-29 00:21:18 +04:00
{
return u2_and
2014-08-21 01:18:34 +04:00
(u2du(dib),
u2_and(j2_mcx(Pt6, ut, firm)(van, p_sut, u2h(dib)),
j2_mcx(Pt6, ut, firm)(van, q_sut, u2t(dib))));
2013-09-29 00:21:18 +04:00
}
2014-08-21 01:18:34 +04:00
case c3__core: u2_cx_cell(u2t(sut), &p_sut, &q_sut);
2013-09-29 00:21:18 +04:00
{
u2_noun pq_sut, qq_sut, rq_sut, prq_sut, qrq_sut;
2014-08-21 01:18:34 +04:00
u2_cx_trel(q_sut, &pq_sut, &qq_sut, &rq_sut);
u2_cx_cell(rq_sut, &prq_sut, &qrq_sut);
2013-09-29 00:21:18 +04:00
return u2_and
2014-08-21 01:18:34 +04:00
(u2du(dib),
2013-09-29 00:21:18 +04:00
u2_and
2014-08-21 01:18:34 +04:00
(j2_mcx(Pt6, ut, firm)(van, p_sut, u2h(dib)),
((u2_nul == prq_sut) ? u2_cm_error("firm-core")
: u2_cr_sing(prq_sut, u2t(dib)))));
2013-09-29 00:21:18 +04:00
}
2014-08-21 01:18:34 +04:00
case c3__cube: u2_cx_cell(u2t(sut), &p_sut, &q_sut);
2013-09-29 00:21:18 +04:00
{
2014-08-21 01:18:34 +04:00
return u2_cr_sing(dib, p_sut);
2013-09-29 00:21:18 +04:00
}
2014-08-21 01:18:34 +04:00
case c3__face: u2_cx_cell(u2t(sut), &p_sut, &q_sut);
2013-09-29 00:21:18 +04:00
{
2014-08-21 01:18:34 +04:00
return j2_mcx(Pt6, ut, firm)(van, q_sut, dib);
2013-09-29 00:21:18 +04:00
}
2014-08-21 01:18:34 +04:00
case c3__fork: u2_cx_cell(u2t(sut), &p_sut, &q_sut);
2013-09-29 00:21:18 +04:00
{
2014-08-21 01:18:34 +04:00
return u2_or(j2_mcx(Pt6, ut, firm)(van, p_sut, dib),
j2_mcx(Pt6, ut, firm)(van, q_sut, dib));
2013-09-29 00:21:18 +04:00
}
case c3__hold:
2013-09-29 00:21:18 +04:00
{
2014-09-03 07:36:29 +04:00
u2_noun goy = u2_cqfu_repo(van, sut);
2014-08-21 01:18:34 +04:00
u2_noun ret = j2_mcx(Pt6, ut, firm)(van, goy, dib);
2013-09-29 00:21:18 +04:00
2014-08-21 01:18:34 +04:00
u2z(goy);
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, firm)[];
u2_noun // transfer
2014-08-21 01:18:34 +04:00
j2_mc(Pt6, ut, firm)(
2013-09-29 00:21:18 +04:00
u2_noun cor) // retain
{
u2_noun sut, dib, van;
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_mean(cor, u2_cv_sam, &dib, 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, firm)(van, sut, dib);
2013-09-29 00:21:18 +04:00
}
}
u2_noun // transfer
2014-09-03 07:36:29 +04:00
u2_cqfu_firm(u2_noun van, // retain
2013-09-29 00:21:18 +04:00
u2_noun sut, // retain
u2_noun dib) // retain
{
2014-08-28 23:40:40 +04:00
return j2_mcx(Pt6, ut, firm)(van, sut, dib);
2013-09-29 00:21:18 +04:00
}
u2_weak
2014-08-28 23:40:40 +04:00
j2_mck(Pt6, ut, firm)(u2_noun cor)
2013-09-29 00:21:18 +04:00
{
u2_noun sut, dib, van;
2014-08-21 01:18:34 +04:00
if ( (u2_no == u2_cr_mean(cor, u2_cv_sam, &dib, 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(dib));
2013-09-29 00:21:18 +04:00
}
}
/* structures
*/
u2_ho_jet
2013-09-29 00:21:18 +04:00
j2_mcj(Pt6, ut, firm)[] = {
{ ".2", c3__hevy,
j2_mc(Pt6, ut, firm),
2013-09-29 00:21:18 +04:00
Tier6_b,
u2_none, u2_none,
j2_mck(Pt6, ut, firm), c3__firm,
},
{ }
};