class TypeProf::Core::BotFilter - typeprof: Ruby Standard Library Documentation

# class TypeProf::Core::BotFilter

### Attributes

base_vtx[R]
next_vtx[R]
prev_vtx[R]
types[R]

### Public Class Methods

new(genv, node, prev_vtx, base_vtx) click to toggle source

    # File typeprof-0.30.1/lib/typeprof/core/graph/filter.rb, line 97
    def initialize(genv, node, prev_vtx, base_vtx)
      @node = node
      @types = {}
      @prev_vtx = prev_vtx
      @next_vtx = Vertex.new(node)
      @base_vtx = base_vtx
      base_vtx.add_edge(genv, self)
      prev_vtx.add_edge(genv, self) if prev_vtx != base_vtx
    end

### Public Instance Methods

filter(types) click to toggle source

    # File typeprof-0.30.1/lib/typeprof/core/graph/filter.rb, line 109
    def filter(types)
      types.select {|ty| (ty == genv.nil_type) == @allow_nil }
    end

on_type_added(genv, src_var, added_types) click to toggle source

    # File typeprof-0.30.1/lib/typeprof/core/graph/filter.rb, line 113
    def on_type_added(genv, src_var, added_types)
      if src_var == @base_vtx
        if @base_vtx.types.size == 1 && @base_vtx.types.include?(Type::Bot.new(genv))
          @next_vtx.on_type_removed(genv, self, @types.keys & @next_vtx.types.keys) # XXX: smoke/control/bot2.rb
        end
      else
        added_types.each do |ty|
          @types[ty] = true
        end
        if @base_vtx.types.size == 1 && @base_vtx.types.include?(Type::Bot.new(genv))
          # ignore
        else
          @next_vtx.on_type_added(genv, self, added_types - @next_vtx.types.keys) # XXX: smoke/control/bot4.rb
        end
      end
    end

on_type_removed(genv, src_var, removed_types) click to toggle source

    # File typeprof-0.30.1/lib/typeprof/core/graph/filter.rb, line 130
    def on_type_removed(genv, src_var, removed_types)
      if src_var == @base_vtx
        if @base_vtx.types.size == 1 && @base_vtx.types.include?(Type::Bot.new(genv))
          # ignore
        else
          @next_vtx.on_type_added(genv, self, @types.keys - @next_vtx.types.keys) # XXX: smoke/control/bot4.rb
        end
      else
        removed_types.each do |ty|
          @types.delete(ty) || raise
        end
        if @base_vtx.types.size == 1 && @base_vtx.types.include?(Type::Bot.new(genv))
          # ignore
        else
          @next_vtx.on_type_removed(genv, self, removed_types & @next_vtx.types.keys) # XXX: smoke/control/bot2.rb
        end
      end
    end

to_s() click to toggle source

@@new_id = 0

    # File typeprof-0.30.1/lib/typeprof/core/graph/filter.rb, line 151
    def to_s
      "BF#{ @id ||= $new_id += 1 } -> #{ @next_vtx }"
    end