ordinary_machine_operations.bend
bendvy-ecs-core@0.1.0.4 · 35 lines · 5 definitions
1import Base
2import bendvy-ecs-core@0.1.0.4/ordinary_machine_declaration.bend as OD
3import bendvy-ecs-core@0.1.0.4/machine_queue.bend as Q
4import bendvy-ecs-core@0.1.0.4/machine.bend as M
5import bendvy-ecs-core@0.1.0.4/machine_world.bend as MW
6import bendvy-ecs-core@0.1.0.4/transaction.bend as Tx
7import bendvy-ecs-core@0.1.0.4/world.bend as W
8import bendvy-ecs-core@0.1.0.4/capabilities.bend as Cap
9
10
11def current(~S:Data,~K:Data,~V:Data,~C:Type,~R:Type,~E:Data,pair:Tx.Tx<W.World<S,C,R,E>,E> & M.Slot<S,K,V>) -> Tx.Tx<W.World<S,C,R,E>,E> & M.CurrentView<S,K,V>:
12 (frame,slot)=pair
13 (frame,M.current_view(~S,~K,~V,slot))
14
15
16
17def get(~S:Data,~K:Data,~V:Data,~C:Type,~R:Type,~E:Data,~take:R -> R & M.Slot<S,K,V>,frame:Tx.Tx<W.World<S,C,R,E>,E>) -> Tx.Tx<W.World<S,C,R,E>,E> & M.CurrentView<S,K,V>:
18 current(~S,~K,~V,~C,~R,~E,M.read(~S,~K,~V,~W.World<S,C,R,E>,~E,~MW.take(~S,~K,~V,~C,~R,~E,~take),frame))
19
20
21
22
23def set(~S:Data,~K:Data,~V:Data,~C:Type,~R:Type,~E:Data,~take:R -> R & M.Slot<S,K,V>,~put:R -> M.Slot<S,K,V> -> R,~same:V -> V -> Bool,~declaration:OD.Declaration<S,K,V,R,take>,frame:Tx.Tx<W.World<S,C,R,E>,E>,input:M.QueueInput<V>) -> Tx.Tx<W.World<S,C,R,E>,E>:
24 Q.next_declared(~S,~K,~V,~W.World<S,C,R,E>,~E,~MW.take(~S,~K,~V,~C,~R,~E,~take),~MW.put(~S,~K,~V,~C,~R,~E,~put),~same,M.Family{OD.name(~S,~K,~V,~R,~take,declaration)},frame,input)
25
26
27
28def read(~S:Data,~K:Data,~V:Data,~C:Type,~R:Type,~E:Data,~take:R -> R & M.Slot<S,K,V>,~declaration:OD.Declaration<S,K,V,R,take>) -> Cap.ValueRead<Tx.Tx<W.World<S,C,R,E>,E>,M.CurrentView<S,K,V>>:
29 Cap.ValueRead{get(~S,~K,~V,~C,~R,~E,~take)}
30
31
32
33
34def write(~S:Data,~K:Data,~V:Data,~C:Type,~R:Type,~E:Data,~take:R -> R & M.Slot<S,K,V>,~put:R -> M.Slot<S,K,V> -> R,~same:V -> V -> Bool,~declaration:OD.Declaration<S,K,V,R,take>) -> Cap.ValueWrite<Tx.Tx<W.World<S,C,R,E>,E>,M.QueueInput<V>,M.CurrentView<S,K,V>>:
35 Cap.ValueWrite{get(~S,~K,~V,~C,~R,~E,~take),set(~S,~K,~V,~C,~R,~E,~take,~put,~same,~declaration)}