From a5afca10f6e9d1d0db7c3fcafe516217699e30ad Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Thu, 12 Nov 2015 20:02:44 +0200 Subject: [PATCH] don't pass machine around, its global --- lib/elf/object_writer.rb | 9 ++++----- test/elf/test_hello.rb | 2 +- test/parfait/test_all.rb | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/elf/object_writer.rb b/lib/elf/object_writer.rb index 93b57282..e1ca5c7a 100644 --- a/lib/elf/object_writer.rb +++ b/lib/elf/object_writer.rb @@ -7,9 +7,8 @@ require_relative 'string_table_section' module Elf class ObjectWriter - def initialize(machine , target = Elf::Constants::TARGET_ARM ) + def initialize(target = Elf::Constants::TARGET_ARM ) @object = Elf::ObjectFile.new(target) - @object_machine = machine sym_strtab = Elf::StringTableSection.new(".strtab") @object.add_section sym_strtab @symbol_table = Elf::SymbolTableSection.new(".symtab", sym_strtab) @@ -18,11 +17,11 @@ module Elf @text = Elf::TextSection.new(".text") @object.add_section @text - assembler = Register::Assembler.new(@object_machine) + assembler = Register::Assembler.new(Register.machine) set_text assembler.write_as_string # for debug add labels to the block positions - @object_machine.space.classes.values.each do |clazz| + Register.machine.space.classes.values.each do |clazz| clazz.instance_methods.each do |f| f.instructions.each_label do |label| add_symbol "#{clazz.name}::#{f.name}:#{label.name}" , label.position @@ -30,7 +29,7 @@ module Elf end end - @object_machine.objects.each do |id,slot| + Register.machine.objects.each do |id,slot| if( slot.respond_to? :sof_reference_name ) label = "#{slot.sof_reference_name}" else diff --git a/test/elf/test_hello.rb b/test/elf/test_hello.rb index c064643d..01043e2b 100644 --- a/test/elf/test_hello.rb +++ b/test/elf/test_hello.rb @@ -7,7 +7,7 @@ class HelloTest < MiniTest::Test machine.parse_and_compile @string_input machine.collect machine.translate_arm - writer = Elf::ObjectWriter.new(machine) + writer = Elf::ObjectWriter.new writer.save "hello.o" end diff --git a/test/parfait/test_all.rb b/test/parfait/test_all.rb index 317d9d70..0b6bb236 100644 --- a/test/parfait/test_all.rb +++ b/test/parfait/test_all.rb @@ -1,3 +1,3 @@ -require_relative "test_layout" require_relative "test_integer" +require_relative "test_layout" require_relative "test_word"