Sha256: 496af1a0fa5c25418240a817162bb4d5371ba83461da155d59850fbe7a3335b1

Contents?: true

Size: 989 Bytes

Versions: 2

Compression:

Stored size: 989 Bytes

Contents

module TypeProf::Core
  class MethodEntity
    def initialize
      @builtin = nil
      @decls = Set[]
      @defs = Set[]
      @aliases = {}
      @method_call_boxes = Set[]
    end

    attr_reader :decls, :defs, :aliases, :method_call_boxes
    attr_accessor :builtin

    def add_decl(decl)
      @decls << decl
    end

    def remove_decl(decl)
      @decls.delete(decl) || raise
    end

    def add_def(mdef)
      @defs << mdef
      self
    end

    def remove_def(mdef)
      @defs.delete(mdef) || raise
    end

    def add_alias(node, old_mid)
      @aliases[node] = old_mid
    end

    def remove_alias(node)
      @aliases.delete(node) || raise
    end

    def exist?
      @builtin || !@decls.empty? || !@defs.empty?
    end

    def add_run_all_mdefs(genv)
      @defs.each do |mdef|
        genv.add_run(mdef)
      end
    end

    def add_run_all_method_call_boxes(genv)
      @method_call_boxes.each do |box|
        genv.add_run(box)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
typeprof-0.30.1 lib/typeprof/core/env/method_entity.rb
typeprof-0.30.0 lib/typeprof/core/env/method_entity.rb