2013-09-29 00:21:18 +04:00
|
|
|
/* j/6/ut_burn.c
|
|
|
|
**
|
|
|
|
** This file is in the public domain.
|
|
|
|
*/
|
|
|
|
#include "all.h"
|
|
|
|
#include "../pit.h"
|
|
|
|
|
|
|
|
/* logic
|
|
|
|
*/
|
|
|
|
static u2_noun
|
2014-08-21 01:18:34 +04:00
|
|
|
_burn_in(
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun van,
|
|
|
|
u2_noun sut,
|
|
|
|
u2_noun gil)
|
|
|
|
{
|
|
|
|
u2_noun p_sut, q_sut, pq_sut, qq_sut, rq_sut, prq_sut, qrq_sut;
|
|
|
|
|
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
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
case c3__noun: return 0;
|
2013-09-29 00:21:18 +04:00
|
|
|
case c3__void: {
|
2014-08-21 01:18:34 +04:00
|
|
|
return u2_cm_error("burn-void");
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
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: return 0;
|
|
|
|
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
|
|
|
return _burn_in(van, q_sut, gil);
|
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
|
|
|
{
|
2014-08-21 01:18:34 +04:00
|
|
|
return u2nc
|
|
|
|
(_burn_in(van, p_sut, gil),
|
|
|
|
_burn_in(van, q_sut, gil));
|
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);
|
|
|
|
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
|
|
|
{
|
2014-08-21 01:18:34 +04:00
|
|
|
return u2nc
|
|
|
|
(u2k(prq_sut),
|
|
|
|
_burn_in(van, p_sut, gil));
|
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 u2k(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 _burn_in(van, q_sut, gil);
|
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 _burn_in(van, p_sut, gil);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
2014-08-21 01:18:34 +04:00
|
|
|
case c3__hold: p_sut = u2t(sut);
|
2013-09-29 00:21:18 +04:00
|
|
|
{
|
2014-09-03 07:36:29 +04:00
|
|
|
if ( (u2_yes == u2_cqdi_has(gil, sut)) ) {
|
|
|
|
u2_noun sux = u2_cqfu_dunq(van, "type", sut);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
u2_ct_push(u2nc(c3__mean, sux));
|
|
|
|
return u2_cm_error("burn-loop");
|
2014-04-22 05:22:11 +04:00
|
|
|
}
|
2013-09-29 00:21:18 +04:00
|
|
|
else {
|
2014-09-03 07:36:29 +04:00
|
|
|
u2_noun zoc = u2_cqdi_put(gil, sut);
|
|
|
|
u2_noun fop = u2_cqfu_repo(van, sut);
|
2014-08-21 01:18:34 +04:00
|
|
|
u2_noun pro = _burn_in(van, fop, 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, burn)(
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun van, // retain
|
|
|
|
u2_noun sut) // retain
|
|
|
|
{
|
2014-08-21 01:18:34 +04:00
|
|
|
return _burn_in(van, sut, u2_nul);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
|
2014-04-22 05:22:11 +04:00
|
|
|
extern u2_ho_jet
|
2013-09-29 00:21:18 +04:00
|
|
|
j2_mbj(Pt6, ut)[];
|
|
|
|
|
|
|
|
u2_noun // transfer
|
2014-09-03 07:36:29 +04:00
|
|
|
u2_cqfu_burn(
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun van, // retain
|
|
|
|
u2_noun sut) // retain
|
|
|
|
{
|
|
|
|
u2_ho_jet *jet_j = &j2_mbj(Pt6, ut)[0]; // total hack
|
|
|
|
|
|
|
|
if ( !(jet_j->sat_s & u2_jet_memo) ) {
|
2014-08-21 01:18:34 +04:00
|
|
|
return j2_mcx(Pt6, ut, burn)(van, sut);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
c3_m fun_m = c3__burn;
|
2014-08-26 20:12:45 +04:00
|
|
|
u2_noun pro = u2_cz_find(fun_m, sut);
|
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, burn)(van, sut);
|
2013-09-29 00:21:18 +04:00
|
|
|
|
2014-08-26 20:12:45 +04:00
|
|
|
return u2_cz_save(fun_m, sut, pro);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u2_noun // transfer
|
2014-08-21 01:18:34 +04:00
|
|
|
j2_mc(Pt6, ut, burn)(
|
2013-09-29 00:21:18 +04:00
|
|
|
u2_noun cor) // retain
|
|
|
|
{
|
|
|
|
u2_noun sut;
|
|
|
|
|
2014-08-21 01:18:34 +04:00
|
|
|
if ( u2_none == (sut = u2_cr_at(u2_cv_sam, cor)) ) {
|
|
|
|
return u2_cm_bail(c3__fail);
|
2013-09-29 00:21:18 +04:00
|
|
|
} else {
|
2014-09-03 07:36:29 +04:00
|
|
|
return u2_cqfu_burn(cor, sut);
|
2013-09-29 00:21:18 +04:00
|
|
|
}
|
|
|
|
}
|