class TypeProf::Scratch::ClassDef
Attributes
absolute_path[R]
consts[R]
cvars[R]
ivars[R]
kind[R]
klass_obj[RW]
methods[R]
modules[R]
name[RW]
subclasses[R]
Public Class Methods
new(kind, name, absolute_path)
click to toggle source
# File typeprof-0.15.2/lib/typeprof/analyzer.rb, line 321 def initialize(kind, name, absolute_path) raise unless name.is_a?(Array) @kind = kind @modules = { :before => { true => [], false => [] }, # before = include/extend :after => { true => [], false => [] }, # after = prepend } @name = name @consts = {} @methods = {} @ivars = VarTable.new @cvars = VarTable.new @absolute_path = absolute_path @namespace = nil @subclasses = [] end
Public Instance Methods
add_constant(name, ty, absolute_path)
click to toggle source
# File typeprof-0.15.2/lib/typeprof/analyzer.rb, line 357 def add_constant(name, ty, absolute_path) if @consts[name] # XXX: warn! end @consts[name] = [ty, absolute_path] end
add_method(mid, singleton, mdef)
click to toggle source
# File typeprof-0.15.2/lib/typeprof/analyzer.rb, line 411 def add_method(mid, singleton, mdef) @methods[[singleton, mid]] ||= Utils::MutableSet.new @methods[[singleton, mid]] << mdef # Need to restart...? end
adjust_substitution(singleton, mid, mthd, subst, direct) { |subst, direct| ... }
click to toggle source
# File typeprof-0.15.2/lib/typeprof/analyzer.rb, line 377 def adjust_substitution(singleton, mid, mthd, subst, direct, &blk) adjust_substitution_for_module(@modules[:before][singleton], mid, mthd, subst, &blk) mthds = @methods[[singleton, mid]] yield subst, direct if mthds&.include?(mthd) adjust_substitution_for_module(@modules[:after][singleton], mid, mthd, subst, &blk) end
adjust_substitution_for_module(mods, mid, mthd, subst, &blk)
click to toggle source
# File typeprof-0.15.2/lib/typeprof/analyzer.rb, line 364 def adjust_substitution_for_module(mods, mid, mthd, subst, &blk) mods.each do |mod_def, type_args,| if mod_def.klass_obj.type_params && type_args subst2 = {} mod_def.klass_obj.type_params.zip(type_args) do |(tyvar, *), tyarg| tyvar = Type::Var.new(tyvar) subst2[tyvar] = tyarg.substitute(subst, Config.options[:type_depth_limit]) end mod_def.adjust_substitution(false, mid, mthd, subst2, false, &blk) end end end
check_typed_method(mid, singleton)
click to toggle source
# File typeprof-0.15.2/lib/typeprof/analyzer.rb, line 403 def check_typed_method(mid, singleton) set = @methods[[singleton, mid]] return nil unless set set = set.select {|mdef| mdef.is_a?(TypedMethodDef) } return nil if set.empty? return set end
get_constant(name)
click to toggle source
# File typeprof-0.15.2/lib/typeprof/analyzer.rb, line 352 def get_constant(name) ty, = @consts[name] ty || Type.any # XXX: warn? end
mix_module(kind, mod, type_args, singleton, absolute_path)
click to toggle source
# File typeprof-0.15.2/lib/typeprof/analyzer.rb, line 341 def mix_module(kind, mod, type_args, singleton, absolute_path) mod_, module_type_args, absolute_paths = @modules[kind][singleton].find {|m,| m == mod } if mod_ raise "inconsistent #{ kind == :after ? "include/extend" : "prepend" } type args in RBS?" if module_type_args != type_args && type_args != [] && type_args != nil else absolute_paths = Utils::MutableSet.new @modules[kind][singleton].unshift([mod, type_args, absolute_paths]) end absolute_paths << absolute_path end
search_method(singleton, mid, visited) { |mthds, klass_obj, singleton| ... }
click to toggle source
# File typeprof-0.15.2/lib/typeprof/analyzer.rb, line 386 def search_method(singleton, mid, visited, &blk) # Currently, circular inclusion of modules is allowed return if visited[self] visited[self] = true @modules[:before][singleton].each do |mod_def,| mod_def.search_method(false, mid, visited, &blk) end mthds = @methods[[singleton, mid]] yield mthds, @klass_obj, singleton if mthds @modules[:after][singleton].each do |mod_def,| mod_def.search_method(false, mid, visited, &blk) end end
set_method(mid, singleton, mdef)
click to toggle source
# File typeprof-0.15.2/lib/typeprof/analyzer.rb, line 417 def set_method(mid, singleton, mdef) if mdef @methods[[singleton, mid]] = Utils::MutableSet.new @methods[[singleton, mid]] << mdef else @methods.delete([singleton, mid]) end end