Add padding if needed

git-svn-id: https://smali.googlecode.com/svn/trunk@418 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
JesusFreke@JesusFreke.com 2009-08-25 02:33:18 +00:00
parent 4da483a55b
commit 3c48a886bd
3 changed files with 16 additions and 1 deletions

View File

@ -50,10 +50,15 @@ public class ArrayDataPseudoInstruction extends Instruction {
throw new RuntimeException("There are not a whole number of " + elementWidth + " byte elements");
}
//write out padding, if necessary
if (out.getCursor() % 4 != 0) {
out.writeShort(0);
}
int elementCount = encodedValues.length / elementWidth;
out.writeByte(0x00);
out.writeShort(0x03);
out.writeByte(0x03);
out.writeShort(elementWidth);
out.writeInt(elementCount);
out.write(encodedValues);

View File

@ -50,6 +50,11 @@ public class PackedSwitchDataPseudoInstruction extends Instruction {
"The maximum number of switch elements is 65535");
}
//write out padding, if necessary
if (out.getCursor() % 4 != 0) {
out.writeShort(0);
}
out.writeByte(0x00);
out.writeByte(0x01);
out.writeShort(targets.length);

View File

@ -58,6 +58,11 @@ public class SparseSwitchDataPseudoInstruction extends Instruction {
"The maximum number of switch elements is 65535");
}
//write out padding, if necessary
if (out.getCursor() % 4 != 0) {
out.writeShort(0);
}
out.writeByte(0x00);
out.writeByte(0x02);
out.writeShort(targets.length);