Class: Rtml::ReverseEngineering::Simulator::VariableValue

Inherits:
Object
  • Object
show all
Includes:
VariableLookup
Defined in:
lib/rtml/reverse_engineering/simulator/variable_value.rb

Overview

Used by Rtml::ReverseEngineering::Simulator to track the value of a variable. Attempts to build a logical value by processing the setvar’s :lo, :op and :ro attributes. References to other variables are automatically resolved. References to nonexistent values assume built-in variables and assign generic values to them.

Implements a #== method to see if one variable’s value is equal to another’s, though this may not always be accurate.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(setvar, all_variables, known_variable_types) ⇒ VariableValue

Returns a new instance of VariableValue.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rtml/reverse_engineering/simulator/variable_value.rb', line 12

def initialize(setvar, all_variables, known_variable_types)
  @setvar, @all_variables, @known_variable_types = setvar, all_variables, known_variable_types
  @value = setvar.to_s

  %w(lo op ro).each { |i| instance_variable_set("@#{i}", resolve(self.send(i), all_variables, known_variable_types)) }
  catch(:done) do
    check_for_assignment
    check_for_operation
  end

  do_casting
  check_boundaries
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



10
11
12
# File 'lib/rtml/reverse_engineering/simulator/variable_value.rb', line 10

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



26
27
28
# File 'lib/rtml/reverse_engineering/simulator/variable_value.rb', line 26

def ==(other)
  self.value == other.value
end