don't pass machine around, its global

This commit is contained in:
Torsten Ruger 2015-11-12 20:02:44 +02:00
parent 6f0d6d831e
commit a5afca10f6
3 changed files with 6 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -1,3 +1,3 @@
require_relative "test_layout"
require_relative "test_integer"
require_relative "test_layout"
require_relative "test_word"