From 3bfd77dff08cfa059ea230017791fca11fa08c53 Mon Sep 17 00:00:00 2001 From: Ben Gruver Date: Wed, 9 Nov 2011 15:47:31 -0800 Subject: [PATCH] Use the term VtableIndex rather than MethodIndex for invoke-*-quick instructions/formats --- .../Adaptors/Format/InstructionMethodItem.java | 2 +- .../Code/Analysis/InlineMethodResolver.java | 4 ++-- .../jf/dexlib/Code/Analysis/MethodAnalyzer.java | 8 ++++---- .../jf/dexlib/Code/Format/Instruction35ms.java | 16 ++++++++-------- .../jf/dexlib/Code/Format/Instruction3rms.java | 16 ++++++++-------- .../org/jf/dexlib/Code/OdexedInvokeVirtual.java | 2 +- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItem.java b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItem.java index b1556b33..4b0a9956 100644 --- a/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItem.java +++ b/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/InstructionMethodItem.java @@ -306,7 +306,7 @@ public class InstructionMethodItem extends MethodItem { protected void writeVtableIndex(IndentingWriter writer) throws IOException { writer.write("vtable@0x"); - writer.printUnsignedLongAsHex(((OdexedInvokeVirtual) instruction).getMethodIndex()); + writer.printUnsignedLongAsHex(((OdexedInvokeVirtual) instruction).getVtableIndex()); } protected void writeReference(IndentingWriter writer) throws IOException { diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Analysis/InlineMethodResolver.java b/dexlib/src/main/java/org/jf/dexlib/Code/Analysis/InlineMethodResolver.java index c7660708..aad4cb53 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/Analysis/InlineMethodResolver.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/Analysis/InlineMethodResolver.java @@ -81,7 +81,7 @@ abstract class InlineMethodResolver { assert analyzedInstruction.instruction instanceof OdexedInvokeVirtual; OdexedInvokeVirtual instruction = (OdexedInvokeVirtual)analyzedInstruction.instruction; - int methodIndex = instruction.getMethodIndex(); + int methodIndex = instruction.getVtableIndex(); if (methodIndex < 0 || methodIndex >= inlineMethods.length) { throw new RuntimeException("Invalid method index: " + methodIndex); @@ -146,7 +146,7 @@ abstract class InlineMethodResolver { assert analyzedInstruction.instruction instanceof OdexedInvokeVirtual; OdexedInvokeVirtual instruction = (OdexedInvokeVirtual)analyzedInstruction.instruction; - int methodIndex = instruction.getMethodIndex(); + int methodIndex = instruction.getVtableIndex(); if (methodIndex < 0 || methodIndex >= inlineMethods.length) { throw new RuntimeException("Invalid method index: " + methodIndex); diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Analysis/MethodAnalyzer.java b/dexlib/src/main/java/org/jf/dexlib/Code/Analysis/MethodAnalyzer.java index 75a371b7..232b8913 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/Analysis/MethodAnalyzer.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/Analysis/MethodAnalyzer.java @@ -3344,7 +3344,7 @@ public class MethodAnalyzer { MethodIdItem inlineMethodIdItem = inlineMethod.getMethodIdItem(); if (inlineMethodIdItem == null) { throw new ValidationException(String.format("Cannot load inline method with index %d", - instruction.getMethodIndex())); + instruction.getVtableIndex())); } Opcode deodexedOpcode = null; @@ -3382,7 +3382,7 @@ public class MethodAnalyzer { MethodIdItem inlineMethodIdItem = inlineMethod.getMethodIdItem(); if (inlineMethodIdItem == null) { throw new ValidationException(String.format("Cannot load inline method with index %d", - instruction.getMethodIndex())); + instruction.getVtableIndex())); } Opcode deodexedOpcode = null; @@ -3458,11 +3458,11 @@ public class MethodAnalyzer { if (isRange) { Instruction3rms instruction = (Instruction3rms)analyzedInstruction.instruction; - methodIndex = instruction.getMethodIndex(); + methodIndex = instruction.getVtableIndex(); objectRegister = instruction.getStartRegister(); } else { Instruction35ms instruction = (Instruction35ms)analyzedInstruction.instruction; - methodIndex = instruction.getMethodIndex(); + methodIndex = instruction.getVtableIndex(); objectRegister = instruction.getRegisterD(); } diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction35ms.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction35ms.java index 13d5ccf2..582bc380 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction35ms.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction35ms.java @@ -45,10 +45,10 @@ public class Instruction35ms extends Instruction implements FiveRegisterInstruct private byte regE; private byte regF; private byte regG; - private short methodIndex; + private short vtableIndex; public Instruction35ms(Opcode opcode, int regCount, byte regD, byte regE, byte regF, byte regG, - byte regA, int methodIndex) { + byte regA, int vtableIndex) { super(opcode); if (regCount > 5) { throw new RuntimeException("regCount cannot be greater than 5"); @@ -62,7 +62,7 @@ public class Instruction35ms extends Instruction implements FiveRegisterInstruct throw new RuntimeException("All register args must fit in 4 bits"); } - if (methodIndex >= 1 << 16) { + if (vtableIndex >= 1 << 16) { throw new RuntimeException("The method index must be less than 65536"); } @@ -72,7 +72,7 @@ public class Instruction35ms extends Instruction implements FiveRegisterInstruct this.regE = regE; this.regF = regF; this.regG = regG; - this.methodIndex = (short)methodIndex; + this.vtableIndex = (short)vtableIndex; } private Instruction35ms(Opcode opcode, byte[] buffer, int bufferIndex) { @@ -84,13 +84,13 @@ public class Instruction35ms extends Instruction implements FiveRegisterInstruct this.regE = NumberUtils.decodeHighUnsignedNibble(buffer[bufferIndex + 4]); this.regF = NumberUtils.decodeLowUnsignedNibble(buffer[bufferIndex + 5]); this.regG = NumberUtils.decodeHighUnsignedNibble(buffer[bufferIndex + 5]); - this.methodIndex = (short)NumberUtils.decodeUnsignedShort(buffer, bufferIndex + 2); + this.vtableIndex = (short)NumberUtils.decodeUnsignedShort(buffer, bufferIndex + 2); } protected void writeInstruction(AnnotatedOutput out, int currentCodeAddress) { out.writeByte(opcode.value); out.writeByte((regCount << 4) | regA); - out.writeShort(methodIndex); + out.writeShort(vtableIndex); out.writeByte((regE << 4) | regD); out.writeByte((regG << 4) | regF); } @@ -123,8 +123,8 @@ public class Instruction35ms extends Instruction implements FiveRegisterInstruct return regG; } - public int getMethodIndex() { - return methodIndex & 0xFFFF; + public int getVtableIndex() { + return vtableIndex & 0xFFFF; } private static class Factory implements Instruction.InstructionFactory { diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction3rms.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction3rms.java index 7ee0f6c7..08d8e410 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction3rms.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction3rms.java @@ -40,9 +40,9 @@ public class Instruction3rms extends Instruction implements RegisterRangeInstruc public static final Instruction.InstructionFactory Factory = new Factory(); private byte regCount; private short startReg; - private short methodIndex; + private short vtableIndex; - public Instruction3rms(Opcode opcode, short regCount, int startReg, int methodIndex) { + public Instruction3rms(Opcode opcode, short regCount, int startReg, int vtableIndex) { super(opcode); if (regCount >= 1 << 8) { @@ -59,27 +59,27 @@ public class Instruction3rms extends Instruction implements RegisterRangeInstruc throw new RuntimeException("The beginning register of the range cannot be negative"); } - if (methodIndex >= 1 << 16) { + if (vtableIndex >= 1 << 16) { throw new RuntimeException("The method index must be less than 65536"); } this.regCount = (byte)regCount; this.startReg = (short)startReg; - this.methodIndex = (short)methodIndex; + this.vtableIndex = (short)vtableIndex; } private Instruction3rms(Opcode opcode, byte[] buffer, int bufferIndex) { super(opcode); this.regCount = (byte)NumberUtils.decodeUnsignedByte(buffer[bufferIndex + 1]); - this.methodIndex = (short)NumberUtils.decodeUnsignedShort(buffer, bufferIndex + 2); + this.vtableIndex = (short)NumberUtils.decodeUnsignedShort(buffer, bufferIndex + 2); this.startReg = (short)NumberUtils.decodeUnsignedShort(buffer, bufferIndex + 4); } protected void writeInstruction(AnnotatedOutput out, int currentCodeAddress) { out.writeByte(opcode.value); out.writeByte(regCount); - out.writeShort(methodIndex); + out.writeShort(vtableIndex); out.writeShort(startReg); } @@ -95,8 +95,8 @@ public class Instruction3rms extends Instruction implements RegisterRangeInstruc return startReg & 0xFFFF; } - public int getMethodIndex() { - return methodIndex & 0xFFFF; + public int getVtableIndex() { + return vtableIndex & 0xFFFF; } private static class Factory implements Instruction.InstructionFactory { diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/OdexedInvokeVirtual.java b/dexlib/src/main/java/org/jf/dexlib/Code/OdexedInvokeVirtual.java index ea4de88c..02fd1e61 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/OdexedInvokeVirtual.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/OdexedInvokeVirtual.java @@ -29,5 +29,5 @@ package org.jf.dexlib.Code; public interface OdexedInvokeVirtual { - int getMethodIndex(); + int getVtableIndex(); }