-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f0905d
commit f474ac1
Showing
4 changed files
with
159 additions
and
105 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,126 +1,80 @@ | ||
::/+ *wrapper | ||
:: | ||
:: arvo-shaped outer core | ||
:: | ||
!: | ||
=< | ||
~& "choo choo" | ||
|_ k=kernel-state | ||
+* this . | ||
=> | ||
|% | ||
+$ choo-state %stateless | ||
++ moat (keep choo-state) | ||
:: | ||
:: nock compiled from hoon, along with type. form is independent of | ||
:: subject, usually expected to be 0 | ||
+$ knob [t=type f=nock] | ||
+$ cause [%compile sub=knob pax=path fil=cord nob=?] | ||
+$ effect [%jam p=*] | ||
-- | ||
:: | ||
~& %choo-choo | ||
%- moat | ||
^- fort:moat | ||
|_ k=choo-state | ||
:: | ||
:: +load: upgrade from previous state | ||
:: | ||
++ load | ||
^- ^ | ||
|= arg=* | ||
^- [(list *) *] | ||
!! | ||
:: TODO work in ares | ||
:: ++ load :: 4 | ||
:: |= hir=kernel-state | ||
:: ^- _this | ||
:: ~& >>> hir+hir | ||
:: =; t ~& >> k.t t | ||
:: =. epoch.hir +(epoch.k) | ||
:: =. chain.k chain.hir | ||
:: this(k hir) | ||
:: | ||
:: +peek: external inspect | ||
:: | ||
++ peek :: 22 | ||
|= arg=* | ||
|= path=* | ||
^- (unit (unit *)) | ||
(do-peek k arg) | ||
!! | ||
:: | ||
:: +poke: external apply | ||
:: | ||
++ poke :: 23 | ||
|= arg=* | ||
^- ^ | ||
:: ~& "poked with arg {<arg>}" | ||
=^ effects k (do-poke k arg) | ||
[effects this(k k)] | ||
|= [event-num=@ud eny=@ our=@ux now=@da dat=*] | ||
^- [(list *) choo-state] | ||
=/ sof-cau=(unit cause) ((soft cause) dat) | ||
?~ sof-cau | ||
~& "cause incorrectly formatted!" | ||
!! | ||
=/ =cause u.sof-cau | ||
|^ | ||
=; p=* | ||
~& nob+nob.cause | ||
[[%jam p]~ k] | ||
?: nob.cause | ||
(compile-knob [sub pax fil]:cause) | ||
(compile-nock [sub pax fil]:cause) | ||
:: | ||
++ compile-knob | ||
|= [sub=knob pax=path fil=cord] | ||
~& %compile-knob | ||
^- knob | ||
=/ ast | ||
~& %parsing (rain pax fil) | ||
=/ [t=type form=nock] | ||
~& %compiling (~(mint ut t.sub) %noun ast) | ||
[t %7 f.sub form] | ||
:: | ||
++ compile-nock | ||
|= [sub=knob pax=path fil=cord] | ||
~& %compile-knob | ||
^- nock | ||
=/ ast | ||
~& %parsing (rain pax fil) | ||
=/ [t=type form=nock] | ||
~& %compiling (~(mint ut t.sub) %noun ast) | ||
[%7 f.sub form] | ||
-- | ||
:: | ||
:: +wish: external compute | ||
:: | ||
++ wish :: 10 | ||
|= txt=@ | ||
!! | ||
-- | ||
:: | ||
:: inner core that does the actual work | ||
|% | ||
+$ kernel-state %stateless | ||
:: | ||
:: nock compiled from hoon, along with type. form is independent of | ||
:: subject, usually expected to be 0 | ||
+$ knob [t=type f=nock] | ||
+$ cause [%compile sub=knob pax=path fil=cord nob=?] | ||
+$ effect [%jam p=*] | ||
+$ goof [mote=term =tang] | ||
+$ ovum $%([[%poke ~] =pok] [%crud =goof %poke =pok]) | ||
+$ pok [eny=@ our=@ux now=@da =cause] | ||
+$ crud [=goof =pok] | ||
++ do-poke | ||
|= [k=kernel-state arg=*] | ||
^- [(list effect) kernel-state] | ||
|^ | ||
?@ arg ~&("bad poke type: {<arg>}" !!) | ||
?+ +.arg ~&("invalid arg: {<arg>}" !!) | ||
[[%$ %arvo ~] %crud gof=* cru=*] | ||
=/ g ((soft goof) gof.arg) | ||
?~ g ~&(%invalid-goof !!) | ||
(handle-crud u.g cru.arg) | ||
:: | ||
[[%poke ~] pok=*] | ||
=/ o ((soft ovum) +.arg) | ||
?~ o | ||
~& "could not mold poke type: {<+.arg>}" | ||
=+ (road |.(;;(ovum +.arg))) | ||
~^k | ||
?. ?=([%poke ~] -.u.o) | ||
~& %bad-poke-header !! | ||
(handle-poke *@da pok.u.o) | ||
== | ||
:: | ||
++ handle-crud | ||
|= [=goof cru=*] | ||
^- [(list effect) kernel-state] | ||
~& "%crud: event failed" | ||
=- [~ k] | ||
%+ turn tang.goof | ||
|=(g=tank ~>(%slog.[3 g] 0)) | ||
:: | ||
++ handle-poke | ||
|= [event-num=@da eny=@ our=@ux now=@da =cause] | ||
^- [(list effect) kernel-state] | ||
:: ~& "poked at {<now>}" | ||
=; p=* | ||
~& nob+nob.cause | ||
[[%jam p]~ k] | ||
?: nob.cause | ||
(compile-knob [sub pax fil]:cause) | ||
(compile-nock [sub pax fil]:cause) | ||
-- | ||
++ compile-knob | ||
|= [sub=knob pax=path fil=cord] | ||
~& %compile-knob | ||
^- knob | ||
=/ ast | ||
~& %parsing (rain pax fil) | ||
=/ [t=type form=nock] | ||
~& %compiling (~(mint ut t.sub) %noun ast) | ||
[t %7 f.sub form] | ||
++ compile-nock | ||
|= [sub=knob pax=path fil=cord] | ||
~& %compile-knob | ||
^- nock | ||
=/ ast | ||
~& %parsing (rain pax fil) | ||
=/ [t=type form=nock] | ||
~& %compiling (~(mint ut t.sub) %noun ast) | ||
[%7 f.sub form] | ||
:: | ||
++ do-peek | ||
|= [k=kernel-state arg=*] | ||
^- (unit (unit *)) | ||
=/ path ((soft path) arg) | ||
~&(invalid-peek+path !!) | ||
-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
|% | ||
+$ goof [mote=term =tang] | ||
+$ ovum | ||
$% [[%poke ~] =input] | ||
[%crud =goof %poke =input] | ||
== | ||
+$ crud [=goof =input] | ||
+$ input [event-num=@ud eny=@ our=@ux now=@da cause=*] | ||
:: | ||
++ keep | ||
|* inner=mold | ||
=> | ||
|% | ||
+$ inner-state inner | ||
+$ outer-state [desk-hash=(unit @uvI) internal=inner] | ||
+$ outer-fort | ||
$_ ^| | ||
|_ outer-state | ||
++ load | ||
|~ arg=* | ||
*[(list *) *] | ||
++ peek | ||
|~ arg=path | ||
*(unit (unit *)) | ||
++ poke | ||
|~ arg=input | ||
*[(list *) outer-state] | ||
++ wish | ||
|~ txt=@ | ||
** | ||
-- | ||
:: | ||
+$ fort | ||
$_ ^| | ||
|_ inner-state | ||
++ load | ||
|~ arg=* | ||
*[(list *) *] | ||
++ peek | ||
|~ arg=path | ||
*(unit (unit *)) | ||
++ poke | ||
|~ arg=input | ||
*[(list *) inner-state] | ||
++ wish | ||
|~ txt=@ | ||
** | ||
-- | ||
-- | ||
:: | ||
|= inner=fort | ||
|= hash=@uvI | ||
=< .(desk-hash.outer `hash) | ||
|_ outer=outer-state | ||
++ load | ||
|= arg=* | ||
^- [(list *) *] | ||
(load:inner arg) | ||
:: | ||
++ peek | ||
|= arg=path | ||
^- (unit (unit *)) | ||
(peek:inner arg) | ||
:: | ||
++ wish | ||
|= arg=@ | ||
^- * | ||
(wish:inner arg) | ||
:: | ||
++ poke | ||
|= =input | ||
^- [(list *) outer-state] | ||
?@ input ~&("bad poke type: {<input>}" !!) | ||
?+ +.input ~&("invalid arg: {<input>}" !!) | ||
[[%$ %arvo ~] %crud gof=* cru=*] | ||
=/ g ((soft goof) gof.arg) | ||
?~ g ~&(%invalid-goof !!) | ||
=- [~ outer] | ||
%+ turn tang.u.g | ||
|=(=tank ~>(%slog.[3 tank] 0)) | ||
:: | ||
[[%poke ~] pok=*] | ||
=/ o ((soft ovum) +.input) | ||
?~ o | ||
~& "could not mold poke type: {<+.input>}" | ||
=+ (road |.(;;(ovum +.input))) | ||
~^outer | ||
~& "going to poke inner" | ||
?> ?=([%poke ~] -.u.o) | ||
=^ effects internal.outer | ||
(poke:inner input) | ||
[effects outer] | ||
== | ||
-- | ||
-- |