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
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
# TODO I'm not sure whether to keep the IfContainer class or just drop it
|
|
2
|
-
# and use Statement.new(If.new,Liter.new(9) etc..)
|
|
3
|
-
# if I don't change it IfContainer should probably become a type of Statement
|
|
4
|
-
|
|
5
|
-
class IfContainer < Statement
|
|
6
|
-
|
|
7
|
-
def initialize(*parameters)
|
|
8
|
-
# TODO It would be better to use super here
|
|
9
|
-
#super(*parameters)
|
|
10
|
-
# TODO i think this is just passed a statement - so it only ever has one parameter - I prefer it that way
|
|
11
|
-
#parameters.each { |x| self.push(x) }
|
|
12
|
-
parameters.each do |code|
|
|
13
|
-
self.push(code.copy)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# TODO I might change the statement_id to be determined by the structure
|
|
17
|
-
# of the statement.
|
|
18
|
-
@statement_id = @@statement_id
|
|
19
|
-
@@statement_id += 1
|
|
20
|
-
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# Retunrs the contents of the if_container instance as string contained
|
|
24
|
-
# within paraenthesis e.g.
|
|
25
|
-
#
|
|
26
|
-
# if(var_a == var_b)
|
|
27
|
-
#
|
|
28
|
-
def write(indent=0)
|
|
29
|
-
line = If.new.write(indent)
|
|
30
|
-
line += '('
|
|
31
|
-
self.each do |x|
|
|
32
|
-
line += x.write
|
|
33
|
-
line += ' ' unless x.object_id == last.object_id
|
|
34
|
-
end
|
|
35
|
-
line += ')'
|
|
36
|
-
return line
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def describe(indent=0)
|
|
40
|
-
line = If.new.write(indent)
|
|
41
|
-
line += '('
|
|
42
|
-
self.each do |x|
|
|
43
|
-
line += x.describe
|
|
44
|
-
line += ' ' unless x.object_id == last.object_id
|
|
45
|
-
end
|
|
46
|
-
line += ')'
|
|
47
|
-
return line
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def replace_theory_variables!(mapping)
|
|
51
|
-
self.each_with_index do |x,i|
|
|
52
|
-
if x.kind_of?(TheoryVariable) && mapping.has_key?(x.theory_variable_id)
|
|
53
|
-
self[i] = mapping[x.theory_variable_id].copy
|
|
54
|
-
next
|
|
55
|
-
end
|
|
56
|
-
self[i].replace_theory_variables!(mapping)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
# TODO Doesn't need to be here(duplicated results)
|
|
61
|
-
def select_all(results=[],&block)
|
|
62
|
-
results.push self if block.call(self)
|
|
63
|
-
self.each do |x|
|
|
64
|
-
if block.call(x)
|
|
65
|
-
results.push(x)
|
|
66
|
-
else
|
|
67
|
-
end
|
|
68
|
-
if x.respond_to?(:select_all)
|
|
69
|
-
x.select_all(results,&block)
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
return results
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# Returns a duplicate of this IfContainer instance
|
|
76
|
-
#
|
|
77
|
-
def copy
|
|
78
|
-
a = IfContainer.new(*self.collect {|x| x.copy})
|
|
79
|
-
a.statement_id = @statement_id
|
|
80
|
-
return a
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
# TODO Write tests for this
|
|
84
|
-
# Returns a string containing the syntax for the container but where
|
|
85
|
-
# all the values are literals e.g.
|
|
86
|
-
#
|
|
87
|
-
# if(var_a == var_b) whould become "if(6 == 7)"
|
|
88
|
-
#
|
|
89
|
-
def to_literal_string
|
|
90
|
-
line = If.new.write
|
|
91
|
-
line += '('
|
|
92
|
-
self.each do |x|
|
|
93
|
-
line += x.to_literal_string
|
|
94
|
-
line += ' ' unless x.object_id == last.object_id
|
|
95
|
-
end
|
|
96
|
-
line += ')'
|
|
97
|
-
return line
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
end
|