tla-sbuilder 0.2.2 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +150 -116
- data/VERSION +1 -1
- data/lib/cli/cli-customer.rb +23 -3
- data/lib/cli/cli-pet.rb +66 -12
- data/lib/cli/cli-text.rb +127 -8
- data/lib/cli/cli.rb +49 -6
- data/lib/sbuilder.rb +26 -3
- data/lib/sbuilder/constants.rb +165 -6
- data/lib/sbuilder/controller.rb +943 -169
- data/lib/sbuilder/controller_utils.rb +122 -0
- data/lib/sbuilder/default-sbuilder.yaml +38 -44
- data/lib/sbuilder/domain.rb +160 -36
- data/lib/sbuilder/domain_cardinality.rb +1 -1
- data/lib/sbuilder/domain_range.rb +102 -0
- data/lib/sbuilder/domain_type.rb +150 -0
- data/lib/sbuilder/domain_value.rb +21 -13
- data/lib/sbuilder/exception.rb +16 -0
- data/lib/sbuilder/extension_loader.rb +67 -686
- data/lib/sbuilder/extension_loader_deprecated_step_extensions.rb +711 -0
- data/lib/sbuilder/extension_loader_step_generator.rb +876 -0
- data/lib/sbuilder/facade/{api_loader.rb → api_loader_facade.rb} +176 -45
- data/lib/sbuilder/facade/api_loader_plugin.rb +6 -32
- data/lib/sbuilder/facade/api_loader_plugin_mixer.rb +35 -0
- data/lib/sbuilder/facade/facade_constants.rb +23 -0
- data/lib/sbuilder/facade/loader_plugin_root.rb +56 -0
- data/lib/sbuilder/facade/param_set_root.rb +55 -0
- data/lib/sbuilder/facade/snippet_loader_facade.rb +600 -0
- data/lib/sbuilder/facade/snippet_loader_plugin.rb +76 -0
- data/lib/sbuilder/facade/snippet_loader_plugin_mixer.rb +56 -0
- data/lib/sbuilder/factory.rb +224 -45
- data/lib/sbuilder/model.rb +125 -45
- data/lib/sbuilder/mustache/template.rb +107 -58
- data/lib/sbuilder/mustache/template_reader.rb +56 -46
- data/lib/sbuilder/mustache/template_reader_context.rb +64 -234
- data/lib/sbuilder/mustache/template_resolve.rb +103 -0
- data/lib/sbuilder/mustache/template_root.rb +71 -0
- data/lib/sbuilder/param_set.rb +30 -15
- data/lib/sbuilder/param_set_db.rb +1 -1
- data/lib/sbuilder/param_set_def.rb +6 -1
- data/lib/sbuilder/param_set_def_func.rb +39 -0
- data/lib/sbuilder/param_set_if.rb +45 -10
- data/lib/sbuilder/param_set_loader_swagger.rb +56 -26
- data/lib/sbuilder/param_set_step.rb +1 -1
- data/lib/sbuilder/param_sets.rb +2 -1
- data/lib/sbuilder/parameter.rb +9 -3
- data/lib/sbuilder/parameter_container.rb +1 -1
- data/lib/sbuilder/parameter_dom.rb +17 -5
- data/lib/sbuilder/parameter_ref.rb +39 -10
- data/lib/sbuilder/parser/parser_facade.rb +310 -0
- data/lib/sbuilder/resolver.rb +11 -6
- data/lib/sbuilder/resolver_loader.rb +1 -1
- data/lib/sbuilder/resolver_loader_yaml.rb +1 -1
- data/lib/sbuilder/resolver_rule.rb +1 -1
- data/lib/sbuilder/resolver_rule_match.rb +10 -4
- data/lib/sbuilder/resolver_rule_ref.rb +1 -1
- data/lib/sbuilder/setup_loader.rb +49 -0
- data/lib/sbuilder/setup_loader_env.rb +478 -0
- data/lib/sbuilder/setup_loader_pref.rb +56 -0
- data/lib/sbuilder/snippet_loader_simple.rb +125 -0
- data/lib/sbuilder/spec/api_loader.rb +34 -0
- data/lib/sbuilder/spec/api_loader_facade.rb +169 -32
- data/lib/sbuilder/spec/loader_plugin.rb +98 -0
- data/lib/sbuilder/spec/snippet_loader.rb +228 -0
- data/lib/sbuilder/symbol_table.rb +279 -0
- data/lib/utils/{cache_lines.rb → fileio.rb} +8 -1
- data/lib/utils/logger.rb +2 -1
- data/lib/utils/powerset.rb +13 -0
- data/lib/utils/validate.rb +38 -0
- data/mustache/cfg/const_def.mustache +2 -0
- data/mustache/cfg/macro_run.mustache +1 -4
- data/mustache/data-model-header.mustache +1 -0
- data/mustache/definition_types.mustache +34 -4
- data/mustache/domains.mustache +1 -1
- data/mustache/domains_assign.mustache +1 -1
- data/mustache/infrastructure-service-init.mustache +1 -1
- data/mustache/interface_processes.mustache +16 -10
- data/mustache/interface_types.mustache +37 -11
- data/mustache/operator-infrastructure-service.mustache +1 -1
- data/mustache/resources/schedule_operator_new_step.tla +8 -0
- data/mustache/resources/schedule_process_macro.tla +37 -0
- data/mustache/resources/schedule_process_procedure.tla +22 -0
- data/mustache/resources/schedule_throw.tla +16 -0
- data/mustache/setup/domains_run.mustache +8 -2
- data/mustache/setup/operator_run.mustache +0 -4
- data/mustache/setup/steps_run.mustache +4 -3
- data/mustache/setup/steps_run_parameterBind.mustache +14 -6
- data/mustache/setup/steps_run_parameterExact.mustache +7 -3
- data/mustache/state_type_invariant-infrastructure-service.mustache +9 -4
- data/mustache/tla/const_def.mustache +1 -1
- data/mustache/tla/macro_run.mustache +7 -1
- data/mustache/tla/module_header.mustache +1 -1
- data/mustache/tla/operator_run.mustache +8 -5
- data/mustache/tla/plc_define_run.mustache +45 -36
- data/mustache/tla/plc_run_state.mustache +12 -5
- data/src-extend/extend/extend_assumptions.mustache +3 -0
- data/src-extend/extend/extend_const.mustache +3 -0
- data/src-extend/extend/extend_implementation.mustache +3 -0
- data/src-extend/extend/extend_invariant.mustache +3 -0
- data/src-extend/extend/extend_macros.mustache +3 -0
- data/src-extend/extend/extend_operations.mustache +3 -0
- data/src-extend/extend/extend_state.mustache +3 -0
- data/src/pet/extend/extend_assumptions.mustache +4 -0
- data/src/pet/extend/extend_implementation.mustache +3 -0
- data/src/pet/extend/extend_invariant.mustache +3 -0
- data/src/pet/extend/extend_macros.mustache +3 -0
- data/src/pet/extend/extend_operations.mustache +4 -0
- data/src/pet/extend/extend_state.mustache +3 -0
- data/src/pet/interface +5 -5
- data/src/pet/interface_delete_pet.tla +1 -1
- data/src/pet/interface_get_pet.tla +1 -1
- data/src/pet/interface_post_pet.tla +4 -2
- data/src/pet/interface_post_tag.tla +1 -1
- data/src/pet/interface_put_tag.tla +1 -1
- data/tla-sbuilder.gemspec +3 -3
- metadata +44 -19
- data/mustache/name_definition_type.mustache +0 -5
- data/mustache/name_domain.mustache +0 -5
- data/mustache/name_domain_value.mustache +0 -5
- data/mustache/name_domain_value_prefix.mustache +0 -5
- data/mustache/name_interface_response_type.mustache +0 -6
- data/mustache/name_interface_type.mustache +0 -6
- data/mustache/name_parameter_type.mustache +0 -6
- data/mustache/name_process.mustache +0 -6
- data/mustache/state_type_invariant.mustache +0 -17
- data/mustache/state_variables.mustache +0 -20
- data/src-extend/extend/extend_invariant_cfg.mustache +0 -7
@@ -2,9 +2,15 @@ module Sbuilder
|
|
2
2
|
|
3
3
|
module Utils
|
4
4
|
|
5
|
-
module
|
5
|
+
module FileIo
|
6
|
+
|
7
|
+
def self.write( path, data )
|
8
|
+
File.open( path, "w" ) { |f| f.write( data ) }
|
9
|
+
end
|
10
|
+
|
6
11
|
|
7
12
|
# write lines in cache file
|
13
|
+
# @todo use Sbuilder::Utils::File.write
|
8
14
|
def self.cache_write( cacheFile, data )
|
9
15
|
File.open( cacheFile, "w" ) { |f| f.write( data ) }
|
10
16
|
end
|
@@ -19,3 +25,4 @@ module Sbuilder
|
|
19
25
|
end
|
20
26
|
end
|
21
27
|
end
|
28
|
+
|
data/lib/utils/logger.rb
CHANGED
@@ -30,8 +30,9 @@ module Sbuilder
|
|
30
30
|
@@logfile = options[:logfile] || File.join( Dir.getwd, LOGFILE )
|
31
31
|
end
|
32
32
|
|
33
|
-
def getLogger( progname, options={} )
|
33
|
+
def getLogger( progname=nil, options={} )
|
34
34
|
|
35
|
+
progname = self.class.name.split('::').last if progname.nil?
|
35
36
|
level = get_level( options )
|
36
37
|
|
37
38
|
if level.nil?
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Sbuilder
|
2
|
+
|
3
|
+
module Utils
|
4
|
+
|
5
|
+
module Validate
|
6
|
+
|
7
|
+
# validate 'defintionHash' all 'required'/only 'allowed' props set
|
8
|
+
#
|
9
|
+
# @param [Hash] hash to validate
|
10
|
+
#
|
11
|
+
# @param [String:Array] required array of mandatory properties
|
12
|
+
#
|
13
|
+
# @param [String:Array] allowed optional list of allowed properties
|
14
|
+
#
|
15
|
+
# @exception when validation fails
|
16
|
+
def self.validateProperties( defintionHash, required, allowed=[] )
|
17
|
+
allowed = required unless allowed
|
18
|
+
allowed = (required + allowed).uniq
|
19
|
+
|
20
|
+
|
21
|
+
missingProps = required - defintionHash.keys
|
22
|
+
raise ValidateException.new "Missing properties #{missingProps} in #{defintionHash} - required #{required}" if missingProps.any?
|
23
|
+
|
24
|
+
invalidProps = defintionHash.keys - allowed
|
25
|
+
raise ValidateException.new "Unknown properties #{invalidProps} in #{defintionHash} - allowed #{allowed}" if invalidProps.any?
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.oneOf( defintionHash, propList, min=1, max=1 )
|
30
|
+
props = propList.select {|prop| defintionHash.has_key?(prop) }.length
|
31
|
+
raise ValidateException.new "Must give min #{min} - max #{max} #{propList} in #{defintionHash}" unless props >= min && props <= max
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -1,7 +1,4 @@
|
|
1
1
|
(* 'enabled' macro check is process enables *)
|
2
|
-
|
3
|
-
CONSTANT ProcessRunning <- RunProcessRunning
|
4
|
-
CONSTANT ProcessParameter <- RunProcessParameter
|
5
|
-
CONSTANT ProcessesToRun <- RunProcessesToRun
|
2
|
+
|
6
3
|
CONSTANT TickNext <- RunTickNext
|
7
4
|
CONSTANT InTransaction <- RunInTransaction
|
@@ -5,11 +5,36 @@ Defined types {{META.desc}}
|
|
5
5
|
- template {{META.template}}
|
6
6
|
*******************************************************************)
|
7
7
|
|
8
|
-
{{#definitions}}
|
9
|
-
|
8
|
+
{{#definitions}}{{!
|
9
|
+
|
10
|
+
Add fixed string 'DEFINITION: definitions:', which can be used
|
11
|
+
to extract definition from specification code
|
12
|
+
|
13
|
+
}}
|
14
|
+
|
15
|
+
(* DEFINITION: definitions:{{definition_name}} *)
|
16
|
+
{{#SPEC_NAME}}definitions.{{definition_name}}{{/SPEC_NAME}} == {{!
|
10
17
|
|
11
18
|
Start of definition.
|
12
19
|
|
20
|
+
Function definition
|
21
|
+
|
22
|
+
}}{{#isFunction}}[ {{!
|
23
|
+
|
24
|
+
Iterate function domain
|
25
|
+
|
26
|
+
}}{{#domainParameters}}{{#SPEC_NAME}}domains.{{type}}{{/SPEC_NAME}}{{_comma}}{{/domainParameters}} -> {{!
|
27
|
+
|
28
|
+
Iterate function range
|
29
|
+
|
30
|
+
}}{{#rangeParameters}}{{#SPEC_NAME}}domains.{{type}}{{/SPEC_NAME}}{{_comma}}{{/rangeParameters}} ]{{/isFunction}}{{!
|
31
|
+
|
32
|
+
Normal definition i.e. not a function starts
|
33
|
+
|
34
|
+
|
35
|
+
}}{{^isFunction}}{{!
|
36
|
+
|
37
|
+
|
13
38
|
Add 'SUBSET ' for an array type
|
14
39
|
|
15
40
|
}}{{#isArray}}SUBSET {{/isArray}}{{!
|
@@ -21,7 +46,7 @@ Defined types {{META.desc}}
|
|
21
46
|
add fiels from #parameter_definitions
|
22
47
|
}}
|
23
48
|
{{#parameter_definitions}}
|
24
|
-
{{>name_parameter_definition.mustache}}: {{#isArray}}SUBSET {{/isArray}}{{
|
49
|
+
{{>name_parameter_definition.mustache}}: {{#isArray}}SUBSET {{/isArray}}{{#SPEC_NAME}}{{metatype}}.{{type}}{{/SPEC_NAME}}{{_comma}}
|
25
50
|
{{/parameter_definitions}}{{!
|
26
51
|
|
27
52
|
end of definition
|
@@ -35,6 +60,11 @@ Defined types {{META.desc}}
|
|
35
60
|
|
36
61
|
Comment in the end
|
37
62
|
|
38
|
-
}}
|
63
|
+
}}{{/isFunction}}{{!
|
64
|
+
|
65
|
+
Add fixed END-OF-DEFINTION to mark end of definition
|
66
|
+
|
67
|
+
}}
|
68
|
+
(* END-OF-DEFINTION {{definition_name}}{{#isFunction}} (function type!){{/isFunction}} *)
|
39
69
|
|
40
70
|
{{/definitions}}
|
data/mustache/domains.mustache
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
******************************************************************)
|
17
17
|
|
18
18
|
{{#domains}}
|
19
|
-
CONSTANT {{
|
19
|
+
CONSTANT {{#SPEC_NAME}}domains.{{domain_name}}{{/SPEC_NAME}} <- Run_{{#SPEC_NAME}}domains.{{domain_name}}{{/SPEC_NAME}}
|
20
20
|
{{/domains}}
|
21
21
|
|
22
22
|
|
@@ -26,7 +26,7 @@ InfrastructureServiceInit == {{!
|
|
26
26
|
- output: <interface_name> |-> Nil,
|
27
27
|
|
28
28
|
|
29
|
-
}}{{#infrastructureServices}} {{
|
29
|
+
}}{{#infrastructureServices}} {{#SPEC_NAME}}infra_services.{{interface_operation}}{{/SPEC_NAME}} |-> InfrastructureServiceResponse( Nil, Nil ){{_comma}}{{/infrastructureServices}}{{!
|
30
30
|
|
31
31
|
Infrastructure-services defined && end
|
32
32
|
|
@@ -13,33 +13,39 @@ Interfaces generated {{META.desc}}
|
|
13
13
|
|
14
14
|
{{#interfaces}}
|
15
15
|
(* Process {{interface_operation}} *)
|
16
|
-
fair process ({{
|
17
|
-
{{
|
18
|
-
enable( "{{
|
16
|
+
fair process ({{#SPEC_NAME}}processes.{{interface_operation}}{{/SPEC_NAME}}="{{interface_operation}}") {
|
17
|
+
{{#SPEC_NAME}}processes.{{interface_operation}}{{/SPEC_NAME}}_enter: while (TRUE) {
|
18
|
+
enable( "{{#SPEC_NAME}}processes.{{interface_operation}}{{/SPEC_NAME}}" );
|
19
19
|
(* enable next process to run parallel *)
|
20
20
|
\* process_done( "{{interface_operation}}" );
|
21
|
-
with ( _input \in { t \in ProcessParameterInput( {{
|
21
|
+
with ( _input \in { t \in ProcessParameterInput( {{#SPEC_NAME}}interface_types.{{interface_operation}}{{/SPEC_NAME}} ) : ProcessParameterBind( t ) } ) {
|
22
22
|
\* PREFERENCES.debug-output: {{PREFERENCES.debug-output}}
|
23
|
-
{{^PREFERENCES.debug-output}}\* {{/PREFERENCES.debug-output}}print <<"Default process {{
|
23
|
+
{{^PREFERENCES.debug-output}}\* {{/PREFERENCES.debug-output}}print <<"Default process {{#SPEC_NAME}}processes.{{interface_operation}}{{/SPEC_NAME}} for operation '{{interface_operation}}',tick=", currentTime>>;
|
24
24
|
{{^implementation}}
|
25
25
|
{{^PREFERENCES.debug-output}}\* {{/PREFERENCES.debug-output}}print <<" - input=>", _input >>;
|
26
|
-
(* print <<" - {{
|
26
|
+
(* print <<" - {{#SPEC_NAME}}interface_types.{{interface_operation}}{{/SPEC_NAME}} =>", {{#SPEC_NAME}}interface_types.{{interface_operation}}{{/SPEC_NAME}} >>; *)
|
27
27
|
{{/implementation}}
|
28
28
|
{{#parameter_definitions.length}}
|
29
29
|
(* Valid input type? - _input must match type of API request *)
|
30
|
-
assert( _input \in {{
|
30
|
+
assert( _input \in {{#SPEC_NAME}}interface_types.{{interface_operation}}{{/SPEC_NAME}} );{{/parameter_definitions.length}}{{!
|
31
31
|
|
32
32
|
else : no parmaeter
|
33
33
|
|
34
34
|
}}{{^parameter_definitions.length}}
|
35
35
|
(* Valid input type? - API configuration did not define any parameters - must have Nil for _input.dummy: *)
|
36
36
|
assert( _input.dummy = Nil );{{/parameter_definitions.length}}
|
37
|
-
{{#implementation}}{{
|
37
|
+
{{#implementation}}{{#SPEC_NAME}}service_implementation.{{interface_operation}}{{/SPEC_NAME}}( _input );{{/implementation}}
|
38
38
|
}; \* with _input
|
39
39
|
(* enable next process - after current process *)
|
40
|
-
{{
|
40
|
+
{{#SPEC_NAME}}processes.{{interface_operation}}{{/SPEC_NAME}}_exit:
|
41
|
+
{{#completion}}{{completion}}( "{{interface_operation}}" );
|
42
|
+
{{/completion}}{{!
|
43
|
+
|
44
|
+
above adds call to completion macro (to simulate transactions)
|
45
|
+
|
46
|
+
}}process_done( "{{interface_operation}}" );
|
41
47
|
} \* while(TRUE)
|
42
|
-
} \*
|
48
|
+
} \* fair process {{#SPEC_NAME}}processes.{{interface_operation}}{{/SPEC_NAME}}
|
43
49
|
|
44
50
|
{{/interfaces}}
|
45
51
|
|
@@ -13,17 +13,25 @@ Interface input types: {{META.desc}}
|
|
13
13
|
- template {{META.template}}
|
14
14
|
*******************************************************************)
|
15
15
|
|
16
|
-
{{#interfaces}}
|
17
|
-
|
18
|
-
|
16
|
+
{{#interfaces}}{{!
|
17
|
+
|
18
|
+
Add fixed string 'REQUEST: which can be used
|
19
|
+
to extract definition from specification code
|
20
|
+
}}
|
21
|
+
(* REQUEST: {{interface_operation}} --> TLA process: {{#SPEC_NAME}}processes.{{interface_operation}}{{/SPEC_NAME}} *)
|
22
|
+
{{#SPEC_NAME}}interface_types.{{interface_operation}}{{/SPEC_NAME}} == [{{#parameter_definitions}}
|
23
|
+
{{>name_parameter_definition.mustache}}: {{#isArray}}SUBSET {{/isArray}}{{#SPEC_NAME}}{{metatype}}.{{type}}{{/SPEC_NAME}}{{_comma}}{{/parameter_definitions}}{{!
|
19
24
|
|
20
25
|
Empty parameter definition (passes swagger schema validation).
|
21
26
|
|
22
27
|
ouput 'dummy : {Nil}'
|
23
28
|
|
24
29
|
}}{{^parameter_definitions.length}}dummy: {Nil}{{/parameter_definitions.length}}
|
25
|
-
]
|
30
|
+
]{{!
|
26
31
|
|
32
|
+
Add fixed string END-OF-REQUEST
|
33
|
+
}}
|
34
|
+
(* END-OF-REQUEST *)
|
27
35
|
{{/interfaces}}
|
28
36
|
|
29
37
|
\* end of Interface input types
|
@@ -35,18 +43,36 @@ Interface response types: {{META.desc}}
|
|
35
43
|
*******************************************************************)
|
36
44
|
|
37
45
|
{{#interfaces}}
|
38
|
-
{{
|
46
|
+
{{!
|
47
|
+
|
48
|
+
Add fixed string 'RESPONSE: which can be used
|
49
|
+
to extract definition from specification code
|
50
|
+
|
51
|
+
|
52
|
+
}}
|
53
|
+
(* RESPONSE: {{interface_operation}} --> TLA process: {{#SPEC_NAME}}processes.{{interface_operation}}{{/SPEC_NAME}} *)
|
54
|
+
{{#SPEC_NAME}}interface_response_types.{{interface_operation}}{{/SPEC_NAME}} =={{!
|
39
55
|
|
40
56
|
When something defined as a response i.e. 'response_definitions.length' exists
|
41
57
|
|
42
|
-
}}{{
|
43
|
-
|
44
|
-
|
58
|
+
}}{{!
|
59
|
+
No new line here
|
60
|
+
}}{{#response_definitions.length}} [
|
61
|
+
{{/response_definitions.length}}{{#response_definitions}} {{>name_parameter_definition.mustache}}: {{#SPEC_NAME}}{{metatype}}.{{type}}{{/SPEC_NAME}}{{_comma}}
|
62
|
+
{{/response_definitions}}{{!
|
63
|
+
NO new line here
|
64
|
+
}}{{#response_definitions.length}}]{{/response_definitions.length}}{{!
|
45
65
|
|
46
|
-
When no response
|
66
|
+
When no response defined i.e. 'response_definitions.length' return false
|
47
67
|
|
48
|
-
}}{{^response_definitions.length}}{ Nil }{{/response_definitions.length}}{{!
|
68
|
+
}}{{^response_definitions.length}} { Nil }{{/response_definitions.length}}{{!
|
49
69
|
|
50
70
|
Put a comment in the end
|
51
|
-
|
71
|
+
|
72
|
+
}}{{!
|
73
|
+
|
74
|
+
Add fixed string END-OF-RESPONSE: to mark end of response
|
75
|
+
}}
|
76
|
+
(* END-OF-RESPONSE *)
|
77
|
+
|
52
78
|
{{/interfaces}}
|
@@ -6,7 +6,7 @@
|
|
6
6
|
******************************************************************)
|
7
7
|
InterfaceOperation2ProcessName( op ) == CASE op = "xxXXxx" -> Nil {{! to ease generation
|
8
8
|
}}{{#infrastructureServices}}
|
9
|
-
[] op = "{{interface_operation}}" -> "{{
|
9
|
+
[] op = "{{interface_operation}}" -> "{{#SPEC_NAME}}infra_services.{{interface_operation}}{{/SPEC_NAME}}" {{/infrastructureServices}}
|
10
10
|
[] OTHER -> Assert( FALSE, "Unknown infrastructure service" )
|
11
11
|
|
12
12
|
|
@@ -0,0 +1,8 @@
|
|
1
|
+
(* Create a step entry to schedule in +steps+ sequence
|
2
|
+
* @param procci process identifier to schedule
|
3
|
+
* @param procInput an elment in process input set to pass to the process
|
4
|
+
* @param ctx context where to resume, Nil if no resume
|
5
|
+
*)
|
6
|
+
NewStep( procci, procInput, ctx ) == [ process |-> procci, bindRule |-> WildCard ,bindSet |-> procInput, ctx |-> ctx ]
|
7
|
+
|
8
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
(*
|
2
|
+
|
3
|
+
Schedule a call for an external process +called+ with +input+, and
|
4
|
+
+resume+ back to the calling process in context +resumeCtx+.
|
5
|
+
|
6
|
+
Implementation adds two step entries in +steps+ sequence.
|
7
|
+
Entries cannot be made to position 1 because it represents
|
8
|
+
currently running process, which get shifted away the sequnce
|
9
|
+
once the process finishes.
|
10
|
+
|
11
|
+
*)
|
12
|
+
|
13
|
+
macro schedule_process_mac( called, input, resume, resumeCtx ) {
|
14
|
+
|
15
|
+
\* NOTICE!!: call and resume steps always successive elements
|
16
|
+
\* The only option is to apped to +steps+
|
17
|
+
if ( Cardinality( { p \in 1..Len(steps) : \A s \in steps[p]: s.ctx = Nil } ) <= 1 ) {
|
18
|
+
steps := steps \o
|
19
|
+
<< { NewStep( called, input, Nil ) },
|
20
|
+
{ NewStep( resume, Nil, resumeCtx ) } >>;
|
21
|
+
} else {
|
22
|
+
\* Non-deteministic choice where to put
|
23
|
+
with ( pos \in { p \in 2..Len(steps) : \A s \in steps[p]: s.ctx = Nil } ) {
|
24
|
+
steps := IF pos = Len(steps) THEN
|
25
|
+
steps \o
|
26
|
+
<< { NewStep( called, input, Nil ) },
|
27
|
+
{ NewStep( resume, Nil, resumeCtx ) } >>
|
28
|
+
ELSE
|
29
|
+
SubSeq( steps, 1, pos-1 ) \o
|
30
|
+
<< { NewStep( called, input, Nil ) },
|
31
|
+
{ NewStep( resume, Nil, resumeCtx ) } >> \o
|
32
|
+
SubSeq( steps, pos, Len(steps))
|
33
|
+
;
|
34
|
+
}; \* with
|
35
|
+
}; \* else
|
36
|
+
skip;
|
37
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
(*
|
2
|
+
|
3
|
+
Schedule process +input.called+ with +input.input+, and resume back
|
4
|
+
to currently running process +step+ to pc of +self+ ProcDef.
|
5
|
+
|
6
|
+
Creates a record with +ret_ctx+ property, which calling process can
|
7
|
+
use to restore its context, adds call step and resume step to
|
8
|
+
+steps+ sequence.
|
9
|
+
|
10
|
+
*)
|
11
|
+
|
12
|
+
procedure schedule_process_proc( input ) {
|
13
|
+
|
14
|
+
schedule_process_start:
|
15
|
+
|
16
|
+
schedule_process_mac(
|
17
|
+
input.called, input.input, step,
|
18
|
+
[ ret_ctx |-> [ stack[self][2] EXCEPT !.pc = stack[self][1].pc ] ]
|
19
|
+
);
|
20
|
+
|
21
|
+
return;
|
22
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
(*
|
2
|
+
Throw exception and exit current process via +exitLocation+.
|
3
|
+
|
4
|
+
Modify +stack+ top to return from current procedure to
|
5
|
+
+exitLocation+, and retain stack bottom to return from current
|
6
|
+
process. *)
|
7
|
+
|
8
|
+
macro schedule_throw( exitLocation ) {
|
9
|
+
|
10
|
+
|
11
|
+
stack := <<
|
12
|
+
[ stack[self][1] EXCEPT !.pc = exitLocation ],
|
13
|
+
stack[self][ Len(stack[self]) ]
|
14
|
+
>>;
|
15
|
+
|
16
|
+
}
|
@@ -14,8 +14,14 @@ Assign values to skeleton domains: {{META.desc}}
|
|
14
14
|
*******************************************************************)
|
15
15
|
|
16
16
|
(* Domains for {{META.setup}} start *)
|
17
|
-
{{#domains}}
|
18
|
-
|
17
|
+
{{#domains}}{{!
|
18
|
+
|
19
|
+
iteratete 'domain_values' && output 'value'
|
20
|
+
'tlaBaseType': wrap domain values in set brackets
|
21
|
+
'nil_value' : union { Nil }
|
22
|
+
|
23
|
+
}}
|
24
|
+
Run_{{#SPEC_NAME}}domains.{{domain_name}}{{/SPEC_NAME}} == {{^tlaBaseType}}{ {{/tlaBaseType}}{{#domain_values}}{{{value}}}{{_comma}} {{/domain_values}} {{^tlaBaseType}} }{{/tlaBaseType}} {{#nil_value}} \cup {Nil} {{/nil_value}}
|
19
25
|
{{/domains}}
|
20
26
|
(* Domains for {{META.setup}} end *)
|
21
27
|
|