2017-12-10 20:47:26 +02:00
|
|
|
module Parfait
|
2016-12-20 20:02:20 +02:00
|
|
|
|
2017-12-10 20:47:26 +02:00
|
|
|
# This represents the method at source code level (sis vool)
|
|
|
|
#
|
|
|
|
# Type objects are already created for args and locals, but the main attribute
|
|
|
|
# is the source, which is a Vool::Statement
|
|
|
|
#
|
|
|
|
# Classes store VoolMethods, while Types store TypedMethod
|
|
|
|
# A Type referes to a Class , but a Class (interface) is implemented by many types
|
|
|
|
# as it changes during the course of it's life. Types do not change. Objects have
|
|
|
|
# type, and so only indirectly a class.
|
|
|
|
#
|
2017-08-31 16:11:06 +03:00
|
|
|
class VoolMethod
|
2016-12-20 20:02:20 +02:00
|
|
|
|
2018-03-14 17:39:04 +05:30
|
|
|
attr_reader :name , :args_type , :frame_type , :source
|
2016-12-21 11:30:35 +02:00
|
|
|
|
2018-03-14 20:24:47 +05:30
|
|
|
def initialize(name , args_type , frame_type , source )
|
|
|
|
@name , @args_type , @frame_type , @source = name , args_type, frame_type , source
|
2017-01-16 17:44:34 +02:00
|
|
|
raise "Name must be symbol" unless name.is_a?(Symbol)
|
|
|
|
raise "args_type must be type" unless args_type.is_a?(Parfait::Type)
|
2018-03-14 20:24:47 +05:30
|
|
|
raise "frame_type must be type" unless frame_type.is_a?(Parfait::Type)
|
2017-12-10 20:47:26 +02:00
|
|
|
raise "source must be vool" unless source.is_a?(Vool::Statement)
|
2016-12-20 20:02:20 +02:00
|
|
|
end
|
|
|
|
|
2017-09-11 14:21:57 +03:00
|
|
|
def create_parfait_method( type )
|
2017-01-15 12:10:37 +02:00
|
|
|
raise "create_method #{type.inspect} is not a Type" unless type.is_a? Parfait::Type
|
2018-03-18 22:09:27 +05:30
|
|
|
type.create_method( @name , @args_type , @frame_type)
|
2017-01-15 12:10:37 +02:00
|
|
|
end
|
|
|
|
|
2016-12-20 20:02:20 +02:00
|
|
|
end
|
|
|
|
end
|