Sha256: 6365498472d894d3950e6c372e367720f77c35144742267cf2df0fa5360dcaff

Contents?: true

Size: 834 Bytes

Versions: 1

Compression:

Stored size: 834 Bytes

Contents

module Furnace
  class SSA::Constant < SSA::Value
    attr_reader :type
    attr_reader :value

    def initialize(type, value)
      @value = value
      @type  = type.to_type

      super()
    end

    def type=(type)
      @type  = type.to_type

      SSA.instrument(self)
    end

    def value=(value)
      @value = value

      SSA.instrument(self)
    end

    def constant?
      true
    end

    def ==(other)
      if other.respond_to? :to_value
        other_value = other.to_value

        other_value.constant? &&
            other_value.type  == type &&
            other_value.value == value
      else
        false
      end
    end

    def awesome_print_as_value(p=AwesomePrinter.new)
      type.awesome_print(p)
      p.text @value.inspect
      p
    end

    def inspect
      awesome_print
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
furnace-0.4.0.beta.2 lib/furnace/ssa/constant.rb