rename locals from type to role in message
This commit is contained in:
parent
0e99ff33ae
commit
ed12108425
@ -115,7 +115,7 @@ module Register
|
|||||||
def type_names
|
def type_names
|
||||||
{ :Word => {:char_length => :Integer} ,
|
{ :Word => {:char_length => :Integer} ,
|
||||||
:List => {:indexed_length => :Integer} ,
|
:List => {:indexed_length => :Integer} ,
|
||||||
:Message => { :next_message => :Message, :receiver => :Object, :named_list => :NamedList ,
|
:Message => { :next_message => :Message, :receiver => :Object, :locals => :NamedList ,
|
||||||
:return_address => :Integer, :return_value => :Integer,
|
:return_address => :Integer, :return_value => :Integer,
|
||||||
:caller => :Message , :name => :Word , :indexed_length => :Integer },
|
:caller => :Message , :name => :Word , :indexed_length => :Integer },
|
||||||
:MetaClass => {:object => :Object},
|
:MetaClass => {:object => :Object},
|
||||||
|
@ -99,7 +99,7 @@ module Register
|
|||||||
|
|
||||||
# if a symbol is given, it may be one of the four objects that the vm knows.
|
# if a symbol is given, it may be one of the four objects that the vm knows.
|
||||||
# These are mapped to register references.
|
# These are mapped to register references.
|
||||||
# The valid symbols (:message, :self,:named_list,:new_message) are the same that are returned
|
# The valid symbols (:message, :self,:locals,: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
|
# 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)
|
# objects. Register defines module methods with the same names (and _reg)
|
||||||
def self.resolve_to_register reference
|
def self.resolve_to_register reference
|
||||||
|
@ -24,7 +24,7 @@ module Typed
|
|||||||
return nil unless index
|
return nil unless index
|
||||||
# TODO, check type @method.locals[index].type
|
# TODO, check type @method.locals[index].type
|
||||||
named_list = use_reg(:NamedList)
|
named_list = use_reg(:NamedList)
|
||||||
add_code Register.get_slot(statement , :message , :named_list , named_list )
|
add_code Register.get_slot(statement , :message , :locals , named_list )
|
||||||
return Register.set_slot(statement , value , named_list , index )
|
return Register.set_slot(statement , value , named_list , index )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -27,7 +27,7 @@ module Typed
|
|||||||
index = @method.has_local( statement.name )
|
index = @method.has_local( statement.name )
|
||||||
raise "must define variable '#{statement.name}' before using it" unless index
|
raise "must define variable '#{statement.name}' before using it" unless index
|
||||||
named_list = use_reg :NamedList
|
named_list = use_reg :NamedList
|
||||||
add_code Register.get_slot(statement , :message , :named_list , named_list )
|
add_code Register.get_slot(statement , :message , :locals , named_list )
|
||||||
ret = use_reg @method.locals_type( index )
|
ret = use_reg @method.locals_type( index )
|
||||||
add_code Register.get_slot(statement , named_list , index, ret )
|
add_code Register.get_slot(statement , named_list , index, ret )
|
||||||
return ret
|
return ret
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
module Parfait
|
module Parfait
|
||||||
class Message < Object
|
class Message < Object
|
||||||
attributes [:next_message , :receiver , :named_list , :return_address ]
|
attributes [:next_message , :receiver , :locals , :return_address ]
|
||||||
attributes [:return_value, :caller , :name ]
|
attributes [:return_value, :caller , :name ]
|
||||||
|
|
||||||
include Indexed
|
include Indexed
|
||||||
@ -17,7 +17,7 @@ module Parfait
|
|||||||
|
|
||||||
def initialize next_m
|
def initialize next_m
|
||||||
self.next_message = next_m
|
self.next_message = next_m
|
||||||
self.named_list = NamedList.new()
|
self.locals = NamedList.new()
|
||||||
self.caller = nil
|
self.caller = nil
|
||||||
super()
|
super()
|
||||||
end
|
end
|
||||||
|
@ -31,7 +31,7 @@ module Register
|
|||||||
# a named_list represents the local and temporary variables at a point in the program.
|
# a named_list represents the local and temporary variables at a point in the program.
|
||||||
@named_list = nil
|
@named_list = nil
|
||||||
end
|
end
|
||||||
attr_reader :me, :next_normal, :next_exception, :arguments , :named_list
|
attr_reader :me, :next_normal, :next_exception, :arguments , :locals
|
||||||
|
|
||||||
#
|
#
|
||||||
end
|
end
|
||||||
|
@ -3,7 +3,7 @@ require_relative "../helper"
|
|||||||
class TestNamedLists < MiniTest::Test
|
class TestNamedLists < MiniTest::Test
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@named_list = Register.machine.boot.space.first_message.named_list
|
@named_list = Register.machine.boot.space.first_message.locals
|
||||||
@type = @named_list.get_type
|
@type = @named_list.get_type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class TestSpace < MiniTest::Test
|
|||||||
all = []
|
all = []
|
||||||
while mess
|
while mess
|
||||||
all << mess
|
all << mess
|
||||||
assert mess.named_list
|
assert mess.locals
|
||||||
mess = mess.next_message
|
mess = mess.next_message
|
||||||
end
|
end
|
||||||
assert_equal all.length , all.uniq.length
|
assert_equal all.length , all.uniq.length
|
||||||
|
Loading…
Reference in New Issue
Block a user