Set the Bytes attribute multiple times, instead of using an array of bytes

git-svn-id: https://smali.googlecode.com/svn/trunk@373 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
JesusFreke@JesusFreke.com 2009-08-08 21:14:37 +00:00
parent fdf48625bb
commit 149225a27f
2 changed files with 14 additions and 16 deletions

View File

@ -45,28 +45,21 @@ public class ArrayDataMethodItem extends InstructionFormatMethodItem<ArrayDataPs
protected void setAttributes(StringTemplate template) { protected void setAttributes(StringTemplate template) {
template.setAttribute("ElementWidth", instruction.getElementWidth()); template.setAttribute("ElementWidth", instruction.getElementWidth());
template.setAttribute("Values", getValues()); setValuesAttribute(template);
} }
private List<ByteArray> getValues() { private void setValuesAttribute(StringTemplate parentTemplate) {
List<ByteArray> values = new ArrayList<ByteArray>();
Iterator<ArrayDataPseudoInstruction.ArrayElement> iterator = instruction.getElements(); Iterator<ArrayDataPseudoInstruction.ArrayElement> iterator = instruction.getElements();
while (iterator.hasNext()) { while (iterator.hasNext()) {
ArrayDataPseudoInstruction.ArrayElement element = iterator.next(); ArrayDataPseudoInstruction.ArrayElement element = iterator.next();
byte[] array = new byte[element.elementWidth];
System.arraycopy(element.buffer, element.bufferIndex, array, 0, element.elementWidth); StringTemplate template = parentTemplate.getGroup().getInstanceOf("ArrayElement");
values.add(new ByteArray(array));
for (int i=element.bufferIndex; i<element.bufferIndex + element.elementWidth; i++) {
template.setAttribute("Bytes", element.buffer[i]);
} }
return values; parentTemplate.setAttribute("Values", template);
}
public static class ByteArray
{
public final byte[] ByteArray;
public ByteArray(byte[] byteArray) {
this.ByteArray = byteArray;
} }
} }
} }

View File

@ -258,10 +258,15 @@ Format51l(Opcode, Register, Literal) ::=
ArrayData(Opcode, ElementWidth, Values) ::= ArrayData(Opcode, ElementWidth, Values) ::=
<< <<
.array-data <ElementWidth> .array-data <ElementWidth>
<Values: {<it.ByteArray; format="unsigned",separator=" ">}; separator="\n"> <Values; separator="\n">
.end array-data .end array-data
>> >>
ArrayElement(Bytes) ::=
<<
<Bytes; format="unsigned",separator=" ">
>>
PackedSwitchData(Opcode, FirstKey, Targets) ::= PackedSwitchData(Opcode, FirstKey, Targets) ::=
<< <<
.packed-switch <FirstKey> .packed-switch <FirstKey>