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.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +150 -116
  3. data/VERSION +1 -1
  4. data/lib/cli/cli-customer.rb +23 -3
  5. data/lib/cli/cli-pet.rb +66 -12
  6. data/lib/cli/cli-text.rb +127 -8
  7. data/lib/cli/cli.rb +49 -6
  8. data/lib/sbuilder.rb +26 -3
  9. data/lib/sbuilder/constants.rb +165 -6
  10. data/lib/sbuilder/controller.rb +943 -169
  11. data/lib/sbuilder/controller_utils.rb +122 -0
  12. data/lib/sbuilder/default-sbuilder.yaml +38 -44
  13. data/lib/sbuilder/domain.rb +160 -36
  14. data/lib/sbuilder/domain_cardinality.rb +1 -1
  15. data/lib/sbuilder/domain_range.rb +102 -0
  16. data/lib/sbuilder/domain_type.rb +150 -0
  17. data/lib/sbuilder/domain_value.rb +21 -13
  18. data/lib/sbuilder/exception.rb +16 -0
  19. data/lib/sbuilder/extension_loader.rb +67 -686
  20. data/lib/sbuilder/extension_loader_deprecated_step_extensions.rb +711 -0
  21. data/lib/sbuilder/extension_loader_step_generator.rb +876 -0
  22. data/lib/sbuilder/facade/{api_loader.rb → api_loader_facade.rb} +176 -45
  23. data/lib/sbuilder/facade/api_loader_plugin.rb +6 -32
  24. data/lib/sbuilder/facade/api_loader_plugin_mixer.rb +35 -0
  25. data/lib/sbuilder/facade/facade_constants.rb +23 -0
  26. data/lib/sbuilder/facade/loader_plugin_root.rb +56 -0
  27. data/lib/sbuilder/facade/param_set_root.rb +55 -0
  28. data/lib/sbuilder/facade/snippet_loader_facade.rb +600 -0
  29. data/lib/sbuilder/facade/snippet_loader_plugin.rb +76 -0
  30. data/lib/sbuilder/facade/snippet_loader_plugin_mixer.rb +56 -0
  31. data/lib/sbuilder/factory.rb +224 -45
  32. data/lib/sbuilder/model.rb +125 -45
  33. data/lib/sbuilder/mustache/template.rb +107 -58
  34. data/lib/sbuilder/mustache/template_reader.rb +56 -46
  35. data/lib/sbuilder/mustache/template_reader_context.rb +64 -234
  36. data/lib/sbuilder/mustache/template_resolve.rb +103 -0
  37. data/lib/sbuilder/mustache/template_root.rb +71 -0
  38. data/lib/sbuilder/param_set.rb +30 -15
  39. data/lib/sbuilder/param_set_db.rb +1 -1
  40. data/lib/sbuilder/param_set_def.rb +6 -1
  41. data/lib/sbuilder/param_set_def_func.rb +39 -0
  42. data/lib/sbuilder/param_set_if.rb +45 -10
  43. data/lib/sbuilder/param_set_loader_swagger.rb +56 -26
  44. data/lib/sbuilder/param_set_step.rb +1 -1
  45. data/lib/sbuilder/param_sets.rb +2 -1
  46. data/lib/sbuilder/parameter.rb +9 -3
  47. data/lib/sbuilder/parameter_container.rb +1 -1
  48. data/lib/sbuilder/parameter_dom.rb +17 -5
  49. data/lib/sbuilder/parameter_ref.rb +39 -10
  50. data/lib/sbuilder/parser/parser_facade.rb +310 -0
  51. data/lib/sbuilder/resolver.rb +11 -6
  52. data/lib/sbuilder/resolver_loader.rb +1 -1
  53. data/lib/sbuilder/resolver_loader_yaml.rb +1 -1
  54. data/lib/sbuilder/resolver_rule.rb +1 -1
  55. data/lib/sbuilder/resolver_rule_match.rb +10 -4
  56. data/lib/sbuilder/resolver_rule_ref.rb +1 -1
  57. data/lib/sbuilder/setup_loader.rb +49 -0
  58. data/lib/sbuilder/setup_loader_env.rb +478 -0
  59. data/lib/sbuilder/setup_loader_pref.rb +56 -0
  60. data/lib/sbuilder/snippet_loader_simple.rb +125 -0
  61. data/lib/sbuilder/spec/api_loader.rb +34 -0
  62. data/lib/sbuilder/spec/api_loader_facade.rb +169 -32
  63. data/lib/sbuilder/spec/loader_plugin.rb +98 -0
  64. data/lib/sbuilder/spec/snippet_loader.rb +228 -0
  65. data/lib/sbuilder/symbol_table.rb +279 -0
  66. data/lib/utils/{cache_lines.rb → fileio.rb} +8 -1
  67. data/lib/utils/logger.rb +2 -1
  68. data/lib/utils/powerset.rb +13 -0
  69. data/lib/utils/validate.rb +38 -0
  70. data/mustache/cfg/const_def.mustache +2 -0
  71. data/mustache/cfg/macro_run.mustache +1 -4
  72. data/mustache/data-model-header.mustache +1 -0
  73. data/mustache/definition_types.mustache +34 -4
  74. data/mustache/domains.mustache +1 -1
  75. data/mustache/domains_assign.mustache +1 -1
  76. data/mustache/infrastructure-service-init.mustache +1 -1
  77. data/mustache/interface_processes.mustache +16 -10
  78. data/mustache/interface_types.mustache +37 -11
  79. data/mustache/operator-infrastructure-service.mustache +1 -1
  80. data/mustache/resources/schedule_operator_new_step.tla +8 -0
  81. data/mustache/resources/schedule_process_macro.tla +37 -0
  82. data/mustache/resources/schedule_process_procedure.tla +22 -0
  83. data/mustache/resources/schedule_throw.tla +16 -0
  84. data/mustache/setup/domains_run.mustache +8 -2
  85. data/mustache/setup/operator_run.mustache +0 -4
  86. data/mustache/setup/steps_run.mustache +4 -3
  87. data/mustache/setup/steps_run_parameterBind.mustache +14 -6
  88. data/mustache/setup/steps_run_parameterExact.mustache +7 -3
  89. data/mustache/state_type_invariant-infrastructure-service.mustache +9 -4
  90. data/mustache/tla/const_def.mustache +1 -1
  91. data/mustache/tla/macro_run.mustache +7 -1
  92. data/mustache/tla/module_header.mustache +1 -1
  93. data/mustache/tla/operator_run.mustache +8 -5
  94. data/mustache/tla/plc_define_run.mustache +45 -36
  95. data/mustache/tla/plc_run_state.mustache +12 -5
  96. data/src-extend/extend/extend_assumptions.mustache +3 -0
  97. data/src-extend/extend/extend_const.mustache +3 -0
  98. data/src-extend/extend/extend_implementation.mustache +3 -0
  99. data/src-extend/extend/extend_invariant.mustache +3 -0
  100. data/src-extend/extend/extend_macros.mustache +3 -0
  101. data/src-extend/extend/extend_operations.mustache +3 -0
  102. data/src-extend/extend/extend_state.mustache +3 -0
  103. data/src/pet/extend/extend_assumptions.mustache +4 -0
  104. data/src/pet/extend/extend_implementation.mustache +3 -0
  105. data/src/pet/extend/extend_invariant.mustache +3 -0
  106. data/src/pet/extend/extend_macros.mustache +3 -0
  107. data/src/pet/extend/extend_operations.mustache +4 -0
  108. data/src/pet/extend/extend_state.mustache +3 -0
  109. data/src/pet/interface +5 -5
  110. data/src/pet/interface_delete_pet.tla +1 -1
  111. data/src/pet/interface_get_pet.tla +1 -1
  112. data/src/pet/interface_post_pet.tla +4 -2
  113. data/src/pet/interface_post_tag.tla +1 -1
  114. data/src/pet/interface_put_tag.tla +1 -1
  115. data/tla-sbuilder.gemspec +3 -3
  116. metadata +44 -19
  117. data/mustache/name_definition_type.mustache +0 -5
  118. data/mustache/name_domain.mustache +0 -5
  119. data/mustache/name_domain_value.mustache +0 -5
  120. data/mustache/name_domain_value_prefix.mustache +0 -5
  121. data/mustache/name_interface_response_type.mustache +0 -6
  122. data/mustache/name_interface_type.mustache +0 -6
  123. data/mustache/name_parameter_type.mustache +0 -6
  124. data/mustache/name_process.mustache +0 -6
  125. data/mustache/state_type_invariant.mustache +0 -17
  126. data/mustache/state_variables.mustache +0 -20
  127. 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 CacheLines
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
+
@@ -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,13 @@
1
+
2
+ module Sbuilder
3
+
4
+ module Powerset
5
+
6
+ # @see http://www.entish.org/wordpress/?p=676
7
+ def self.powerset( arr )
8
+ return arr.inject([[]]){|c,y|c.inject([]){|r,i|r+=[i,i+[y]]}}
9
+ end
10
+
11
+ end
12
+
13
+ end
@@ -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
@@ -2,6 +2,8 @@
2
2
  (* Declare magic constants *)
3
3
  CONSTANT WildCard = WildCard
4
4
  CONSTANT Nil = Nil
5
+ CONSTANT Abort = Abort
6
+
5
7
 
6
8
  (* Pluscal sets 'defaultInitValue' for unitialized variables *)
7
9
  CONSTANT defaultInitValue <- Nil
@@ -1,7 +1,4 @@
1
1
  (* 'enabled' macro check is process enables *)
2
- CONSTANT ProcessEnabled <- RunProcessEnabled
3
- CONSTANT ProcessRunning <- RunProcessRunning
4
- CONSTANT ProcessParameter <- RunProcessParameter
5
- CONSTANT ProcessesToRun <- RunProcessesToRun
2
+
6
3
  CONSTANT TickNext <- RunTickNext
7
4
  CONSTANT InTransaction <- RunInTransaction
@@ -7,6 +7,7 @@
7
7
 
8
8
 
9
9
  <!-- ul>
10
+ <li><a href="#Metatypes">Metatypes</a></li>
10
11
  <li><a href="#interfaces">Model interfaces</a></li>
11
12
  <li><a href="#definitions">Model definitions</a></li>
12
13
  <li><a href="#domains">Model domains</a></li>
@@ -5,11 +5,36 @@ Defined types {{META.desc}}
5
5
  - template {{META.template}}
6
6
  *******************************************************************)
7
7
 
8
- {{#definitions}}
9
- {{>name_definition_type.mustache}} == {{!
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}}{{>name_parameter_type.mustache}}{{_comma}}
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
- }} \* definition '{{definition_name}}'
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}}
@@ -14,7 +14,7 @@
14
14
  ******************************************************************)
15
15
 
16
16
  {{#domains}}
17
- CONSTANTS {{>name_domain.mustache}}
17
+ CONSTANTS {{#SPEC_NAME}}domains.{{domain_name}}{{/SPEC_NAME}}
18
18
  {{/domains}}
19
19
 
20
20
 
@@ -16,7 +16,7 @@
16
16
  ******************************************************************)
17
17
 
18
18
  {{#domains}}
19
- CONSTANT {{>name_domain.mustache}} <- Run_{{>name_domain.mustache}}
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}} {{>name_process.mustache}} |-> InfrastructureServiceResponse( Nil, Nil ){{_comma}}{{/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 ({{>name_process.mustache}}="{{interface_operation}}") {
17
- {{>name_process.mustache}}_enter: while (TRUE) {
18
- enable( "{{>name_process.mustache}}" );
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( {{>name_interface_type.mustache}} ) : ProcessParameterBind( t ) } ) {
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 {{>name_process.mustache}} for operation '{{interface_operation}}',tick=", currentTime>>;
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 <<" - {{>name_interface_type.mustache}}=>", {{>name_interface_type.mustache}} >>; *)
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 {{>name_interface_type.mustache}} );{{/parameter_definitions.length}}{{!
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}}{{implementation}}( _input );{{/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
- {{>name_process.mustache}}_exit: process_done( "{{interface_operation}}" );
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
- } \* failr process {{>name_process.mustache}}
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
- {{>name_interface_type.mustache}} == [{{#parameter_definitions}}
18
- {{>name_parameter_definition.mustache}}: {{>name_parameter_type.mustache}}{{_comma}}{{/parameter_definitions}}{{!
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
- ] \* operation '{{interface_operation}}' --> process '{{>name_process.mustache}}'
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
- {{>name_interface_response_type.mustache}} =={{!
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
- }}{{#response_definitions.length}}[{{/response_definitions.length}}{{#response_definitions}}
43
- {{>name_parameter_definition.mustache}}: {{>name_parameter_type.mustache}}{{_comma}}{{/response_definitions}}
44
- {{#response_definitions.length}}]{{/response_definitions.length}}{{!
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 defidined i.e. 'response_definitions.length' exists
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
- }} \* interface '{{interface_name}}' response type
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}}" -> "{{>name_process.mustache}}" {{/infrastructureServices}}
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
- Run_{{>name_domain.mustache}} == { {{#domain_values}}"{{>name_domain_value.mustache}}"{{_comma}} {{/domain_values}} } {{#nil_value}} \cup {Nil} {{/nil_value}} \*
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