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.



370
371
372
373
374
375
# File 'lib/typeprof/core/env.rb', line 370

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.



377
378
379
# File 'lib/typeprof/core/env.rb', line 377

def cpath
  @cpath
end

#midObject (readonly)

Returns the value of attribute mid.



377
378
379
# File 'lib/typeprof/core/env.rb', line 377

def mid
  @mid
end

#outerObject (readonly)

Returns the value of attribute outer.



377
378
379
# File 'lib/typeprof/core/env.rb', line 377

def outer
  @outer
end

#scope_levelObject (readonly)

Returns the value of attribute scope_level.



377
378
379
# File 'lib/typeprof/core/env.rb', line 377

def scope_level
  @scope_level
end

Instance Method Details

#get_self(genv) ⇒ Object



379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/typeprof/core/env.rb', line 379

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