Refactor out the getRegCount method into a seperate InvokeInstruction interface

This commit is contained in:
Ben Gruver 2011-11-09 16:37:14 -08:00 committed by Ben Gruver
parent f40b4e9a1e
commit 166fc9296e
9 changed files with 43 additions and 18 deletions

View File

@ -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();
}
};
}
}

View File

@ -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();

View File

@ -105,7 +105,7 @@ public class Instruction35c extends InstructionWithReference implements FiveRegi
return Format.Format35c;
}
public byte getRegCount() {
public short getRegCount() {
return regCount;
}

View File

@ -99,7 +99,7 @@ public class Instruction35mi extends Instruction implements FiveRegisterInstruct
return Format.Format35ms;
}
public byte getRegCount() {
public short getRegCount() {
return regCount;
}

View File

@ -99,7 +99,7 @@ public class Instruction35ms extends Instruction implements FiveRegisterInstruct
return Format.Format35ms;
}
public byte getRegCount() {
public short getRegCount() {
return regCount;
}

View File

@ -105,7 +105,7 @@ public class Instruction35s extends InstructionWithReference implements FiveRegi
return Format.Format35s;
}
public byte getRegCount() {
public short getRegCount() {
return regCount;
}

View File

@ -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();
}

View File

@ -31,6 +31,6 @@
package org.jf.dexlib.Code;
public interface OdexedInvokeInline {
public interface OdexedInvokeInline extends InvokeInstruction {
int getInlineIndex();
}

View File

@ -28,7 +28,6 @@
package org.jf.dexlib.Code;
public interface RegisterRangeInstruction {
short getRegCount();
public interface RegisterRangeInstruction extends InvokeInstruction {
int getStartRegister();
}