import Base import ./execution_lifecycle_notices.bend as Notice import ./execution_composer_layout.bend as Layout import ./execution_state.bend as State import ./execution_declaration.bend as D type Next<-S:Data,-H:Type,-origin:Layout.Layout,-selector:Notice.Selector> is Type: Next{next:H -> Notice.Reader -> H & Notice.Reading} def Ops(~S:Data,~origin:Layout.Layout,~selector:Notice.Selector,H:Type) -> Type: Next def next(~S:Data,~H:Type,~origin:Layout.Layout,~selector:Notice.Selector,cap:Next,owner:H,reader:Notice.Reader) -> H & Notice.Reading: match cap: case Next{invoke}:invoke(owner,reader) def read(~S:Data,~C:Type,~R:Type,~origin:Layout.Layout,~selector:Notice.Selector,scope:State.Scope,reader:Notice.Reader) -> State.Scope & Notice.Reading: match scope: case State.Scope{store,resource,handles,tick,prior,+view}:(State.Scope{store,resource,handles,tick,prior,view},Notice.read(~S,~origin,~selector,view,reader)) def removed(~S:Data,~WC:Type,~C:Type,~R:Type,~layout:Layout.Layout,~route:Layout.Route,~same:{WC == Layout.columns(~S,layout) : Type},~valid:{Layout.grant_valid(~layout,~route) == True{} : Bool}) -> D.Declaration: D.Declaration{Next{read(~S,~C,~R,~(Layout.origin(layout,route)),~(Notice.Removed{Layout.key(layout,route)}))},[D.Access{"removed/" ++ Layout.key(layout,route),D.LifecycleAccess{},D.SharedView{},D.ReadOnly{}}]} def despawned(~S:Data,~C:Type,~R:Type) -> D.Declaration: D.Declaration{Next{read(~S,~C,~R,~(Layout.EmptyLayout{}),~(Notice.Despawned{}))},[D.Access{"despawn",D.LifecycleAccess{},D.SharedView{},D.ReadOnly{}}]}