Tested leap.

This commit is contained in:
C. Guy Yarvin 2014-10-01 12:17:40 -07:00
parent 7355b8d998
commit 98925768c3
4 changed files with 81 additions and 48 deletions

View File

@ -312,13 +312,11 @@ LIBED25519=outside/ed25519/ed25519.a
LIBANACHRONISM=outside/anachronism/build/libanachronism.a
all: meme
all: vere
vere: $(BIN)/vere
meme: $(BIN)/meme
$(LIBUV_MAKEFILE) $(LIBUV_MAKEFILE2):
cd outside/libuv_0.11 ; sh autogen.sh ; ./configure --disable-dtrace

78
g/a.c
View File

@ -680,28 +680,6 @@ _me_take_north(u3_noun dog)
}
}
/* _me_gain_north(): gain on a north road.
*/
static u3_noun
_me_gain_north(u3_noun dog)
{
if ( u3_yes == u3_co_north_is_senior(dog) ) {
/* senior pointers are not refcounted
*/
return dog;
}
else {
/* junior nouns are disallowed
*/
c3_assert(u3_ne(u3_co_north_is_junior(dog)));
/* normal pointers are refcounted
*/
_me_gain_use(dog);
return dog;
}
}
/* _me_take_south(): take on a south road.
*/
static u3_noun
@ -728,6 +706,45 @@ _me_take_south(u3_noun dog)
}
}
/* u3_ca_take(): gain, copying juniors.
*/
u3_noun
u3_ca_take(u3_noun som)
{
c3_assert(u3_none != som);
if ( u3_so(u3_co_is_cat(som)) ) {
return som;
}
else {
return u3_so(u3_co_is_north)
? _me_take_north(som)
: _me_take_south(som);
}
}
/* _me_gain_north(): gain on a north road.
*/
static u3_noun
_me_gain_north(u3_noun dog)
{
if ( u3_yes == u3_co_north_is_senior(dog) ) {
/* senior pointers are not refcounted
*/
return dog;
}
else {
/* junior nouns are disallowed
*/
c3_assert(u3_ne(u3_co_north_is_junior(dog)));
/* normal pointers are refcounted
*/
_me_gain_use(dog);
return dog;
}
}
/* _me_gain_south(): gain on a south road.
*/
static u3_noun
@ -830,23 +847,6 @@ top:
}
}
/* u3_ca_take(): gain, copying juniors.
*/
u3_noun
u3_ca_take(u3_noun som)
{
c3_assert(u3_none != som);
if ( u3_so(u3_co_is_cat(som)) ) {
return som;
}
else {
return u3_so(u3_co_is_north)
? _me_take_north(som)
: _me_take_south(som);
}
}
/* u3_ca_gain(): gain a reference count in normal space.
*/
u3_noun

5
g/m.c
View File

@ -232,6 +232,7 @@ u3_cm_bail(u3_noun how)
printf("bail: %d (at %llu)\r\n", u3h(how), u3N);
}
}
// abort();
/* Reconstruct a correct error ball.
*/
@ -287,7 +288,7 @@ u3_cm_leap(c3_w pad_w)
else {
pad_w -= u3R->all.fre_w;
}
if ( (pad_w + c3_wiseof(u3_cs_road)) <= u3_co_open ) {
if ( (pad_w + c3_wiseof(u3_cs_road)) >= u3_co_open ) {
u3_cm_bail(c3__meme);
}
len_w = u3_co_open - (pad_w + c3_wiseof(u3_cs_road));
@ -344,7 +345,7 @@ u3_cm_fall()
{
c3_assert(0 != u3R->par_u);
printf("leap: from %s %p, to %s %p (cap %p, was %p)\r\n",
printf("fall: from %s %p, to %s %p (cap %p, was %p)\r\n",
u3_so(u3_co_is_north) ? "north" : "south",
u3R,
u3_so(u3_co_is_north) ? "north" : "south",

View File

@ -198,6 +198,39 @@ _test_jam(void)
}
#endif
static void
_test_leap(void)
{
#if 1
u3_cm_dump();
{
u3_noun pil;
u3_noun cue, jam;
u3_cm_leap(0);
pil = u3_walk_load("urb/urbit.pill");
printf("cueing pill - %d bytes\n", u3_cr_met(3, pil));
cue = u3_cke_cue(pil);
printf("cued - mug %x\n", u3_cr_mug(cue));
u3_cm_fall();
cue = u3_ca_take(cue);
printf("cued - mug %x\n", u3_cr_mug(cue));
u3z(pil);
#if 1
jam = u3_cke_jam(cue);
printf("jammed - %d bytes\n", u3_cr_met(3, jam));
cue = u3_cke_cue(jam);
printf("cued - mug %x\n", u3_cr_mug(cue));
#endif
u3z(cue);
}
u3_cm_dump();
#endif
}
static void
_test_test(void)
{
@ -222,16 +255,17 @@ main(int argc, char *argv[])
u3_ce_init(u3_no);
u3_cm_boot(u3_yes);
u3_cj_boot();
// u3_cj_boot();
u3_cm_dump();
// u3_cm_dump();
printf("booted.\n");
{
_test_hash();
_test_leap();
// _test_hash();
// _test_jam();
}
u3_cm_clear();
u3_cm_dump();
// u3_cm_dump();
}