2018-07-07 08:11:09 +02:00
|
|
|
# A CallableMethod is static object that primarily holds the executable code.
|
|
|
|
# It is callable through it's binary code
|
|
|
|
# Additionally to the base class it has a name
|
|
|
|
#
|
|
|
|
# It's relation to the method a ruby programmer knows (called VoolMethod) is many to one,
|
|
|
|
# meaning one VoolMethod (untyped) has many CallableMethod implementations.
|
|
|
|
# The VoolMethod only holds vool code, no binary.
|
|
|
|
|
|
|
|
|
|
|
|
module Parfait
|
|
|
|
|
|
|
|
class CallableMethod < Callable
|
|
|
|
|
|
|
|
def ==(other)
|
|
|
|
return false unless other.is_a?(CallableMethod)
|
|
|
|
return false if @name != other.name
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def rxf_reference_name
|
|
|
|
"Method: " + @name.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def inspect
|
|
|
|
"#{@self_type.object_class.name}:#{name}(#{arguments_type.inspect})"
|
|
|
|
end
|
|
|
|
|
|
|
|
def each_method( &block )
|
|
|
|
block.call( self )
|
|
|
|
@next.each_method( &block ) if @next
|
|
|
|
end
|
2018-07-07 14:50:43 +02:00
|
|
|
|
|
|
|
def create_block(args , frame)
|
2018-07-30 09:21:43 +02:00
|
|
|
block_name = "#{@name}_block".to_sym #TODO with id, to distinguish
|
|
|
|
add_block( Block.new(block_name , self_type , args , frame))
|
2018-07-07 21:42:00 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def add_block(bl)
|
2018-07-27 09:46:22 +02:00
|
|
|
was = @blocks
|
|
|
|
bl.set_next(was) if(was)
|
2018-07-07 14:50:43 +02:00
|
|
|
@blocks = bl
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_block(block)
|
|
|
|
each_block{ |bl| return true if bl == block}
|
|
|
|
false
|
|
|
|
end
|
|
|
|
def each_block(&bl)
|
|
|
|
blo = blocks
|
|
|
|
while( blo )
|
|
|
|
yield(blo)
|
|
|
|
blo = blo.next
|
|
|
|
end
|
|
|
|
end
|
2018-07-07 08:11:09 +02:00
|
|
|
end
|
|
|
|
end
|