Sha256: 7041c104ac676a71f60096a4638dccdff0dfcb2f4eb159b1ef250fad0b52ec1c

Contents?: true

Size: 711 Bytes

Versions: 6

Compression:

Stored size: 711 Bytes

Contents

module Furnace::CFG
  class Node
    attr_reader :label, :operations

    def initialize(cfg, label, operations)
      @cfg, @label, @operations = cfg, label, operations
    end

    def entering_edges
      @cfg.edges.select { |e| e.target == self }
    end

    def leaving_edges
      @cfg.edges.select { |e| e.source == self }
    end

    def leaving_edge(source)
      leaving_edges.find { |e| e.source_operation == source }
    end

    def default_leaving_edge
      leaving_edge(nil)
    end

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

    def inspect
      if @label
        "<#{@label}:#{@operations.map(&:inspect).join ", "}>"
      else
        "<!exit>"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
furnace-0.0.8 lib/furnace/cfg/node.rb
furnace-0.0.7 lib/furnace/cfg/node.rb
furnace-0.0.6 lib/furnace/cfg/node.rb
furnace-0.0.4 lib/furnace/cfg/node.rb
furnace-0.0.3 lib/furnace/cfg/node.rb
furnace-0.0.2 lib/furnace/cfg/node.rb