mirror of
https://github.com/revanced/smali.git
synced 2025-05-09 19:04:32 +02:00
Add support for odex formats 3rms and 3rmi
This commit is contained in:
parent
2a91d72a15
commit
61277b50b3
@ -212,8 +212,7 @@ public class InstructionMethodItem<T extends Instruction> extends MethodItem {
|
|||||||
writer.write(", ");
|
writer.write(", ");
|
||||||
writeReference(writer);
|
writeReference(writer);
|
||||||
return true;
|
return true;
|
||||||
//TODO: uncomment
|
case Format3rmi:
|
||||||
/*case Format3rmi:
|
|
||||||
writeOpcode(writer);
|
writeOpcode(writer);
|
||||||
writer.write(' ');
|
writer.write(' ');
|
||||||
writeInvokeRangeRegisters(writer);
|
writeInvokeRangeRegisters(writer);
|
||||||
@ -226,7 +225,7 @@ public class InstructionMethodItem<T extends Instruction> extends MethodItem {
|
|||||||
writeInvokeRangeRegisters(writer);
|
writeInvokeRangeRegisters(writer);
|
||||||
writer.write(", ");
|
writer.write(", ");
|
||||||
writeVtableIndex(writer);
|
writeVtableIndex(writer);
|
||||||
return true;*/
|
return true;
|
||||||
}
|
}
|
||||||
assert false;
|
assert false;
|
||||||
return false;
|
return false;
|
||||||
|
@ -128,6 +128,10 @@ public abstract class DexBackedInstruction implements Instruction {
|
|||||||
return new DexBackedInstruction35mi(dexFile, opcode, instructionStartOffset);
|
return new DexBackedInstruction35mi(dexFile, opcode, instructionStartOffset);
|
||||||
case Format3rc:
|
case Format3rc:
|
||||||
return new DexBackedInstruction3rc(dexFile, opcode, instructionStartOffset);
|
return new DexBackedInstruction3rc(dexFile, opcode, instructionStartOffset);
|
||||||
|
case Format3rmi:
|
||||||
|
return new DexBackedInstruction3rmi(dexFile, opcode, instructionStartOffset);
|
||||||
|
case Format3rms:
|
||||||
|
return new DexBackedInstruction3rms(dexFile, opcode, instructionStartOffset);
|
||||||
case Format51l:
|
case Format51l:
|
||||||
return new DexBackedInstruction51l(dexFile, opcode, instructionStartOffset);
|
return new DexBackedInstruction51l(dexFile, opcode, instructionStartOffset);
|
||||||
case PackedSwitchPayload:
|
case PackedSwitchPayload:
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013, Google Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are
|
||||||
|
* met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * 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.
|
||||||
|
* * Neither the name of Google Inc. nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "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 COPYRIGHT
|
||||||
|
* OWNER OR CONTRIBUTORS 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.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
|
import org.jf.dexlib2.Opcode;
|
||||||
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
|
import org.jf.dexlib2.iface.instruction.formats.Instruction3rmi;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
public class DexBackedInstruction3rmi extends DexBackedInstruction implements Instruction3rmi {
|
||||||
|
public DexBackedInstruction3rmi(@Nonnull DexBackedDexFile dexFile,
|
||||||
|
@Nonnull Opcode opcode,
|
||||||
|
int instructionStart) {
|
||||||
|
super(dexFile, opcode, instructionStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public int getRegisterCount() {
|
||||||
|
return dexFile.readUbyte(instructionStart + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStartRegister() {
|
||||||
|
return dexFile.readUshort(instructionStart + 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInlineIndex() {
|
||||||
|
return dexFile.readUshort(instructionStart + 2);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013, Google Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are
|
||||||
|
* met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * 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.
|
||||||
|
* * Neither the name of Google Inc. nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "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 COPYRIGHT
|
||||||
|
* OWNER OR CONTRIBUTORS 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.dexlib2.dexbacked.instruction;
|
||||||
|
|
||||||
|
import org.jf.dexlib2.Opcode;
|
||||||
|
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||||
|
import org.jf.dexlib2.iface.instruction.formats.Instruction3rms;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
public class DexBackedInstruction3rms extends DexBackedInstruction implements Instruction3rms {
|
||||||
|
public DexBackedInstruction3rms(@Nonnull DexBackedDexFile dexFile,
|
||||||
|
@Nonnull Opcode opcode,
|
||||||
|
int instructionStart) {
|
||||||
|
super(dexFile, opcode, instructionStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public int getRegisterCount() {
|
||||||
|
return dexFile.readUbyte(instructionStart + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStartRegister() {
|
||||||
|
return dexFile.readUshort(instructionStart + 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getVtableIndex() {
|
||||||
|
return dexFile.readUshort(instructionStart + 2);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013, Google Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are
|
||||||
|
* met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * 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.
|
||||||
|
* * Neither the name of Google Inc. nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "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 COPYRIGHT
|
||||||
|
* OWNER OR CONTRIBUTORS 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.dexlib2.iface.instruction.formats;
|
||||||
|
|
||||||
|
import org.jf.dexlib2.iface.instruction.InlineIndexInstruction;
|
||||||
|
import org.jf.dexlib2.iface.instruction.RegisterRangeInstruction;
|
||||||
|
|
||||||
|
public interface Instruction3rmi extends RegisterRangeInstruction, InlineIndexInstruction {
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013, Google Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are
|
||||||
|
* met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * 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.
|
||||||
|
* * Neither the name of Google Inc. nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "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 COPYRIGHT
|
||||||
|
* OWNER OR CONTRIBUTORS 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.dexlib2.iface.instruction.formats;
|
||||||
|
|
||||||
|
import org.jf.dexlib2.iface.instruction.RegisterRangeInstruction;
|
||||||
|
import org.jf.dexlib2.iface.instruction.VtableIndexInstruction;
|
||||||
|
|
||||||
|
public interface Instruction3rms extends RegisterRangeInstruction, VtableIndexInstruction {
|
||||||
|
}
|
@ -111,6 +111,10 @@ public abstract class ImmutableInstruction implements Instruction {
|
|||||||
return ImmutableInstruction35ms.of((Instruction35ms)instruction);
|
return ImmutableInstruction35ms.of((Instruction35ms)instruction);
|
||||||
case Format3rc:
|
case Format3rc:
|
||||||
return ImmutableInstruction3rc.of((Instruction3rc)instruction);
|
return ImmutableInstruction3rc.of((Instruction3rc)instruction);
|
||||||
|
case Format3rmi:
|
||||||
|
return ImmutableInstruction3rmi.of((Instruction3rmi)instruction);
|
||||||
|
case Format3rms:
|
||||||
|
return ImmutableInstruction3rms.of((Instruction3rms)instruction);
|
||||||
case Format51l:
|
case Format51l:
|
||||||
return ImmutableInstruction51l.of((Instruction51l)instruction);
|
return ImmutableInstruction51l.of((Instruction51l)instruction);
|
||||||
case PackedSwitchPayload:
|
case PackedSwitchPayload:
|
||||||
|
@ -54,9 +54,9 @@ public class ImmutableInstruction3rc extends ImmutableInstruction implements Ins
|
|||||||
int registerCount,
|
int registerCount,
|
||||||
@Nonnull Reference reference) {
|
@Nonnull Reference reference) {
|
||||||
super(opcode);
|
super(opcode);
|
||||||
Preconditions.checkFormat(opcode, Format.Format3rc);
|
Preconditions.checkFormat(opcode, FORMAT);
|
||||||
this.startRegister = Preconditions.checkShortRegister(startRegister);
|
this.startRegister = Preconditions.checkShortRegister(startRegister);
|
||||||
this.registerCount = Preconditions.check3rcRegisterCount(registerCount);
|
this.registerCount = Preconditions.checkRegisterRangeCount(registerCount);
|
||||||
this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
|
this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013, Google Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are
|
||||||
|
* met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * 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.
|
||||||
|
* * Neither the name of Google Inc. nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "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 COPYRIGHT
|
||||||
|
* OWNER OR CONTRIBUTORS 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.dexlib2.immutable.instruction;
|
||||||
|
|
||||||
|
import org.jf.dexlib2.Format;
|
||||||
|
import org.jf.dexlib2.Opcode;
|
||||||
|
import org.jf.dexlib2.iface.instruction.formats.Instruction3rmi;
|
||||||
|
import org.jf.dexlib2.util.Preconditions;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
public class ImmutableInstruction3rmi extends ImmutableInstruction implements Instruction3rmi {
|
||||||
|
public static final Format FORMAT = Format.Format3rmi;
|
||||||
|
|
||||||
|
protected final int startRegister;
|
||||||
|
protected final int registerCount;
|
||||||
|
|
||||||
|
protected final int inlineIndex;
|
||||||
|
|
||||||
|
public ImmutableInstruction3rmi(@Nonnull Opcode opcode,
|
||||||
|
int startRegister,
|
||||||
|
int registerCount,
|
||||||
|
int inlineIndex) {
|
||||||
|
super(opcode);
|
||||||
|
Preconditions.checkFormat(opcode, FORMAT);
|
||||||
|
this.startRegister = Preconditions.checkShortRegister(startRegister);
|
||||||
|
this.registerCount = Preconditions.checkRegisterRangeCount(registerCount);
|
||||||
|
this.inlineIndex = Preconditions.checkInlineIndex(inlineIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ImmutableInstruction3rmi of(Instruction3rmi instruction) {
|
||||||
|
if (instruction instanceof ImmutableInstruction3rmi) {
|
||||||
|
return (ImmutableInstruction3rmi)instruction;
|
||||||
|
}
|
||||||
|
return new ImmutableInstruction3rmi(
|
||||||
|
instruction.getOpcode(),
|
||||||
|
instruction.getStartRegister(),
|
||||||
|
instruction.getRegisterCount(),
|
||||||
|
instruction.getInlineIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public int getStartRegister() { return startRegister; }
|
||||||
|
@Override public int getRegisterCount() { return registerCount; }
|
||||||
|
@Override public int getInlineIndex() { return inlineIndex; }
|
||||||
|
|
||||||
|
@Override public Format getFormat() { return FORMAT; }
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013, Google Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are
|
||||||
|
* met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * 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.
|
||||||
|
* * Neither the name of Google Inc. nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "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 COPYRIGHT
|
||||||
|
* OWNER OR CONTRIBUTORS 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.dexlib2.immutable.instruction;
|
||||||
|
|
||||||
|
import org.jf.dexlib2.Format;
|
||||||
|
import org.jf.dexlib2.Opcode;
|
||||||
|
import org.jf.dexlib2.iface.instruction.formats.Instruction3rms;
|
||||||
|
import org.jf.dexlib2.util.Preconditions;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
public class ImmutableInstruction3rms extends ImmutableInstruction implements Instruction3rms {
|
||||||
|
public static final Format FORMAT = Format.Format3rms;
|
||||||
|
|
||||||
|
protected final int startRegister;
|
||||||
|
protected final int registerCount;
|
||||||
|
|
||||||
|
protected final int vtableIndex;
|
||||||
|
|
||||||
|
public ImmutableInstruction3rms(@Nonnull Opcode opcode,
|
||||||
|
int startRegister,
|
||||||
|
int registerCount,
|
||||||
|
int vtableIndex) {
|
||||||
|
super(opcode);
|
||||||
|
Preconditions.checkFormat(opcode, FORMAT);
|
||||||
|
this.startRegister = Preconditions.checkShortRegister(startRegister);
|
||||||
|
this.registerCount = Preconditions.checkRegisterRangeCount(registerCount);
|
||||||
|
this.vtableIndex = Preconditions.checkVtableIndex(vtableIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ImmutableInstruction3rms of(Instruction3rms instruction) {
|
||||||
|
if (instruction instanceof ImmutableInstruction3rms) {
|
||||||
|
return (ImmutableInstruction3rms)instruction;
|
||||||
|
}
|
||||||
|
return new ImmutableInstruction3rms(
|
||||||
|
instruction.getOpcode(),
|
||||||
|
instruction.getStartRegister(),
|
||||||
|
instruction.getRegisterCount(),
|
||||||
|
instruction.getVtableIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public int getStartRegister() { return startRegister; }
|
||||||
|
@Override public int getRegisterCount() { return registerCount; }
|
||||||
|
@Override public int getVtableIndex() { return vtableIndex; }
|
||||||
|
|
||||||
|
@Override public Format getFormat() { return FORMAT; }
|
||||||
|
}
|
||||||
|
|
@ -130,7 +130,7 @@ public class Preconditions {
|
|||||||
return registerCount;
|
return registerCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int check3rcRegisterCount(int registerCount) {
|
public static int checkRegisterRangeCount(int registerCount) {
|
||||||
if ((registerCount & 0xFFFFFF00) != 0) {
|
if ((registerCount & 0xFFFFFF00) != 0) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
String.format("Invalid register count: %d. Must be between 0 and 255, inclusive.", registerCount));
|
String.format("Invalid register count: %d. Must be between 0 and 255, inclusive.", registerCount));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user