fix indexing when accessing locals or args
Was missing the offset of object variables
This commit is contained in:
parent
a44b88f570
commit
ede0fe5f16
@ -28,5 +28,9 @@ module Parfait
|
|||||||
class Frame < Object
|
class Frame < Object
|
||||||
attribute :next_frame
|
attribute :next_frame
|
||||||
|
|
||||||
|
def self.offset
|
||||||
|
Space.object_space.get_class_by_name(:Frame).object_layout.object_instance_length
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -56,6 +56,10 @@ module Parfait
|
|||||||
names
|
names
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def object_instance_length
|
||||||
|
self.get_length - 2
|
||||||
|
end
|
||||||
|
|
||||||
alias :list_index :index_of
|
alias :list_index :index_of
|
||||||
# private inheritance is something to think off, we don't really want the list api exported
|
# private inheritance is something to think off, we don't really want the list api exported
|
||||||
def index_of name
|
def index_of name
|
||||||
|
@ -29,35 +29,8 @@ module Parfait
|
|||||||
get_at(index)
|
get_at(index)
|
||||||
end
|
end
|
||||||
|
|
||||||
# def __send
|
def self.offset
|
||||||
# typ = get_type_for( :receiver )
|
Space.object_space.get_class_by_name(:Message).object_layout.object_instance_length
|
||||||
# # TODO: this will obviously be recoded as case, once that is done :-)
|
end
|
||||||
# # depending on value type get method
|
|
||||||
# if( typ == Integer )
|
|
||||||
# method = Integer.get_method @method_name
|
|
||||||
# else
|
|
||||||
# if( typ != ObjectReference )
|
|
||||||
# raise "unimplemented case"
|
|
||||||
# else
|
|
||||||
# method = @receiver.get_singeton_method @method_name
|
|
||||||
# # Find the method for the given object (receiver) according to ruby dispatch rules:
|
|
||||||
# # - see if the receiver object has a (singleton) method by the name
|
|
||||||
# # - get receivers class and look for instance methods of the name
|
|
||||||
# # - go up inheritance tree
|
|
||||||
# # - start over with method_missing instead
|
|
||||||
# # -> guaranteed to end at object.method_missing
|
|
||||||
# unless method
|
|
||||||
# cl = @receiver.layout.object_class
|
|
||||||
# method = cl.get_instance_or_super_method @method_name
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# unless method
|
|
||||||
# message = Message.new( @receiver , :method_missing , [@method_name] + @args)
|
|
||||||
# message.send
|
|
||||||
# else
|
|
||||||
# method.call
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -76,7 +76,7 @@ module Parfait
|
|||||||
def get_layout()
|
def get_layout()
|
||||||
l = internal_object_get(LAYOUT_INDEX)
|
l = internal_object_get(LAYOUT_INDEX)
|
||||||
#puts "get layout for #{self.class} returns #{l.class}"
|
#puts "get layout for #{self.class} returns #{l.class}"
|
||||||
raise "No layout #{self.object_id.to_s(16)}:#{self.class} " unless l
|
raise "No layout #{self.object_id}:#{self.class} " unless l
|
||||||
return l
|
return l
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,14 +11,14 @@ module Phisol
|
|||||||
code = nil
|
code = nil
|
||||||
if( index = @method.has_arg(name))
|
if( index = @method.has_arg(name))
|
||||||
# TODO, check type @method.arguments[index].type
|
# TODO, check type @method.arguments[index].type
|
||||||
code = Register.set_slot(statement , v , :message , index )
|
code = Register.set_slot(statement , v , :message , index + Parfait::Message.offset )
|
||||||
else # or a local so it is in the frame
|
else # or a local so it is in the frame
|
||||||
index = @method.has_local( name )
|
index = @method.has_local( name )
|
||||||
if(index)
|
if(index)
|
||||||
# TODO, check type @method.locals[index].type
|
# TODO, check type @method.locals[index].type
|
||||||
frame = use_reg(:Frame)
|
frame = use_reg(:Frame)
|
||||||
@method.source.add_code Register.get_slot(statement , :message , :frame , frame )
|
@method.source.add_code Register.get_slot(statement , :message , :frame , frame )
|
||||||
code = Register.set_slot(statement , v , frame , index )
|
code = Register.set_slot(statement , v , frame , index + Parfait::Frame.offset )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if( code )
|
if( code )
|
||||||
|
@ -15,7 +15,7 @@ module Phisol
|
|||||||
# either an argument, so it's stored in message
|
# either an argument, so it's stored in message
|
||||||
if( index = @method.has_arg(name))
|
if( index = @method.has_arg(name))
|
||||||
ret = use_reg @method.arguments[index].type
|
ret = use_reg @method.arguments[index].type
|
||||||
@method.source.add_code Register.get_slot(statement , :message , index , ret )
|
@method.source.add_code Register.get_slot(statement , :message , index + Parfait::Message.offset , ret )
|
||||||
return ret
|
return ret
|
||||||
else # or a local so it is in the frame
|
else # or a local so it is in the frame
|
||||||
index = @method.has_local( name )
|
index = @method.has_local( name )
|
||||||
@ -23,7 +23,7 @@ module Phisol
|
|||||||
frame = use_reg :Frame
|
frame = use_reg :Frame
|
||||||
@method.source.add_code Register.get_slot(statement , :message , :frame , frame )
|
@method.source.add_code Register.get_slot(statement , :message , :frame , frame )
|
||||||
ret = use_reg @method.locals[index].type
|
ret = use_reg @method.locals[index].type
|
||||||
@method.source.add_code Register.get_slot(statement , frame , index , ret )
|
@method.source.add_code Register.get_slot(statement , frame , index + Parfait::Frame.offset , ret )
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user