it actually assembles again
This commit is contained in:
parent
0122585b3b
commit
f8688cbe17
@ -22,9 +22,9 @@ module Elf
|
||||
set_text assembler.assemble
|
||||
|
||||
# for debug add labels to the block positions
|
||||
space.classes.values.each do |clazz|
|
||||
@object_machine.space.classes.values.each do |clazz|
|
||||
clazz.instance_methods.each do |f|
|
||||
f.blocks.each do |b|
|
||||
f.info.blocks.each do |b|
|
||||
add_symbol "#{clazz.name}::#{f.name}@#{b.name}" , b.position
|
||||
end
|
||||
end
|
||||
|
@ -157,11 +157,20 @@ module Register
|
||||
end
|
||||
puts "layout length=#{layout.get_length.to_s(16)} mem_len=#{layout.word_length.to_s(16)}"
|
||||
l = layout.get_length
|
||||
if( object.is_a? Parfait::List)
|
||||
object.each do |inst|
|
||||
write_ref_for(inst)
|
||||
end
|
||||
l += object.get_length
|
||||
end
|
||||
pad_after( l * 4)
|
||||
object.position
|
||||
end
|
||||
|
||||
def assemble_List array
|
||||
assemble_object array
|
||||
return
|
||||
|
||||
type = type_word(array)
|
||||
@stream.write_uint32( type )
|
||||
write_ref_for(array.layout[:names]) #ref
|
||||
@ -177,7 +186,7 @@ module Register
|
||||
end
|
||||
def assemble_Dictionary hash
|
||||
# so here we can be sure to have _identical_ keys/values arrays
|
||||
assemble_object( hash , [ hash.keys , hash.values ] )
|
||||
assemble_object( hash )
|
||||
end
|
||||
|
||||
def assemble_Space(space)
|
||||
@ -196,7 +205,8 @@ module Register
|
||||
end
|
||||
|
||||
def assemble_Method(method)
|
||||
raise "no"
|
||||
assemble_object(method)
|
||||
return
|
||||
count = method.info.blocks.inject(0) { |c , block| c += block.word_length }
|
||||
word = (count+7) / 32 # all object are multiple of 8 words (7 for header)
|
||||
raise "Method too long, splitting not implemented #{method.name}/#{count}" if word > 15
|
||||
@ -245,7 +255,12 @@ module Register
|
||||
# write means we write the resulting address straight into the assembler stream
|
||||
# object means the object of which we write the address
|
||||
def write_ref_for object
|
||||
@stream.write_sint32 object.position
|
||||
if object.nil?
|
||||
pos = 0
|
||||
else
|
||||
pos = object.position
|
||||
end
|
||||
@stream.write_sint32 pos
|
||||
end
|
||||
|
||||
# pad_after is always in bytes and pads (writes 0's) up to the next 8 word boundary
|
||||
|
@ -37,6 +37,8 @@ module Virtual
|
||||
end
|
||||
class Symbol
|
||||
include Positioned
|
||||
include Padding
|
||||
|
||||
def init_layout; end
|
||||
def has_layout?
|
||||
true
|
||||
@ -45,7 +47,7 @@ class Symbol
|
||||
Virtual.machine.class_mappings[:Word].object_layout
|
||||
end
|
||||
def word_length
|
||||
to_s.length
|
||||
padded to_s.length
|
||||
end
|
||||
# not the prettiest addition to the game, but it wasn't me who decided symbols are frozen in 2.x
|
||||
def cache_positions
|
||||
|
Loading…
Reference in New Issue
Block a user