class Archruby::Ruby::VarPropagation

Attributes

vars[R]

Public Class Methods

new() click to toggle source
# File lib/archruby/ruby/var_propagation.rb, line 6
def initialize
  @vars = []
end

Public Instance Methods

find_var(var_name) click to toggle source
# File lib/archruby/ruby/var_propagation.rb, line 35
def find_var var_name
  vars.each do | var |
    if var.keys.first == var_name
      return var
    end
  end
  return nil
end
push(var_name, line_number, type = nil) click to toggle source
# File lib/archruby/ruby/var_propagation.rb, line 10
def push var_name, line_number, type = nil
  var = find_var var_name
  if var
    lines = var[var.keys.first][:lines]
    lines.push(line_number)
  else
    @vars.push(
      {
        var_name =>
          {
            :lines => [line_number],
            :type => type
          }
      }
    )
  end
end
put_type(var_name, type) click to toggle source
# File lib/archruby/ruby/var_propagation.rb, line 28
def put_type var_name, type
  var = find_var var_name
  if var
    var[var.keys.first][:type] = type
  end
end