Clean up some data structures.

This commit is contained in:
C. Guy Yarvin 2014-10-25 15:11:49 -07:00
parent 30392202a9
commit 9eb236eeda
3 changed files with 45 additions and 46 deletions

71
g/j.c
View File

@ -45,11 +45,9 @@
struct _cj_dash { struct _cj_dash {
u3_noun sys; u3_noun sys;
u3_noun haw; u3_noun haw;
u3_noun top;
}; };
struct _cj_cope { struct _cj_cope {
u3_noun soh; u3_noun soh;
u3_noun sub;
u3_noun hud; u3_noun hud;
u3_noun mop; u3_noun mop;
}; };
@ -135,12 +133,9 @@ _cj_insert(u3_cs_core* cop_u)
static void static void
_cj_x_dash(u3_noun das, struct _cj_dash* das_u) _cj_x_dash(u3_noun das, struct _cj_dash* das_u)
{ {
u3_noun saw; u3_cx_cell(das, &(das_u->sys), &(das_u->haw));
u3_cx_cell(das, &saw, &(das_u->top)); u3k(das_u->sys); u3k(das_u->haw);
u3_cx_cell(saw, &(das_u->sys), &(das_u->haw));
u3k(das_u->sys); u3k(das_u->haw); u3k(das_u->top);
} }
/* _cj_m_dash(): import dash. /* _cj_m_dash(): import dash.
@ -148,7 +143,7 @@ _cj_x_dash(u3_noun das, struct _cj_dash* das_u)
static u3_noun static u3_noun
_cj_m_dash(struct _cj_dash* das_u) _cj_m_dash(struct _cj_dash* das_u)
{ {
return u3nc(u3nc(das_u->sys, das_u->haw), das_u->top); return u3nc(das_u->sys, das_u->haw);
} }
/* _cj_f_dash(): release dash. /* _cj_f_dash(): release dash.
@ -158,7 +153,6 @@ _cj_f_dash(struct _cj_dash* das_u)
{ {
u3z(das_u->sys); u3z(das_u->sys);
u3z(das_u->haw); u3z(das_u->haw);
u3z(das_u->top);
} }
/* _cj_x_cope(): export cope. RETAIN. /* _cj_x_cope(): export cope. RETAIN.
@ -166,13 +160,11 @@ _cj_f_dash(struct _cj_dash* das_u)
static void static void
_cj_x_cope(u3_noun coe, struct _cj_cope* coe_u) _cj_x_cope(u3_noun coe, struct _cj_cope* coe_u)
{ {
u3_cx_qual(coe, &(coe_u->soh), u3_cx_trel(coe, &(coe_u->soh),
&(coe_u->sub),
&(coe_u->hud), &(coe_u->hud),
&(coe_u->mop)); &(coe_u->mop));
u3k(coe_u->soh); u3k(coe_u->soh);
u3k(coe_u->sub);
u3k(coe_u->hud); u3k(coe_u->hud);
u3k(coe_u->mop); u3k(coe_u->mop);
} }
@ -182,7 +174,7 @@ _cj_x_cope(u3_noun coe, struct _cj_cope* coe_u)
static u3_noun static u3_noun
_cj_m_cope(struct _cj_cope* coe_u) _cj_m_cope(struct _cj_cope* coe_u)
{ {
return u3nq(coe_u->soh, coe_u->sub, coe_u->hud, coe_u->mop); return u3nt(coe_u->soh, coe_u->hud, coe_u->mop);
} }
/* _cj_f_cope(): release cope. /* _cj_f_cope(): release cope.
@ -191,7 +183,6 @@ static void
_cj_f_cope(struct _cj_cope* coe_u) _cj_f_cope(struct _cj_cope* coe_u)
{ {
u3z(coe_u->soh); u3z(coe_u->soh);
u3z(coe_u->sub);
u3z(coe_u->hud); u3z(coe_u->hud);
u3z(coe_u->mop); u3z(coe_u->mop);
} }
@ -508,22 +499,20 @@ _cj_cold_mine(u3_noun cey, u3_noun cor)
_cj_x_cope(coe, &coe_u); _cj_x_cope(coe, &coe_u);
coe_u.hud = u3_ckdb_put(coe_u.hud, u3k(bat), u3k(r_cey)); coe_u.hud = u3_ckdb_put(coe_u.hud, u3k(bat), u3k(r_cey));
u3z(coe);
coe = _cj_m_cope(&coe_u); coe = _cj_m_cope(&coe_u);
} }
}
else {
// fprintf(stderr, "fund: new %s\r\n", u3_cr_string(p_cey));
coe = u3nt(u3k(soh),
u3nt(u3nc(u3k(bat), u3k(r_cey)), u3_nul, u3_nul),
u3k(mop));
}
das_u.haw = u3_ckdb_put(das_u.haw, u3k(soh), coe); das_u.haw = u3_ckdb_put(das_u.haw, u3k(soh), coe);
das_u.sys = u3_ckdb_put(das_u.sys, u3k(bat), u3k(soh)); das_u.sys = u3_ckdb_put(das_u.sys, u3k(bat), u3k(soh));
} }
else {
// fprintf(stderr, "fund: new %s\r\n", u3_cr_string(p_cey));
coe = u3nq(u3k(soh),
u3_nul,
u3nt(u3nc(u3k(bat), u3k(r_cey)), u3_nul, u3_nul),
u3k(mop));
_cj_je_fuel(&das_u, u3k(bat), coe);
}
}
u3z(mop); u3z(mop);
u3z(soh); u3z(soh);
} }
@ -711,13 +700,35 @@ _cj_boil_mine(u3_noun cor)
return jax_l; return jax_l;
} }
/* _cj_warm_boot(): with all warm state cleared, reboot it. RETAINS. /* _cj_warm_fresh_in(): refresh in `tys`; RETAINS.
*/ */
#if 0 static void
static _cj_warm_fresh_in(struct _cj_dash* das_u, u3_noun tys)
_cj_warm_boot_in(struct _cj_dash* das_u, u3_noun {
#endif if ( u3_nul == tys ) {
u3_noun n_tys, l_tys, r_tys, pn_tys, qn_tys;
u3_cx_trel(tys, &n_tys, &l_tys, &r_tys);
u3_cx_cell(n_tys, &pn_tys, &qn_tys);
_cj_warm_fresh_in(das_u, l_tys);
_cj_warm_fresh_in(das_u, r_tys);
}
}
/* _cj_warm_fresh(): refresh warm from cold state.
*/
static void
_cj_warm_fresh(void)
{
struct _cj_dash das_u;
_cj_x_dash(u3R->jed.das, &das_u);
{
_cj_warm_boot_in(&das_u, das_u.sys);
}
_cj_f_dash(&das_u);
}
/* _cj_warm_mine(): in warm mode, declare a core. /* _cj_warm_mine(): in warm mode, declare a core.
*/ */
static void static void

2
g/m.c
View File

@ -343,7 +343,7 @@ _boot_parts(void)
{ {
u3R->cax.har_u = u3_ch_new(); u3R->cax.har_u = u3_ch_new();
u3R->jed.har_u = u3_ch_new(); u3R->jed.har_u = u3_ch_new();
u3R->jed.das = u3nc(u3nc(u3_nul, u3_nul), u3_nul); u3R->jed.das = u3nc(u3_nul, u3_nul);
} }
/* u3_cm_mark(): mark all nouns in the road. /* u3_cm_mark(): mark all nouns in the road.

View File

@ -16,16 +16,13 @@
huc=(map ,@tas nock) :: name/tool huc=(map ,@tas nock) :: name/tool
== :: == ::
++ dash :: jet engine ++ dash :: jet engine
$: $: sys=(map batt bash) :: battery/identity $: sys=(map batt bash) :: battery/identity
haw=(map bash cope) :: identity/core haw=(map bash cope) :: identity/core
== :: == ::
top=(map bane bash) :: root core
== ::
++ cope :: core pattern ++ cope :: core pattern
$: soh=bash :: identity $: soh=bash :: identity
sub=(map bane bash) :: subcores hud=(map batt (map ,@tas nock)) :: instances
hud=(map batt (map ,@tas nock)) :: hooks mop=(trel bane axis (each bash ,*)) :: ancestry
mop=(trel bane axis (each bash ,*)) :: mother
== :: == ::
++ je !: :: dashboard door ++ je !: :: dashboard door
|_ dash |_ dash
@ -64,19 +61,10 @@
:: ::
++ fuel :: attach battery ++ fuel :: attach battery
|= [bat=* coe=cope] |= [bat=* coe=cope]
^+ +> %_ +>
=: sys (~(put by sys) bat soh.coe) sys (~(put by sys) bat soh.coe)
haw (~(put by haw) soh.coe coe) haw (~(put by haw) soh.coe coe)
== ==
?- -.r.mop.coe
| +>(top (~(put by top) p.mop.coe soh.coe))
&
=+ par=(~(got by haw) p.r.mop.coe)
%_ +>.$
haw %+ ~(put by haw) soh.par
par(sub (~(put by sub.par) p.mop.coe soh.coe))
==
==
:: ::
++ fund :: register battery ++ fund :: register battery
|= [clu=clue cor=*] :: |= [clu=clue cor=*] ::
@ -95,7 +83,7 @@
sys (~(put by sys) -.cor soh)) sys (~(put by sys) -.cor soh))
haw (~(put by haw) soh u.cup(hud (~(put by hud.u.cup) -.cor r.cey))) haw (~(put by haw) soh u.cup(hud (~(put by hud.u.cup) -.cor r.cey)))
== ==
(fuel -.cor `cope`[soh ~ [[-.cor r.cey] ~ ~] mop]) (fuel -.cor `cope`[soh [[-.cor r.cey] ~ ~] mop])
-- --
#endif #endif
/** Data structures. /** Data structures.