rename frame to named_list to be shared soon
This commit is contained in:
parent
b242f9e223
commit
0040baae28
@ -30,7 +30,7 @@ module Melon
|
|||||||
|
|
||||||
def make_locals(body)
|
def make_locals(body)
|
||||||
locals = LocalsCollector.new.collect(body)
|
locals = LocalsCollector.new.collect(body)
|
||||||
type = Parfait::Space.object_space.get_class_by_name(:Frame ).instance_type
|
type = Parfait::Space.object_space.get_class_by_name(:NamedList ).instance_type
|
||||||
locals.each do |name , local_type |
|
locals.each do |name , local_type |
|
||||||
type = type.add_instance_variable( name , local_type )
|
type = type.add_instance_variable( name , local_type )
|
||||||
end
|
end
|
||||||
|
@ -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, :frame => :Frame ,
|
:Message => { :next_message => :Message, :receiver => :Object, :frame => :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},
|
||||||
@ -124,7 +124,7 @@ module Register
|
|||||||
:Kernel => {}, #fix, kernel is a class, but should be a module
|
:Kernel => {}, #fix, kernel is a class, but should be a module
|
||||||
:BinaryCode => {:char_length => :Integer} ,
|
:BinaryCode => {:char_length => :Integer} ,
|
||||||
:Space => {:classes => :Dictionary , :types => :Dictionary , :first_message => :Message},
|
:Space => {:classes => :Dictionary , :types => :Dictionary , :first_message => :Message},
|
||||||
:Frame => {:next_frame => :Frame, :indexed_length => :Integer},
|
:NamedList => {:next_list => :NamedList, :indexed_length => :Integer},
|
||||||
:Type => {:object_class => :Class, :instance_methods => :List , :indexed_length => :Integer} ,
|
:Type => {:object_class => :Class, :instance_methods => :List , :indexed_length => :Integer} ,
|
||||||
:Class => {:instance_methods => :List, :instance_type => :Type, :name => :Word,
|
:Class => {:instance_methods => :List, :instance_type => :Type, :name => :Word,
|
||||||
:super_class_name => :Word , :instance_names => :List },
|
:super_class_name => :Word , :instance_names => :List },
|
||||||
|
@ -23,9 +23,9 @@ module Typed
|
|||||||
index = @method.has_local( name )
|
index = @method.has_local( name )
|
||||||
return nil unless index
|
return nil unless index
|
||||||
# TODO, check type @method.locals[index].type
|
# TODO, check type @method.locals[index].type
|
||||||
frame = use_reg(:Frame)
|
frame = use_reg(:NamedList)
|
||||||
add_code Register.get_slot(statement , :message , :frame , frame )
|
add_code Register.get_slot(statement , :message , :frame , frame )
|
||||||
return Register.set_slot(statement , value , frame , Parfait::Frame.get_indexed(index) )
|
return Register.set_slot(statement , value , frame , Parfait::NamedList.get_indexed(index) )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -26,10 +26,10 @@ module Typed
|
|||||||
def handle_local statement
|
def handle_local statement
|
||||||
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
|
||||||
frame = use_reg :Frame
|
frame = use_reg :NamedList
|
||||||
add_code Register.get_slot(statement , :message , :frame , frame )
|
add_code Register.get_slot(statement , :message , :frame , frame )
|
||||||
ret = use_reg @method.locals_type( index )
|
ret = use_reg @method.locals_type( index )
|
||||||
add_code Register.get_slot(statement , frame , Parfait::Frame.get_indexed(index), ret )
|
add_code Register.get_slot(statement , frame , Parfait::NamedList.get_indexed(index), ret )
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -14,6 +14,6 @@ require_relative "parfait/meta_class"
|
|||||||
require_relative "parfait/dictionary"
|
require_relative "parfait/dictionary"
|
||||||
require_relative "parfait/type"
|
require_relative "parfait/type"
|
||||||
require_relative "parfait/message"
|
require_relative "parfait/message"
|
||||||
require_relative "parfait/frame"
|
require_relative "parfait/named_list"
|
||||||
require_relative "parfait/space"
|
require_relative "parfait/space"
|
||||||
require_relative "parfait/symbol_adapter"
|
require_relative "parfait/symbol_adapter"
|
||||||
|
@ -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.frame = Frame.new()
|
self.frame = NamedList.new()
|
||||||
self.caller = nil
|
self.caller = nil
|
||||||
super()
|
super()
|
||||||
end
|
end
|
||||||
|
@ -1,29 +1,30 @@
|
|||||||
|
|
||||||
# A Frame is set up by functions that use local variables or temporary variables
|
# A NamedList is for local variables arguments when calling methods.
|
||||||
# in fact temporary variables are local variables named by the system
|
# Also temporary variables, which are local variables named by the system
|
||||||
|
|
||||||
# It allows for access to those variables basically
|
# The items are named (and typed) by the objects type instance. In effect the
|
||||||
|
# variables are like instance variables
|
||||||
|
|
||||||
# A Message and a Frame make up the two sides of message passing:
|
# 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 Message (see details there) is created by the caller and control is transferred
|
||||||
# A Frame is created by the receiver
|
# A NamedList is created by the receiver
|
||||||
# PS: it turns out that both messages and frames are created at compile, not run-time, and
|
# 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
|
# just constantly reused. Each message has a frame object ready and is also linked
|
||||||
# to the next message.
|
# 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 frame by the callee.
|
||||||
|
|
||||||
# Also at runtime Messages and Frames remain completely "normal" objects.
|
# Also at runtime Messages and NamedLists remain completely "normal" objects.
|
||||||
# Ie they have have type and instances and so on.*
|
# Ie they have have type and instances and so on.*
|
||||||
# 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.
|
||||||
#
|
#
|
||||||
# *Alas the type for each call instance is unique.
|
# *Alas the type for each call instance is unique.
|
||||||
#
|
#
|
||||||
module Parfait
|
module Parfait
|
||||||
class Frame < Object
|
class NamedList < Object
|
||||||
attribute :next_frame
|
attribute :next_list
|
||||||
|
|
||||||
include Indexed
|
include Indexed
|
||||||
self.offset(2) # 1 == the next_frame attributes above + type. (indexed_length gets added)
|
self.offset(2) # 1 == the next_list attributes above + type. (indexed_length gets added)
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -12,7 +12,7 @@ module Register
|
|||||||
|
|
||||||
# The caller creates the Message and passes control to the receiver's method
|
# The caller creates the Message and passes control to the receiver's method
|
||||||
|
|
||||||
# The receiver create a new Frame to hold local and temporary variables and (later) creates
|
# The receiver create a new NamedList to hold local and temporary variables and (later) creates
|
||||||
# default values for arguments that were not passed
|
# default values for arguments that were not passed
|
||||||
|
|
||||||
# How the actual finding of the method takes place (acording to the ruby rules) is not simple,
|
# How the actual finding of the method takes place (acording to the ruby rules) is not simple,
|
||||||
|
@ -7,7 +7,7 @@ module Register
|
|||||||
|
|
||||||
# Four known objects exist and those correspond to subclasses:
|
# Four known objects exist and those correspond to subclasses:
|
||||||
# - the message that has been received: MessageSlot
|
# - the message that has been received: MessageSlot
|
||||||
# - the frame of the method that is executing (local variables): FrameSlot
|
# - the frame of the method that is executing (local variables): NamedListSlot
|
||||||
# - self as an object: SelfsSlot
|
# - self as an object: SelfsSlot
|
||||||
# - a message that will be sent, NewMessageSlot
|
# - a message that will be sent, NewMessageSlot
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "test_attributes"
|
require_relative "test_attributes"
|
||||||
require_relative "test_class"
|
require_relative "test_class"
|
||||||
require_relative "test_dictionary"
|
require_relative "test_dictionary"
|
||||||
require_relative "test_frame"
|
require_relative "test_named_list"
|
||||||
require_relative "test_list"
|
require_relative "test_list"
|
||||||
require_relative "test_message"
|
require_relative "test_message"
|
||||||
require_relative "test_meta_class"
|
require_relative "test_meta_class"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
require_relative "../helper"
|
require_relative "../helper"
|
||||||
|
|
||||||
class TestFrames < MiniTest::Test
|
class TestNamedLists < MiniTest::Test
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@frame = Register.machine.boot.space.first_message.frame
|
@frame = Register.machine.boot.space.first_message.frame
|
||||||
@ -12,8 +12,8 @@ class TestFrames < MiniTest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_frame_next_set
|
def test_frame_next_set
|
||||||
@frame.next_frame = :next_frame
|
@frame.next_list = :next_list
|
||||||
assert_equal :next_frame , @frame.next_frame
|
assert_equal :next_list , @frame.next_list
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
@ -6,7 +6,7 @@ class TestSpace < MiniTest::Test
|
|||||||
@machine = Register.machine.boot
|
@machine = Register.machine.boot
|
||||||
end
|
end
|
||||||
def classes
|
def classes
|
||||||
[:Kernel,:Word,:List,:Message,:Frame,:Type,:Object,:Class,:Dictionary,:TypedMethod , :Integer]
|
[:Kernel,:Word,:List,:Message,:NamedList,:Type,:Object,:Class,:Dictionary,:TypedMethod , :Integer]
|
||||||
end
|
end
|
||||||
def test_booted
|
def test_booted
|
||||||
assert_equal true , @machine.booted
|
assert_equal true , @machine.booted
|
||||||
|
Loading…
Reference in New Issue
Block a user