use of com.tencent.tinker.android.dex.DexException in project tinker by Tencent.
the class InstructionPromoter method visitFillArrayDataPayloadInsn.
@Override
public void visitFillArrayDataPayloadInsn(int currentAddress, int opcode, Object data, int size, int elementWidth) {
mapAddressIfNeeded(currentAddress);
this.currentPromotedAddress += 2 + 2;
switch(elementWidth) {
case 1:
{
int length = ((byte[]) data).length;
this.currentPromotedAddress += (length >> 1) + (length & 1);
break;
}
case 2:
{
this.currentPromotedAddress += ((short[]) data).length * 1;
break;
}
case 4:
{
this.currentPromotedAddress += ((int[]) data).length * 2;
break;
}
case 8:
{
this.currentPromotedAddress += ((long[]) data).length * 4;
break;
}
default:
{
throw new DexException("bogus element_width: " + Hex.u2(elementWidth));
}
}
}
use of com.tencent.tinker.android.dex.DexException in project tinker by Tencent.
the class InstructionWriter method visitFillArrayDataPayloadInsn.
public void visitFillArrayDataPayloadInsn(int currentAddress, int opcode, Object data, int size, int elementWidth) {
short opcodeUnit = (short) opcode;
codeOut.write(opcodeUnit);
short elementWidthUnit = (short) elementWidth;
codeOut.write(elementWidthUnit);
codeOut.writeInt(size);
switch(elementWidth) {
case 1:
{
codeOut.write((byte[]) data);
break;
}
case 2:
{
codeOut.write((short[]) data);
break;
}
case 4:
{
codeOut.write((int[]) data);
break;
}
case 8:
{
codeOut.write((long[]) data);
break;
}
default:
{
throw new DexException("bogus element_width: " + Hex.u2(elementWidth));
}
}
}
use of com.tencent.tinker.android.dex.DexException in project tinker by Tencent.
the class DexDataBuffer method readStringData.
public StringData readStringData() {
int off = data.position();
try {
int expectedLength = readUleb128();
String result = Mutf8.decode(this, new char[expectedLength]);
if (result.length() != expectedLength) {
throw new DexException("Declared length " + expectedLength + " doesn't match decoded length of " + result.length());
}
return new StringData(off, result);
} catch (UTFDataFormatException e) {
throw new DexException(e);
}
}
use of com.tencent.tinker.android.dex.DexException in project tinker by Tencent.
the class InstructionTransformer method transform.
public short[] transform(short[] encodedInstructions) throws DexException {
ShortArrayCodeOutput out = new ShortArrayCodeOutput(encodedInstructions.length);
InstructionPromoter ipmo = new InstructionPromoter();
InstructionWriter iw = new InstructionWriter(out, ipmo);
InstructionReader ir = new InstructionReader(new ShortArrayCodeInput(encodedInstructions));
try {
// First visit, we collect mappings from original target address to promoted target address.
ir.accept(new InstructionTransformVisitor(ipmo));
// Then do the real transformation work.
ir.accept(new InstructionTransformVisitor(iw));
} catch (EOFException e) {
throw new DexException(e);
}
return out.getArray();
}
Aggregations