Sha256: 6a153d2b68b1fcac9fb1d1a124f991075a8d17b9e69df9643463d982a51ac992

Contents?: true

Size: 785 Bytes

Versions: 9

Compression:

Stored size: 785 Bytes

Contents

module Furnace
  module ANF
    class LetNode < Node
      attr_reader :arguments

      def initialize(graph, arguments)
        super(graph)

        @arguments = arguments
      end

      def try_eliminate
        if identity?
          entering_edges.each do |edge|
            edge.target = leaving_edge.target
          end
        end
      end

      def identity?
        @arguments.reduce(true) { |r, (k, v)| r && (v === k) }
      end

      def try_propagate
      end

      def static?(node)
        [ NilClass, TrueClass, FalseClass, Fixnum, Symbol,
          AST::LocalVariable, AST::InstanceVariable ].include? node.class
      end

      def to_human_readable
        "let\n#{@arguments.map { |k, v| "  #{k} = #{humanize v}" }.join "\n"}"
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
furnace-0.1.1 lib/furnace/anf/let_node.rb
furnace-0.1.0 lib/furnace/anf/let_node.rb
furnace-0.0.8 lib/furnace/anf/let_node.rb
furnace-0.0.7 lib/furnace/anf/let_node.rb
furnace-0.0.6 lib/furnace/anf/let_node.rb
furnace-0.0.4 lib/furnace/anf/let_node.rb
furnace-0.0.3 lib/furnace/anf/let_node.rb
furnace-0.0.2 lib/furnace/anf/let_node.rb
furnace-0.0.1 lib/furnace/anf/let_node.rb