mirror of
https://github.com/revanced/smali.git
synced 2025-05-29 12:20:11 +02:00
Add basic support for ODEX instructions
This commit is contained in:
parent
dd22a795d8
commit
d4702a45a7
@ -601,6 +601,9 @@ public class MutableMethodImplementation implements MethodImplementation {
|
|||||||
case Format22c:
|
case Format22c:
|
||||||
setInstruction(location, newBuilderInstruction22c((Instruction22c) instruction));
|
setInstruction(location, newBuilderInstruction22c((Instruction22c) instruction));
|
||||||
return;
|
return;
|
||||||
|
case Format22cs:
|
||||||
|
setInstruction(location, newBuilderInstruction22cs((Instruction22cs) instruction));
|
||||||
|
return;
|
||||||
case Format22s:
|
case Format22s:
|
||||||
setInstruction(location, newBuilderInstruction22s((Instruction22s) instruction));
|
setInstruction(location, newBuilderInstruction22s((Instruction22s) instruction));
|
||||||
return;
|
return;
|
||||||
@ -636,9 +639,21 @@ public class MutableMethodImplementation implements MethodImplementation {
|
|||||||
case Format35c:
|
case Format35c:
|
||||||
setInstruction(location, newBuilderInstruction35c((Instruction35c) instruction));
|
setInstruction(location, newBuilderInstruction35c((Instruction35c) instruction));
|
||||||
return;
|
return;
|
||||||
|
case Format35mi:
|
||||||
|
setInstruction(location, newBuilderInstruction35mi((Instruction35mi) instruction));
|
||||||
|
return;
|
||||||
|
case Format35ms:
|
||||||
|
setInstruction(location, newBuilderInstruction35ms((Instruction35ms) instruction));
|
||||||
|
return;
|
||||||
case Format3rc:
|
case Format3rc:
|
||||||
setInstruction(location, newBuilderInstruction3rc((Instruction3rc)instruction));
|
setInstruction(location, newBuilderInstruction3rc((Instruction3rc)instruction));
|
||||||
return;
|
return;
|
||||||
|
case Format3rmi:
|
||||||
|
setInstruction(location, newBuilderInstruction3rmi((Instruction3rmi)instruction));
|
||||||
|
return;
|
||||||
|
case Format3rms:
|
||||||
|
setInstruction(location, newBuilderInstruction3rms((Instruction3rms)instruction));
|
||||||
|
return;
|
||||||
case Format51l:
|
case Format51l:
|
||||||
setInstruction(location, newBuilderInstruction51l((Instruction51l)instruction));
|
setInstruction(location, newBuilderInstruction51l((Instruction51l)instruction));
|
||||||
return;
|
return;
|
||||||
@ -770,6 +785,15 @@ public class MutableMethodImplementation implements MethodImplementation {
|
|||||||
instruction.getReference());
|
instruction.getReference());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private BuilderInstruction22cs newBuilderInstruction22cs(@Nonnull Instruction22cs instruction) {
|
||||||
|
return new BuilderInstruction22cs(
|
||||||
|
instruction.getOpcode(),
|
||||||
|
instruction.getRegisterA(),
|
||||||
|
instruction.getRegisterB(),
|
||||||
|
instruction.getFieldOffset());
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private BuilderInstruction22s newBuilderInstruction22s(@Nonnull Instruction22s instruction) {
|
private BuilderInstruction22s newBuilderInstruction22s(@Nonnull Instruction22s instruction) {
|
||||||
return new BuilderInstruction22s(
|
return new BuilderInstruction22s(
|
||||||
@ -868,6 +892,32 @@ public class MutableMethodImplementation implements MethodImplementation {
|
|||||||
instruction.getReference());
|
instruction.getReference());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private BuilderInstruction35mi newBuilderInstruction35mi(@Nonnull Instruction35mi instruction) {
|
||||||
|
return new BuilderInstruction35mi(
|
||||||
|
instruction.getOpcode(),
|
||||||
|
instruction.getRegisterCount(),
|
||||||
|
instruction.getRegisterC(),
|
||||||
|
instruction.getRegisterD(),
|
||||||
|
instruction.getRegisterE(),
|
||||||
|
instruction.getRegisterF(),
|
||||||
|
instruction.getRegisterG(),
|
||||||
|
instruction.getInlineIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private BuilderInstruction35ms newBuilderInstruction35ms(@Nonnull Instruction35ms instruction) {
|
||||||
|
return new BuilderInstruction35ms(
|
||||||
|
instruction.getOpcode(),
|
||||||
|
instruction.getRegisterCount(),
|
||||||
|
instruction.getRegisterC(),
|
||||||
|
instruction.getRegisterD(),
|
||||||
|
instruction.getRegisterE(),
|
||||||
|
instruction.getRegisterF(),
|
||||||
|
instruction.getRegisterG(),
|
||||||
|
instruction.getVtableIndex());
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private BuilderInstruction3rc newBuilderInstruction3rc(@Nonnull Instruction3rc instruction) {
|
private BuilderInstruction3rc newBuilderInstruction3rc(@Nonnull Instruction3rc instruction) {
|
||||||
return new BuilderInstruction3rc(
|
return new BuilderInstruction3rc(
|
||||||
@ -877,6 +927,24 @@ public class MutableMethodImplementation implements MethodImplementation {
|
|||||||
instruction.getReference());
|
instruction.getReference());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private BuilderInstruction3rmi newBuilderInstruction3rmi(@Nonnull Instruction3rmi instruction) {
|
||||||
|
return new BuilderInstruction3rmi(
|
||||||
|
instruction.getOpcode(),
|
||||||
|
instruction.getStartRegister(),
|
||||||
|
instruction.getRegisterCount(),
|
||||||
|
instruction.getInlineIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private BuilderInstruction3rms newBuilderInstruction3rms(@Nonnull Instruction3rms instruction) {
|
||||||
|
return new BuilderInstruction3rms(
|
||||||
|
instruction.getOpcode(),
|
||||||
|
instruction.getStartRegister(),
|
||||||
|
instruction.getRegisterCount(),
|
||||||
|
instruction.getVtableIndex());
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private BuilderInstruction51l newBuilderInstruction51l(@Nonnull Instruction51l instruction) {
|
private BuilderInstruction51l newBuilderInstruction51l(@Nonnull Instruction51l instruction) {
|
||||||
return new BuilderInstruction51l(
|
return new BuilderInstruction51l(
|
||||||
|
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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.builder.instruction;
|
||||||
|
|
||||||
|
import org.jf.dexlib2.Format;
|
||||||
|
import org.jf.dexlib2.Opcode;
|
||||||
|
import org.jf.dexlib2.builder.BuilderInstruction;
|
||||||
|
import org.jf.dexlib2.iface.instruction.formats.Instruction22c;
|
||||||
|
import org.jf.dexlib2.iface.instruction.formats.Instruction22cs;
|
||||||
|
import org.jf.dexlib2.iface.reference.Reference;
|
||||||
|
import org.jf.dexlib2.util.Preconditions;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
public class BuilderInstruction22cs extends BuilderInstruction implements Instruction22cs {
|
||||||
|
public static final Format FORMAT = Format.Format22cs;
|
||||||
|
|
||||||
|
protected final int registerA;
|
||||||
|
protected final int registerB;
|
||||||
|
protected final int fieldOffset;
|
||||||
|
|
||||||
|
public BuilderInstruction22cs(@Nonnull Opcode opcode,
|
||||||
|
int registerA,
|
||||||
|
int registerB,
|
||||||
|
int fieldOffset) {
|
||||||
|
super(opcode);
|
||||||
|
this.registerA = Preconditions.checkNibbleRegister(registerA);
|
||||||
|
this.registerB = Preconditions.checkNibbleRegister(registerB);
|
||||||
|
this.fieldOffset = fieldOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public int getRegisterA() { return registerA; }
|
||||||
|
@Override public int getRegisterB() { return registerB; }
|
||||||
|
@Override public int getFieldOffset() { return fieldOffset; }
|
||||||
|
@Override public Format getFormat() { return FORMAT; }
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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.builder.instruction;
|
||||||
|
|
||||||
|
import org.jf.dexlib2.Format;
|
||||||
|
import org.jf.dexlib2.Opcode;
|
||||||
|
import org.jf.dexlib2.builder.BuilderInstruction;
|
||||||
|
import org.jf.dexlib2.iface.instruction.formats.Instruction35mi;
|
||||||
|
import org.jf.dexlib2.util.Preconditions;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
public class BuilderInstruction35mi extends BuilderInstruction implements Instruction35mi {
|
||||||
|
public static final Format FORMAT = Format.Format35mi;
|
||||||
|
|
||||||
|
protected final int registerCount;
|
||||||
|
protected final int registerC;
|
||||||
|
protected final int registerD;
|
||||||
|
protected final int registerE;
|
||||||
|
protected final int registerF;
|
||||||
|
protected final int registerG;
|
||||||
|
protected final int inlineIndex;
|
||||||
|
|
||||||
|
public BuilderInstruction35mi(@Nonnull Opcode opcode,
|
||||||
|
int registerCount,
|
||||||
|
int registerC,
|
||||||
|
int registerD,
|
||||||
|
int registerE,
|
||||||
|
int registerF,
|
||||||
|
int registerG,
|
||||||
|
int inlineIndex) {
|
||||||
|
super(opcode);
|
||||||
|
this.registerCount = Preconditions.check35cAnd45ccRegisterCount(registerCount);
|
||||||
|
this.registerC = (registerCount>0) ? Preconditions.checkNibbleRegister(registerC) : 0;
|
||||||
|
this.registerD = (registerCount>1) ? Preconditions.checkNibbleRegister(registerD) : 0;
|
||||||
|
this.registerE = (registerCount>2) ? Preconditions.checkNibbleRegister(registerE) : 0;
|
||||||
|
this.registerF = (registerCount>3) ? Preconditions.checkNibbleRegister(registerF) : 0;
|
||||||
|
this.registerG = (registerCount>4) ? Preconditions.checkNibbleRegister(registerG) : 0;
|
||||||
|
this.inlineIndex = inlineIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public int getRegisterCount() { return registerCount; }
|
||||||
|
@Override public int getRegisterC() { return registerC; }
|
||||||
|
@Override public int getRegisterD() { return registerD; }
|
||||||
|
@Override public int getRegisterE() { return registerE; }
|
||||||
|
@Override public int getRegisterF() { return registerF; }
|
||||||
|
@Override public int getRegisterG() { return registerG; }
|
||||||
|
@Override public int getInlineIndex() { return inlineIndex; }
|
||||||
|
@Override public Format getFormat() { return FORMAT; }
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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.builder.instruction;
|
||||||
|
|
||||||
|
import org.jf.dexlib2.Format;
|
||||||
|
import org.jf.dexlib2.Opcode;
|
||||||
|
import org.jf.dexlib2.builder.BuilderInstruction;
|
||||||
|
import org.jf.dexlib2.iface.instruction.formats.Instruction35ms;
|
||||||
|
import org.jf.dexlib2.util.Preconditions;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
public class BuilderInstruction35ms extends BuilderInstruction implements Instruction35ms {
|
||||||
|
public static final Format FORMAT = Format.Format35ms;
|
||||||
|
|
||||||
|
protected final int registerCount;
|
||||||
|
protected final int registerC;
|
||||||
|
protected final int registerD;
|
||||||
|
protected final int registerE;
|
||||||
|
protected final int registerF;
|
||||||
|
protected final int registerG;
|
||||||
|
protected final int vtableIndex;
|
||||||
|
|
||||||
|
public BuilderInstruction35ms(@Nonnull Opcode opcode,
|
||||||
|
int registerCount,
|
||||||
|
int registerC,
|
||||||
|
int registerD,
|
||||||
|
int registerE,
|
||||||
|
int registerF,
|
||||||
|
int registerG,
|
||||||
|
int vtableIndex) {
|
||||||
|
super(opcode);
|
||||||
|
this.registerCount = Preconditions.check35cAnd45ccRegisterCount(registerCount);
|
||||||
|
this.registerC = (registerCount>0) ? Preconditions.checkNibbleRegister(registerC) : 0;
|
||||||
|
this.registerD = (registerCount>1) ? Preconditions.checkNibbleRegister(registerD) : 0;
|
||||||
|
this.registerE = (registerCount>2) ? Preconditions.checkNibbleRegister(registerE) : 0;
|
||||||
|
this.registerF = (registerCount>3) ? Preconditions.checkNibbleRegister(registerF) : 0;
|
||||||
|
this.registerG = (registerCount>4) ? Preconditions.checkNibbleRegister(registerG) : 0;
|
||||||
|
this.vtableIndex = vtableIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public int getRegisterCount() { return registerCount; }
|
||||||
|
@Override public int getRegisterC() { return registerC; }
|
||||||
|
@Override public int getRegisterD() { return registerD; }
|
||||||
|
@Override public int getRegisterE() { return registerE; }
|
||||||
|
@Override public int getRegisterF() { return registerF; }
|
||||||
|
@Override public int getRegisterG() { return registerG; }
|
||||||
|
@Override public int getVtableIndex() { return vtableIndex; }
|
||||||
|
@Override public Format getFormat() { return FORMAT; }
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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.builder.instruction;
|
||||||
|
|
||||||
|
import org.jf.dexlib2.Format;
|
||||||
|
import org.jf.dexlib2.Opcode;
|
||||||
|
import org.jf.dexlib2.builder.BuilderInstruction;
|
||||||
|
import org.jf.dexlib2.iface.instruction.formats.Instruction3rmi;
|
||||||
|
import org.jf.dexlib2.iface.instruction.formats.Instruction3rms;
|
||||||
|
import org.jf.dexlib2.util.Preconditions;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
public class BuilderInstruction3rmi extends BuilderInstruction implements Instruction3rmi {
|
||||||
|
public static final Format FORMAT = Format.Format3rmi;
|
||||||
|
|
||||||
|
protected final int startRegister;
|
||||||
|
protected final int registerCount;
|
||||||
|
protected final int inlineIndex;
|
||||||
|
|
||||||
|
public BuilderInstruction3rmi(@Nonnull Opcode opcode,
|
||||||
|
int startRegister,
|
||||||
|
int registerCount,
|
||||||
|
int inlineIndex) {
|
||||||
|
super(opcode);
|
||||||
|
this.startRegister = Preconditions.checkShortRegister(startRegister);
|
||||||
|
this.registerCount = Preconditions.checkRegisterRangeCount(registerCount);
|
||||||
|
this.inlineIndex = inlineIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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,66 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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.builder.instruction;
|
||||||
|
|
||||||
|
import org.jf.dexlib2.Format;
|
||||||
|
import org.jf.dexlib2.Opcode;
|
||||||
|
import org.jf.dexlib2.builder.BuilderInstruction;
|
||||||
|
import org.jf.dexlib2.iface.instruction.formats.Instruction3rc;
|
||||||
|
import org.jf.dexlib2.iface.instruction.formats.Instruction3rms;
|
||||||
|
import org.jf.dexlib2.iface.reference.Reference;
|
||||||
|
import org.jf.dexlib2.util.Preconditions;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
public class BuilderInstruction3rms extends BuilderInstruction implements Instruction3rms {
|
||||||
|
public static final Format FORMAT = Format.Format3rms;
|
||||||
|
|
||||||
|
protected final int startRegister;
|
||||||
|
protected final int registerCount;
|
||||||
|
protected final int vtableIndex;
|
||||||
|
|
||||||
|
public BuilderInstruction3rms(@Nonnull Opcode opcode,
|
||||||
|
int startRegister,
|
||||||
|
int registerCount,
|
||||||
|
int vtableIndex) {
|
||||||
|
super(opcode);
|
||||||
|
this.startRegister = Preconditions.checkShortRegister(startRegister);
|
||||||
|
this.registerCount = Preconditions.checkRegisterRangeCount(registerCount);
|
||||||
|
this.vtableIndex = vtableIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public int getStartRegister() { return startRegister; }
|
||||||
|
@Override public int getRegisterCount() { return registerCount; }
|
||||||
|
@Override public int getVtableIndex() { return vtableIndex; }
|
||||||
|
@Override public Format getFormat() { return FORMAT; }
|
||||||
|
}
|
||||||
|
|
@ -1017,6 +1017,9 @@ public abstract class DexWriter<
|
|||||||
case Format22c:
|
case Format22c:
|
||||||
instructionWriter.write((Instruction22c)instruction);
|
instructionWriter.write((Instruction22c)instruction);
|
||||||
break;
|
break;
|
||||||
|
case Format22cs:
|
||||||
|
instructionWriter.write((Instruction22cs)instruction);
|
||||||
|
break;
|
||||||
case Format22s:
|
case Format22s:
|
||||||
instructionWriter.write((Instruction22s)instruction);
|
instructionWriter.write((Instruction22s)instruction);
|
||||||
break;
|
break;
|
||||||
@ -1047,9 +1050,21 @@ public abstract class DexWriter<
|
|||||||
case Format35c:
|
case Format35c:
|
||||||
instructionWriter.write((Instruction35c)instruction);
|
instructionWriter.write((Instruction35c)instruction);
|
||||||
break;
|
break;
|
||||||
|
case Format35mi:
|
||||||
|
instructionWriter.write((Instruction35mi)instruction);
|
||||||
|
break;
|
||||||
|
case Format35ms:
|
||||||
|
instructionWriter.write((Instruction35ms)instruction);
|
||||||
|
break;
|
||||||
case Format3rc:
|
case Format3rc:
|
||||||
instructionWriter.write((Instruction3rc)instruction);
|
instructionWriter.write((Instruction3rc)instruction);
|
||||||
break;
|
break;
|
||||||
|
case Format3rmi:
|
||||||
|
instructionWriter.write((Instruction3rmi)instruction);
|
||||||
|
break;
|
||||||
|
case Format3rms:
|
||||||
|
instructionWriter.write((Instruction3rms)instruction);
|
||||||
|
break;
|
||||||
case Format45cc:
|
case Format45cc:
|
||||||
instructionWriter.write((Instruction45cc)instruction);
|
instructionWriter.write((Instruction45cc)instruction);
|
||||||
break;
|
break;
|
||||||
|
@ -239,6 +239,16 @@ public class InstructionWriter<StringRef extends StringReference, TypeRef extend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void write(@Nonnull Instruction22cs instruction) {
|
||||||
|
try {
|
||||||
|
writer.write(getOpcodeValue(instruction.getOpcode()));
|
||||||
|
writer.write(packNibbles(instruction.getRegisterA(), instruction.getRegisterB()));
|
||||||
|
writer.writeUshort(instruction.getFieldOffset());
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void write(@Nonnull Instruction22s instruction) {
|
public void write(@Nonnull Instruction22s instruction) {
|
||||||
try {
|
try {
|
||||||
writer.write(getOpcodeValue(instruction.getOpcode()));
|
writer.write(getOpcodeValue(instruction.getOpcode()));
|
||||||
@ -343,6 +353,30 @@ public class InstructionWriter<StringRef extends StringReference, TypeRef extend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void write(@Nonnull Instruction35mi instruction) {
|
||||||
|
try {
|
||||||
|
writer.write(getOpcodeValue(instruction.getOpcode()));
|
||||||
|
writer.write(packNibbles(instruction.getRegisterG(), instruction.getRegisterCount()));
|
||||||
|
writer.writeUshort(instruction.getInlineIndex());
|
||||||
|
writer.write(packNibbles(instruction.getRegisterC(), instruction.getRegisterD()));
|
||||||
|
writer.write(packNibbles(instruction.getRegisterE(), instruction.getRegisterF()));
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(@Nonnull Instruction35ms instruction) {
|
||||||
|
try {
|
||||||
|
writer.write(getOpcodeValue(instruction.getOpcode()));
|
||||||
|
writer.write(packNibbles(instruction.getRegisterG(), instruction.getRegisterCount()));
|
||||||
|
writer.writeUshort(instruction.getVtableIndex());
|
||||||
|
writer.write(packNibbles(instruction.getRegisterC(), instruction.getRegisterD()));
|
||||||
|
writer.write(packNibbles(instruction.getRegisterE(), instruction.getRegisterF()));
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void write(@Nonnull Instruction3rc instruction) {
|
public void write(@Nonnull Instruction3rc instruction) {
|
||||||
try {
|
try {
|
||||||
writer.write(getOpcodeValue(instruction.getOpcode()));
|
writer.write(getOpcodeValue(instruction.getOpcode()));
|
||||||
@ -354,6 +388,29 @@ public class InstructionWriter<StringRef extends StringReference, TypeRef extend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void write(@Nonnull Instruction3rmi instruction) {
|
||||||
|
try {
|
||||||
|
writer.write(getOpcodeValue(instruction.getOpcode()));
|
||||||
|
writer.write(instruction.getRegisterCount());
|
||||||
|
writer.writeUshort(instruction.getInlineIndex());
|
||||||
|
writer.writeUshort(instruction.getStartRegister());
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void write(@Nonnull Instruction3rms instruction) {
|
||||||
|
try {
|
||||||
|
writer.write(getOpcodeValue(instruction.getOpcode()));
|
||||||
|
writer.write(instruction.getRegisterCount());
|
||||||
|
writer.writeUshort(instruction.getVtableIndex());
|
||||||
|
writer.writeUshort(instruction.getStartRegister());
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void write(@Nonnull Instruction45cc instruction) {
|
public void write(@Nonnull Instruction45cc instruction) {
|
||||||
try {
|
try {
|
||||||
writer.write(getOpcodeValue(instruction.getOpcode()));
|
writer.write(getOpcodeValue(instruction.getOpcode()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user