dependency_registry_program.bend
bendvy-ecs-core@0.1.0.3 · 39 lines · 17 definitions
1import Base
2import bendvy-ecs-core@0.1.0.3/dependency_registration.bend as Reg
3import bendvy-ecs-core@0.1.0.3/dependency_executor.bend as Exec
4
5
6def Dispatch(~World:Type,~Owners:Type,~Error:Data,~Out:Data) -> Type:
7 Owners -> World -> U32 -> Owners & (World & Exec.Invocation<Error,Out>)
8def Family(~Error:Data,~Out:Data) -> Type:
9 @-World:Type -> @-Owners:Type -> @-dispatch:Dispatch(~World,~Owners,~Error,~Out) -> Type
10def Embed(~Error:Data,~Out:Data,~F:Family(~Error,~Out)) -> Type:
11 @-World:Type -> @-Owners:Type -> @-dispatch:Dispatch(~World,~Owners,~Error,~Out) -> Reg.Registry<World,Owners,Error,Out,dispatch> -> F(World,Owners,dispatch)
12def Join(~Error:Data,~Out:Data,~F:Family(~Error,~Out)) -> Type:
13 @-World:Type -> @-L:Type -> @-R:Type -> @-left:Dispatch(~World,~L,~Error,~Out) -> @-right:Dispatch(~World,~R,~Error,~Out) -> F(World,L,left) -> F(World,R,right) -> F(World,Reg.Product<L,R>,Reg.paired_dispatch(~World,~L,~R,~Error,~Out,~left,~right))
14def Vacant(~Error:Data,~Out:Data,~F:Family(~Error,~Out)) -> Type:
15 @-World:Type -> F(World,Unit,Reg.empty_dispatch(~World,~Error,~Out))
16def Selection(~World:Type,~Owners:Type,~Error:Data,~Out:Data,~dispatch:Dispatch(~World,~Owners,~Error,~Out)) -> Type:
17 @-F:Family(~Error,~Out) -> @-embed:Embed(~Error,~Out,~F) -> @-pair:Join(~Error,~Out,~F) -> @-empty:Vacant(~Error,~Out,~F) -> Owners -> F(World,Owners,dispatch)
18def Checked(~Error:Data,~Out:Data,~World:Type,~Owners:Type,~dispatch:Dispatch(~World,~Owners,~Error,~Out)) -> Type:
19 Reg.Registry<World,Owners,Error,Out,dispatch>
20def compile_embed(~Error:Data,~Out:Data,~World:Type,~Owners:Type,~dispatch:Dispatch(~World,~Owners,~Error,~Out),registry:Reg.Registry<World,Owners,Error,Out,dispatch>) -> Reg.Registry<World,Owners,Error,Out,dispatch>:
21 registry
22def compile_join(~Error:Data,~Out:Data,~World:Type,~L:Type,~R:Type,~left:Dispatch(~World,~L,~Error,~Out),~right:Dispatch(~World,~R,~Error,~Out),l:Reg.Registry<World,L,Error,Out,left>,r:Reg.Registry<World,R,Error,Out,right>) -> Reg.Registry<World,Reg.Product<L,R>,Error,Out,Reg.paired_dispatch(~World,~L,~R,~Error,~Out,~left,~right)>:
23 Reg.paired(~World,~L,~R,~Error,~Out,~left,~right,l,r)
24def compile_empty(~Error:Data,~Out:Data,~World:Type) -> Reg.Registry<World,Unit,Error,Out,Reg.empty_dispatch(~World,~Error,~Out)>:
25 Reg.empty(~World,~Error,~Out)
26def compile(~World:Type,~Owners:Type,~Error:Data,~Out:Data,~dispatch:Dispatch(~World,~Owners,~Error,~Out),~selection:Selection(~World,~Owners,~Error,~Out,~dispatch),owners:Owners) -> Reg.Registry<World,Owners,Error,Out,dispatch>:
27 selection(Checked(~Error,~Out),compile_embed(~Error,~Out),compile_join(~Error,~Out),compile_empty(~Error,~Out),owners)
28def ConditionChecked(~Error:Data,~World:Type,~Owners:Type,~dispatch:Dispatch(~World,~Owners,~Error,~Bool)) -> Type:
29 Reg.ConditionRegistry<World,Owners,Error,dispatch>
30def condition_embed(~Error:Data,~World:Type,~Owners:Type,~dispatch:Dispatch(~World,~Owners,~Error,~Bool),registry:Reg.Registry<World,Owners,Error,Bool,dispatch>) -> Reg.ConditionRegistry<World,Owners,Error,dispatch>:
31 Reg.ConditionRegistry{registry,None{}}
32def condition_join(~Error:Data,~World:Type,~L:Type,~R:Type,~left:Dispatch(~World,~L,~Error,~Bool),~right:Dispatch(~World,~R,~Error,~Bool),l:Reg.ConditionRegistry<World,L,Error,left>,r:Reg.ConditionRegistry<World,R,Error,right>) -> Reg.ConditionRegistry<World,Reg.Product<L,R>,Error,Reg.paired_dispatch(~World,~L,~R,~Error,~Bool,~left,~right)>:
33 Reg.paired_conditions(~World,~L,~R,~Error,~left,~right,l,r)
34def condition_empty(~Error:Data,~World:Type) -> Reg.ConditionRegistry<World,Unit,Error,Reg.empty_dispatch(~World,~Error,~Bool)>:
35 Reg.empty_conditions(~World,~Error)
36def compile_conditions(~World:Type,~Owners:Type,~Error:Data,~dispatch:Dispatch(~World,~Owners,~Error,~Bool),~selection:Selection(~World,~Owners,~Error,~Bool,~dispatch),owners:Owners) -> Reg.ConditionRegistry<World,Owners,Error,dispatch>:
37 selection(ConditionChecked(~Error),condition_embed(~Error),condition_join(~Error),condition_empty(~Error),owners)
38def empty(~World:Type,~Error:Data,~Out:Data,~F:Family(~Error,~Out),~embed:Embed(~Error,~Out,~F),~pair:Join(~Error,~Out,~F),~empty:Vacant(~Error,~Out,~F),_:Unit) -> F(World,Unit,Reg.empty_dispatch(~World,~Error,~Out)):
39 empty(World)