1 import Base 2 import ./world.bend as W 3 import ./execution_composer_layout.bend as Layout 4 import ./execution_command_permission.bend as Permission 5 import ./execution_relation_context.bend as Context 6 import ./execution_lifetime_scope_resource_dispatch.bend as Dispatch 7 import ./execution_lifetime_scope_store.bend as Store 8 import ./execution_relation_resource_snapshot.bend as Snapshot 9 import ./execution_relation_world_publication.bend as Publication 10 import ./entity_allocator.bend as Allocator 11 import ./change_tick.bend as Tick 12 13 def restored(-S:Data,-C:Type,-R:Type,-E:Data,-Physical:Type,same:{R == Physical : Type},frame:Publication.Frame,result:Allocator.Allocator & (Physical & Dispatch.Outcome)) -> W.World & Dispatch.Outcome: 14 match frame result: 15 case Publication.Frame{namespace,columns,events,pending,registrations,nextSystem,clock,lifecycle}, (allocator,(owners,outcome)):(W.World{namespace,allocator,columns,Layout.checked_owner(Physical,R,Equal.sym(Type,R,Physical,same),owners),events,pending,registrations,nextSystem,clock,lifecycle},outcome) 16 def run(~S:Data,~C:Type,~R:Type,~E:Data,~resources:Layout.Layout,~same:{R == Layout.resources(~S,resources) : Type},~program:Dispatch.Program(~S,~resources),context:Context.Context,route:Layout.Route,request:Store.Request,world:W.World,tick:Tick.Tick) -> W.World & Dispatch.Outcome: 17 match context world: 18 case Context.Context{expected} W.World{+namespace,allocator,columns,owners,events,pending,registrations,nextSystem,clock,lifecycle}:restored(S,C,R,E,Layout.resources(~S,resources),same,Publication.Frame{namespace,columns,events,pending,registrations,nextSystem,clock,lifecycle},program(expected,namespace,allocator,Layout.checked_owner(R,Layout.resources(~S,resources),same,owners),route,request,tick)) 19 def apply(~S:Data,~C:Type,~R:Type,~E:Data,~resources:Layout.Layout,~same:{R == Layout.resources(~S,resources) : Type},~selection:Permission.Selection,context:Context.Context,route:Layout.Route,request:Store.Request,world:W.World,tick:Tick.Tick) -> W.World & Dispatch.Outcome: 20 run(~S,~C,~R,~E,~resources,~same,~Permission.scopes_field(S,resources,selection),context,route,request,world,tick) 21 def observed(-S:Data,-C:Type,-R:Type,-E:Data,-Physical:Type,same:{R == Physical : Type},allocator:Allocator.Allocator,frame:Publication.Frame,result:Physical & List<&2,Snapshot.GraphView>) -> W.World & List<&2,Snapshot.GraphView>: 22 match frame result: 23 case Publication.Frame{namespace,columns,events,pending,registrations,nextSystem,clock,lifecycle}, (owners,views):(W.World{namespace,allocator,columns,Layout.checked_owner(Physical,R,Equal.sym(Type,R,Physical,same),owners),events,pending,registrations,nextSystem,clock,lifecycle},views) 24 def gather(~S:Data,~C:Type,~R:Type,~E:Data,~resources:Layout.Layout,~same:{R == Layout.resources(~S,resources) : Type},~program:Snapshot.Program(~S,~resources),world:W.World) -> W.World & List<&2,Snapshot.GraphView>: 25 match world: 26 case W.World{namespace,allocator,columns,owners,events,pending,registrations,nextSystem,clock,lifecycle}:observed(S,C,R,E,Layout.resources(~S,resources),same,allocator,Publication.Frame{namespace,columns,events,pending,registrations,nextSystem,clock,lifecycle},program(Layout.checked_owner(R,Layout.resources(~S,resources),same,owners))) 27 def graphs(~S:Data,~C:Type,~R:Type,~E:Data,~resources:Layout.Layout,~same:{R == Layout.resources(~S,resources) : Type},~selection:Permission.Selection,world:W.World) -> W.World & List<&2,Snapshot.GraphView>: 28 gather(~S,~C,~R,~E,~resources,~same,~Permission.snapshot_field(S,resources,selection),world)