change assembly order
first objects, then methods. methods change length, so at least this way objects stay did mean hacking the arm code (something for later)
This commit is contained in:
parent
458610b970
commit
9a2fe42167
@ -24,7 +24,14 @@ module Register
|
||||
@machine.init.set_position(at)
|
||||
at += @machine.init.byte_length
|
||||
at += 8 # thats the padding
|
||||
# want to have the methods first in the executable
|
||||
# want to have the objects first in the executable
|
||||
@machine.objects.each do | id , objekt|
|
||||
next if objekt.is_a? Register::Label # will get assembled as method.instructions
|
||||
next if objekt.is_a? Parfait::BinaryCode
|
||||
objekt.position = at
|
||||
at += objekt.padded_length
|
||||
end
|
||||
# and then everything code
|
||||
@machine.objects.each do |id , objekt|
|
||||
next unless objekt.is_a? Parfait::Method
|
||||
objekt.binary.position = at
|
||||
@ -34,13 +41,6 @@ module Register
|
||||
objekt.binary.set_length(len , 0)
|
||||
at += objekt.binary.padded_length
|
||||
end
|
||||
# and then everything else
|
||||
@machine.objects.each do | id , objekt|
|
||||
next if objekt.is_a? Register::Label # will get assembled as method.instructions
|
||||
next if objekt.is_a? Parfait::BinaryCode
|
||||
objekt.position = at
|
||||
at += objekt.padded_length
|
||||
end
|
||||
end
|
||||
|
||||
def write_as_string
|
||||
@ -64,28 +64,31 @@ module Register
|
||||
log.debug "Linked #{objekt.class}(#{objekt.object_id}) at #{objekt.position} / #{objekt.padded_length}"
|
||||
objekt.position
|
||||
end
|
||||
|
||||
# first we need to create the binary code for the methods
|
||||
@machine.objects.each do |id , objekt|
|
||||
next unless objekt.is_a? Parfait::Method
|
||||
assemble_binary_method(objekt)
|
||||
end
|
||||
|
||||
@stream = StringIO.new
|
||||
@machine.init.assemble( @stream )
|
||||
8.times do
|
||||
@stream.write_uint8(0)
|
||||
end
|
||||
|
||||
# then write the methods to file
|
||||
@machine.objects.each do |id, objekt|
|
||||
next unless objekt.is_a? Parfait::BinaryCode
|
||||
write_any( objekt )
|
||||
end
|
||||
# and then the rest of the object machine
|
||||
# then the objects , not code yet
|
||||
@machine.objects.each do | id, objekt|
|
||||
next if objekt.is_a? Parfait::BinaryCode
|
||||
next if objekt.is_a? Register::Label # ignore
|
||||
write_any( objekt )
|
||||
end
|
||||
|
||||
# then write the methods to file
|
||||
@machine.objects.each do |id, objekt|
|
||||
next unless objekt.is_a? Parfait::BinaryCode
|
||||
write_any( objekt )
|
||||
end
|
||||
log.debug "Assembled #{stream_position} bytes"
|
||||
return @stream.string
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user