Merge remote-tracking branch 'origin/yu/ames-fixes' into philip/tomb

This commit is contained in:
Philip Monk 2022-05-17 14:07:05 -07:00
commit 7e4ad62a51

View File

@ -788,6 +788,13 @@
|= [now=@da eny=@ rof=roof]
=* larval-gate .
=* adult-core (adult-gate +<)
=< |%
++ call ^call
++ load ^load
++ scry ^scry
++ stay ^stay
++ take ^take
--
|%
:: +call: handle request $task
::
@ -800,17 +807,8 @@
?^ dud
~|(%ames-larval-call-dud (mean tang.u.dud))
::
=/ update-ready=?
?& ?=(^ cached-state)
?=(~ queued-events)
==
?: update-ready
=. ames-state.adult-gate
?> ?=(^ cached-state)
(state-5-to-6:load:adult-core +.u.cached-state)
=. cached-state ~
~> %slog.0^leaf/"ames: metamorphosis reload"
[~ adult-gate]
?: &(?=(^ cached-state) ?=(~ queued-events))
(molt ~)
:: %born: set .unix-duct and start draining .queued-events
::
?: ?=(%born -.task)
@ -840,11 +838,17 @@
~|(%ames-larval-take-dud (mean tang.u.dud))
:: enqueue event if not a larval drainage timer
::
=? queued-events !=(/larva wire)
(~(put to queued-events) %take wire duct sign)
:: start drainage timer if have regressed from adult ames
::
?: ?& !=(/larva wire)
?=(^ cached-state)
==
[[duct %pass /larva %b %wait now]~ larval-gate]
:: XX what to do with errors?
::
?. =(/larva wire)
=. queued-events (~(put to queued-events) %take wire duct sign)
[~ larval-gate]
?. =(/larva wire) [~ larval-gate]
:: larval event drainage timer; pop and process a queued event
::
?. ?=([%behn %wake *] sign)
@ -883,20 +887,10 @@
%call (call:adult-core [duct ~ wrapped-task]:+.first-event)
%take (take:adult-core [wire duct ~ sign]:+.first-event)
==
=/ update-ready=?
?& ?=(^ cached-state)
?=(~ queued-events)
==
?: update-ready
=. ames-state.adult-gate
?> ?=(^ cached-state)
(state-5-to-6:load:adult-core +.u.cached-state)
=. cached-state ~
~> %slog.0^leaf/"ames: metamorphosis reload"
[moves adult-gate]
:: .queued-events has been cleared; metamorphose
::
?~ queued-events
?: ?=(^ cached-state) (molt moves)
~> %slog.0^leaf/"ames: metamorphosis"
[moves adult-gate]
:: set timer to drain next event
@ -956,6 +950,17 @@
=. adult-gate (load:adult-core %6 state.old)
larval-gate
==
:: +molt: re-evolve to adult-ames
::
++ molt
|= moves=(list move)
^- (quip move _adult-gate)
=. ames-state.adult-gate
?> ?=(^ cached-state)
(state-5-to-6:load:adult-core +.u.cached-state)
=. cached-state ~
~> %slog.0^leaf/"ames: metamorphosis reload"
[~ adult-gate]
--
:: adult ames, after metamorphosis from larva
::