node/lib/metasm/metasm/disassemble_api.rb
# merge two instruction blocks if they form a simple chain and are adjacent
# returns true if merged
merge two instruction blocks if they form a simple chain and are adjacent
returns true if merged
merge two instruction blocks if they form a simple chain and are adjacent returns true if merged
def merge_blocks(b1, b2, allow_nonadjacent = false)
		if b1 and not b1.kind_of? InstructionBlock
			return if not b1 = block_at(b1)
		end
		if b2 and not b2.kind_of? InstructionBlock
			return if not b2 = block_at(b2)
		end
		if b1 and b2 and (allow_nonadjacent or b1.list.last.next_addr == b2.address) and
				b1.to_normal.to_a == [b2.address] and b2.from_normal.to_a.length == 1 and	
				b1.to_subfuncret.to_a == [] and b2.from_subfuncret.to_a == [] and
				b1.to_indirect.to_a == [] and b2.from_indirect.to_a == []
			b2.list.each { |di| b1.add_di di }
			b1.to_normal = b2.to_normal
			b2.list.clear
			@addrs_done.delete_if { |ad| normalize(ad[0]) == b2.address }
			true
		end
	end
def merge_blocks ( b1 , b2 , allow_nonadjacent = false ) if b1 and not b1 . kind_of? InstructionBlock return if not b1 = block_at ( b1 ) end if b2 and not b2 . kind_of? InstructionBlock return if not b2 = block_at ( b2 ) end if b1 and b2 and ( allow_nonadjacent or b1 . list . last . next_addr == b2 . address ) and b1 . to_normal . to_a == [ b2 . address ] and b2 . from_normal . to_a . length == 1 and b1 . to_subfuncret . to_a == [ ] and b2 . from_subfuncret . to_a == [ ] and b1 . to_indirect . to_a == [ ] and b2 . from_indirect . to_a == [ ] b2 . list . each { | di | b1 . add_di di } b1 . to_normal = b2 . to_normal b2 . list . clear @addrs_done . delete_if { | ad | normalize ( ad [ 0 ] ) == b2 . address } true end end
merge two instruction blocks if they form a simple chain and are adjacent
returns true if merged
merge two instruction blocks if they form a simple chain and are adjacent returns true if merged
# that handles delay_slot
b1
b2
allow_nonadjacent