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"
|
2014-04-30 22:33:23 +04:00
|
|
|
#include "f/nash.h"
|
2013-09-29 00:21:18 +04:00
|
|
|
/* functions
|
|
|
|
*/
|
2014-04-30 22:33:23 +04:00
|
|
|
struct u2_nash* T_r;
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
static u2_noun // produce
|
|
|
|
_cue_in(u2_wire wir_r,
|
|
|
|
u2_atom a, // retain
|
2014-04-30 22:33:23 +04:00
|
|
|
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
|
|
|
|
|
|
|
if ( _0 == j2_mbc(Pt3, cut)(wir_r, 0, b, 1, a) ) {
|
|
|
|
u2_noun x = j2_mbc(Pt1, inc)(wir_r, b);
|
|
|
|
u2_noun c = j2_mby(Pt5, rub)(wir_r, x, a);
|
|
|
|
|
|
|
|
p = j2_mbc(Pt1, inc)(wir_r, u2_h(c));
|
|
|
|
q = u2_rx(wir_r, u2_t(c));
|
2014-05-20 20:59:41 +04:00
|
|
|
u2_na_put(T_r, b, (void*)(c3_p)q);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
u2_rz(wir_r, c);
|
|
|
|
u2_rz(wir_r, x);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
u2_noun c = j2_mbc(Pt1, add)(wir_r, _2, b);
|
|
|
|
u2_noun l = j2_mbc(Pt1, inc)(wir_r, b);
|
|
|
|
|
|
|
|
if ( _0 == j2_mbc(Pt3, cut)(wir_r, 0, l, 1, a) ) {
|
|
|
|
u2_noun u, v, w;
|
|
|
|
u2_noun x, y;
|
|
|
|
|
2014-04-30 22:33:23 +04:00
|
|
|
u = _cue_in(wir_r, a, c);
|
2013-09-29 00:21:18 +04:00
|
|
|
x = j2_mbc(Pt1, add)(wir_r, u2_h(u), c);
|
2014-04-30 22:33:23 +04:00
|
|
|
v = _cue_in(wir_r, a, x);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-04-22 05:22:11 +04:00
|
|
|
w = u2_bc(wir_r, u2_rx(wir_r, u2_h(u2_t(u))),
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_rx(wir_r, u2_h(u2_t(v))));
|
|
|
|
|
|
|
|
y = j2_mbc(Pt1, add)(wir_r, u2_h(u), u2_h(v));
|
|
|
|
|
|
|
|
p = j2_mbc(Pt1, add)(wir_r, _2, y);
|
|
|
|
q = w;
|
2014-05-20 20:59:41 +04:00
|
|
|
u2_na_put(T_r, b, (void*)(c3_p)q);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
u2_rz(wir_r, u); u2_rz(wir_r, v); u2_rz(wir_r, x); u2_rz(wir_r, y);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
u2_noun d = j2_mby(Pt5, rub)(wir_r, c, a);
|
2014-04-30 22:33:23 +04:00
|
|
|
u2_noun x = u2_na_get(T_r, u2_t(d));
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
p = j2_mbc(Pt1, add)(wir_r, _2, u2_h(d));
|
2014-05-07 22:21:16 +04:00
|
|
|
if ( u2_none == x ) {
|
2013-09-29 00:21:18 +04:00
|
|
|
return u2_bl_bail(wir_r, c3__exit);
|
|
|
|
}
|
2014-04-30 22:33:23 +04:00
|
|
|
q = u2_rx(wir_r, x);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
|
|
|
u2_rz(wir_r, d);
|
|
|
|
}
|
|
|
|
u2_rz(wir_r, l);
|
|
|
|
u2_rz(wir_r, c);
|
|
|
|
}
|
2014-04-30 22:33:23 +04:00
|
|
|
return u2_bt(wir_r, p, q, 0);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
u2_noun // transfer
|
2014-04-22 05:22:11 +04:00
|
|
|
j2_mby(Pt5, cue)(u2_wire wir_r,
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_atom a) // retain
|
|
|
|
{
|
2014-04-30 22:33:23 +04:00
|
|
|
T_r = u2_na_make();
|
2014-04-29 04:13:57 +04:00
|
|
|
|
2014-04-30 22:33:23 +04:00
|
|
|
u2_noun x = _cue_in(wir_r, a, _0);
|
|
|
|
u2_noun y = u2_rx(wir_r, u2_h(u2_t(x)));
|
|
|
|
|
|
|
|
u2_na_take(T_r);
|
|
|
|
T_r = 0;
|
|
|
|
|
|
|
|
u2_rz(wir_r, x);
|
|
|
|
return y;
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
u2_noun // transfer
|
2014-04-22 05:22:11 +04:00
|
|
|
j2_mb(Pt5, cue)(u2_wire wir_r,
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun cor) // retain
|
|
|
|
{
|
|
|
|
u2_noun a;
|
|
|
|
|
|
|
|
if ( (u2_none == (a = u2_frag(u2_cv_sam, cor))) ) {
|
|
|
|
return u2_bl_bail(wir_r, c3__fail);
|
|
|
|
} else {
|
|
|
|
return j2_mby(Pt5, cue)(wir_r, a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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 },
|
|
|
|
{ }
|
|
|
|
};
|