captures.bend
bendvy-ecs-core@0.1.0.0 · 26 lines · 0 definitions
1import Base
2import bendvy-ecs-core@0.1.0.0/world.bend as W
3import bendvy-ecs-core@0.1.0.0/local.bend as Local
4
5# Closed runner identity with an actual affine per-instance capture owner.
6def register(~S: Data,~C: Type,~R: Type,~E: Data,~L: Type,~Args: Type,~Error: Data,~Out: Type,~runner: W.World<S,C,R,E> -> L -> Args -> Local.Outcome<W.World<S,C,R,E>,L,Error,Out>,world: W.World<S,C,R,E>,name: String,access: List<&2,String>,local: L) -> Local.Registered<S,C,R,E,L,Args,Error,Out,runner>:
7 Local.register(~S,~C,~R,~E,~L,~Args,~Error,~Out,~runner,world,name,access,local)
8
9def run(~S: Data,~C: Type,~R: Type,~E: Data,~L: Type,~Args: Type,~Error: Data,~Out: Type,~runner: W.World<S,C,R,E> -> L -> Args -> Local.Outcome<W.World<S,C,R,E>,L,Error,Out>,instance: Local.Instance<S,C,R,E,L,Args,Error,Out,runner>,world: W.World<S,C,R,E>,args: Args) -> Local.Run<S,C,R,E,L,Args,Error,Out,runner>:
10 Local.run(~S,~C,~R,~E,~L,~Args,~Error,~Out,~runner,instance,world,args)
11
12def skip(~S: Data,~C: Type,~R: Type,~E: Data,~L: Type,~Args: Type,~Error: Data,~Out: Type,~runner: W.World<S,C,R,E> -> L -> Args -> Local.Outcome<W.World<S,C,R,E>,L,Error,Out>,instance: Local.Instance<S,C,R,E,L,Args,Error,Out,runner>) -> Local.Instance<S,C,R,E,L,Args,Error,Out,runner>:
13 Local.skip(~S,~C,~R,~E,~L,~Args,~Error,~Out,~runner,instance)
14
15def observe(~S: Data,~C: Type,~R: Type,~E: Data,~L: Type,~Args: Type,~Error: Data,~Out: Type,~runner: W.World<S,C,R,E> -> L -> Args -> Local.Outcome<W.World<S,C,R,E>,L,Error,Out>,~V: Data,~project: L -> L & V,instance: Local.Instance<S,C,R,E,L,Args,Error,Out,runner>) -> Local.Instance<S,C,R,E,L,Args,Error,Out,runner> & V:
16 Local.observe(~S,~C,~R,~E,~L,~Args,~Error,~Out,~runner,~V,~project,instance)
17
18def identity(~S: Data,~C: Type,~R: Type,~E: Data,~L: Type,~Args: Type,~Error: Data,~Out: Type,~runner: W.World<S,C,R,E> -> L -> Args -> Local.Outcome<W.World<S,C,R,E>,L,Error,Out>,instance: Local.Instance<S,C,R,E,L,Args,Error,Out,runner>) -> Local.Instance<S,C,R,E,L,Args,Error,Out,runner> & U32:
19 Local.identity(~S,~C,~R,~E,~L,~Args,~Error,~Out,~runner,instance)
20
21def returned(~L: Type,owner: L) -> L:
22 owner
23
24# Unregister invalidates the registration and returns the capture unchanged.
25def unregister(~S: Data,~C: Type,~R: Type,~E: Data,~L: Type,~Args: Type,~Error: Data,~Out: Type,~runner: W.World<S,C,R,E> -> L -> Args -> Local.Outcome<W.World<S,C,R,E>,L,Error,Out>,instance: Local.Instance<S,C,R,E,L,Args,Error,Out,runner>,world: W.World<S,C,R,E>) -> Local.Disposal<S,C,R,E,L,Args,Error,Out,runner,L>:
26 Local.dispose(~S,~C,~R,~E,~L,~Args,~Error,~Out,~runner,~L,~returned(~L),instance,world)