Class: TypedRb::Types::TyTopLevelObject
Instance Attribute Summary
Attributes inherited from TyObject
#classes, #hierarchy, #modules, #ruby_type, #with_ruby_type
Attributes inherited from Type
#node
Instance Method Summary
collapse
Methods inherited from TyObject
#<=>, #check_type, #dynamic?, #either?, #find_function_type_in_hierarchy, #generic?, #join, #max, #singleton?, #union
Methods included from Comparable
#<=>
Methods inherited from Type
#either?, #stack_jump?
Constructor Details
Returns a new instance of TyTopLevelObject.
4
5
6
|
# File 'lib/typed/types/ty_top_level_object.rb', line 4
def initialize
super(TOPLEVEL_BINDING.receiver.class)
end
|
Instance Method Details
#as_object_type ⇒ Object
12
13
14
|
# File 'lib/typed/types/ty_top_level_object.rb', line 12
def as_object_type
self
end
|
#compatible?(_other_type) ⇒ Boolean
8
9
10
|
# File 'lib/typed/types/ty_top_level_object.rb', line 8
def compatible?(_other_type)
fail StandardError, 'invoking compatible? in the top level object'
end
|
#find_function_type(message, num_args, block) ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/typed/types/ty_top_level_object.rb', line 16
def find_function_type(message, num_args, block)
found_type = select_matching_function_in_class(:main, :instance, message, num_args, block)
if found_type && !found_type.is_a?(TyDynamicFunction)
[:main, found_type]
else
TyObject.new(ruby_type, node).find_function_type(message, num_args, block)
end
end
|
#find_var_type(var) ⇒ Object
25
26
27
|
# File 'lib/typed/types/ty_top_level_object.rb', line 25
def find_var_type(var)
super(var, :main)
end
|
#resolve_ruby_method(message) ⇒ Object
29
30
31
|
# File 'lib/typed/types/ty_top_level_object.rb', line 29
def resolve_ruby_method(message)
@ruby_type.method(message)
end
|
33
34
35
|
# File 'lib/typed/types/ty_top_level_object.rb', line 33
def to_s
'Object[\'main\']'
end
|