Sha256: 2a53b02c923b52b48129dc54bc3b95532612f2365ea8134b99af1d4490265a16

Contents?: true

Size: 1.92 KB

Versions: 13

Compression:

Stored size: 1.92 KB

Contents

module Steep
  module AST
    module Types
      module Logic
        class Base
          attr_reader :location

          def subst(s)
            self
          end

          def free_variables
            @fvs ||= Set[]
          end

          def hash
            self.class.hash
          end

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

          alias eql? ==

          def to_s
            "<% #{self.class} %>"
          end
        end

        class Not < Base
          def initialize(location: nil)
            @location = location
          end
        end

        class ReceiverIsNil < Base
          def initialize(location: nil)
            @location = location
          end
        end

        class ReceiverIsNotNil < Base
          def initialize(location: nil)
            @location = location
          end
        end

        class ReceiverIsArg < Base
          def initialize(location: nil)
            @location = location
          end
        end

        class ArgIsReceiver < Base
          def initialize(location: nil)
            @location = location
          end
        end

        class ArgEqualsReceiver < Base
          def initialize(location: nil)
            @location = location
          end
        end

        class Env < Base
          attr_reader :truthy, :falsy, :type

          def initialize(truthy:, falsy:, type:, location: nil)
            @truthy = truthy
            @falsy = falsy
            @type = type
          end

          def ==(other)
            other.is_a?(Env) && other.truthy == truthy && other.falsy == falsy && other.type == type
          end

          alias eql? ==

          def hash
            self.class.hash ^ truthy.hash ^ falsy.hash
          end

          def inspect
            "#<Steep::AST::Types::Env @type=#{type}, @truthy=..., @falsy=...>"
          end

          alias to_s inspect
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
steep-0.48.0 lib/steep/ast/types/logic.rb
steep-0.47.1 lib/steep/ast/types/logic.rb
steep-0.47.0 lib/steep/ast/types/logic.rb
steep-0.46.0 lib/steep/ast/types/logic.rb
steep-0.45.0 lib/steep/ast/types/logic.rb
steep-0.44.1 lib/steep/ast/types/logic.rb
steep-0.44.0 lib/steep/ast/types/logic.rb
steep-0.43.1 lib/steep/ast/types/logic.rb
steep-0.43.0 lib/steep/ast/types/logic.rb
steep-0.42.0 lib/steep/ast/types/logic.rb
steep-0.41.0 lib/steep/ast/types/logic.rb
steep-0.40.0 lib/steep/ast/types/logic.rb
steep-0.39.0 lib/steep/ast/types/logic.rb