This commit is contained in:
Torsten Ruger 2014-09-18 17:05:22 +03:00
parent f80df69262
commit c32ca84861

View File

@ -41,7 +41,6 @@ module Register
link link
@stream = StringIO.new @stream = StringIO.new
mid , main = @objects.find{|k,objekt| objekt.is_a?(Virtual::CompiledMethod) and (objekt.name == :__init__ )} mid , main = @objects.find{|k,objekt| objekt.is_a?(Virtual::CompiledMethod) and (objekt.name == :__init__ )}
puts "function found #{main.name}"
initial_jump = RegisterMachine.instance.b( main ) initial_jump = RegisterMachine.instance.b( main )
initial_jump.set_position( 0) initial_jump.set_position( 0)
initial_jump.assemble( @stream ) initial_jump.assemble( @stream )
@ -54,15 +53,15 @@ module Register
assemble_object( objekt ) assemble_object( objekt )
end end
rescue LinkException => e rescue LinkException => e
puts "coought #{e}" # knowing that we fix the problem, we hope to get away with retry.
retry retry
end end
puts "Assembled #{@stream.length.to_s(16)}" puts "Assembled 0x#{@stream.length.to_s(16)}/#{@stream.length} bytes"
return @stream.string return @stream.string
end end
def assemble_object obj def assemble_object obj
puts "Assemble #{obj.class}(#{obj.object_id}) at stream #{(@stream.length).to_s(16)} pos:#{obj.position.to_s(16)} , len:#{obj.mem_length}" #puts "Assemble #{obj.class}(#{obj.object_id}) at stream #{(@stream.length).to_s(16)} pos:#{obj.position.to_s(16)} , len:#{obj.mem_length}"
raise "Assemble #{obj.class} at #{@stream.length.to_s(16)} not #{obj.position.to_s(16)}" if @stream.length != obj.position raise "Assemble #{obj.class} at #{@stream.length.to_s(16)} not #{obj.position.to_s(16)}" if @stream.length != obj.position
clazz = obj.class.name.split("::").last clazz = obj.class.name.split("::").last
send("assemble_#{clazz}".to_sym , obj) send("assemble_#{clazz}".to_sym , obj)
@ -225,7 +224,7 @@ module Register
pad.times do pad.times do
@stream.write_uint8(0) @stream.write_uint8(0)
end end
puts "padded #{length} with #{pad} stream pos #{@stream.length.to_s(16)}" #puts "padded #{length} with #{pad} stream pos #{@stream.length.to_s(16)}"
end end
end end