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