diff --git a/lib/parfait/frame.rb b/lib/parfait/frame.rb index 489e6b0b..ab8cb7ad 100644 --- a/lib/parfait/frame.rb +++ b/lib/parfait/frame.rb @@ -28,5 +28,9 @@ module Parfait class Frame < Object attribute :next_frame + def self.offset + Space.object_space.get_class_by_name(:Frame).object_layout.object_instance_length + end + end end diff --git a/lib/parfait/layout.rb b/lib/parfait/layout.rb index 01ceb8a3..91977eec 100644 --- a/lib/parfait/layout.rb +++ b/lib/parfait/layout.rb @@ -56,6 +56,10 @@ module Parfait names end + def object_instance_length + self.get_length - 2 + end + alias :list_index :index_of # private inheritance is something to think off, we don't really want the list api exported def index_of name diff --git a/lib/parfait/message.rb b/lib/parfait/message.rb index ac9ac0e6..aba80e20 100644 --- a/lib/parfait/message.rb +++ b/lib/parfait/message.rb @@ -29,35 +29,8 @@ module Parfait get_at(index) end - # def __send - # typ = get_type_for( :receiver ) - # # TODO: this will obviously be recoded as case, once that is done :-) - # # 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 + def self.offset + Space.object_space.get_class_by_name(:Message).object_layout.object_instance_length + end end end diff --git a/lib/parfait/object.rb b/lib/parfait/object.rb index 3b238c60..05e462c0 100644 --- a/lib/parfait/object.rb +++ b/lib/parfait/object.rb @@ -76,7 +76,7 @@ module Parfait def get_layout() l = internal_object_get(LAYOUT_INDEX) #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 end diff --git a/lib/phisol/compiler/assignment.rb b/lib/phisol/compiler/assignment.rb index e2951914..0b3ecf71 100644 --- a/lib/phisol/compiler/assignment.rb +++ b/lib/phisol/compiler/assignment.rb @@ -11,14 +11,14 @@ module Phisol code = nil if( index = @method.has_arg(name)) # 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 index = @method.has_local( name ) if(index) # TODO, check type @method.locals[index].type frame = use_reg(: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 if( code ) diff --git a/lib/phisol/compiler/name_expression.rb b/lib/phisol/compiler/name_expression.rb index 89d18b7c..5f6bcf27 100644 --- a/lib/phisol/compiler/name_expression.rb +++ b/lib/phisol/compiler/name_expression.rb @@ -15,7 +15,7 @@ module Phisol # either an argument, so it's stored in message if( index = @method.has_arg(name)) 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 else # or a local so it is in the frame index = @method.has_local( name ) @@ -23,7 +23,7 @@ module Phisol frame = use_reg :Frame @method.source.add_code Register.get_slot(statement , :message , :frame , frame ) 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 end end