Burn stuff builds, doesn't work...

This commit is contained in:
C. Guy Yarvin 2016-01-13 10:06:42 -08:00
parent d7c6eda7b4
commit 42580bda5c
4 changed files with 159 additions and 25 deletions

View File

@ -99,11 +99,6 @@
u3_noun
u3kf_frog(u3_noun yed);
/* u3kf_grof(): build %fork span.
*/
u3_noun
u3kf_grof(u3_noun yed);
/* u3kfu_repo():
*/
u3_noun

View File

@ -19,6 +19,7 @@
else if ( c3__void == hoz ) {
return u3k(bur);
}
// else return u3kf_frog(u3nt(u3k(hoz), u3k(bur), u3_nul));
else return u3nq
(c3__frog, u3k(hoz), u3k(bur), u3_nul);
}
@ -47,25 +48,10 @@
return ret;
}
else {
// return u3nc(c3__frog, u3kdi_tap(lez, u3_nul));
return u3nc(c3__fork, lez);
}
}
u3_noun
u3qf_grof(u3_noun bez)
{
return u3nc(c3__frog, u3qdi_tap(bez, u3_nul));
}
u3_noun
u3kf_grof(u3_noun bez)
{
u3_noun ret = u3qf_grof(bez);
u3z(bez);
return ret;
}
u3_noun
u3wf_frog(u3_noun cor)
{

View File

@ -6,6 +6,157 @@
/* logic
*/
#if 0
static u3_noun
_burn_in(u3_noun van, u3_noun sut, u3_noun gil);
static u3_noun
_burn_frog(u3_noun van,
u3_noun yed,
u3_noun gil)
{
if ( u3_nul == yed ) {
return u3_nul;
} else {
u3_noun dis = _burn_in(van, u3h(yed), gil);
u3_noun mor = _burn_frog(van, u3t(yed), gil);
if ( u3_nul == dis ) return mor;
if ( u3_nul == mor ) return dis;
{
u3_noun u_dis = u3t(dis);
u3_noun u_mor = u3t(mor);
if ( u3du(u_dis) == u3du(u_mor) ) {
if ( c3y == u3qc_gor(u_mor, u_dis) ) {
u3z(dis);
return mor;
} else {
u3z(mor);
return dis;
}
} else {
if ( c3y == u3ud(u_dis) ) {
u3z(mor);
return dis;
}
else {
u3z(dis);
return mor;
}
}
}
}
}
static u3_noun
_burn_in(u3_noun van,
u3_noun sut,
u3_noun gil)
{
u3_noun p_sut, q_sut, pq_sut, qq_sut, rq_sut, prq_sut, qrq_sut;
if ( c3n == u3du(sut) ) switch ( sut ) {
default: return u3m_bail(c3__fail);
case c3__noun: return u3nc(u3_nul, 0);
case c3__void: {
return u3_nul;
}
}
else switch ( u3h(sut) ) {
default: return u3m_bail(c3__fail);
case c3__atom: u3x_cell(u3t(sut), &p_sut, &q_sut);
{
if ( c3y == u3du(q_sut) ) {
return u3nc(u3_nul, u3k(u3t(q_sut)));
} else {
return u3nc(u3_nul, 0);
}
}
case c3__cell: u3x_cell(u3t(sut), &p_sut, &q_sut);
{
u3_noun hed = _burn_in(van, p_sut, gil);
if ( u3_nul == hed ) {
return u3_nul;
}
else {
u3_noun tal = _burn_in(van, q_sut, gil);
if ( u3_nul == tal ) {
u3z(hed);
return u3_nul;
}
else return u3nt(u3_nul, hed, tal);
}
}
case c3__core: u3x_cell(u3t(sut), &p_sut, &q_sut);
u3x_trel(q_sut, &pq_sut, &qq_sut, &rq_sut);
u3x_cell(rq_sut, &prq_sut, &qrq_sut);
{
u3_noun pay = _burn_in(van, p_sut, gil);
if ( u3_nul == pay ) {
return u3_nul;
}
else {
return u3nt(u3_nul, u3k(prq_sut), pay);
}
}
case c3__face: u3x_cell(u3t(sut), &p_sut, &q_sut);
{
return _burn_in(van, q_sut, gil);
}
case c3__fork: p_sut = u3t(sut);
{
u3_noun yed = u3qdi_tap(p_sut, u3_nul);
u3_noun ret = _burn_frog(van, yed, gil);
u3z(yed);
return ret;
}
case c3__frog: p_sut = u3t(sut);
{
return _burn_in(van, u3h(p_sut), gil);
}
case c3__hold:
{
if ( (c3y == u3qdi_has(gil, sut)) ) {
return u3_nul;
}
else {
u3_noun zoc = u3qdi_put(gil, sut);
u3_noun fop = u3qfu_repo(van, sut);
u3_noun pro = _burn_in(van, fop, zoc);
u3z(fop);
u3z(zoc);
return pro;
}
}
}
}
u3_noun
_cqfu_burn(u3_noun van,
u3_noun sut)
{
u3_noun unt = _burn_in(van, sut, u3_nul);
if ( u3_nul == unt ) {
return u3m_error("burn");
}
else {
u3_noun ret = u3k(u3t(unt));
u3z(unt);
return ret;
}
}
#else
static u3_noun
_burn_in(u3_noun van,
u3_noun sut,
@ -86,6 +237,7 @@
{
return _burn_in(van, sut, u3_nul);
}
#endif
u3_noun
u3qfu_burn(u3_noun van,

View File

@ -15,14 +15,15 @@
if ( c3n == u3du(sut) ) switch ( sut ) {
default: return u3k(sut);
case c3__noun:
return u3nq(c3__frog,
u3nt(c3__atom, u3_blip, u3_nul),
u3nt(c3__cell, c3__noun, c3__noun),
u3_nul);
case c3__noun: {
return u3kf_frog(u3nt(u3nt(c3__atom, u3_blip, u3_nul),
u3nt(c3__cell, c3__noun, c3__noun),
u3_nul));
}
}
else switch ( u3h(sut) ) {
default: {
u3m_p("head", u3h(sut));
return u3m_error("repo-flat");
}