cauldron 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -0
- data/Rakefile +7 -0
- data/VERSION +1 -1
- data/features/cauldron_generates_runtime_method.feature +3 -2
- data/features/step_definitions/cauldron_steps.rb +0 -1
- data/features/support/method_1.example +3 -0
- data/features/support/method_2.example +6 -0
- data/lib/Chain.rb +140 -264
- data/lib/CodeHandler.rb +0 -4
- data/lib/ScopeDependencies.rb +1 -0
- data/lib/Theory.rb +12 -15
- data/lib/UnifiedChain.rb +265 -8
- data/lib/cauldron.rb +1 -1
- data/lib/cauldron/demos.rb +280 -0
- data/lib/cauldron/pot.rb +56 -30
- data/lib/cauldron/sexp2cauldron.rb +109 -126
- data/lib/cauldron/terminal.rb +5 -74
- data/lib/core/ClassMethodCallContainer.rb +14 -0
- data/lib/core/Container.rb +12 -2
- data/lib/core/InstanceCallContainer.rb +30 -4
- data/lib/core/TheoryGenerator.rb +2 -9
- data/lib/core/assignment/Equal.rb +1 -1
- data/lib/core/assignment/Equivalent.rb +1 -1
- data/lib/core/assignment/NotEqual.rb +1 -1
- data/lib/core/call_container/CallContainer.rb +7 -1
- data/lib/core/instance_call/Chop.rb +0 -9
- data/lib/core/instance_call/instance_calls.rb +8 -0
- data/lib/core/instance_call/length_equal.rb +1 -1
- data/lib/core/requirement/Requirement.rb +1 -0
- data/lib/core/runtime_class/class_names.rb +12 -12
- data/lib/core/runtime_method/ActsAsRuntimeMethod.rb +0 -7
- data/lib/core/runtime_method/RuntimeMethod.rb +59 -45
- data/lib/core/statement/ActsAsStatement.rb +1 -1
- data/lib/core/statement/ArrayAccess.rb +28 -2
- data/lib/core/statement/OpenStatement.rb +7 -0
- data/lib/core/statement/Statement.rb +22 -18
- data/lib/core/statement/TheoryStatement.rb +8 -1
- data/lib/core/syntax/Addition.rb +3 -2
- data/lib/core/syntax/If.rb +8 -0
- data/lib/core/syntax/Return.rb +1 -1
- data/lib/core/variable/BaseVariable.rb +0 -2
- data/lib/core/variable/MethodParameter.rb +4 -31
- data/lib/core/variable/Unknown.rb +1 -5
- data/lib/implemented_chain.rb +3 -2
- data/lib/required.rb +0 -1
- data/lib/ruby_code/String.rb +0 -17
- data/lib/theories.rb +25 -1
- data/lib/theory/TheoryAction.rb +35 -5
- data/lib/theory/TheoryChainValidator.rb +10 -8
- data/lib/theory/TheoryComponent.rb +17 -0
- data/lib/theory/TheoryConnector.rb +76 -9
- data/lib/theory/TheoryDependent.rb +2 -2
- data/lib/theory/TheoryImplementation.rb +7 -7
- data/lib/util/ClassEvaluation.rb +2 -7
- data/lib/util/MethodValidation.rb +10 -6
- data/lib/util/Parser.rb +26 -20
- data/lib/util/StringToTheory.rb +27 -3
- data/spec/cauldron/chain_spec.rb +24 -0
- data/spec/cauldron/demos_spec.rb +30 -0
- data/spec/cauldron/pot_spec.rb +66 -0
- data/spec/cauldron/runtime_method_spec.rb +47 -5
- data/spec/cauldron/sexp_2_cauldron_spec.rb +92 -0
- data/spec/cauldron/terminal_spec.rb +1 -1
- data/spec/cauldron/theory_action_spec.rb +20 -0
- data/spec/cauldron/theory_connector_spec.rb +52 -0
- data/spec/cauldron/theory_spec.rb +59 -0
- data/spec/cauldron/unified_chain_spec.rb +102 -0
- data/spec/spec_helper.rb +10 -1
- data/tasks/theory_tasks.rake +274 -0
- data/test/fixtures/implementation_results/0/dump +0 -0
- data/test/fixtures/theories/0/dump +0 -0
- data/test/fixtures/theories/1/dump +0 -0
- data/test/fixtures/theories/10/dump +0 -0
- data/test/fixtures/theories/11/dump +0 -0
- data/test/fixtures/theories/12/dump +0 -0
- data/test/fixtures/theories/13/declaration.txt +1 -1
- data/test/fixtures/theories/13/desc +1 -1
- data/test/fixtures/theories/13/dump +0 -0
- data/test/fixtures/theories/14/dump +0 -0
- data/test/fixtures/theories/15/dump +0 -0
- data/test/fixtures/theories/16/dump +0 -0
- data/test/fixtures/theories/17/dump +0 -0
- data/test/fixtures/theories/18/dump +0 -0
- data/test/fixtures/theories/19/dump +0 -0
- data/test/fixtures/theories/2/dump +0 -0
- data/test/fixtures/theories/20/declaration.txt +1 -1
- data/test/fixtures/theories/20/desc +1 -1
- data/test/fixtures/theories/20/dump +0 -0
- data/test/fixtures/theories/3/dump +0 -0
- data/test/fixtures/theories/4/dump +0 -0
- data/test/fixtures/theories/5/dump +0 -0
- data/test/fixtures/theories/6/dump +0 -0
- data/test/fixtures/theories/7/dump +0 -0
- data/test/fixtures/theories/8/dump +0 -0
- data/test/fixtures/theories/9/dump +0 -0
- data/test/fixtures/theory_implementations/0/declaration.txt +1 -1
- data/test/fixtures/theory_implementations/0/dump +0 -0
- data/test/fixtures/theory_implementations/1/declaration.txt +11 -0
- data/test/fixtures/theory_implementations/1/dump +0 -0
- data/test/fixtures/theory_implementations/2/declaration.txt +11 -0
- data/test/fixtures/theory_implementations/2/dump +0 -0
- data/test/output/simple_method.txt +0 -1
- data/test/tc_contextual_variables.rb +2 -41
- data/test/tc_describe.rb +1 -2
- data/test/tc_method.rb +2 -5
- data/test/unit/core/runtime_method/tc_realised_runtime_method.rb +5 -3
- data/test/unit/core/runtime_method/tc_runtime_method.rb +34 -56
- data/test/unit/core/statement/tc_block_statement.rb +2 -0
- data/test/unit/core/statement/tc_open_statement.rb +15 -6
- data/test/unit/core/statement/tc_statement.rb +4 -5
- data/test/unit/core/statement/tc_statement_dependencies.rb +1 -0
- data/test/unit/core/statement/tc_theory_statement.rb +2 -0
- data/test/unit/core/syntax/tc_if_container.rb +5 -5
- data/test/unit/core/tc_theory_generator_heavy.rb +1 -1
- data/test/unit/core/tracking/tc_history.rb +3 -1
- data/test/unit/core/variable/tc_method_parameter_variable.rb +2 -2
- data/test/unit/tc_chain_with_case_1.rb +1 -1
- data/test/unit/tc_method_usage.rb +1 -1
- data/test/unit/tc_theory.rb +8 -2
- data/test/unit/theory/tc_theory_action.rb +37 -5
- data/test/unit/theory/tc_theory_chain_validator.rb +3 -3
- data/test/unit/theory/tc_theory_connector.rb +2 -37
- data/test/unit/theory/tc_theory_dependent.rb +2 -0
- data/test/unit/theory/tc_theory_implementation.rb +5 -1
- data/test/unit/theory/tc_theory_result.rb +3 -2
- data/test/unit/util/tc_method_validation.rb +4 -1
- data/test/unit/util/tc_parser.rb +2 -0
- data/test/unit/util/tc_string_to_theory.rb +3 -2
- data/tmp/runtime_method_evaluation.rb +7 -4
- metadata +59 -13
- data/lib/core/syntax/IfContainer.rb +0 -100
|
@@ -41,5 +41,19 @@ class ClassMethodCallContainer < CallContainer
|
|
|
41
41
|
end
|
|
42
42
|
return true
|
|
43
43
|
end
|
|
44
|
+
|
|
45
|
+
def replace_variables_alt!(map)
|
|
46
|
+
@parameters.each_with_index do |x,i|
|
|
47
|
+
if x.kind_of?(TheoryVariable)
|
|
48
|
+
map.each do |key,value|
|
|
49
|
+
if x.theory_variable_id == key.theory_variable_id
|
|
50
|
+
@parameters[i] = value
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
else
|
|
54
|
+
x.replace_variables_alt!(map)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
44
58
|
|
|
45
59
|
end
|
data/lib/core/Container.rb
CHANGED
|
@@ -16,13 +16,24 @@ class Container
|
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
def subst_variable!(id,var)
|
|
20
|
+
@tokens.each_with_index do |token,i|
|
|
21
|
+
if token.kind_of?(Variable) && id == token.variable_id
|
|
22
|
+
@tokens[i] = var
|
|
23
|
+
end
|
|
24
|
+
if token.kind_of?(Statement)
|
|
25
|
+
token.subst_variable!(id,var)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
self
|
|
29
|
+
end
|
|
30
|
+
|
|
19
31
|
def write(tab=0)
|
|
20
32
|
line = '('
|
|
21
33
|
tab.times {line += "\t" }
|
|
22
34
|
@tokens.each do |code|
|
|
23
35
|
line += code.write
|
|
24
36
|
break if code.object_id == @tokens.last.object_id
|
|
25
|
-
line += ' '
|
|
26
37
|
end
|
|
27
38
|
return line+')'
|
|
28
39
|
end
|
|
@@ -33,7 +44,6 @@ class Container
|
|
|
33
44
|
@tokens.each do |code|
|
|
34
45
|
line += code.describe
|
|
35
46
|
break if code.object_id == @tokens.last.object_id
|
|
36
|
-
line += ' '
|
|
37
47
|
end
|
|
38
48
|
return line+')'
|
|
39
49
|
end
|
|
@@ -21,7 +21,7 @@ class InstanceCallContainer < CallContainer
|
|
|
21
21
|
#
|
|
22
22
|
def initialize(subject,method_call,*params)
|
|
23
23
|
raise StandardError.new('Use ClassMethodCallContainer here') if subject.kind_of?(ClassName)
|
|
24
|
-
super(subject,method_call,*params)
|
|
24
|
+
super(subject,method_call,*params)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def write_with_uniq_id
|
|
@@ -248,6 +248,32 @@ class InstanceCallContainer < CallContainer
|
|
|
248
248
|
end
|
|
249
249
|
return true
|
|
250
250
|
end
|
|
251
|
+
|
|
252
|
+
def replace_variables_alt!(map)
|
|
253
|
+
if @subject.kind_of?(TheoryVariable)
|
|
254
|
+
map.each do |key,value|
|
|
255
|
+
if @subject.theory_variable_id == key.theory_variable_id
|
|
256
|
+
@subject = value
|
|
257
|
+
break
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
elsif(@subject.kind_of?(StringLengthClass))
|
|
261
|
+
else
|
|
262
|
+
@subject.replace_variables_alt!(map)
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
@parameters.each_with_index do |x,i|
|
|
266
|
+
if x.kind_of?(TheoryVariable)
|
|
267
|
+
map.each do |key,value|
|
|
268
|
+
if x == key
|
|
269
|
+
@parameters[i] = value
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
else
|
|
273
|
+
@parameters.replace_variables_alt!(map)
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
end
|
|
251
277
|
|
|
252
278
|
protected
|
|
253
279
|
|
|
@@ -262,9 +288,9 @@ protected
|
|
|
262
288
|
copied_subject = @subject.copy
|
|
263
289
|
|
|
264
290
|
# Retrieve any requirements associated with the method call
|
|
265
|
-
@method_call.requirements do |req|
|
|
266
|
-
copied_subject.push(req)
|
|
267
|
-
end
|
|
291
|
+
# @method_call.requirements do |req|
|
|
292
|
+
# copied_subject.push(req)
|
|
293
|
+
# end
|
|
268
294
|
return copied_subject
|
|
269
295
|
|
|
270
296
|
end
|
data/lib/core/TheoryGenerator.rb
CHANGED
|
@@ -17,14 +17,7 @@ class TheoryGenerator
|
|
|
17
17
|
# * Create the values array [{:value=>x,:statement=>:step=>}]
|
|
18
18
|
master_theories = []
|
|
19
19
|
chain.each_theory_progression(initial_runtime_method,test_cases) do |implemented_theory,theory|
|
|
20
|
-
|
|
21
|
-
# TODO Include this as a test to confirm an exception is raised
|
|
22
|
-
# QUICK: Adding a new value in the test cases :after so it changes the output
|
|
23
|
-
# and the variable mapping - the error should be picked up.
|
|
24
|
-
# if implemented_theory.accessor_values[:after][1]
|
|
25
|
-
# implemented_theory.accessor_values[:after][1].push({:params=>["pip"],:output=>"pip"})
|
|
26
|
-
# end
|
|
27
|
-
|
|
20
|
+
|
|
28
21
|
dependent_accessors = retrieve_accessors(implemented_theory.accessor_values[:before],creation_history)
|
|
29
22
|
result_accessors = retrieve_accessors(implemented_theory.accessor_values[:after],creation_history)
|
|
30
23
|
|
|
@@ -279,7 +272,7 @@ class TheoryGenerator
|
|
|
279
272
|
actions << TheoryAction.new(
|
|
280
273
|
TheoryStatement.new(
|
|
281
274
|
StringToTheory.run(
|
|
282
|
-
"OpenStatement.new(
|
|
275
|
+
"OpenStatement.new(Statement.new(If.new,Container.new(#{x[:statement].write},Equivalent.new,#{y[:statement].write})))"
|
|
283
276
|
)
|
|
284
277
|
),
|
|
285
278
|
StringToTheory.run(z[:statement].write)
|
|
@@ -48,7 +48,13 @@ class CallContainer < Array
|
|
|
48
48
|
@parameters.select_all(results,&block)
|
|
49
49
|
return results
|
|
50
50
|
end
|
|
51
|
-
|
|
51
|
+
|
|
52
|
+
def map_to(mapping)
|
|
53
|
+
a = copy
|
|
54
|
+
a.replace_theory_variables!(mapping)
|
|
55
|
+
return a
|
|
56
|
+
end
|
|
57
|
+
|
|
52
58
|
def replace_theory_variables!(mapping)
|
|
53
59
|
@parameters.each_with_index do |x,i|
|
|
54
60
|
if x.kind_of?(TheoryVariable) && mapping.has_key?(x.theory_variable_id)
|
|
@@ -2,11 +2,6 @@ class Chop <InstanceCall
|
|
|
2
2
|
|
|
3
3
|
def initialize
|
|
4
4
|
super
|
|
5
|
-
|
|
6
|
-
@use_requirements = [
|
|
7
|
-
Requirement.new(InstanceCallContainer.new(This.new,ClassCall.new), Equal.new , StringClass.new)
|
|
8
|
-
]
|
|
9
|
-
|
|
10
5
|
end
|
|
11
6
|
|
|
12
7
|
def write
|
|
@@ -17,10 +12,6 @@ class Chop <InstanceCall
|
|
|
17
12
|
return Chop.new
|
|
18
13
|
end
|
|
19
14
|
|
|
20
|
-
def requirements
|
|
21
|
-
@use_requirements.each {|req| yield req}
|
|
22
|
-
end
|
|
23
|
-
|
|
24
15
|
def use(val)
|
|
25
16
|
return val.chop
|
|
26
17
|
end
|
|
@@ -22,18 +22,6 @@ class OpenStatementClass < ClassName
|
|
|
22
22
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
class IfContainerClass < ClassName
|
|
26
|
-
|
|
27
|
-
def initialize
|
|
28
|
-
super
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def write(context=nil)
|
|
32
|
-
return 'IfContainer'
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
end
|
|
36
|
-
|
|
37
25
|
class BlockStatementClass < ClassName
|
|
38
26
|
|
|
39
27
|
def initialize
|
|
@@ -92,4 +80,16 @@ class ChopClass < ClassName
|
|
|
92
80
|
return 'Chop'
|
|
93
81
|
end
|
|
94
82
|
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
class IfClass < ClassName
|
|
86
|
+
|
|
87
|
+
def initialize
|
|
88
|
+
super
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def write(tab=0)
|
|
92
|
+
return 'If'
|
|
93
|
+
end
|
|
94
|
+
|
|
95
95
|
end
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
module ActsAsRuntimeMethod
|
|
3
3
|
include WriteParameters
|
|
4
4
|
|
|
5
|
-
# TODO Write tests
|
|
6
5
|
# Returns a variable instance with the id specified. This essential just finds the varialbe
|
|
7
6
|
# at the last line of the method.
|
|
8
7
|
#
|
|
@@ -10,10 +9,6 @@ module ActsAsRuntimeMethod
|
|
|
10
9
|
# variable id.
|
|
11
10
|
#
|
|
12
11
|
def find_variable(uniq_id)
|
|
13
|
-
#return find_variable_at_line(id,self.length)
|
|
14
|
-
#statement_count
|
|
15
|
-
# TODO I don't know whether I should be using statement_count, self.length or line_count
|
|
16
|
-
#return find_variable_at_line(id,self.length)
|
|
17
12
|
|
|
18
13
|
# TODO I don't know if progressively building up the method is necessary now
|
|
19
14
|
|
|
@@ -61,7 +56,6 @@ module ActsAsRuntimeMethod
|
|
|
61
56
|
raise StandardError.new('Failed to find statement that declared variable '+variable_id.to_s)
|
|
62
57
|
end
|
|
63
58
|
|
|
64
|
-
# TODO Write tests
|
|
65
59
|
def find_statement_that_created_variable(uniq_id)
|
|
66
60
|
self.each do |x|
|
|
67
61
|
if x.kind_of?(Statement)
|
|
@@ -172,7 +166,6 @@ module ActsAsRuntimeMethod
|
|
|
172
166
|
self.each do |statement|
|
|
173
167
|
line += statement.write(tab+1)+"\n"
|
|
174
168
|
end
|
|
175
|
-
line += "\n" if self.empty?
|
|
176
169
|
|
|
177
170
|
# Close the method
|
|
178
171
|
tab.times {|x| line += "\t" }
|
|
@@ -11,6 +11,7 @@ class RuntimeMethod < StatementGroup
|
|
|
11
11
|
|
|
12
12
|
attr_reader :method_id, :method_return, :usage
|
|
13
13
|
attr_writer :method_id
|
|
14
|
+
|
|
14
15
|
|
|
15
16
|
alias :statement_group_push :array_push
|
|
16
17
|
|
|
@@ -24,13 +25,16 @@ class RuntimeMethod < StatementGroup
|
|
|
24
25
|
# parameters.length
|
|
25
26
|
# @param method_return The response variable to return or nil if nothing is returned
|
|
26
27
|
#
|
|
27
|
-
def initialize(usage,method_return=nil,*statements)
|
|
28
|
+
#def initialize(usage,method_return=nil,*statements)
|
|
29
|
+
def initialize(usage,method_id=nil,*statements)
|
|
28
30
|
super(*statements)
|
|
29
31
|
|
|
30
32
|
# Set the method id for the generated method
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
if method_id.nil?
|
|
34
|
+
@@METHOD_ID += 1
|
|
35
|
+
method_id = @@METHOD_ID
|
|
36
|
+
end
|
|
37
|
+
@method_id = method_id
|
|
34
38
|
|
|
35
39
|
# Save how the method should be used
|
|
36
40
|
@usage = usage
|
|
@@ -79,6 +83,42 @@ class RuntimeMethod < StatementGroup
|
|
|
79
83
|
)
|
|
80
84
|
end
|
|
81
85
|
|
|
86
|
+
def reset_ids!
|
|
87
|
+
copied_method = copy
|
|
88
|
+
copied_method.method_id = '0'
|
|
89
|
+
unique_variable_ids = variables.collect {|x| x.variable_id}.uniq
|
|
90
|
+
reset_variable_ids = (0...unique_variable_ids.length)
|
|
91
|
+
mapping = {}
|
|
92
|
+
unique_variable_ids.zip(reset_variable_ids.to_a) do |var_id,reset_id|
|
|
93
|
+
mapping[var_id] = reset_id
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
method_parameters = []
|
|
97
|
+
@usage.each do |x|
|
|
98
|
+
method_parameters.push(MethodParameter.new(mapping[x.variable_id]))
|
|
99
|
+
end
|
|
100
|
+
usage = MethodUsage.new(*method_parameters)
|
|
101
|
+
|
|
102
|
+
copied_method.usage = usage
|
|
103
|
+
|
|
104
|
+
replacement_mapping = {}
|
|
105
|
+
mapping.each do |var_id,reset_id|
|
|
106
|
+
replacement_mapping[var_id] = Unknown.new(reset_id)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
copied_method.each do |statement|
|
|
110
|
+
replacement_mapping.each do |var_id,value|
|
|
111
|
+
statement.subst_variable!(var_id,value)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
copied_method
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def variables
|
|
119
|
+
return @usage
|
|
120
|
+
end
|
|
121
|
+
|
|
82
122
|
# Returns an array of variables that are available at a particular line
|
|
83
123
|
# in the method.
|
|
84
124
|
#
|
|
@@ -105,7 +145,6 @@ class RuntimeMethod < StatementGroup
|
|
|
105
145
|
|
|
106
146
|
concept.each_unknown do |unknown|
|
|
107
147
|
|
|
108
|
-
#temp = gets
|
|
109
148
|
# Go through each of the varialbes and see if they could be the unknown
|
|
110
149
|
available_variables.each do |var|
|
|
111
150
|
|
|
@@ -328,9 +367,8 @@ class RuntimeMethod < StatementGroup
|
|
|
328
367
|
|
|
329
368
|
# Returns a duplicate method but without any statements in it
|
|
330
369
|
#
|
|
331
|
-
def copy_base
|
|
332
|
-
copied_method = RuntimeMethod.new(@usage.copy
|
|
333
|
-
copied_method.method_id = method_id
|
|
370
|
+
def copy_base
|
|
371
|
+
copied_method = RuntimeMethod.new(@usage.copy,method_id)
|
|
334
372
|
return copied_method
|
|
335
373
|
end
|
|
336
374
|
|
|
@@ -376,8 +414,12 @@ class RuntimeMethod < StatementGroup
|
|
|
376
414
|
# Returns a statement that declares the runtime method instance.
|
|
377
415
|
# e.g. RuntimeMethod.new(MethodUsage.new,ResponseVariable.new)
|
|
378
416
|
#
|
|
379
|
-
def declaration_statement
|
|
380
|
-
new_runtime_method = ClassMethodCallContainer.new(
|
|
417
|
+
def declaration_statement
|
|
418
|
+
new_runtime_method = ClassMethodCallContainer.new(
|
|
419
|
+
RuntimeMethodClass.new,
|
|
420
|
+
New.new,
|
|
421
|
+
@usage.declaration_statement
|
|
422
|
+
)
|
|
381
423
|
return Statement.new(new_runtime_method)
|
|
382
424
|
end
|
|
383
425
|
|
|
@@ -535,7 +577,7 @@ class RuntimeMethod < StatementGroup
|
|
|
535
577
|
copied = self.copy.trackify(params,tracking_method)
|
|
536
578
|
|
|
537
579
|
# Create a method to call the method and return the results
|
|
538
|
-
process_method = RuntimeMethod.new(MethodUsage.new
|
|
580
|
+
process_method = RuntimeMethod.new(MethodUsage.new)
|
|
539
581
|
track_statement = Statement.new( DefCall.new(NilVariable.new,copied,*params.collect {|x| x.value} ) )
|
|
540
582
|
process_method << track_statement
|
|
541
583
|
return_statement = Statement.new( Return.new,instance_tracking_variable )
|
|
@@ -545,7 +587,7 @@ class RuntimeMethod < StatementGroup
|
|
|
545
587
|
# TODO This might need to have a number pre-fixed (I'm not certain it's overwritten)
|
|
546
588
|
# runtime_class = RuntimeClass.new('Temporary'+rand(1000).to_s,tracking_method,copied,process_method,*additional_methods)
|
|
547
589
|
runtime_class = RuntimeClass.new('Temporary',tracking_method,copied,process_method,*additional_methods)
|
|
548
|
-
result = ClassEvaluation.new.evaluate_class(runtime_class,process_method.method_name
|
|
590
|
+
result = ClassEvaluation.new.evaluate_class(runtime_class,process_method.method_name)
|
|
549
591
|
return result
|
|
550
592
|
end
|
|
551
593
|
|
|
@@ -780,38 +822,10 @@ class RuntimeMethod < StatementGroup
|
|
|
780
822
|
return IntrinsicRuntimeMethod.new()
|
|
781
823
|
end
|
|
782
824
|
|
|
783
|
-
|
|
825
|
+
protected
|
|
826
|
+
|
|
827
|
+
def usage=(usage)
|
|
828
|
+
@usage = usage
|
|
829
|
+
end
|
|
784
830
|
|
|
785
|
-
# # TODO Not sure this is needed
|
|
786
|
-
# This returns an array of variables and def_calls by replacing
|
|
787
|
-
# any supplied runtime_method instances with def_calls.
|
|
788
|
-
#
|
|
789
|
-
def convert_methods_to_def_calls(available)
|
|
790
|
-
updated_available = []
|
|
791
|
-
available.each do |x|
|
|
792
|
-
if(x.kind_of?(RuntimeMethod))
|
|
793
|
-
|
|
794
|
-
# Create a copy of available values (removing the call for this method)
|
|
795
|
-
copied_available = available.collect! {|x| x.copy}
|
|
796
|
-
|
|
797
|
-
# Separate the variables from the runtime method
|
|
798
|
-
copied_avialable_vars = copied_available.find_all {|y| y.kind_of?(Variable)}
|
|
799
|
-
|
|
800
|
-
# Separate the runtime method calls from the variables excluding the current method
|
|
801
|
-
copied_avialable_methods = copied_available.find_all {|y| y.kind_of?(RuntimeMethod)}
|
|
802
|
-
copied_avialable_methods.delete_if {|y| y.method_id == x.method_id }
|
|
803
|
-
|
|
804
|
-
# Combine the two so that the method used is excluded to prevent recursive calls
|
|
805
|
-
safe_copied_available = copied_avialable_methods+copied_avialable_vars
|
|
806
|
-
|
|
807
|
-
# Convert any runtime method instances to def_call instances
|
|
808
|
-
updated_available += x.callable_combinations(safe_copied_available)
|
|
809
|
-
|
|
810
|
-
else
|
|
811
|
-
updated_available.push(x)
|
|
812
|
-
end
|
|
813
|
-
end
|
|
814
|
-
return updated_available
|
|
815
|
-
end
|
|
816
|
-
|
|
817
831
|
end
|