more renaming of frame

This commit is contained in:
Torsten Ruger 2016-12-21 18:51:22 +02:00
parent 0040baae28
commit 93ba5543b3
13 changed files with 35 additions and 35 deletions

View File

@ -2,7 +2,7 @@ require_relative "attributed"
module Arm
# A Machines main responsibility in the framework is to instantiate Instructions
# A Machines main responsibility in the named_listwork is to instantiate Instructions
# Value functions are mapped to machines by concatenating the values class name + the methd name
# Example: IntegerValue.plus( value ) -> Machine.signed_plus (value )

View File

@ -115,7 +115,7 @@ module Register
def type_names
{ :Word => {:char_length => :Integer} ,
:List => {:indexed_length => :Integer} ,
:Message => { :next_message => :Message, :receiver => :Object, :frame => :NamedList ,
:Message => { :next_message => :Message, :receiver => :Object, :named_list => :NamedList ,
:return_address => :Integer, :return_value => :Integer,
:caller => :Message , :name => :Word , :indexed_length => :Integer },
:MetaClass => {:object => :Object},

View File

@ -99,7 +99,7 @@ module Register
# if a symbol is given, it may be one of the four objects that the vm knows.
# These are mapped to register references.
# The valid symbols (:message, :self,:frame,:new_message) are the same that are returned
# The valid symbols (:message, :self,:named_list,:new_message) are the same that are returned
# by the slots. All data (at any time) is in one of the instance variables of these four
# objects. Register defines module methods with the same names (and _reg)
def self.resolve_to_register reference

View File

@ -19,13 +19,13 @@ module Typed
# TODO, check type @method.arguments[index].type
return Register.set_slot(statement , value , :message , Parfait::Message.get_indexed(index) )
end
# or a local so it is in the frame
# or a local so it is in the named_list
index = @method.has_local( name )
return nil unless index
# TODO, check type @method.locals[index].type
frame = use_reg(:NamedList)
add_code Register.get_slot(statement , :message , :frame , frame )
return Register.set_slot(statement , value , frame , Parfait::NamedList.get_indexed(index) )
named_list = use_reg(:NamedList)
add_code Register.get_slot(statement , :message , :named_list , named_list )
return Register.set_slot(statement , value , named_list , Parfait::NamedList.get_indexed(index) )
end
end
end

View File

@ -17,7 +17,7 @@ module Typed
add_code Register.get_slot(statement , :message , Parfait::Message.get_indexed(index), ret )
return ret
end
# or a local so it is in the frame
# or a local so it is in the named_list
handle_local(statement)
end
@ -26,10 +26,10 @@ module Typed
def handle_local statement
index = @method.has_local( statement.name )
raise "must define variable '#{statement.name}' before using it" unless index
frame = use_reg :NamedList
add_code Register.get_slot(statement , :message , :frame , frame )
named_list = use_reg :NamedList
add_code Register.get_slot(statement , :message , :named_list , named_list )
ret = use_reg @method.locals_type( index )
add_code Register.get_slot(statement , frame , Parfait::NamedList.get_indexed(index), ret )
add_code Register.get_slot(statement , named_list , Parfait::NamedList.get_indexed(index), ret )
return ret
end

View File

@ -9,7 +9,7 @@
module Parfait
class Message < Object
attributes [:next_message , :receiver , :frame , :return_address ]
attributes [:next_message , :receiver , :named_list , :return_address ]
attributes [:return_value, :caller , :name ]
include Indexed
@ -17,7 +17,7 @@ module Parfait
def initialize next_m
self.next_message = next_m
self.frame = NamedList.new()
self.named_list = NamedList.new()
self.caller = nil
super()
end

View File

@ -8,10 +8,10 @@
# A Message with is arguments, and a NamedList make up the two sides of message passing:
# A Message (see details there) is created by the caller and control is transferred
# A NamedList is created by the receiver
# PS: it turns out that both messages and frames are created at compile, not run-time, and
# just constantly reused. Each message has a frame object ready and is also linked
# PS: it turns out that both messages and named_lists are created at compile, not run-time, and
# just constantly reused. Each message has a named_list object ready and is also linked
# to the next message.
# The better way to say above is that a message is *used* by the caller, and a frame by the callee.
# The better way to say above is that a message is *used* by the caller, and a named_list by the callee.
# Also at runtime Messages and NamedLists remain completely "normal" objects.
# Ie they have have type and instances and so on.*

View File

@ -2,7 +2,7 @@ module Register
# So when an object calls a method, or sends a message, this is what it sends: a Message
# A message contains the sender, return and exceptional return addresses,the arguments,
# and a slot for the frame.
# and a slot for the named_list.
# As such it is a very run-time object, deep in the machinery as it were, and does not have
# meaningful methods you could call at compile time.
@ -19,7 +19,7 @@ module Register
# but as there is a guaranteed result (be it method_missing) it does not matter to the passing
# mechanism described
# During compilation Message and frame objects are created to do type analysis
# During compilation Message and named_list objects are created to do type analysis
class Message
@ -28,10 +28,10 @@ module Register
@next_normal = normal
@next_exception = exceptional
@arguments = arguments
# a frame represents the local and temporary variables at a point in the program.
@frame = nil
# a named_list represents the local and temporary variables at a point in the program.
@named_list = nil
end
attr_reader :me, :next_normal, :next_exception, :arguments , :frame
attr_reader :me, :next_normal, :next_exception, :arguments , :named_list
#
end

View File

@ -7,11 +7,11 @@ module Register
# Four known objects exist and those correspond to subclasses:
# - the message that has been received: MessageSlot
# - the frame of the method that is executing (local variables): NamedListSlot
# - the named_list of the method that is executing (local variables): NamedListSlot
# - self as an object: SelfsSlot
# - a message that will be sent, NewMessageSlot
# additionally frame, self and return are slots in Message and NewMessage
# additionally named_list, self and return are slots in Message and NewMessage
# Slot has a lot of small subclasses
# Names for the slots avoid indexes

View File

@ -3,17 +3,17 @@ require_relative "../helper"
class TestNamedLists < MiniTest::Test
def setup
@frame = Register.machine.boot.space.first_message.frame
@type = @frame.get_type
@named_list = Register.machine.boot.space.first_message.named_list
@type = @named_list.get_type
end
def test_frame_get_type
def test_named_list_get_type
assert_equal Parfait::Type , @type.class
end
def test_frame_next_set
@frame.next_list = :next_list
assert_equal :next_list , @frame.next_list
def test_named_list_next_set
@named_list.next_list = :next_list
assert_equal :next_list , @named_list.next_list
end
end

View File

@ -60,7 +60,7 @@ class TestSpace < MiniTest::Test
all = []
while mess
all << mess
assert mess.frame
assert mess.named_list
mess = mess.next_message
end
assert_equal all.length , all.uniq.length

View File

@ -40,7 +40,7 @@ class TestAssignStatement < MiniTest::Test
check
end
def test_frame_get
def test_named_list_get
Register.machine.space.get_main.add_local(:r , :Integer)
@input = s(:statements, s(:assignment, s(:name, :r), s(:int, 5)), s(:return, s(:name, :r)))
@expect = [Label, LoadConstant, GetSlot, SetSlot, GetSlot, GetSlot, SetSlot ,
@ -48,7 +48,7 @@ class TestAssignStatement < MiniTest::Test
was = check
get = was.next(5)
assert_equal GetSlot , get.class
assert_equal 4, get.index , "Get to frame index must be offset, not #{get.index}"
assert_equal 4, get.index , "Get to named_list index must be offset, not #{get.index}"
end
def test_assign_int
@ -58,7 +58,7 @@ class TestAssignStatement < MiniTest::Test
was = check
set = was.next(3)
assert_equal SetSlot , set.class
assert_equal 4, set.index , "Set to frame index must be offset, not #{set.index}"
assert_equal 4, set.index , "Set to named_list index must be offset, not #{set.index}"
end
def test_assign_arg
@ -79,7 +79,7 @@ class TestAssignStatement < MiniTest::Test
was = check
get = was.next(1)
assert_equal GetSlot , get.class
assert_equal 10, get.index , "Get to frame index must be offset, not #{get.index}"
assert_equal 10, get.index , "Get to named_list index must be offset, not #{get.index}"
end
end
end

View File

@ -5,7 +5,7 @@ module Register
class TestFieldStatement < MiniTest::Test
include Statements
def test_field_frame
def test_field_named_list
Register.machine.space.get_main.add_local( :m , :Message)
@input = s(:statements, s(:return, s(:field_access,
s(:receiver, s(:name, :m)), s(:field, s(:name, :name)))))