mostly renames from the type change
also making setters as explicit set_xx methods
This commit is contained in:
parent
f4b3c645e5
commit
b5f04ec718
@ -8,7 +8,7 @@ module Register
|
||||
def __init__ context
|
||||
compiler = Typed::MethodCompiler.new.create_method(:Kernel,:__init__ )
|
||||
new_start = Register.label("__init__ start" , "__init__" )
|
||||
compiler.method.instructions = new_start
|
||||
compiler.method.set_instructions( new_start)
|
||||
compiler.set_current new_start
|
||||
|
||||
space = Parfait::Space.object_space
|
||||
|
@ -21,7 +21,7 @@ module Register
|
||||
type = object.get_type
|
||||
keep(type , depth + 1)
|
||||
return if object.is_a? Symbol
|
||||
type.instance_names.each do |name|
|
||||
type.names.each do |name|
|
||||
#puts "Keep #{name} for #{object.class}"
|
||||
inst = object.get_instance_variable name
|
||||
keep(inst , depth + 1)
|
||||
|
@ -88,7 +88,7 @@ module Register
|
||||
clazz = Parfait::Space.object_space.get_class_by_name(real_name)
|
||||
raise "Class name not given #{real_name}" unless clazz
|
||||
index = clazz.instance_type.variable_index( instance_name )
|
||||
raise "Instance name=#{instance_name} not found on #{real_name}" unless index.is_a?(Numeric)
|
||||
raise "Instance name=#{instance_name} not found on #{real_name}:#{clazz.instance_type}" unless index.is_a?(Numeric)
|
||||
return index # the type word is at index 0, but type is a list and starts at 1 == type
|
||||
end
|
||||
|
||||
|
@ -133,7 +133,7 @@ module Typed
|
||||
def init_method
|
||||
source = "_init_method"
|
||||
name = "#{method.for_type.name}.#{method.name}"
|
||||
@method.instructions = Register.label(source, name)
|
||||
@method.set_instructions( Register.label(source, name))
|
||||
@current = enter = method.instructions
|
||||
add_label( source, "return #{name}")
|
||||
#load the return address into pc, affecting return. (other cpus have commands for this, but not arm)
|
||||
|
@ -30,7 +30,7 @@ module Melon
|
||||
def test_compile_class
|
||||
Compiler.compile "class TestIvar < Object ; def meth; @ivar;end; end"
|
||||
itest = Parfait::Space.object_space.get_class_by_name(:TestIvar)
|
||||
assert itest.instance_type.instance_names.include?(:ivar) , itest.instance_type.instance_names.inspect
|
||||
assert itest.instance_type.names.include?(:ivar) , itest.instance_type.names.inspect
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -10,18 +10,15 @@ class TestPositioning < MiniTest::Test
|
||||
end
|
||||
def test_list1
|
||||
list = Parfait.new_list([1])
|
||||
list.set_type( Parfait::Type.new Object)
|
||||
assert_equal 32 , list.padded_length
|
||||
end
|
||||
def test_list5
|
||||
list = Parfait.new_list([1,2,3,4,5])
|
||||
list.set_type( Parfait::Type.new Object)
|
||||
assert_equal 32 , list.padded_length
|
||||
end
|
||||
def test_type
|
||||
type = Parfait::Type.new Object
|
||||
type.set_type( Parfait::Type.new Object)
|
||||
type.push 5
|
||||
type = Parfait::Type.new Parfait::Space.object_space.get_class_by_name(:Object)
|
||||
type.set_type( type )
|
||||
assert_equal 32 , type.padded_length
|
||||
end
|
||||
def test_word
|
||||
|
@ -11,7 +11,7 @@ class TestMessage < MiniTest::Test
|
||||
end
|
||||
|
||||
def test_attribute_set
|
||||
@mess.receiver = 55
|
||||
@mess.set_receiver( 55)
|
||||
assert_equal 55 , @mess.receiver
|
||||
end
|
||||
|
||||
@ -19,4 +19,7 @@ class TestMessage < MiniTest::Test
|
||||
assert_equal 9 , @mess.get_type.variable_index(:arguments)
|
||||
end
|
||||
|
||||
def test_next
|
||||
assert @mess.next_message
|
||||
end
|
||||
end
|
||||
|
@ -9,7 +9,7 @@ class TestNamedLists < MiniTest::Test
|
||||
|
||||
def test_named_list_get_type
|
||||
assert_equal Parfait::Type , @type.class
|
||||
assert @type.instance_names
|
||||
assert @type.names
|
||||
assert @named_list.get_instance_variables
|
||||
end
|
||||
|
||||
|
@ -4,7 +4,7 @@ class TestMethod < MiniTest::Test
|
||||
|
||||
def setup
|
||||
obj = Register.machine.space.get_class_by_name(:Object).instance_type
|
||||
args = Parfait::Type.for_hash( obj , { bar: :Integer , foo: :Type})
|
||||
args = Parfait::Type.for_hash( obj.object_class , { bar: :Integer , foo: :Type})
|
||||
@method = ::Parfait::TypedMethod.new obj , :meth , args
|
||||
@method.add_local :local_bar , :Integer
|
||||
@method.add_local :local_foo , :Type
|
||||
@ -20,7 +20,7 @@ class TestMethod < MiniTest::Test
|
||||
|
||||
def test_arg1
|
||||
assert_equal 2 , @method.arguments_length , @method.arguments.inspect
|
||||
assert_equal Symbol , @method.arguments.first.class
|
||||
assert_equal Symbol , @method.arguments.names.first.class
|
||||
assert_equal :bar , @method.argument_name(1)
|
||||
end
|
||||
|
||||
@ -57,7 +57,7 @@ class TestMethod < MiniTest::Test
|
||||
|
||||
def test_local1
|
||||
assert_equal 2 , @method.locals_length , @method.locals.inspect
|
||||
assert_equal Symbol , @method.locals.first.class
|
||||
assert_equal Symbol , @method.locals.names.first.class
|
||||
assert_equal :local_bar , @method.locals_name(1)
|
||||
end
|
||||
|
||||
|
@ -21,7 +21,7 @@ class TypeMessages < MiniTest::Test
|
||||
end
|
||||
|
||||
def test_type_methods
|
||||
assert_equal 3 , @mess.get_type.get_type.variable_index(:instance_methods)
|
||||
assert_equal 5 , @mess.get_type.get_type.variable_index(:instance_methods)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -16,8 +16,8 @@ class TypeApi < MiniTest::Test
|
||||
assert_equal Parfait::Class , oc.class
|
||||
type = oc.instance_type
|
||||
assert_equal Parfait::Type , type.class
|
||||
assert_equal 1 , type.instance_names.get_length , type.instance_names.inspect
|
||||
assert_equal type.first , :type
|
||||
assert_equal 1 , type.names.get_length , type.names.inspect
|
||||
assert_equal type.names.first , :type
|
||||
end
|
||||
|
||||
def test_class_space
|
||||
@ -25,20 +25,22 @@ class TypeApi < MiniTest::Test
|
||||
assert_equal Parfait::Space , space.class
|
||||
type = space.get_type
|
||||
assert_equal Parfait::Type , type.class
|
||||
assert_equal 4 , type.instance_names.get_length
|
||||
assert_equal 4 , type.names.get_length
|
||||
assert_equal type.object_class.class , Parfait::Class
|
||||
assert_equal type.object_class.name , :Space
|
||||
end
|
||||
|
||||
def test_add_name
|
||||
@type.add_instance_variable( :boo , :Object)
|
||||
t = @type.add_instance_variable( :boo , :Object)
|
||||
assert t
|
||||
t
|
||||
end
|
||||
|
||||
def test_added_name_length
|
||||
type = test_add_name
|
||||
assert_equal 4 , type.get_length , type.inspect
|
||||
assert_equal :type , type.get(1)
|
||||
assert_equal :boo , type.get(3)
|
||||
assert_equal 2 , type.names.get_length , type.inspect
|
||||
assert_equal :type , type.names.get(1)
|
||||
assert_equal :boo , type.names.get(2)
|
||||
end
|
||||
|
||||
def test_added_name_index
|
||||
@ -61,16 +63,26 @@ class TypeApi < MiniTest::Test
|
||||
|
||||
def test_added_names
|
||||
type = test_add_name
|
||||
assert_equal :type , type.instance_names.get(1)
|
||||
assert_equal :boo , type.instance_names.get(2)
|
||||
assert_equal 2 , type.instance_names.get_length
|
||||
assert_equal :type , type.names.get(1)
|
||||
assert_equal :boo , type.names.get(2)
|
||||
assert_equal 2 , type.names.get_length
|
||||
end
|
||||
|
||||
def test_each
|
||||
def test_each_name
|
||||
type = test_add_name
|
||||
assert_equal 4 , type.get_length
|
||||
counter = [ :boo , :Object , :type , :Type]
|
||||
type.each do |item|
|
||||
assert_equal 2 , type.get_length
|
||||
counter = [ :boo , :type ]
|
||||
type.names.each do |item|
|
||||
assert_equal item , counter.delete(item)
|
||||
end
|
||||
assert counter.empty? , counter.inspect
|
||||
end
|
||||
|
||||
def test_each_type
|
||||
type = test_add_name
|
||||
assert_equal 2 , type.get_length
|
||||
counter = [ :Object , :Type]
|
||||
type.types.each do |item|
|
||||
assert_equal item , counter.delete(item)
|
||||
end
|
||||
assert counter.empty? , counter.inspect
|
||||
|
Loading…
Reference in New Issue
Block a user