2013-09-29 00:21:18 +04:00
|
|
|
/* j/6/peek.c
|
|
|
|
**
|
|
|
|
** This file is in the public domain.
|
|
|
|
*/
|
|
|
|
#include "all.h"
|
|
|
|
#include "../pit.h"
|
|
|
|
|
|
|
|
/* logic
|
|
|
|
*/
|
|
|
|
u2_noun
|
2014-08-21 01:18:34 +04:00
|
|
|
j2_mcx(Pt6, ut, peek)(u2_noun, u2_noun, u2_noun, u2_atom);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
static u2_noun // produce
|
2014-08-21 01:18:34 +04:00
|
|
|
_peek_in(
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun van, // retain
|
|
|
|
u2_noun sut, // retain
|
|
|
|
u2_noun way, // retain
|
|
|
|
u2_atom axe, // retain
|
|
|
|
u2_noun gil) // retain
|
|
|
|
{
|
2013-12-31 23:30:37 +04:00
|
|
|
u2_noun p_sut, q_sut;
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun pro;
|
|
|
|
|
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: {
|
|
|
|
return c3__noun;
|
|
|
|
}
|
|
|
|
case c3__void: {
|
|
|
|
return c3__void;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
|
|
|
case c3__atom: {
|
|
|
|
return c3__void;
|
|
|
|
}
|
2014-02-18 20:42:47 +04:00
|
|
|
case c3__bull: {
|
2014-08-21 01:18:34 +04:00
|
|
|
if ( (u2_no == u2_cr_trel(sut, 0, &p_sut, &q_sut)) ) {
|
|
|
|
return u2_cm_bail(c3__fail);
|
2014-02-18 20:42:47 +04:00
|
|
|
} else {
|
2014-08-21 01:18:34 +04:00
|
|
|
return _peek_in(van, q_sut, way, axe, gil);
|
2014-02-18 20:42:47 +04:00
|
|
|
}
|
|
|
|
}
|
2013-09-29 00:21:18 +04:00
|
|
|
case c3__cell: {
|
2014-08-21 01:18:34 +04:00
|
|
|
if ( (u2_no == u2_cr_trel(sut, 0, &p_sut, &q_sut)) ) {
|
|
|
|
return u2_cm_bail(c3__fail);
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
2014-08-21 01:18:34 +04:00
|
|
|
u2_atom tip = j2_mbc(Pt3, cap)(axe);
|
|
|
|
u2_atom tap = j2_mbc(Pt3, mas)(axe);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
if ( 2 == tip ) {
|
|
|
|
pro = j2_mcx(Pt6, ut, peek)(van, p_sut, way, tap);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-08-21 01:18:34 +04:00
|
|
|
pro = j2_mcx(Pt6, ut, peek)(van, q_sut, way, tap);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
2014-08-21 01:18:34 +04:00
|
|
|
u2z(tap);
|
|
|
|
u2z(tip);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
return pro;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case c3__core: {
|
|
|
|
u2_noun pq_sut, qq_sut, rq_sut;
|
|
|
|
u2_noun prq_sut, qrq_sut;
|
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
if ( (u2_no == u2_cr_trel(sut, 0, &p_sut, &q_sut)) ||
|
|
|
|
(u2_no == u2_cr_trel(q_sut, &pq_sut, &qq_sut, &rq_sut)) ||
|
|
|
|
(u2_no == u2_cr_cell(rq_sut, &prq_sut, &qrq_sut)) )
|
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
|
|
|
u2_atom tip = j2_mbc(Pt3, cap)(axe);
|
|
|
|
u2_atom tap = j2_mbc(Pt3, mas)(axe);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
if ( 3 == tip ) {
|
|
|
|
if ( u2_no == j2_mcy(Pt6, ut, park)(van, sut, way, tap) )
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-08-21 01:18:34 +04:00
|
|
|
// u2_noun dun = j2_mcy(Pt6, ut, dunq)(van, "type", sut);
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun waz = j2_mcy(Pt6, ut, shep)
|
2014-08-21 01:18:34 +04:00
|
|
|
(van, "axis", 'd', u2k(axe));
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
// u2_ct_push(u2nc(c3__mean, dun));
|
|
|
|
u2_ct_push(u2nc(c3__mean, waz));
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
return u2_cm_error("peek-park");
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
2014-08-21 01:18:34 +04:00
|
|
|
else pro = j2_mcx(Pt6, ut, peek)(van, p_sut, way, tap);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
pro = c3__noun;
|
|
|
|
}
|
2014-08-21 01:18:34 +04:00
|
|
|
u2z(tap);
|
|
|
|
u2z(tip);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
return pro;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case c3__cube: {
|
2014-08-21 01:18:34 +04:00
|
|
|
if ( (u2_no == u2_cr_trel(sut, 0, &p_sut, &q_sut)) ) {
|
|
|
|
return u2_cm_bail(c3__fail);
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
2014-08-21 01:18:34 +04:00
|
|
|
return _peek_in(van, q_sut, way, axe, gil);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case c3__face: {
|
2014-08-21 01:18:34 +04:00
|
|
|
if ( (u2_no == u2_cr_trel(sut, 0, &p_sut, &q_sut)) ) {
|
|
|
|
return u2_cm_bail(c3__fail);
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
2014-08-21 01:18:34 +04:00
|
|
|
return _peek_in(van, q_sut, way, axe, gil);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
case c3__fork: {
|
2014-08-21 01:18:34 +04:00
|
|
|
if ( (u2_no == u2_cr_trel(sut, 0, &p_sut, &q_sut)) ) {
|
|
|
|
return u2_cm_bail(c3__fail);
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
2014-08-21 01:18:34 +04:00
|
|
|
u2_noun hed = _peek_in(van, p_sut, way, axe, gil);
|
|
|
|
u2_noun tal = _peek_in(van, q_sut, way, axe, gil);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
pro = j2_mby(Pt6, fork)(hed, tal);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
u2z(hed);
|
|
|
|
u2z(tal);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
return pro;
|
|
|
|
}
|
2014-04-22 05:22:11 +04:00
|
|
|
}
|
2013-09-29 00:21:18 +04:00
|
|
|
case c3__hold: {
|
2014-08-21 01:18:34 +04:00
|
|
|
p_sut = u2t(sut);
|
|
|
|
if ( (u2_yes == j2_mcc(Pt4, in, has)(gil, sut)) ) {
|
2013-09-29 00:21:18 +04:00
|
|
|
return c3__void;
|
2014-04-22 05:22:11 +04:00
|
|
|
}
|
2013-09-29 00:21:18 +04:00
|
|
|
else {
|
2014-08-21 01:18:34 +04:00
|
|
|
u2_noun zoc = j2_mcc(Pt4, in, put)(gil, sut);
|
|
|
|
u2_noun fop = j2_mcy(Pt6, ut, repo)(van, sut);
|
|
|
|
u2_noun pro = _peek_in(van, fop, way, axe, zoc);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
u2z(fop);
|
|
|
|
u2z(zoc);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
return pro;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u2_noun // transfer
|
2014-08-21 01:18:34 +04:00
|
|
|
j2_mcx(Pt6, ut, peek)(
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun van, // retain
|
|
|
|
u2_noun sut, // retain
|
|
|
|
u2_noun way,
|
|
|
|
u2_atom axe) // retain
|
|
|
|
{
|
2014-08-21 01:18:34 +04:00
|
|
|
if ( 1 == axe ) {
|
|
|
|
return u2k(sut);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
2014-08-21 01:18:34 +04:00
|
|
|
else return _peek_in(van, sut, way, axe, u2_nul);
|
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, peek)[];
|
|
|
|
|
|
|
|
u2_noun // transfer
|
2014-08-21 01:18:34 +04:00
|
|
|
j2_mc(Pt6, ut, peek)(
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun cor) // retain
|
|
|
|
{
|
|
|
|
u2_noun sut, way, axe, van;
|
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
if ( (u2_no == u2_cr_mean(cor, u2_cv_sam_2, &way,
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_cv_sam_3, &axe,
|
2014-04-22 05:22:11 +04:00
|
|
|
u2_cv_con, &van,
|
2013-09-29 00:21:18 +04:00
|
|
|
0)) ||
|
2014-08-21 01:18:34 +04:00
|
|
|
(u2_no == u2ud(axe)) ||
|
|
|
|
(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, peek)(van, sut, way, axe);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u2_weak // transfer
|
2014-08-21 01:18:34 +04:00
|
|
|
j2_mci(Pt6, ut, peek)(
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun van, // retain
|
2014-04-22 05:22:11 +04:00
|
|
|
u2_noun sut, // retain
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun way, // retain
|
|
|
|
u2_noun axe) // retain
|
|
|
|
{
|
2014-08-21 01:24:29 +04:00
|
|
|
u2_weak hoc = u2_cj_look(u2k(van), "peek");
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
if ( u2_none == hoc ) {
|
|
|
|
c3_assert(!"register peek");
|
|
|
|
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_2, u2k(way),
|
|
|
|
u2_cv_sam_3, u2k(axe),
|
2013-09-29 00:21:18 +04:00
|
|
|
0);
|
|
|
|
|
|
|
|
if ( (u2_none == j2_mcj(Pt6, ut, peek)[0].xip) ) {
|
2014-08-21 01:24:29 +04:00
|
|
|
u2_noun xip = u2_cj_find(u2k(cor));
|
2014-04-22 05:22:11 +04:00
|
|
|
|
2013-09-29 00:21:18 +04:00
|
|
|
c3_assert(u2_none != xip);
|
|
|
|
j2_mcj(Pt6, ut, peek)[0].xip = xip;
|
|
|
|
}
|
2014-08-21 01:18:34 +04:00
|
|
|
u2z(gat);
|
2013-09-29 00:21:18 +04:00
|
|
|
return cor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u2_noun // transfer
|
2014-08-21 01:18:34 +04:00
|
|
|
j2_mcy(Pt6, ut, peek)(
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun van, // retain
|
|
|
|
u2_noun sut, // retain
|
|
|
|
u2_noun way, // retain
|
|
|
|
u2_noun axe) // retain
|
|
|
|
{
|
|
|
|
u2_ho_jet *jet_j = &j2_mcj(Pt6, ut, peek)[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, peek)(van, sut, way, axe);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
c3_m fun_m = c3__peek;
|
2014-08-26 20:12:45 +04:00
|
|
|
u2_noun pro = u2_cz_find_3(fun_m, sut, way, axe);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
if ( u2_none != pro ) {
|
|
|
|
return pro;
|
|
|
|
}
|
|
|
|
else {
|
2014-08-21 01:18:34 +04:00
|
|
|
pro = j2_mcx(Pt6, ut, peek)(van, sut, way, axe);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-26 20:12:45 +04:00
|
|
|
return u2_cz_save_3(fun_m, sut, way, axe, pro);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
u2_noun cor, fol, pro;
|
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
cor = j2_mci(Pt6, ut, peek)(van, sut, way, axe);
|
|
|
|
fol = u2h(cor);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
pro = u2_ho_use(jet_j, cor, fol);
|
|
|
|
if ( u2_none == pro ) return u2_cm_bail(c3__fail);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
u2z(cor);
|
|
|
|
u2z(fol);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
return pro;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u2_weak
|
2014-08-21 01:18:34 +04:00
|
|
|
j2_mck(Pt6, ut, peek)(
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun cor)
|
|
|
|
{
|
|
|
|
u2_noun sut, way, axe, van;
|
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
if ( (u2_no == u2_cr_mean(cor, u2_cv_sam_2, &way,
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_cv_sam_3, &axe,
|
2014-04-22 05:22:11 +04:00
|
|
|
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 u2nt
|
|
|
|
(u2k(sut), u2k(way), u2k(axe));
|
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, peek)[] = {
|
2014-04-22 05:22:11 +04:00
|
|
|
{ ".2", c3__hevy,
|
|
|
|
j2_mc(Pt6, ut, peek),
|
2013-09-29 00:21:18 +04:00
|
|
|
Tier6_b_memo,
|
|
|
|
u2_none, u2_none,
|
|
|
|
j2_mck(Pt6, ut, peek), c3__peek
|
|
|
|
},
|
|
|
|
{ }
|
|
|
|
};
|