Sha256: 1088a2cf58dd7d52ccca7dbaac085c65fb58b0d882fe0dad3e5459a73e3f41e6
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
module Steep module AST module Types class Hash attr_reader :location attr_reader :elements def initialize(elements:, location: nil) @elements = elements @location = location end def ==(other) other.is_a?(Hash) && other.elements == elements end def hash self.class.hash ^ elements.hash end alias eql? == def subst(s) self.class.new(location: location, elements: elements.transform_values {|type| type.subst(s) }) end def to_s "{ #{elements.map {|key, value| "#{key.inspect} => #{value}" }.join(", ")} }" end def free_variables elements.each_value.with_object(Set.new) do |type, set| set.merge(type.free_variables) end end include Helper::ChildrenLevel def level [0] + level_of_children(elements.values) end def with_location(new_location) self.class.new(elements: elements, location: new_location) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
steep-0.7.0 | lib/steep/ast/types/hash.rb |
steep-0.6.0 | lib/steep/ast/types/hash.rb |