Sha256: c69e7e07886bbbf4f656f69edcab53d040f1745e324eaa35ab5d3eeb1c4dff34

Contents?: true

Size: 1.22 KB

Versions: 18

Compression:

Stored size: 1.22 KB

Contents

module Steep
  module AST
    module Types
      class Masked
        attr_reader :location
        attr_reader :type
        attr_reader :mask

        def initialize(type:, mask:, location:)
          @type = type
          @mask = mask
          @location = location
        end

        def ==(other)
          other.is_a?(Masked) &&
            other.type == type &&
            other.mask == mask
        end

        alias eql? ==

        def hash
          self.class.hash ^ type.hash ^ mask.hash
        end

        def to_json(*a)
          { class: :masked,
            type: type,
            mask: mask,
            location: location }.to_json(*a)
        end

        def to_s(level = 0)
          "masked(#{type}|#{mask})"
        end

        def free_variables(set = Set.new)
          type.free_variables(set)
          mask.free_variables(set)
        end

        def each_type(&block)
          if block_given?
            yield type
            yield mask
          else
            enum_for :each_type
          end
        end

        def sub(s)
          self.class.new(type: type.sub(s),
                         mask: mask.sub(s),
                         location: location)
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
steep-0.25.0 lib/steep/ast/types.rb
steep-0.24.0 lib/steep/ast/types.rb
steep-0.23.0 lib/steep/ast/types.rb
steep-0.22.0 lib/steep/ast/types.rb
steep-0.21.0 lib/steep/ast/types.rb
steep-0.20.0 lib/steep/ast/types.rb
steep-0.19.0 lib/steep/ast/types.rb
steep-0.18.0 lib/steep/ast/types.rb
steep-0.17.1 lib/steep/ast/types.rb
steep-0.17.0 lib/steep/ast/types.rb
steep-0.16.3 lib/steep/ast/types.rb
steep-0.16.2 lib/steep/ast/types.rb
steep-0.16.1 lib/steep/ast/types.rb
steep-0.16.0 lib/steep/ast/types.rb
steep-0.15.0 lib/steep/ast/types.rb
steep-0.14.0 lib/steep/ast/types.rb
steep-0.13.0 lib/steep/ast/types.rb
steep-0.12.0 lib/steep/ast/types.rb