remove last block occurrences

fixed.
This commit is contained in:
Torsten Ruger 2015-10-25 12:03:31 +02:00
parent 471329917b
commit 0921073025
7 changed files with 26 additions and 16 deletions

View File

@ -1,6 +1,6 @@
GIT GIT
remote: git://github.com/salama/salama-arm.git remote: git://github.com/salama/salama-arm.git
revision: b6acdc95e954aa1580faa7eaf34685625be6fdbe revision: eaba799b1773771328842b1b3d59fb07fa712c87
specs: specs:
salama-arm (0.3.0) salama-arm (0.3.0)

View File

@ -24,15 +24,12 @@ module Elf
# for debug add labels to the block positions # for debug add labels to the block positions
@object_machine.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.source.blocks.each do |b| f.source.instructions.each_label do |label|
add_symbol "#{clazz.name}::#{f.name}:#{b.name}" , b.position add_symbol "#{clazz.name}::#{f.name}:#{label.name}" , label.position
end end
end end
end end
# @object_machine.space.main.blocks.each do |b|
# add_symbol "main@#{b.name}" , b.position
# end
# add_symbol "#register@#{@object_machine.space.init.name}" , @object_machine.space.init.position
@object_machine.objects.each do |id,slot| @object_machine.objects.each do |id,slot|
if( slot.respond_to? :sof_reference_name ) if( slot.respond_to? :sof_reference_name )
label = "#{slot.sof_reference_name}" label = "#{slot.sof_reference_name}"

View File

@ -32,7 +32,7 @@ module Register
end end
#need the initial jump at 0 and then functions #need the initial jump at 0 and then functions
@machine.init.set_position(at) @machine.init.set_position(at)
at += @machine.init.total_byte_length at += @machine.init.byte_length
at += 8 # thats the padding at += 8 # thats the padding
# then we make sure we really get the binary codes first # then we make sure we really get the binary codes first
@ -61,7 +61,6 @@ module Register
return try_write return try_write
rescue LinkException rescue LinkException
# knowing that we fix the problem, we hope to get away with retry. # knowing that we fix the problem, we hope to get away with retry.
puts "retry"
retry retry
end end
end end
@ -82,9 +81,7 @@ module Register
assemble_binary_method(objekt) assemble_binary_method(objekt)
end end
@stream = StringIO.new @stream = StringIO.new
@machine.init.codes.each do |code| @machine.init.assemble( @stream )
code.assemble( @stream )
end
8.times do 8.times do
@stream.write_uint8(0) @stream.write_uint8(0)
end end
@ -107,9 +104,9 @@ module Register
# and then plonk that binary data into the method.code array # and then plonk that binary data into the method.code array
def assemble_binary_method method def assemble_binary_method method
stream = StringIO.new stream = StringIO.new
puts "Method #{method.source.instructions.to_ac}" #puts "Method #{method.source.instructions.to_ac}"
begin begin
puts "assemble #{method.source.instructions}" #puts "assemble #{method.source.instructions}"
method.source.instructions.assemble_all( stream ) method.source.instructions.assemble_all( stream )
rescue => e rescue => e
puts "Assembly error #{method.name}\n#{Sof.write(method.source.instructions).to_s[0...2000]}" puts "Assembly error #{method.name}\n#{Sof.write(method.source.instructions).to_s[0...2000]}"
@ -227,7 +224,6 @@ module Register
@stream.write_uint8(0) @stream.write_uint8(0)
end end
after = stream_position after = stream_position
before - after # shut up the linter
#puts "padded #{length.to_s(16)} with #{pad.to_s(16)} stream #{before}/#{after}" #puts "padded #{length.to_s(16)} with #{pad.to_s(16)} stream #{before}/#{after}"
end end

View File

@ -106,6 +106,11 @@ module Register
position position
end end
end end
def each_label labels =[] , &block
self.next.each_label(labels , &block) if self.next
end
end end
end end

View File

@ -45,6 +45,11 @@ module Register
self.next.assemble_all(io, labels) if self.next self.next.assemble_all(io, labels) if self.next
end end
def each_label labels =[] , &block
super
self.label.each_label(labels , &block) if self.label
end
end end
class IsZero < Branch class IsZero < Branch

View File

@ -56,5 +56,12 @@ module Register
self.position = position self.position = position
self.next.set_position(position,labels) self.next.set_position(position,labels)
end end
def each_label labels =[] , &block
return if labels.include?(self)
labels << self
block.yield(self)
super
end
end end
end end

View File

@ -46,7 +46,7 @@ module Register
def init method , return_type = nil def init method , return_type = nil
set_return_type( return_type ) set_return_type( return_type )
@instructions = @current = Label.new(self, "Method_#{method.name}") @instructions = @current = Label.new(self, "#{method.for_class.name}_#{method.name}")
add_code enter = Register.save_return(self, :message , :return_address) add_code enter = Register.save_return(self, :message , :return_address)
add_code Label.new( method, "return") add_code Label.new( method, "return")
# move the current message to new_message # move the current message to new_message