Sha256: 510a71a87bf34dd735247eae6eb05bd66a1b6b8cc00c9223a7650e409972f339
Contents?: true
Size: 1.22 KB
Versions: 26
Compression:
Stored size: 1.22 KB
Contents
module Steep module AST module Types class Record attr_reader :location attr_reader :elements def initialize(elements:, location: nil) @elements = elements @location = location end def ==(other) other.is_a?(Record) && 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 strings = elements.keys.sort.map do |key| "#{key.inspect} => #{elements[key]}" end "{ #{strings.join(", ")} }" end def free_variables() @fvs ||= Set.new.tap do |set| elements.each_value do |type| set.merge(type.free_variables) end 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
26 entries across 26 versions & 1 rubygems