vere: scry reform

This commit is contained in:
Joe Bryan 2020-11-23 18:05:15 -08:00
parent f95e1f48c2
commit 71fb3d66d8
7 changed files with 51 additions and 132 deletions

View File

@ -796,8 +796,10 @@
# define c3__off c3_s3('o','f','f')
# define c3__ogre c3_s4('o','g','r','e')
# define c3__old c3_s3('o','l','d')
# define c3__omen c3_s4('o','m','e','n')
# define c3__on c3_s2('o','n')
# define c3__onan c3_s4('o','n','a','n')
# define c3__once c3_s4('o','n','c','e')
# define c3__one c3_s3('o','n','e')
# define c3__only c3_s4('o','n','l','y')
# define c3__oops c3_s4('o','o','p','s')

View File

@ -382,8 +382,7 @@
*/
typedef enum {
u3_pico_full = 0,
u3_pico_mine = 1,
u3_pico_last = 2
u3_pico_once = 1
} u3_pico_type;
/* u3_pico: proto-peek
@ -395,12 +394,8 @@
u3_noun gan; // leakset
u3_pico_type typ_e; // type-tagged
union { //
u3_noun ful; // full: /care/beam
struct { // mine:
c3_m car_m; // care
u3_noun pax; // /desk/case/path
} min_u; //
struct { // last:
u3_noun ful; // (each path [%beam term beam])
struct { // once:
c3_m car_m; // care
u3_atom des; // desk
u3_noun pax; // /path
@ -413,9 +408,8 @@
typedef struct _u3_peek {
void* ptr_v; // context
u3_peek_cb fun_f; // callback
u3_noun now; // XX
u3_noun gan; // leakset
u3_noun ful; // /care/beam
u3_pico_type typ_e; // type
u3_noun sam; // +peek sample
} u3_peek;
/* u3_writ_type: king->serf ipc message types
@ -1241,16 +1235,6 @@
void* ptr_v,
u3_peek_cb fun_f);
/* u3_pier_peek_mine(): read namespace, injecting ship.
*/
void
u3_pier_peek_mine(u3_pier* pir_u,
u3_noun gan,
c3_m car_m,
u3_noun pax,
void* ptr_v,
u3_peek_cb fun_f);
/* u3_pier_peek_last(): read namespace, injecting ship and case.
*/
void

View File

@ -191,11 +191,9 @@ _cv_time_bump(u3_reck* rec_u)
/* u3v_peek(): query the reck namespace (protected).
*/
u3_noun
u3v_peek(u3_noun hap)
u3v_peek(u3_noun sam)
{
u3_noun fun = u3n_nock_on(u3k(u3A->roc), u3k(u3x_at(_CVX_PEEK, u3A->roc)));
u3_noun sam = u3nc(u3k(u3A->now), hap);
return u3n_slam_on(fun, sam);
}

View File

@ -35,7 +35,7 @@
[%meld ~]
[%pack ~]
== ==
[%peek mil=@ now=@da lyc=gang pat=path]
[%peek mil=@ sam=*] :: gang (each path $%([%once @tas @tas path] [beam @tas beam]))
[%play eve=@ lit=(list ?((pair @da ovum) *))]
[%work mil=@ job=(pair @da ovum)]
==
@ -99,9 +99,7 @@ _lord_writ_free(u3_writ* wit_u)
} break;
case u3_writ_peek: {
u3z(wit_u->pek_u->now);
u3z(wit_u->pek_u->gan);
u3z(wit_u->pek_u->ful);
u3z(wit_u->pek_u->sam);
} break;
case u3_writ_play: {
@ -371,9 +369,7 @@ _lord_plea_peek_bail(u3_lord* god_u, u3_peek* pek_u, u3_noun dud)
pek_u->fun_f(pek_u->ptr_v, u3_nul);
u3z(pek_u->now);
u3z(pek_u->gan);
u3z(pek_u->ful);
u3z(pek_u->sam);
c3_free(pek_u);
}
@ -382,13 +378,25 @@ _lord_plea_peek_bail(u3_lord* god_u, u3_peek* pek_u, u3_noun dud)
static void
_lord_plea_peek_done(u3_lord* god_u, u3_peek* pek_u, u3_noun rep)
{
// XX review
//
if ( (u3_pico_once == pek_u->typ_e)
&& (u3_nul != rep) )
{
u3_noun dat;
if ( c3y == u3r_pq(u3t(rep), c3__omen, 0, &dat) ) {
u3k(dat);
u3z(rep);
rep = u3nc(u3_nul, dat);
}
}
// XX cache [dat] (unless last)
//
pek_u->fun_f(pek_u->ptr_v, rep);
u3z(pek_u->now);
u3z(pek_u->gan);
u3z(pek_u->ful);
u3z(pek_u->sam);
c3_free(pek_u);
}
@ -754,10 +762,9 @@ _lord_writ_make(u3_lord* god_u, u3_writ* wit_u)
} break;
case u3_writ_peek: {
msg = u3nc(c3__peek, u3nq(0, // XX support timeouts
u3k(wit_u->pek_u->now),
u3k(wit_u->pek_u->gan),
u3k(wit_u->pek_u->ful)));
// XX support timeouts,
//
msg = u3nc(c3__peek, u3nc(0, u3k(wit_u->pek_u->sam)));
} break;
case u3_writ_play: {
@ -862,39 +869,28 @@ u3_lord_peek(u3_lord* god_u, u3_pico* pic_u)
wit_u->pek_u = c3_calloc(sizeof(*wit_u->pek_u));
wit_u->pek_u->ptr_v = pic_u->ptr_v;
wit_u->pek_u->fun_f = pic_u->fun_f;
wit_u->pek_u->now = u3_time_in_tv(&wit_u->tim_u);
wit_u->pek_u->gan = u3k(pic_u->gan);
wit_u->pek_u->typ_e = pic_u->typ_e;
// construct the full scry path
//
switch ( pic_u->typ_e ) {
default: c3_assert(0);
{
u3_noun sam;
switch ( pic_u->typ_e ) {
default: c3_assert(0);
case u3_pico_full: {
wit_u->pek_u->ful = u3k(pic_u->ful);
} break;
case u3_pico_full: {
sam = u3k(pic_u->ful);
} break;
case u3_pico_mine: {
// XX cache
//
u3_pier* pir_u = god_u->cb_u.ptr_v; // XX do better
u3_noun our = u3dc("scot", 'p', u3i_chubs(2, pir_u->who_d));
wit_u->pek_u->ful = u3nt(pic_u->min_u.car_m, our, u3k(pic_u->min_u.pax));
} break;
case u3_pico_once: {
sam = u3nc(c3n, u3nq(c3__once,
pic_u->las_u.car_m,
u3k(pic_u->las_u.des),
u3k(pic_u->las_u.pax)));
} break;
}
case u3_pico_last: {
// XX cache
//
u3_pier* pir_u = god_u->cb_u.ptr_v; // XX do better
u3_noun our = u3dc("scot", 'p', u3i_chubs(2, pir_u->who_d));
u3_noun cas = u3dc("scot", c3__da, u3k(wit_u->pek_u->now));
wit_u->pek_u->ful = u3nc(pic_u->las_u.car_m,
u3nq(our,
u3k(pic_u->las_u.des),
cas,
u3k(pic_u->las_u.pax)));
} break;
wit_u->pek_u->sam = u3nc(u3k(pic_u->gan), sam);
}
// XX cache check, unless last

View File

@ -436,29 +436,6 @@ u3_pier_peek(u3_pier* pir_u,
_pier_peek_plan(pir_u, pic_u);
}
/* u3_pier_peek_mine(): read namespace, injecting ship.
*/
void
u3_pier_peek_mine(u3_pier* pir_u,
u3_noun gan,
c3_m car_m,
u3_noun pax,
void* ptr_v,
u3_peek_cb fun_f)
{
u3_pico* pic_u = u3_pico_init();
pic_u->ptr_v = ptr_v;
pic_u->fun_f = fun_f;
pic_u->gan = gan;
//
pic_u->typ_e = u3_pico_mine;
pic_u->min_u.car_m = car_m;
pic_u->min_u.pax = pax;
_pier_peek_plan(pir_u, pic_u);
}
/* u3_pier_peek_last(): read namespace, injecting ship and case.
*/
void
@ -476,7 +453,7 @@ u3_pier_peek_last(u3_pier* pir_u,
pic_u->fun_f = fun_f;
pic_u->gan = gan;
//
pic_u->typ_e = u3_pico_last;
pic_u->typ_e = u3_pico_once;
pic_u->las_u.car_m = car_m;
pic_u->las_u.des = des;
pic_u->las_u.pax = pax;

View File

@ -191,11 +191,7 @@ u3_pico_free(u3_pico* pic_u)
u3z(pic_u->ful);
} break;
case u3_pico_mine: {
u3z(pic_u->min_u.pax);
} break;
case u3_pico_last: {
case u3_pico_once: {
u3z(pic_u->las_u.des);
u3z(pic_u->las_u.pax);
} break;

View File

@ -37,7 +37,7 @@
[%meld ~]
[%pack ~]
== ==
[%peek mil=@ now=@da lyc=gang pat=path]
[%peek mil=@ sam=*] :: gang (each path $%([%once @tas @tas path] [beam @tas beam]))
[%play eve=@ lit=(list ?((pair @da ovum) *))]
[%work mil=@ job=(pair @da ovum)]
==
@ -776,43 +776,17 @@ u3_serf_play(u3_serf* sef_u, c3_d eve_d, u3_noun lit)
u3_noun
u3_serf_peek(u3_serf* sef_u, c3_w mil_w, u3_noun sam)
{
u3_noun wen, pat, pro;
// stash the previous date and set current
//
// XX incomplete interface, arvo should track the date
//
wen = u3A->now;
{
u3_noun now, lyc;
u3x_trel(sam, &now, &lyc, &pat);
u3A->now = u3k(now);
}
u3_noun gon = u3m_soft(mil_w, u3v_peek, sam);
u3_noun pro;
{
u3_noun tag, dat;
// XX incomplete interface, should pass [lyc] as well
//
u3_noun gon = u3m_soft(mil_w, u3v_peek, u3k(pat));
u3x_cell(gon, &tag, &dat);
// read succeeded, produce result
//
if ( u3_blip == tag ) {
if ( u3_nul == dat ) {
pro = u3nc(c3__done, u3_nul);
}
else {
// prepend the %noun mark
//
// XX incomplete interface, should recv mark from arvo
//
pro = u3nq(c3__done, u3_nul, c3__noun, u3k(u3t(dat)));
}
pro = u3nc(c3__done, u3k(dat));
u3z(gon);
}
// read failed, produce trace
@ -824,14 +798,6 @@ u3_serf_peek(u3_serf* sef_u, c3_w mil_w, u3_noun sam)
}
}
// restore the previous date
//
// XX incomplete interface, arvo should track the date
//
u3z(u3A->now);
u3A->now = wen;
u3z(sam);
return u3nc(c3__peek, pro);
}