Class: TheoryStatement
- Defined in:
- lib/core/statement/TheoryStatement.rb
Overview
This class represents the general descriptions used inside the three components of theories.
TODO The statement class this extends is extremely bloated but I
need to create some complex journeys before I can start to
trim the fat.
Instance Attribute Summary
Attributes inherited from Statement
#overrides, #scope, #statement_id, #statement_level
Instance Method Summary collapse
-
#describe(tab = 0) ⇒ Object
TODO Maybe use a opject to handle the output of the statement.
-
#initialize(*parameters) ⇒ TheoryStatement
constructor
A new instance of TheoryStatement.
-
#map_to(mapping) ⇒ Object
TODO This method was just nicked from TheoryDependent TODO A similar method exists in Statement.
-
#replace_theory_variables!(mapping) ⇒ Object
TODO map_to might replace the need for this method TODO How does this work for instance call containers and array access?.
-
#replace_variables_alt!(map) ⇒ Object
> => map [<TheoryVariable>=><TheoryVariable>].
Methods inherited from Statement
#[], #[]=, #add, #assignment?, #cauldron_method_calls, #clear, #confirmed?, #contains_method_call?, #context_variable, #contextual_variable, #copy, #created_variable, #created_variable_id, #creates_variable?, #decalares_variable?, #declared_variable, #declared_variable_id, #each, #each_unrealised_variable, #each_untyped_variable, #each_variable, #each_with_index, #equivalent?, #exchange_variables, #find_actual_variable, #find_all_required_runtime_methods, #find_overriding_statements, #find_statement, #find_variable, #first, #has?, #identify_overriding_statements, #is_simple?, #last, #left_hand_side, #length, #literalise, #not_declared_variables, #overrides?, #push, #realise2, #realised?, #replace_variable!, #replace_variable_if, #required_variable_ids, reset_global_id, #right_hand_side, #same_not_declared_variables?, #select_all, #statement_count, #subst, #subst!, #subst_variable!, #to_declaration, #to_literal_string, #to_var, #tokens, #unrealised_variables, #untyped_variables, #valid_syntax?, #variables, #write, #write_with_uniq_id, #write_with_value, #write_with_variable_id
Methods included from ActsAsCode
Methods included from ActsAsStatement
#classes_match?, #statement_type
Methods included from PrintVariables
Constructor Details
#initialize(*parameters) ⇒ TheoryStatement
Returns a new instance of TheoryStatement.
10 11 12 |
# File 'lib/core/statement/TheoryStatement.rb', line 10 def initialize(*parameters) super(*parameters) end |
Instance Method Details
#describe(tab = 0) ⇒ Object
TODO Maybe use a opject to handle the output of the statement.
58 59 60 61 62 63 64 65 66 |
# File 'lib/core/statement/TheoryStatement.rb', line 58 def describe(tab=0) line = '' tab.times {line += "\t" } self.each do |code| line += code.describe break if code.object_id == self.last.object_id end return line end |
#map_to(mapping) ⇒ Object
TODO This method was just nicked from TheoryDependent TODO A similar method exists in Statement
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/core/statement/TheoryStatement.rb', line 30 def map_to(mapping) # Duplicate the current statement before it is rewritten rewritten_statement = self.copy # Find all the containers that contain TheoryVariables # NOTE The statement is put in an array because select all doesn't include the array itself containers = [rewritten_statement].select_all {|x| x.respond_to?(:has?)} theory_variable_containers = containers.select {|x| x.has? {|y| y.kind_of?(TheoryVariable)}} # Rewrite the statement replacing the values theory_variable_containers.each do |z| z.replace_theory_variables!(mapping) end return rewritten_statement #return TheoryDependent.new(rewritten_statement,@theory_component_id) end |
#replace_theory_variables!(mapping) ⇒ Object
TODO map_to might replace the need for this method TODO How does this work for instance call containers and array access?
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/core/statement/TheoryStatement.rb', line 16 def replace_theory_variables!(mapping) self.each_with_index do |x,i| if x.kind_of?(TheoryVariable) && mapping.has_key?(x.theory_variable_id) self[i] = mapping[x.theory_variable_id].copy next end self[i].replace_theory_variables!(mapping) if self[i].respond_to?(:replace_theory_variables!) end self end |
#replace_variables_alt!(map) ⇒ Object
>
> map [<TheoryVariable>=><TheoryVariable>]
51 52 53 54 55 |
# File 'lib/core/statement/TheoryStatement.rb', line 51 def replace_variables_alt!(map) self.each do |x| x.replace_variables_alt!(map) end end |