From 884bf23e5f3aaa4b91358076e377112c1222eef5 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Thu, 15 Dec 2016 17:57:45 +0200 Subject: [PATCH] fix elf test --- lib/arm/instructions/call_instruction.rb | 2 +- lib/arm/instructions/logic_instruction.rb | 4 ++-- lib/register/boot.rb | 3 ++- lib/register/machine.rb | 4 ++-- lib/typed/parfait/typed_method.rb | 2 +- test/elf/test_hello.rb | 7 +++++-- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/arm/instructions/call_instruction.rb b/lib/arm/instructions/call_instruction.rb index 50e6ed02..901bec57 100644 --- a/lib/arm/instructions/call_instruction.rb +++ b/lib/arm/instructions/call_instruction.rb @@ -48,7 +48,7 @@ module Arm # relative addressing for jumps/calls # but because of the arm "theoretical" 3- stage pipeline, # we have to subtract 2 words (fetch/decode) - arg = arg.position - self.position - 8 + arg = @first.position - self.position - 8 when Parfait::TypedMethod # But, for methods, this happens to be the size of the object header, # so there it balances out, but not blocks diff --git a/lib/arm/instructions/logic_instruction.rb b/lib/arm/instructions/logic_instruction.rb index 21bd4203..3683380e 100644 --- a/lib/arm/instructions/logic_instruction.rb +++ b/lib/arm/instructions/logic_instruction.rb @@ -49,7 +49,7 @@ module Arm val |= instruction_code val |= condition_code io.write_uint32 val - assemble_extra + assemble_extra(io) end def result @@ -104,7 +104,7 @@ module Arm end # by now we have the extra add so assemble that - def assemble_extra + def assemble_extra(io) return unless @extra if(@extra == 1) # unles things have changed and then we add a noop (to keep the length same) @extra = ArmMachine.mov( :r1 , :r1 ) diff --git a/lib/register/boot.rb b/lib/register/boot.rb index bba54b77..404942b2 100644 --- a/lib/register/boot.rb +++ b/lib/register/boot.rb @@ -74,8 +74,9 @@ module Register cl = object_with_type Parfait::Class cl.instance_type = @types[name] @types[name].object_class = cl + @types[name].instance_methods = object_with_type Parfait::List cl.instance_methods = object_with_type Parfait::List -# puts "instance_methods is #{cl.instance_methods.class}" + #puts "instance_methods is #{cl.instance_methods.class}" cl.name = name classes[name] = cl end diff --git a/lib/register/machine.rb b/lib/register/machine.rb index 30ce343d..2c276f2c 100644 --- a/lib/register/machine.rb +++ b/lib/register/machine.rb @@ -27,8 +27,8 @@ module Register def translate_arm translator = Arm::Translator.new methods = [] - @space.classes.values.each do |c| - c.instance_methods.each do |f| + self.space.types.each do |hash , t| + t.instance_methods.each do |f| methods << f end end diff --git a/lib/typed/parfait/typed_method.rb b/lib/typed/parfait/typed_method.rb index 1e247bb1..a9ada113 100644 --- a/lib/typed/parfait/typed_method.rb +++ b/lib/typed/parfait/typed_method.rb @@ -90,7 +90,7 @@ module Parfait end def inspect - "#{self.for_class.name}:#{name}(#{arguments.inspect})" + "#{self.for_type.object_class.name}:#{name}(#{arguments.inspect})" end end diff --git a/test/elf/test_hello.rb b/test/elf/test_hello.rb index e587853d..31e48c4a 100644 --- a/test/elf/test_hello.rb +++ b/test/elf/test_hello.rb @@ -13,8 +13,11 @@ class HelloTest < MiniTest::Test end def test_string_put - @input = s(:statements, s(:class, :Object, s(:derives, nil), s(:statements, s(:function, :Integer, s(:name, :main), s(:parameters), s(:statements, s(:return, s(:call, s(:name, :putstring), s(:arguments), s(:receiver, s(:string, "Hello again\\n"))))))))) + @input = s(:statements, s(:class, :Object, s(:derives, nil), + s(:statements, s(:function, :Integer, s(:name, :main), s(:parameters), + s(:statements, s(:return, s(:call, s(:name, :putstring), s(:arguments), + s(:receiver, s(:string, "Hello again\\n"))))))))) #FIXME: some more assembly tests need to get to the bottom of this one -# check + check end end