@@ -5,14 +5,14 @@ defmodule ColouredFlow.EnabledBindingElements.Computation do
55
66 alias ColouredFlow.Definition.Arc
77 alias ColouredFlow.Definition.ColourSet
8- alias ColouredFlow.Definition.ColouredPetriNet
98 alias ColouredFlow.Definition.Expression
109 alias ColouredFlow.Definition.Place
1110 alias ColouredFlow.Definition.Transition
1211 alias ColouredFlow.EnabledBindingElements.Binding
1312 alias ColouredFlow.Enactment.BindingElement
1413 alias ColouredFlow.Enactment.Marking
1514 alias ColouredFlow.MultiSet
15+ alias ColouredFlow.Runner.RuntimeCpnet
1616
1717 import ColouredFlow.EnabledBindingElements.Utils
1818
@@ -22,12 +22,12 @@ defmodule ColouredFlow.EnabledBindingElements.Computation do
2222 """
2323 @ spec list (
2424 transition :: Transition . t ( ) ,
25- cpnet :: ColouredPetriNet . t ( ) ,
25+ runtime_cpnet :: RuntimeCpnet . t ( ) ,
2626 markings :: % { Place . name ( ) => Marking . t ( ) }
2727 ) :: [ BindingElement . t ( ) ]
28- def list ( transition , cpnet , markings ) do
29- inputs = get_arcs_with_place ( transition , :p_to_t , cpnet )
30- constants = build_constants ( cpnet )
28+ def list ( transition , % RuntimeCpnet { } = runtime_cpnet , markings ) do
29+ inputs = get_arcs_with_place ( transition , :p_to_t , runtime_cpnet )
30+ constants = runtime_cpnet . constants
3131
3232 arc_bindings =
3333 inputs
@@ -46,35 +46,35 @@ defmodule ColouredFlow.EnabledBindingElements.Computation do
4646 Binding . match_bag ( marking . tokens , arc_bind_expr )
4747 end )
4848 end )
49- |> reject_invalid_bandings ( cpnet )
49+ |> reject_invalid_bandings ( runtime_cpnet )
5050
5151 binding_combinations = Binding . combine ( arc_bindings )
5252
5353 Enum . flat_map ( binding_combinations , fn binding ->
54- build_binding_element ( inputs , binding , transition , constants , markings , cpnet )
54+ build_binding_element ( inputs , binding , transition , constants , markings , runtime_cpnet )
5555 end )
5656 end
5757
58- defp build_binding_element ( inputs , binding , transition , constants , markings , cpnet ) do
59- case collect_consumption ( inputs , binding , transition , constants , markings , cpnet ) do
58+ defp build_binding_element ( inputs , binding , transition , constants , markings , runtime_cpnet ) do
59+ case collect_consumption ( inputs , binding , transition , constants , markings , runtime_cpnet ) do
6060 :error -> [ ]
6161 to_consume -> [ BindingElement . new ( transition . name , binding , to_consume ) ]
6262 end
6363 end
6464
65- defp collect_consumption ( inputs , binding , transition , constants , markings , cpnet ) do
65+ defp collect_consumption ( inputs , binding , transition , constants , markings , runtime_cpnet ) do
6666 Enum . reduce_while ( inputs , [ ] , fn { arc , place } , acc ->
67- try_consume ( arc , place , binding , transition , constants , markings , cpnet , acc )
67+ try_consume ( arc , place , binding , transition , constants , markings , runtime_cpnet , acc )
6868 end )
6969 end
7070
71- defp try_consume ( arc , place , binding , transition , constants , markings , cpnet , acc ) do
71+ defp try_consume ( arc , place , binding , transition , constants , markings , runtime_cpnet , acc ) do
7272 arc_binding = merge_constants ( binding , arc , constants )
7373
7474 with (
7575 { :ok , { coefficient , value } } <- eval_arc ( arc , arc_binding ) ,
76- colour_set = fetch_colour_set! ( place . colour_set , cpnet ) ,
77- of_type_context = build_of_type_context ( cpnet ) ,
76+ colour_set = fetch_colour_set! ( place . colour_set , runtime_cpnet ) ,
77+ of_type_context = runtime_cpnet . of_type_context ,
7878 { :ok , ^ value } <- ColourSet.Of . of_type ( value , colour_set . type , of_type_context ) ,
7979 guard_binding = merge_constants ( binding , transition , constants ) ,
8080 { :ok , true } <- eval_transition_guard ( transition , guard_binding ) ,
@@ -88,14 +88,14 @@ defmodule ColouredFlow.EnabledBindingElements.Computation do
8888 end
8989 end
9090
91- @ spec reject_invalid_bandings ( [ [ [ BindingElement . binding ( ) ] ] ] , ColouredPetriNet . t ( ) ) ::
91+ @ spec reject_invalid_bandings ( [ [ [ BindingElement . binding ( ) ] ] ] , RuntimeCpnet . t ( ) ) ::
9292 [ [ [ BindingElement . binding ( ) ] ] ]
93- defp reject_invalid_bandings ( bindings_list , cpnet ) do
94- of_type_context = build_of_type_context ( cpnet )
93+ defp reject_invalid_bandings ( bindings_list , % RuntimeCpnet { } = runtime_cpnet ) do
94+ of_type_context = runtime_cpnet . of_type_context
9595
9696 valid_binding? = fn binding ->
9797 Enum . all? ( binding , fn { name , value } ->
98- variable = fetch_variable! ( name , cpnet )
98+ variable = fetch_variable! ( name , runtime_cpnet )
9999
100100 match? (
101101 { :ok , _value } ,
0 commit comments