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.



341
342
343
344
345
346
# File 'lib/typeprof/core/env.rb', line 341

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.



348
349
350
# File 'lib/typeprof/core/env.rb', line 348

def cpath
  @cpath
end

#midObject (readonly)

Returns the value of attribute mid.



348
349
350
# File 'lib/typeprof/core/env.rb', line 348

def mid
  @mid
end

#outerObject (readonly)

Returns the value of attribute outer.



348
349
350
# File 'lib/typeprof/core/env.rb', line 348

def outer
  @outer
end

#scope_levelObject (readonly)

Returns the value of attribute scope_level.



348
349
350
# File 'lib/typeprof/core/env.rb', line 348

def scope_level
  @scope_level
end

Instance Method Details

#get_self(genv) ⇒ Object



350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/typeprof/core/env.rb', line 350

def get_self(genv)
  case @scope_level
  when :instance
    mod = genv.resolve_cpath(@cpath || [])
    type_params = mod.type_params.map {|ty_param| 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