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
remote: git://github.com/salama/salama-arm.git
revision: b6acdc95e954aa1580faa7eaf34685625be6fdbe
revision: eaba799b1773771328842b1b3d59fb07fa712c87
specs:
salama-arm (0.3.0)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -46,7 +46,7 @@ module Register
def init method , return_type = nil
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 Label.new( method, "return")
# move the current message to new_message