rubyx/lib/vool/vool_method.rb

30 lines
925 B
Ruby
Raw Normal View History

module Vool
class VoolMethod
attr_reader :name , :args_type , :locals_type , :source
def initialize(name , args_type , locals_type , source )
@name , @args_type , @locals_type , @source = name , args_type, locals_type , source
2017-01-16 16:44:34 +01:00
raise "Name must be symbol" unless name.is_a?(Symbol)
raise "args_type must be type" unless args_type.is_a?(Parfait::Type)
raise "locals_type must be type" unless locals_type.is_a?(Parfait::Type)
end
def normalize_source
@source = yield @source
end
def create_vm_method( type )
raise "create_method #{type.inspect} is not a Type" unless type.is_a? Parfait::Type
type.create_method( @name , @args_type )#FIXME, @locals_type)
end
2017-08-30 21:27:12 +02:00
def create_tmp
2017-08-30 21:54:03 +02:00
tmp_name = "tmp_#{@locals_type.instance_length}".to_sym
2017-08-30 21:27:12 +02:00
@locals_type = @locals_type.add_instance_variable( tmp_name , :Object )
tmp_name
end
end
end