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 eb4e9dc7..cd0f75c3 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 @@ -28,8 +28,6 @@ package org.jf.dexlib.Code.Analysis; -import org.jf.dexlib.Code.Format.Instruction35mi; -import org.jf.dexlib.Code.Format.Instruction3rmi; import org.jf.dexlib.Code.OdexedInvokeInline; import org.jf.dexlib.Code.OdexedInvokeVirtual; @@ -88,7 +86,7 @@ abstract class InlineMethodResolver { } return inlineMethods[methodIndex]; } - }; + } private static class InlineMethodResolver_version36 extends InlineMethodResolver { @@ -176,11 +174,7 @@ abstract class InlineMethodResolver { } private int getParameterCount(OdexedInvokeInline instruction) { - if (instruction instanceof Instruction35mi) { - return ((Instruction35mi)instruction).getRegCount(); - } else { - return ((Instruction3rmi)instruction).getRegCount(); - } + return instruction.getRegCount(); } - }; + } } diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/FiveRegisterInstruction.java b/dexlib/src/main/java/org/jf/dexlib/Code/FiveRegisterInstruction.java index 1e476890..b9ff0661 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/FiveRegisterInstruction.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/FiveRegisterInstruction.java @@ -28,8 +28,7 @@ package org.jf.dexlib.Code; -public interface FiveRegisterInstruction { - byte getRegCount(); +public interface FiveRegisterInstruction extends InvokeInstruction { byte getRegisterA(); byte getRegisterD(); byte getRegisterE(); diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction35c.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction35c.java index 1be1061f..bf2a1e5c 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction35c.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction35c.java @@ -105,7 +105,7 @@ public class Instruction35c extends InstructionWithReference implements FiveRegi return Format.Format35c; } - public byte getRegCount() { + public short getRegCount() { return regCount; } diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction35mi.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction35mi.java index 787bd07f..a68b76a4 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction35mi.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction35mi.java @@ -99,7 +99,7 @@ public class Instruction35mi extends Instruction implements FiveRegisterInstruct return Format.Format35ms; } - public byte getRegCount() { + public short getRegCount() { return regCount; } 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 582bc380..2154ef92 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 @@ -99,7 +99,7 @@ public class Instruction35ms extends Instruction implements FiveRegisterInstruct return Format.Format35ms; } - public byte getRegCount() { + public short getRegCount() { return regCount; } diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction35s.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction35s.java index 494ecccf..8a487f52 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction35s.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction35s.java @@ -105,7 +105,7 @@ public class Instruction35s extends InstructionWithReference implements FiveRegi return Format.Format35s; } - public byte getRegCount() { + public short getRegCount() { return regCount; } diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/InvokeInstruction.java b/dexlib/src/main/java/org/jf/dexlib/Code/InvokeInstruction.java new file mode 100644 index 00000000..cb0128c9 --- /dev/null +++ b/dexlib/src/main/java/org/jf/dexlib/Code/InvokeInstruction.java @@ -0,0 +1,33 @@ +/* + * [The "BSD licence"] + * Copyright (c) 2011 Ben Gruver + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.jf.dexlib.Code; + +public interface InvokeInstruction { + short getRegCount(); +} diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/OdexedInvokeInline.java b/dexlib/src/main/java/org/jf/dexlib/Code/OdexedInvokeInline.java index 1f077fa0..639d7408 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/OdexedInvokeInline.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/OdexedInvokeInline.java @@ -31,6 +31,6 @@ package org.jf.dexlib.Code; -public interface OdexedInvokeInline { +public interface OdexedInvokeInline extends InvokeInstruction { int getInlineIndex(); } diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/RegisterRangeInstruction.java b/dexlib/src/main/java/org/jf/dexlib/Code/RegisterRangeInstruction.java index c946cc89..21e37196 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/RegisterRangeInstruction.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/RegisterRangeInstruction.java @@ -28,7 +28,6 @@ package org.jf.dexlib.Code; -public interface RegisterRangeInstruction { - short getRegCount(); +public interface RegisterRangeInstruction extends InvokeInstruction { int getStartRegister(); }