urbit/j/f/ut_bust.c

72 lines
1.3 KiB
C
Raw Normal View History

2013-09-29 00:21:18 +04:00
/* j/6/bust.c
**
*/
#include "all.h"
2014-09-04 07:10:43 +04:00
2013-09-29 00:21:18 +04:00
/* logic
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-09-03 09:46:55 +04:00
_cqfu_bust(
2014-09-06 00:13:24 +04:00
u3_noun van,
u3_noun sut,
u3_noun dib)
2013-09-29 00:21:18 +04:00
{
2014-11-06 22:13:57 +03:00
u3_noun yam = u3qfu_burn(van, sut);
2014-09-06 00:13:24 +04:00
u3_noun yib = u3nc
2014-08-21 01:18:34 +04:00
(
2014-09-06 00:13:24 +04:00
u3nc(u3k(u3h(u3h(yam))),
u3k(dib)),
u3k(u3t(yam)));
u3_noun woo = u3nc(c3__cnzy, u3_blip);
2014-11-06 22:13:57 +03:00
u3_noun wox = u3qfu_mint(van, sut, c3__noun, woo);
2014-11-06 03:20:01 +03:00
u3_noun ret = u3n_nock_on(yib, u3k(u3t(wox)));
2013-09-29 00:21:18 +04:00
2014-11-06 02:36:30 +03:00
if ( u3_none == ret ) {
2014-11-06 03:20:01 +03:00
return u3m_error("bust-nock");
2013-09-29 00:21:18 +04:00
}
2014-09-06 00:13:24 +04:00
u3z(wox);
u3z(woo);
u3z(yam);
2013-09-29 00:21:18 +04:00
return ret;
}
/* boilerplate
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3wfu_bust(u3_noun cor)
2013-09-29 00:21:18 +04:00
{
2014-09-06 00:13:24 +04:00
u3_noun sut, dib, van;
2013-09-29 00:21:18 +04:00
2014-11-18 00:56:51 +03:00
if ( (c3n == u3r_mean(cor, u3x_sam, &dib, u3x_con, &van, 0)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
2013-09-29 00:21:18 +04:00
{
2014-11-06 03:20:01 +03:00
return u3m_bail(c3__fail);
2013-09-29 00:21:18 +04:00
} else {
2014-09-03 09:46:55 +04:00
return _cqfu_bust(van, sut, dib);
2013-09-29 00:21:18 +04:00
}
}
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 22:13:57 +03:00
u3qfu_bust(u3_noun van,
2014-09-06 00:13:24 +04:00
u3_noun sut,
u3_noun dib)
2013-09-29 00:21:18 +04:00
{
2014-08-28 23:40:40 +04:00
#if 1
2014-09-03 09:46:55 +04:00
return _cqfu_bust(van, sut, dib);
2014-08-28 23:40:40 +04:00
#else
c3_m fun_m = c3__bust;
2014-11-06 03:20:01 +03:00
u3_noun pro = u3z_find_2(fun_m, sut, dib);
2013-09-29 00:21:18 +04:00
2014-11-06 02:36:30 +03:00
if ( u3_none != pro ) {
2014-08-28 23:40:40 +04:00
return pro;
2013-09-29 00:21:18 +04:00
}
else {
2014-09-03 09:46:55 +04:00
pro = _cqfu_bust(van, sut, dib);
2013-09-29 00:21:18 +04:00
2014-11-06 03:20:01 +03:00
return u3z_save_2(fun_m, sut, dib, pro);
2013-09-29 00:21:18 +04:00
}
2014-08-28 23:40:40 +04:00
#endif
2013-09-29 00:21:18 +04:00
}