WIP refactored but still dying

This commit is contained in:
Ted Blackman 2019-01-15 19:42:40 -08:00
parent 63ccf3ad7e
commit e815ad4be7
2 changed files with 23 additions and 13 deletions

View File

@ -1701,14 +1701,10 @@ u3r_mug(u3_noun veb)
veb = fam->veb;
veb_u = u3a_to_ptr(veb);
if ( _(u3a_is_atom(veb)) ) {
mug_w = _mug_atom(veb);
fam = _mug_pop(mov, off, mug_w);
}
// both head and tail are mugged; combine them and pop stack
//
else if ( (0 != a) && (0 != b) ) {
//fprintf(stderr, "combining head and tail mugs\r\n");
if ( (0 != a) && (0 != b) ) {
fprintf(stderr, "combining head and tail mugs\r\n");
mug_w = u3r_mug_both(a, b);
veb_u->mug_w = mug_w;
fam = _mug_pop(mov, off, mug_w);
@ -1716,24 +1712,38 @@ u3r_mug(u3_noun veb)
// head is mugged, but not tail; push tail onto stack
//
else if ( (0 != a) && (0 == b) ) {
//fprintf(stderr, "pushing tail\r\n");
fam = _mug_push(mov, off, u3t(veb));
if ( _(u3a_is_atom(u3t(veb))) ) {
fprintf(stderr, "tail is atom\r\n");
mug_w = _mug_atom(u3t(veb));
fam->b = mug_w;
}
else {
fprintf(stderr, "pushing tail\r\n");
fam = _mug_push(mov, off, u3t(veb));
}
}
// cell, and neither head nor tail is mugged; push head onto stack
//
else {
//fprintf(stderr, "asserting cell\r\n");
fprintf(stderr, "asserting cell\r\n");
c3_assert(_(u3a_is_cell(veb)));
// already mugged; pop stack
//
if ( veb_u->mug_w ) {
//fprintf(stderr, "already mugged\r\n");
fprintf(stderr, "already mugged\r\n");
mug_w = veb_u->mug_w;
fam = _mug_pop(mov, off, mug_w);
}
else {
//fprintf(stderr, "pushing head\r\n");
fam = _mug_push(mov, off, u3h(veb));
if ( _(u3a_is_atom(u3h(veb))) ) {
fprintf(stderr, "head is atom\r\n");
mug_w = _mug_atom(u3h(veb));
fam->a = mug_w;
}
else {
fprintf(stderr, "pushing head\r\n");
fam = _mug_push(mov, off, u3h(veb));
}
}
}
}

View File

@ -72,7 +72,7 @@ _test_mug(void)
u3_noun set = u3_nul;
c3_w len_w = 0;
while ( 0xf > len_w ) {
while ( 0x1 > len_w ) {
set = u3qdi_put(set, len_w++);
}
u3r_mug(set);