class TypeProf::Core::Vertex
Attributes
next_vtxs[R]
types[R]
Public Class Methods
new(origin)
click to toggle source
Calls superclass method
TypeProf::Core::BasicVertex::new
# File typeprof-0.30.1/lib/typeprof/core/graph/vertex.rb, line 142 def initialize(origin) # Note that origin is just for debug. # When an AST node is reused, the value of the origin will be invalid. case origin when AST::Node when RBS::AST::Declarations::Base when ValueEntity when ActualArguments when Array when Symbol else raise "unknown class: #{ origin.class }" end @next_vtxs = Set[] super({}) end
Public Instance Methods
add_edge(genv, nvtx)
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/graph/vertex.rb, line 207 def add_edge(genv, nvtx) @next_vtxs << nvtx nvtx.on_type_added(genv, self, @types.keys) unless @types.empty? end
new_vertex(genv, origin)
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/graph/vertex.rb, line 201 def new_vertex(genv, origin) nvtx = Vertex.new(origin) add_edge(genv, nvtx) nvtx end
on_type_added(genv, src_var, added_types)
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/graph/vertex.rb, line 161 def on_type_added(genv, src_var, added_types) new_added_types = [] added_types.each do |ty| if @types[ty] @types[ty] << src_var else set = Set[] begin @types[ty] = set rescue @types_to_be_added[ty] = set end set << src_var new_added_types << ty end end unless new_added_types.empty? @next_vtxs.each do |nvtx| nvtx.on_type_added(genv, self, new_added_types) end end end
on_type_removed(genv, src_var, removed_types)
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/graph/vertex.rb, line 184 def on_type_removed(genv, src_var, removed_types) new_removed_types = [] removed_types.each do |ty| raise "!!! not implemented" if @types_to_be_added[ty] @types[ty].delete(src_var) || raise if @types[ty].empty? @types.delete(ty) || raise new_removed_types << ty end end unless new_removed_types.empty? @next_vtxs.each do |nvtx| nvtx.on_type_removed(genv, self, new_removed_types) end end end
remove_edge(genv, nvtx)
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/graph/vertex.rb, line 212 def remove_edge(genv, nvtx) @next_vtxs.delete(nvtx) || raise nvtx.on_type_removed(genv, self, @types.keys) unless @types.empty? end
to_s()
click to toggle source
# File typeprof-0.30.1/lib/typeprof/core/graph/vertex.rb, line 219 def to_s "v#{ @id ||= $new_id += 1 }" end
Also aliased as: inspect