2013-09-29 00:21:18 +04:00
|
|
|
/* j/3/cue.c
|
|
|
|
**
|
|
|
|
** This file is in the public domain.
|
|
|
|
*/
|
|
|
|
#include "all.h"
|
|
|
|
#include "../pit.h"
|
|
|
|
|
|
|
|
static u2_noun // produce
|
2014-08-26 01:35:37 +04:00
|
|
|
_cue_in(u2_ch_root* har_u,
|
2014-08-25 10:58:38 +04:00
|
|
|
u2_atom a, // retain
|
|
|
|
u2_atom b) // retain
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-04-30 22:33:23 +04:00
|
|
|
u2_noun p, q;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-20 10:22:41 +04:00
|
|
|
if ( 0 == j2_mbc(Pt3, cut)(0, b, 1, a) ) {
|
|
|
|
u2_noun x = j2_mbc(Pt1, inc)(b);
|
|
|
|
u2_noun c = j2_mby(Pt5, rub)(x, a);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-22 05:40:06 +04:00
|
|
|
p = j2_mbc(Pt1, inc)(u2k(u2h(c)));
|
2014-08-20 10:22:41 +04:00
|
|
|
q = u2k(u2t(c));
|
2014-08-25 10:58:38 +04:00
|
|
|
|
2014-08-26 01:35:37 +04:00
|
|
|
u2_ch_put(har_u, u2k(b), u2k(q));
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-20 10:22:41 +04:00
|
|
|
u2z(c);
|
|
|
|
u2z(x);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-08-20 10:22:41 +04:00
|
|
|
u2_noun c = j2_mbc(Pt1, add)(2, b);
|
|
|
|
u2_noun l = j2_mbc(Pt1, inc)(b);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-20 10:22:41 +04:00
|
|
|
if ( 0 == j2_mbc(Pt3, cut)(0, l, 1, a) ) {
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun u, v, w;
|
|
|
|
u2_noun x, y;
|
|
|
|
|
2014-08-25 10:58:38 +04:00
|
|
|
u = _cue_in(har_u, a, c);
|
2014-08-20 10:22:41 +04:00
|
|
|
x = j2_mbc(Pt1, add)(u2h(u), c);
|
2014-08-25 10:58:38 +04:00
|
|
|
v = _cue_in(har_u, a, x);
|
|
|
|
w = u2nc(u2k(u2h(u2t(u))), u2k(u2h(u2t(v))));
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-20 10:22:41 +04:00
|
|
|
y = j2_mbc(Pt1, add)(u2h(u), u2h(v));
|
|
|
|
p = j2_mbc(Pt1, add)(2, y);
|
2014-08-25 10:58:38 +04:00
|
|
|
|
2013-09-29 00:21:18 +04:00
|
|
|
q = w;
|
2014-08-26 01:35:37 +04:00
|
|
|
u2_ch_put(har_u, u2k(b), u2k(q));
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-20 10:22:41 +04:00
|
|
|
u2z(u); u2z(v); u2z(x); u2z(y);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-08-20 10:22:41 +04:00
|
|
|
u2_noun d = j2_mby(Pt5, rub)(c, a);
|
2014-08-26 01:35:37 +04:00
|
|
|
u2_noun x = u2_ch_get(har_u, u2k(u2t(d)));
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-20 10:22:41 +04:00
|
|
|
p = j2_mbc(Pt1, add)(2, u2h(d));
|
2014-05-07 22:21:16 +04:00
|
|
|
if ( u2_none == x ) {
|
2014-08-20 10:22:41 +04:00
|
|
|
return u2_cm_bail(c3__exit);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
2014-08-25 10:58:38 +04:00
|
|
|
q = x;
|
2014-08-20 10:22:41 +04:00
|
|
|
u2z(d);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
2014-08-20 10:22:41 +04:00
|
|
|
u2z(l);
|
|
|
|
u2z(c);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
2014-08-20 10:22:41 +04:00
|
|
|
return u2nt(p, q, 0);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
u2_noun // transfer
|
2014-08-25 10:58:38 +04:00
|
|
|
j2_mby(Pt5, cue)(u2_atom a) // retain
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-08-26 01:35:37 +04:00
|
|
|
u2_ch_root* har_u = u2_ch_new();
|
2014-04-29 04:13:57 +04:00
|
|
|
|
2014-08-25 10:58:38 +04:00
|
|
|
u2_noun x = _cue_in(har_u, a, 0);
|
2014-08-20 10:22:41 +04:00
|
|
|
u2_noun y = u2k(u2h(u2t(x)));
|
2014-04-30 22:33:23 +04:00
|
|
|
|
2014-08-26 01:35:37 +04:00
|
|
|
u2_ch_free(har_u);
|
2014-04-30 22:33:23 +04:00
|
|
|
|
2014-08-20 10:22:41 +04:00
|
|
|
u2z(x);
|
2014-04-30 22:33:23 +04:00
|
|
|
return y;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
u2_noun // transfer
|
2014-08-25 10:58:38 +04:00
|
|
|
j2_mb(Pt5, cue)(u2_noun cor) // retain
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
|
|
|
u2_noun a;
|
|
|
|
|
2014-08-20 10:22:41 +04:00
|
|
|
if ( (u2_none == (a = u2_cr_at(u2_cv_sam, cor))) ) {
|
|
|
|
return u2_cm_bail(c3__fail);
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
2014-08-20 10:22:41 +04:00
|
|
|
return j2_mby(Pt5, cue)(a);
|
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_mbj(Pt5, cue)[] = {
|
|
|
|
{ ".2", c3__hevy, j2_mb(Pt5, cue), Tier3, u2_none, u2_none },
|
|
|
|
{ }
|
|
|
|
};
|