Sha256: 39d9ff13e8d1ff4777250a888754621099bd08105c3a05d9ce79d53185cd8abf

Contents?: true

Size: 1.21 KB

Versions: 43

Compression:

Stored size: 1.21 KB

Contents

module Steep
  module Subtyping
    class Trace
      attr_reader :array

      def initialize(array: [])
        @array = array
      end

      def interface(sub, sup, &block)
        push :interface, sub, sup, &block
      end

      def method(name, sub, sup, &block)
        push :method, sub, sup, name, &block
      end

      def method_type(name, sub, sup, &block)
        push :method_type, sub, sup, name, &block
      end

      def type(sub, sup, &block)
        push :type, sub, sup, &block
      end

      def push(*xs)
        array << xs
        yield
      ensure
        array.pop
      end

      def add(sup, sub)
        array << [sup, sub]
        yield
      ensure
        array.pop
      end

      def empty?
        array.empty?
      end

      def drop(n)
        self.class.new(array: array.drop(n))
      end

      def size
        array.size
      end

      def +(other)
        self.class.new(array: array + other.array)
      end

      def initialize_copy(source)
        @array = source.array.dup
      end

      def each
        if block_given?
          array.each do |pair|
            yield(*pair)
          end
        else
          enum_for :each
        end
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
steep-0.47.1 lib/steep/subtyping/trace.rb
steep-0.47.0 lib/steep/subtyping/trace.rb
steep-0.46.0 lib/steep/subtyping/trace.rb
steep-0.45.0 lib/steep/subtyping/trace.rb
steep-0.44.1 lib/steep/subtyping/trace.rb
steep-0.44.0 lib/steep/subtyping/trace.rb
steep-0.43.1 lib/steep/subtyping/trace.rb
steep-0.43.0 lib/steep/subtyping/trace.rb
steep-0.42.0 lib/steep/subtyping/trace.rb
steep-0.41.0 lib/steep/subtyping/trace.rb
steep-0.40.0 lib/steep/subtyping/trace.rb
steep-0.39.0 lib/steep/subtyping/trace.rb
steep-0.38.0 lib/steep/subtyping/trace.rb
steep-0.37.0 lib/steep/subtyping/trace.rb
steep-0.36.0 lib/steep/subtyping/trace.rb
steep-0.35.0 lib/steep/subtyping/trace.rb
steep-0.34.0 lib/steep/subtyping/trace.rb
steep-0.33.0 lib/steep/subtyping/trace.rb
steep-0.32.0 lib/steep/subtyping/trace.rb
steep-0.31.1 lib/steep/subtyping/trace.rb