2014-11-08 01:54:59 +03:00
|
|
|
/* include/n/j.h
|
2014-09-04 07:44:53 +04:00
|
|
|
**
|
|
|
|
** This file is in the public domain.
|
|
|
|
*/
|
2014-11-05 03:29:08 +03:00
|
|
|
/** Noun semantics.
|
|
|
|
**/
|
|
|
|
#if 0
|
|
|
|
++ bane ,@tas :: battery name
|
2014-11-28 23:29:10 +03:00
|
|
|
++ bash ,@uvH :: label hash
|
|
|
|
++ bosh ,@uvH :: battery hash
|
2014-11-05 03:29:08 +03:00
|
|
|
++ batt ,* :: battery
|
2014-11-18 01:57:05 +03:00
|
|
|
++ calf ::
|
2014-11-18 13:49:03 +03:00
|
|
|
$: jax=,@ud :: hot core index
|
|
|
|
hap=(map ,@ud ,@ud) :: axis/hot arm index
|
2014-11-28 23:29:10 +03:00
|
|
|
lab=path :: label as path
|
2014-11-19 02:17:56 +03:00
|
|
|
jit=* :: arbitrary data
|
2014-11-05 03:29:08 +03:00
|
|
|
== ::
|
2014-11-18 23:59:59 +03:00
|
|
|
++ calx (trel calf (pair bash cope) club) :: cached by battery
|
2014-11-28 23:29:10 +03:00
|
|
|
++ clog (pair cope (map batt club)) :: label record
|
2014-11-18 02:24:40 +03:00
|
|
|
++ club (pair corp (map term nock)) :: battery pattern
|
2014-11-05 03:29:08 +03:00
|
|
|
++ cope (trel bane axis (each bash noun)) :: core pattern
|
2014-11-25 01:41:47 +03:00
|
|
|
++ core ,*
|
2014-11-19 02:17:56 +03:00
|
|
|
++ corp (each core batt) :: parent or static
|
2014-11-20 22:58:55 +03:00
|
|
|
++ dash (map bash clog) :: jet system
|
2014-11-05 03:29:08 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/** Data structures.
|
|
|
|
***
|
2014-11-18 01:12:11 +03:00
|
|
|
*** All of these are transient structures allocated with malloc.
|
2014-11-05 03:29:08 +03:00
|
|
|
**/
|
2014-11-08 01:54:59 +03:00
|
|
|
/* u3j_harm: jet arm.
|
2014-11-05 03:29:08 +03:00
|
|
|
*/
|
2014-11-08 01:54:59 +03:00
|
|
|
typedef struct _u3j_harm {
|
2014-11-18 13:49:03 +03:00
|
|
|
c3_c* fcs_c; // `.axe` or name
|
2014-11-18 01:12:11 +03:00
|
|
|
u3_noun (*fun_f)(u3_noun); // compute or 0 / semitransfer
|
|
|
|
// c3_o (*val_f)(u3_noun); // validate or 0 / retain
|
2014-11-18 13:49:03 +03:00
|
|
|
c3_o ice; // perfect (don't test)
|
|
|
|
c3_o tot; // total (never punts)
|
|
|
|
c3_o liv; // live (enabled)
|
|
|
|
c3_l axe_l; // computed/discovered axis
|
|
|
|
struct _u3j_core* cop_u; // containing core
|
2014-11-08 01:54:59 +03:00
|
|
|
} u3j_harm;
|
2014-11-05 03:29:08 +03:00
|
|
|
|
2014-11-08 01:54:59 +03:00
|
|
|
/* u3j_core: driver definition.
|
2014-11-05 03:29:08 +03:00
|
|
|
*/
|
2014-11-08 01:54:59 +03:00
|
|
|
typedef struct _u3j_core {
|
2014-12-04 02:21:55 +03:00
|
|
|
c3_c* cos_c; // control string
|
2014-11-18 13:49:03 +03:00
|
|
|
struct _u3j_harm* arm_u; // blank-terminated static list
|
|
|
|
struct _u3j_core* dev_u; // blank-terminated static list
|
|
|
|
struct _u3j_core* par_u; // dynamic parent pointer
|
|
|
|
c3_l axe_l; // axis to parent
|
|
|
|
c3_l jax_l; // index in global dashboard
|
2014-11-08 01:54:59 +03:00
|
|
|
} u3j_core;
|
2014-11-05 03:29:08 +03:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
/* u3e_dash, u3_Dash, u3D: jet dashboard singleton
|
2014-11-05 03:29:08 +03:00
|
|
|
*/
|
2014-11-06 03:20:01 +03:00
|
|
|
typedef struct _u3e_dash {
|
2014-11-18 01:12:11 +03:00
|
|
|
u3j_core* dev_u; // null-terminated static list
|
2014-11-18 13:49:03 +03:00
|
|
|
c3_l len_l; // dynamic array length
|
|
|
|
c3_l all_l; // allocated length
|
2014-11-18 01:12:11 +03:00
|
|
|
u3j_core* ray_u; // dynamic array by axis
|
2014-11-08 01:54:59 +03:00
|
|
|
} u3j_dash;
|
2014-11-05 03:29:08 +03:00
|
|
|
|
2018-04-30 19:57:09 +03:00
|
|
|
/* u3j_fist: a single step in a fine check */
|
2018-04-26 21:08:34 +03:00
|
|
|
typedef struct {
|
2018-04-30 19:57:09 +03:00
|
|
|
u3_noun bat; // battery
|
|
|
|
u3_noun pax; // parent axis
|
2018-04-26 21:08:34 +03:00
|
|
|
} u3j_fist;
|
|
|
|
|
2018-04-30 19:57:09 +03:00
|
|
|
/* u3j_fink: (fine check) verify a located core */
|
2018-04-26 21:08:34 +03:00
|
|
|
typedef struct {
|
2018-04-30 19:57:09 +03:00
|
|
|
c3_w len_w; // number of fists
|
|
|
|
u3_noun sat; // static noun at end of check
|
|
|
|
u3j_fist fis_u[0]; // fists
|
2018-04-26 21:08:34 +03:00
|
|
|
} u3j_fink;
|
|
|
|
|
2018-04-30 19:57:09 +03:00
|
|
|
/* u3j_rite: site of a %fast, used to skip re-mining */
|
2018-04-26 21:08:34 +03:00
|
|
|
typedef struct {
|
2018-04-30 19:57:09 +03:00
|
|
|
c3_o own_o; // rite owns fink?
|
|
|
|
u3_weak clu; // cached product of clue formula
|
|
|
|
u3p(u3j_fink) fin_p; // fine check
|
2018-04-26 21:08:34 +03:00
|
|
|
} u3j_rite;
|
|
|
|
|
2018-04-30 19:57:09 +03:00
|
|
|
/* u3j_site: site of a nock 9 */
|
2018-04-26 21:08:34 +03:00
|
|
|
struct _u3n_prog;
|
|
|
|
typedef struct {
|
|
|
|
struct _u3n_prog *pog_u;
|
|
|
|
u3_noun axe;
|
|
|
|
u3_weak bat;
|
|
|
|
u3_weak loc;
|
|
|
|
c3_o jet_o;
|
|
|
|
c3_o fon_o;
|
|
|
|
u3_weak lab;
|
|
|
|
u3j_core* cop_u;
|
|
|
|
u3j_harm* ham_u;
|
|
|
|
u3j_fink* fin_u;
|
|
|
|
} u3j_site;
|
|
|
|
|
2014-11-05 03:29:08 +03:00
|
|
|
/** Globals.
|
|
|
|
**/
|
|
|
|
/* u3_Dash: jet dashboard.
|
|
|
|
*/
|
2014-11-08 01:54:59 +03:00
|
|
|
extern u3j_dash u3j_Dash;
|
|
|
|
# define u3D u3j_Dash
|
2014-11-05 03:29:08 +03:00
|
|
|
|
|
|
|
/** Functions.
|
2014-09-04 07:44:53 +04:00
|
|
|
**/
|
2014-11-06 03:20:01 +03:00
|
|
|
/* u3j_boot(): initialize jet system.
|
2014-09-04 07:44:53 +04:00
|
|
|
*/
|
|
|
|
void
|
2014-11-06 03:20:01 +03:00
|
|
|
u3j_boot(void);
|
2014-09-04 07:44:53 +04:00
|
|
|
|
2014-11-18 01:12:11 +03:00
|
|
|
/* u3j_clear(): clear jet table to re-register.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u3j_clear(void);
|
|
|
|
|
2018-04-27 02:36:29 +03:00
|
|
|
/* u3j_cook():
|
|
|
|
**
|
|
|
|
** Execute hook from core, call site cached by arbitrary c string
|
|
|
|
*/
|
|
|
|
u3_noun
|
|
|
|
u3j_cook(const c3_c* key_c,
|
|
|
|
u3_noun cor,
|
|
|
|
const c3_c* tam_c);
|
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
/* u3j_hook():
|
2014-09-04 07:44:53 +04:00
|
|
|
**
|
|
|
|
** Execute hook from core.
|
|
|
|
*/
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun
|
2014-11-06 03:20:01 +03:00
|
|
|
u3j_hook(u3_noun cor,
|
2018-04-27 02:36:29 +03:00
|
|
|
const c3_c* tam_c);
|
2014-09-04 07:44:53 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
/* u3j_soft():
|
2014-09-17 23:56:55 +04:00
|
|
|
**
|
|
|
|
** Execute hook from core, without jet.
|
|
|
|
*/
|
|
|
|
u3_noun
|
2014-11-06 03:20:01 +03:00
|
|
|
u3j_soft(u3_noun cor,
|
2018-04-27 02:36:29 +03:00
|
|
|
const c3_c* tam_c);
|
2014-09-17 23:56:55 +04:00
|
|
|
|
2018-03-30 21:49:18 +03:00
|
|
|
/* u3j_spot():
|
|
|
|
**
|
|
|
|
** Identify `cor`s location. RETAIN.
|
2014-09-04 07:44:53 +04:00
|
|
|
*/
|
2014-11-29 05:19:11 +03:00
|
|
|
u3_weak
|
2018-03-30 21:49:18 +03:00
|
|
|
u3j_spot(u3_noun cor);
|
2014-09-04 07:44:53 +04:00
|
|
|
|
2018-04-26 21:08:34 +03:00
|
|
|
/* u3j_fine(): check core against u3j_fink.
|
|
|
|
*/
|
|
|
|
c3_o
|
|
|
|
u3j_fine(u3_noun cor, u3j_fink* fin_u);
|
|
|
|
|
2018-04-26 21:15:46 +03:00
|
|
|
/* u3j_cast(): create u3j_fink from core and location.
|
|
|
|
*/
|
|
|
|
u3j_fink*
|
|
|
|
u3j_cast(u3_noun cor, u3_noun loc);
|
|
|
|
|
2018-04-17 23:47:52 +03:00
|
|
|
/* u3j_nail(): resolve hot state for location and axis. RETAIN.
|
|
|
|
** return value indicates presence of driver.
|
|
|
|
**/
|
|
|
|
c3_o
|
|
|
|
u3j_nail(u3_noun loc, u3_noun axe,
|
|
|
|
u3_noun* lab, u3j_core** cop_u, u3j_harm** ham_u);
|
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
/* u3j_kick(): try to kick by jet. If no kick, produce u3_none.
|
2014-09-04 07:44:53 +04:00
|
|
|
**
|
|
|
|
** `axe` is RETAINED by the caller; `cor` is RETAINED iff there
|
|
|
|
** is no kick, TRANSFERRED if one.
|
|
|
|
*/
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_weak
|
2014-11-26 22:00:50 +03:00
|
|
|
u3j_kick(u3_noun cor, u3_noun axe);
|
2014-09-04 07:44:53 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
/* u3j_kink(): kick either by jet or by nock.
|
2014-09-04 07:44:53 +04:00
|
|
|
*/
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun
|
2014-11-18 01:12:11 +03:00
|
|
|
u3j_kink(u3_noun cor,
|
|
|
|
u3_noun axe);
|
2018-04-15 00:57:12 +03:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
/* u3j_mine(): register core for jets.
|
2014-09-04 07:44:53 +04:00
|
|
|
*/
|
2014-10-25 01:04:44 +04:00
|
|
|
void
|
2014-11-18 01:12:11 +03:00
|
|
|
u3j_mine(u3_noun clu,
|
|
|
|
u3_noun cor);
|
2014-10-28 20:36:22 +03:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
/* u3j_ream(): refresh after restoring from checkpoint.
|
2014-10-28 20:36:22 +03:00
|
|
|
*/
|
|
|
|
void
|
2014-11-06 03:20:01 +03:00
|
|
|
u3j_ream(void);
|
2014-10-31 00:40:05 +03:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
/* u3j_reap(): promote jet state. RETAINS.
|
2014-10-31 00:40:05 +03:00
|
|
|
*/
|
|
|
|
void
|
2018-04-27 02:36:29 +03:00
|
|
|
u3j_reap(u3p(u3h_root) cod_p, u3p(u3h_root) war_p, u3p(u3h_root) han_p);
|
2018-04-26 21:23:03 +03:00
|
|
|
|
2018-04-26 22:06:57 +03:00
|
|
|
/* u3j_rite_mine(): mine cor with clu, using u3j_rite for caching
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u3j_rite_mine(u3j_rite* rit_u, u3_noun clu, u3_noun cor);
|
|
|
|
|
|
|
|
/* u3j_rite_copy(): copy rite references from src_u to dst_u,
|
|
|
|
** losing old references if los_o is yes
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u3j_rite_copy(u3j_rite* dst_u, u3j_rite* src_u, c3_o los_o);
|
|
|
|
|
|
|
|
/* u3j_site_copy(): copy site references from src_u to dst_u,
|
|
|
|
** losing old references if los_o is yes
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u3j_site_copy(u3j_site* dst_u, u3j_site* src_u, c3_o los_o);
|
|
|
|
|
2018-04-27 02:36:29 +03:00
|
|
|
/* u3j_site_ream(): refresh u3j_site after restoring from checkpoint
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u3j_site_ream(u3j_site* sit_u);
|
|
|
|
|
2018-04-26 22:06:57 +03:00
|
|
|
/* u3j_site_kick(): kick a core with a u3j_site cache.
|
|
|
|
*/
|
|
|
|
u3_weak
|
|
|
|
u3j_site_kick(u3_noun cor, u3j_site* sit_u);
|
|
|
|
|
2018-04-27 03:42:38 +03:00
|
|
|
/* u3j_gate_prep(): prepare a locally cached gate to call repeatedly.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u3j_gate_prep(u3j_site* sit_u, u3_noun cor);
|
|
|
|
|
|
|
|
/* u3j_gate_slam(): slam a site prepared by u3j_gate_find() with sample.
|
|
|
|
*/
|
|
|
|
u3_noun
|
|
|
|
u3j_gate_slam(u3j_site* sit_u, u3_noun sam);
|
|
|
|
|
|
|
|
/* u3j_gate_lose(): clean up site prepared by u3j_gate_find().
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u3j_gate_lose(u3j_site* sit_u);
|
|
|
|
|
2018-04-26 21:23:03 +03:00
|
|
|
/* u3j_rite_mark(): mark u3j_rite for gc.
|
|
|
|
*/
|
|
|
|
c3_w
|
|
|
|
u3j_rite_mark(u3j_rite* rit_u);
|
|
|
|
|
2018-04-26 22:06:57 +03:00
|
|
|
/* u3j_rite_lose(): lose references of u3j_rite (but do not free).
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u3j_rite_lose(u3j_rite* rit_u);
|
|
|
|
|
|
|
|
/* u3j_site_lose(): lose references of u3j_site (but do not free).
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u3j_site_lose(u3j_site* sit_u);
|
|
|
|
|
2018-04-26 21:23:03 +03:00
|
|
|
/* u3j_site_mark(): mark u3j_site for gc.
|
|
|
|
*/
|
|
|
|
c3_w
|
|
|
|
u3j_site_mark(u3j_site* sit_u);
|
2018-04-27 02:36:29 +03:00
|
|
|
|
|
|
|
/* u3j_mark(): mark jet state for gc.
|
|
|
|
*/
|
|
|
|
c3_w
|
|
|
|
u3j_mark(void);
|
|
|
|
|
|
|
|
/* u3j_free(): free jet state.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u3j_free(void);
|