Sha256: a808eda6eea4c43db313da72160163c731160135f7d885f1c849301797ff571a

Contents?: true

Size: 1.58 KB

Versions: 3

Compression:

Stored size: 1.58 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 Env < Base
          attr_reader :truthy, :falsy

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

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

          alias eql? ==

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
steep-0.38.0 lib/steep/ast/types/logic.rb
steep-0.37.0 lib/steep/ast/types/logic.rb
steep-0.36.0 lib/steep/ast/types/logic.rb