execution_query_recipe.bend
bendvy-ecs-core@0.1.0.3 · 35 lines · 6 definitions
1import Base
2import bendvy-ecs-core@0.1.0.3/execution_composer_layout.bend as L
3import bendvy-ecs-core@0.1.0.3/execution_query_matches.bend as Match
4
5type QueryKind is Data:
6 ReadRows{}
7 WriteRows{}
8type Bound is Data:
9 AllLive{}
10 With{route:L.Route}
11 Without{route:L.Route}
12
13
14
15 Changed{route:L.Route}
16 And{left:Bound,right:Bound}
17 Or{left:Bound,right:Bound}
18
19
20type Entry is Data:
21 Entry{route:L.Route,kind:QueryKind,bound:Bound,presence:Match.Presence}
22type Recipe<-S:Data,-WC:Type> is Data:
23 Recipe{entry:Entry}
24def brand(-S:Data,-WC:Type,entries:List<&2,Entry>) -> List<&2,Recipe<S,WC>>:
25 match entries:
26 case []:[]
27 case entry <> rest:Recipe{entry} <> brand(S,WC,rest)
28def bound_valid(~full:L.Layout,bound:Bound) -> Bool:
29 match bound:
30 case AllLive{}:True{}
31 case With{route}:L.valid(full,route)
32 case Without{route}:L.valid(full,route)
33 case Changed{route}:L.valid(full,route)
34 case And{left,right}:Bool.and(bound_valid(~full,left),bound_valid(~full,right))
35 case Or{left,right}:Bool.and(bound_valid(~full,left),bound_valid(~full,right))