passing frame (locals) into method creation

so typed_method have correct frame information and
can resolve slots correctly (next step)
This commit is contained in:
Torsten Ruger
2018-03-18 22:09:27 +05:30
parent 0813312ddc
commit af94d40cab
4 changed files with 30 additions and 13 deletions

View File

@ -74,14 +74,18 @@ module Parfait
names
end
def create_method( method_name , arguments )
def create_method( method_name , arguments , frame)
raise "create_method #{method_name}.#{method_name.class}" unless method_name.is_a?(Symbol)
#puts "Self: #{self.class} clazz: #{clazz.name}"
found = get_method( method_name )
#TODO check types and then what ?
return found if found
arg_type = arguments
arg_type = NamedList.type_for( arguments ) if arguments.is_a?(Hash)
add_method TypedMethod.new( self , method_name , arg_type )
if arguments.is_a?(Hash)
raise "May want to get rid of this way"
arguments = NamedList.type_for( arguments )
end
raise "frame must be a type, not:#{frame}" unless frame.is_a?(Type)
add_method TypedMethod.new( self , method_name , arguments , frame )
end
def add_method( method )

View File

@ -26,16 +26,17 @@ module Parfait
# not part of the parfait model, hence ruby accessor
attr_accessor :source
def initialize( type , name , arguments )
def initialize( type , name , arguments , frame)
super()
raise "No class #{name}" unless type
raise "For type, not class #{type}" unless type.is_a?(Type)
raise "Wrong argument type, expect Type not #{arguments.class}" unless arguments.is_a? Type
raise "Wrong frame type, expect Type not #{frame.class}" unless frame.is_a? Type
@for_type = type
@name = name
@binary = BinaryCode.new 0
@arguments = arguments
@frame = Parfait.object_space.get_class_by_name( :NamedList ).instance_type
@frame = frame
end
def set_instructions(inst)

View File

@ -28,7 +28,7 @@ module Parfait
def create_parfait_method( type )
raise "create_method #{type.inspect} is not a Type" unless type.is_a? Parfait::Type
type.create_method( @name , @args_type )#FIXME, @frame_type)
type.create_method( @name , @args_type , @frame_type)
end
def create_tmp