rubyx/lib/mom/instruction/dynamic_call.rb

25 lines
800 B
Ruby
Raw Normal View History

2017-09-14 15:07:02 +02:00
module Mom
# A dynamic call calls a method at runtime. This off course implies that we don't know the
# method at compile time and so must "find" it. Resolving, or finding the method, is a
2018-03-10 14:17:36 +01:00
# a seperate step though, and here we assume that we know this Method instance.
2017-09-14 15:07:02 +02:00
#
2018-03-10 14:17:36 +01:00
# Both (to be called) Method instance and the type of receiver are stored as
# variables here. The type is used to check before calling.
2017-09-14 15:07:02 +02:00
#
2018-03-10 14:17:36 +01:00
# Setting up the method is not part of the instructions scope. That setup
# includes the type check and any necccessay method resolution.
# See vool send statement
2017-09-14 15:07:02 +02:00
#
class DynamicCall < Instruction
2018-03-10 14:17:36 +01:00
attr :cached_type
attr :cached_method
2017-09-14 15:07:02 +02:00
2018-03-10 14:17:36 +01:00
def initialize(type = nil, method = nil)
@cached_type = type
@cached_method = method
2017-09-14 15:07:02 +02:00
end
end
end