Class: TypeProf::Core::CRef

Inherits:
Object
  • Object
show all
Defined in:
lib/typeprof/core/env.rb

Constant Summary collapse

Toplevel =
self.new([], :instance, nil, nil)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cpath, scope_level, mid, outer) ⇒ CRef

Returns a new instance of CRef.



446
447
448
449
450
451
# File 'lib/typeprof/core/env.rb', line 446

def initialize(cpath, scope_level, mid, outer)
  @cpath = cpath
  @scope_level = scope_level
  @mid = mid
  @outer = outer
end

Instance Attribute Details

#cpathObject (readonly)

Returns the value of attribute cpath.



453
454
455
# File 'lib/typeprof/core/env.rb', line 453

def cpath
  @cpath
end

#midObject (readonly)

Returns the value of attribute mid.



453
454
455
# File 'lib/typeprof/core/env.rb', line 453

def mid
  @mid
end

#outerObject (readonly)

Returns the value of attribute outer.



453
454
455
# File 'lib/typeprof/core/env.rb', line 453

def outer
  @outer
end

#scope_levelObject (readonly)

Returns the value of attribute scope_level.



453
454
455
# File 'lib/typeprof/core/env.rb', line 453

def scope_level
  @scope_level
end

Instance Method Details

#get_self(genv) ⇒ Object



455
456
457
458
459
460
461
462
463
464
465
466
467
# File 'lib/typeprof/core/env.rb', line 455

def get_self(genv)
  case @scope_level
  when :instance
    mod = genv.resolve_cpath(@cpath || [])
    type_params = mod.type_params.map {|(_name, _default_ty)| Source.new() } # TODO: better support
    ty = Type::Instance.new(genv, mod, type_params)
    Source.new(ty)
  when :class
    Source.new(Type::Singleton.new(genv, genv.resolve_cpath(@cpath || [])))
  else
    Source.new()
  end
end