correctly linking frames and messages
This commit is contained in:
parent
31635d9747
commit
8674c322c4
@ -21,8 +21,9 @@
|
|||||||
# Which resolves the dichotomy of objects on the stack or heap. Sama sama.
|
# Which resolves the dichotomy of objects on the stack or heap. Sama sama.
|
||||||
|
|
||||||
module Parfait
|
module Parfait
|
||||||
class Frame < List
|
class Frame < Object
|
||||||
def initialize
|
def initialize next_f
|
||||||
|
@next_frame = next_f
|
||||||
super()
|
super()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
module Parfait
|
module Parfait
|
||||||
class Message < Object
|
class Message < Object
|
||||||
|
|
||||||
|
def initialize next_m
|
||||||
|
@next_message = next_m
|
||||||
|
super()
|
||||||
|
end
|
||||||
|
|
||||||
def get_type_for(name)
|
def get_type_for(name)
|
||||||
index = @layout.get_index(name)
|
index = @layout.get_index(name)
|
||||||
get_at(index)
|
get_at(index)
|
||||||
|
@ -29,7 +29,7 @@ module Parfait
|
|||||||
@locals = List.new
|
@locals = List.new
|
||||||
@tmps = List.new
|
@tmps = List.new
|
||||||
end
|
end
|
||||||
attr_reader :name , :arg_names , :for_class , :code
|
attr_reader :name , :arg_names , :for_class , :code , :locals , :tmps
|
||||||
|
|
||||||
|
|
||||||
# determine whether this method has a variable by the given name
|
# determine whether this method has a variable by the given name
|
||||||
|
@ -29,21 +29,18 @@ module Parfait
|
|||||||
@classes = Parfait::Dictionary.new_object
|
@classes = Parfait::Dictionary.new_object
|
||||||
@syscall_message = nil # a hack sto store the message during syscall
|
@syscall_message = nil # a hack sto store the message during syscall
|
||||||
end
|
end
|
||||||
attr_reader :classes , :frames, :messages, :next_message , :next_frame
|
attr_reader :classes , :next_message , :next_frame
|
||||||
|
|
||||||
# need a two phase init for the object space (and generally parfait) because the space
|
# need a two phase init for the object space (and generally parfait) because the space
|
||||||
# is an interconnected graph, so not everthing is ready
|
# is an interconnected graph, so not everthing is ready
|
||||||
def late_init
|
def late_init
|
||||||
@frames = List.new_object
|
|
||||||
@messages = List.new_object
|
|
||||||
counter = 0
|
counter = 0
|
||||||
while( counter < 5)
|
@next_message = Message.new(nil)
|
||||||
@frames.push Frame.new_object
|
@next_frame = Frame.new(nil)
|
||||||
@messages.push Message.new_object
|
5.times do |i|
|
||||||
counter = counter + 1
|
@next_message = Message.new @next_message
|
||||||
|
@next_frame = Frame.new @next_frame
|
||||||
end
|
end
|
||||||
@next_message = @messages.first
|
|
||||||
@next_frame = @frames.first
|
|
||||||
init_layout
|
init_layout
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -34,16 +34,19 @@ module Register
|
|||||||
# move the spave to it's register (mov instruction gets the address of the object)
|
# move the spave to it's register (mov instruction gets the address of the object)
|
||||||
new_codes = [ LoadConstant.new( Parfait::Space.object_space , space_tmp )]
|
new_codes = [ LoadConstant.new( Parfait::Space.object_space , space_tmp )]
|
||||||
# find index in the space where to grab frame/message
|
# find index in the space where to grab frame/message
|
||||||
ind = Parfait::Space.object_space.get_layout().index_of( kind )
|
space_index = Parfait::Space.object_space.get_layout().index_of( kind )
|
||||||
raise "index not found for #{kind}.#{kind.class}" unless ind
|
raise "index not found for #{kind}.#{kind.class}" unless space_index
|
||||||
# load the frame/message from space by index
|
# load the frame/message from space by index
|
||||||
new_codes << GetSlot.new( space_tmp , ind , RegisterReference.frame_reg )
|
new_codes << GetSlot.new( space_tmp , space_index , RegisterReference.frame_reg )
|
||||||
# a temporary place to store the new frame
|
# a temporary place to store the new frame
|
||||||
frame_tmp = space_tmp.next_reg_use
|
frame_tmp = space_tmp.next_reg_use
|
||||||
# get the next_frame
|
# get the next_frame
|
||||||
new_codes << GetSlot.new( RegisterReference.frame_reg , 2 , frame_tmp) # 2 index of next_frame
|
from = Parfait::Space.object_space.send( kind )
|
||||||
|
kind_index = from.get_layout().index_of( kind )
|
||||||
|
raise "index not found for #{kind}.#{kind.class}" unless kind_index
|
||||||
|
new_codes << GetSlot.new( RegisterReference.frame_reg , kind_index , frame_tmp) # 2 index of next_frame
|
||||||
# save next frame into space
|
# save next frame into space
|
||||||
new_codes << SetSlot.new( frame_tmp , space_tmp , ind)
|
new_codes << SetSlot.new( frame_tmp , space_tmp , space_index)
|
||||||
block.replace(code , new_codes )
|
block.replace(code , new_codes )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -25,11 +25,11 @@ module Virtual
|
|||||||
value_classes = values.collect { |cl| @space.create_class(cl,nil) }
|
value_classes = values.collect { |cl| @space.create_class(cl,nil) }
|
||||||
layouts = { :Word => [] ,
|
layouts = { :Word => [] ,
|
||||||
:List => [] ,
|
:List => [] ,
|
||||||
:Message => [],
|
:Message => [:next_message],
|
||||||
:MetaClass => [],
|
:MetaClass => [],
|
||||||
:BinaryCode => [],
|
:BinaryCode => [],
|
||||||
:Space => [:classes ,:frames ,:messages ,:next_message ,:next_frame, :syscall_message],
|
:Space => [:classes ,:next_message ,:next_frame, :syscall_message],
|
||||||
:Frame => [:locals , :tmps ],
|
:Frame => [:next_frame ],
|
||||||
:Layout => [:object_class] ,
|
:Layout => [:object_class] ,
|
||||||
:Class => [:object_layout ],
|
:Class => [:object_layout ],
|
||||||
:Dictionary => [:keys , :values ] ,
|
:Dictionary => [:keys , :values ] ,
|
||||||
|
Loading…
Reference in New Issue
Block a user