node/lib/metasm/metasm/encode.rb
def assemble_sequence(seq, cpu)
		# an array of edata or sub-array of ambiguous edata
		# its last element is always an edata
		ary = [EncodedData.new]

		seq.each { |e|
			case e
			when Label; ary.last.add_export(e.name, ary.last.virtsize)
			when Data;  ary.last << e.encode(cpu.endianness)
			when Align, Padding
				e.fillwith = e.fillwith.encode(cpu.endianness) if e.fillwith and not e.fillwith.kind_of? EncodedData
				ary << e << EncodedData.new
			when Offset; ary << e << EncodedData.new
			when Instruction
				case i = cpu.encode_instruction(self, e)
				when Array
					case i.length
					when 0; raise EncodeError, "failed to encode #{e}"
					when 1; ary.last << i.first
					else ary << i << EncodedData.new # to solve later
					end
				else
					ary.last << i
				end
			end
		}

		edata = (ary.length > 1) ? assemble_resolve(ary) : ary.shift
		edata.fixup edata.binding
		edata
	end
# encodes an Array of source (Label/Data/Instruction etc) to an EncodedData
# resolves ambiguities using +encode_resolve+
encodes an Array of source (Label/Data/Instruction etc) to an EncodedData
resolves ambiguities using +encode_resolve+
encodes an Array of source ( Label / Data / Instruction etc ) to an EncodedData resolves ambiguities using + encode_resolve +
def assemble_sequence(seq, cpu)
		ary = [EncodedData.new]
		seq.each { |e|
			case e
			when Label; ary.last.add_export(e.name, ary.last.virtsize)
			when Data;  ary.last << e.encode(cpu.endianness)
			when Align, Padding
				e.fillwith = e.fillwith.encode(cpu.endianness) if e.fillwith and not e.fillwith.kind_of? EncodedData
				ary << e << EncodedData.new
			when Offset; ary << e << EncodedData.new
			when Instruction
				case i = cpu.encode_instruction(self, e)
				when Array
					case i.length
					when 0; raise EncodeError, "failed to encode #{e}"
					when 1; ary.last << i.first
					else ary << i << EncodedData.new 
					end
				else
					ary.last << i
				end
			end
		}
		edata = (ary.length > 1) ? assemble_resolve(ary) : ary.shift
		edata.fixup edata.binding
		edata
	end
def assemble_sequence ( seq , cpu ) ary = [ EncodedData . new ] seq . each { | e | case e when Label ; ary . last . add_export ( e . name , ary . last . virtsize ) when Data ; ary . last << e . encode ( cpu . endianness ) when Align , Padding e . fillwith = e . fillwith . encode ( cpu . endianness ) if e . fillwith and not e . fillwith . kind_of? EncodedData ary << e << EncodedData . new when Offset ; ary << e << EncodedData . new when Instruction case i = cpu . encode_instruction ( self , e ) when Array case i . length when 0 ; raise EncodeError , "failed to encode #{e}" when 1 ; ary . last << i . first else ary << i << EncodedData . new end else ary . last << i end end } edata = ( ary . length > 1 ) ? assemble_resolve ( ary ) : ary . shift edata . fixup edata . binding edata end
encodes an Array of source (Label/Data/Instruction etc) to an EncodedData
resolves ambiguities using +encode_resolve+
encodes an Array of source ( Label / Data / Instruction etc ) to an EncodedData resolves ambiguities using + encode_resolve +
# an array of edata or sub-array of ambiguous edata # its last element is always an edata # to solve later
seq
cpu