@@ -62,6 +62,17 @@ def parse_module(examples_root, parser, path):
62
62
tree = parser .parse (module_text )
63
63
return (tree , module_text , tree .root_node .has_error )
64
64
65
+ def all_nodes_of (query_map ):
66
+ """
67
+ Flatten a query result to get all matched nodes. Returned in order of
68
+ occurrence in file.
69
+ """
70
+ return sorted ([
71
+ node
72
+ for capture in query_map .values ()
73
+ for node in capture
74
+ ], key = lambda node : node .start_byte )
75
+
65
76
def node_to_string (module_bytes , node ):
66
77
"""
67
78
Gets the string covered by the given tree-sitter parse tree node.
@@ -93,6 +104,15 @@ def get_run_mode(mode):
93
104
else :
94
105
raise NotImplementedError (f'Undefined model-check mode { mode } ' )
95
106
107
+ def get_tlc_feature_flags (module_features , model_features ):
108
+ """
109
+ Selectively enables experimental TLC features according to needs.
110
+ """
111
+ jvm_parameters = []
112
+ if 'action composition' in module_features :
113
+ jvm_parameters .append ('-Dtlc2.tool.impl.Tool.cdot=true' )
114
+ return jvm_parameters
115
+
96
116
def check_model (
97
117
tools_jar_path ,
98
118
apalache_path ,
@@ -101,6 +121,8 @@ def check_model(
101
121
tlapm_lib_path ,
102
122
community_jar_path ,
103
123
mode ,
124
+ module_features ,
125
+ model_features ,
104
126
hard_timeout_in_seconds
105
127
):
106
128
"""
@@ -127,8 +149,7 @@ def check_model(
127
149
)
128
150
return apalache
129
151
else :
130
- tlc = subprocess .run ([
131
- 'java' ,
152
+ jvm_parameters = [
132
153
'-enableassertions' ,
133
154
'-Dtlc2.TLC.ide=Github' ,
134
155
'-Dutil.ExecutionStatisticsCollector.id=abcdef60f238424fa70d124d0c77ffff' ,
@@ -140,13 +161,16 @@ def check_model(
140
161
community_jar_path ,
141
162
tlapm_lib_path
142
163
]),
143
- 'tlc2.TLC' ,
164
+ ] + get_tlc_feature_flags (module_features , model_features )
165
+ tlc_parameters = [
144
166
module_path ,
145
167
'-config' , model_path ,
146
168
'-workers' , 'auto' ,
147
169
'-lncheck' , 'final' ,
148
170
'-cleanup'
149
- ] + get_run_mode (mode ),
171
+ ] + get_run_mode (mode )
172
+ tlc = subprocess .run (
173
+ ['java' ] + jvm_parameters + ['tlc2.TLC' ] + tlc_parameters ,
150
174
timeout = hard_timeout_in_seconds ,
151
175
stdout = subprocess .PIPE ,
152
176
stderr = subprocess .STDOUT ,
0 commit comments