Remove unneeded format precondition checks

The format precondition check should always occur in the base instruction
class
This commit is contained in:
Ben Gruver 2013-08-24 16:35:26 -07:00
parent 766f285a70
commit f97289cf3e
33 changed files with 2 additions and 41 deletions

View File

@ -45,8 +45,8 @@ public abstract class ImmutableInstruction implements Instruction {
@Nonnull protected final Opcode opcode;
protected ImmutableInstruction(@Nonnull Opcode opcode) {
this.opcode = opcode;
Preconditions.checkFormat(opcode, getFormat());
this.opcode = opcode;
}
@Nonnull

View File

@ -46,7 +46,6 @@ public class ImmutableInstruction10t extends ImmutableInstruction implements Ins
public ImmutableInstruction10t(@Nonnull Opcode opcode,
int codeOffset) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.codeOffset = Preconditions.checkByteCodeOffset(codeOffset);
}

View File

@ -34,7 +34,6 @@ package org.jf.dexlib2.immutable.instruction;
import org.jf.dexlib2.Format;
import org.jf.dexlib2.Opcode;
import org.jf.dexlib2.iface.instruction.formats.Instruction10x;
import org.jf.dexlib2.util.Preconditions;
import javax.annotation.Nonnull;
@ -43,7 +42,6 @@ public class ImmutableInstruction10x extends ImmutableInstruction implements Ins
public ImmutableInstruction10x(@Nonnull Opcode opcode) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
}
public static ImmutableInstruction10x of(Instruction10x instruction) {

View File

@ -48,7 +48,6 @@ public class ImmutableInstruction11n extends ImmutableInstruction implements Ins
int registerA,
int literal) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkNibbleRegister(registerA);
this.literal = Preconditions.checkNibbleLiteral(literal);
}

View File

@ -46,7 +46,6 @@ public class ImmutableInstruction11x extends ImmutableInstruction implements Ins
public ImmutableInstruction11x(@Nonnull Opcode opcode,
int registerA) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkByteRegister(registerA);
}

View File

@ -48,7 +48,6 @@ public class ImmutableInstruction12x extends ImmutableInstruction implements Ins
int registerA,
int registerB) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkNibbleRegister(registerA);
this.registerB = Preconditions.checkNibbleRegister(registerB);
}

View File

@ -51,7 +51,6 @@ public class ImmutableInstruction20bc extends ImmutableInstruction implements In
int verificationError,
@Nonnull Reference reference) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.verificationError = Preconditions.checkVerificationError(verificationError);
this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}

View File

@ -46,7 +46,6 @@ public class ImmutableInstruction20t extends ImmutableInstruction implements Ins
public ImmutableInstruction20t(@Nonnull Opcode opcode,
int codeOffset) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.codeOffset = Preconditions.checkShortCodeOffset(codeOffset);
}

View File

@ -51,7 +51,6 @@ public class ImmutableInstruction21c extends ImmutableInstruction implements Ins
int registerA,
@Nonnull Reference reference) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkByteRegister(registerA);
this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}

View File

@ -48,7 +48,6 @@ public class ImmutableInstruction21ih extends ImmutableInstruction implements In
int registerA,
int literal) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkByteRegister(registerA);
this.literal = Preconditions.checkIntegerHatLiteral(literal);
}

View File

@ -48,7 +48,6 @@ public class ImmutableInstruction21lh extends ImmutableInstruction implements In
int registerA,
long literal) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkByteRegister(registerA);
this.literal = Preconditions.checkLongHatLiteral(literal);
}

View File

@ -48,7 +48,6 @@ public class ImmutableInstruction21s extends ImmutableInstruction implements Ins
int registerA,
int literal) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkByteRegister(registerA);
this.literal = Preconditions.checkShortLiteral(literal);
}

View File

@ -48,7 +48,6 @@ public class ImmutableInstruction21t extends ImmutableInstruction implements Ins
int registerA,
int codeOffset) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkByteRegister(registerA);
this.codeOffset = Preconditions.checkShortCodeOffset(codeOffset);
}

View File

@ -50,7 +50,6 @@ public class ImmutableInstruction22b extends ImmutableInstruction implements Ins
int registerB,
int literal) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkByteRegister(registerA);
this.registerB = Preconditions.checkByteRegister(registerB);
this.literal = Preconditions.checkByteLiteral(literal);

View File

@ -53,7 +53,6 @@ public class ImmutableInstruction22c extends ImmutableInstruction implements Ins
int registerB,
@Nonnull Reference reference) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkNibbleRegister(registerA);
this.registerB = Preconditions.checkNibbleRegister(registerB);
this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);

View File

@ -50,7 +50,6 @@ public class ImmutableInstruction22cs extends ImmutableInstruction implements In
int registerB,
int fieldOffset) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkNibbleRegister(registerA);
this.registerB = Preconditions.checkNibbleRegister(registerB);
this.fieldOffset = Preconditions.checkFieldOffset(fieldOffset);

View File

@ -50,7 +50,6 @@ public class ImmutableInstruction22s extends ImmutableInstruction implements Ins
int registerB,
int literal) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkNibbleRegister(registerA);
this.registerB = Preconditions.checkNibbleRegister(registerB);
this.literal = Preconditions.checkShortLiteral(literal);

View File

@ -50,7 +50,6 @@ public class ImmutableInstruction22t extends ImmutableInstruction implements Ins
int registerB,
int codeOffset) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkNibbleRegister(registerA);
this.registerB = Preconditions.checkNibbleRegister(registerB);
this.codeOffset = Preconditions.checkShortCodeOffset(codeOffset);

View File

@ -48,7 +48,6 @@ public class ImmutableInstruction22x extends ImmutableInstruction implements Ins
int registerA,
int registerB) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkByteRegister(registerA);
this.registerB = Preconditions.checkShortRegister(registerB);
}

View File

@ -50,7 +50,6 @@ public class ImmutableInstruction23x extends ImmutableInstruction implements Ins
int registerB,
int registerC) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkByteRegister(registerA);
this.registerB = Preconditions.checkByteRegister(registerB);
this.registerC = Preconditions.checkByteRegister(registerC);

View File

@ -34,7 +34,6 @@ package org.jf.dexlib2.immutable.instruction;
import org.jf.dexlib2.Format;
import org.jf.dexlib2.Opcode;
import org.jf.dexlib2.iface.instruction.formats.Instruction30t;
import org.jf.dexlib2.util.Preconditions;
import javax.annotation.Nonnull;
@ -46,7 +45,6 @@ public class ImmutableInstruction30t extends ImmutableInstruction implements Ins
public ImmutableInstruction30t(@Nonnull Opcode opcode,
int codeOffset) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.codeOffset = codeOffset;
}

View File

@ -51,7 +51,6 @@ public class ImmutableInstruction31c extends ImmutableInstruction implements Ins
int registerA,
@Nonnull Reference reference) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkByteRegister(registerA);
this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}

View File

@ -48,7 +48,6 @@ public class ImmutableInstruction31i extends ImmutableInstruction implements Ins
int registerA,
int literal) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkByteRegister(registerA);
this.literal = literal;
}

View File

@ -48,7 +48,6 @@ public class ImmutableInstruction31t extends ImmutableInstruction implements Ins
int registerA,
int codeOffset) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkByteRegister(registerA);
this.codeOffset = codeOffset;
}

View File

@ -48,7 +48,6 @@ public class ImmutableInstruction32x extends ImmutableInstruction implements Ins
int registerA,
int registerB) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkShortRegister(registerA);
this.registerB = Preconditions.checkShortRegister(registerB);
}

View File

@ -61,7 +61,6 @@ public class ImmutableInstruction35c extends ImmutableInstruction implements Ins
int registerG,
@Nonnull Reference reference) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerCount = Preconditions.check35cRegisterCount(registerCount);
this.registerC = (registerCount>0) ? Preconditions.checkNibbleRegister(registerC) : 0;
this.registerD = (registerCount>1) ? Preconditions.checkNibbleRegister(registerD) : 0;

View File

@ -58,7 +58,6 @@ public class ImmutableInstruction35mi extends ImmutableInstruction implements In
int registerG,
int inlineIndex) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerCount = Preconditions.check35cRegisterCount(registerCount);
this.registerC = (registerCount>0) ? Preconditions.checkNibbleRegister(registerC) : 0;
this.registerD = (registerCount>1) ? Preconditions.checkNibbleRegister(registerD) : 0;

View File

@ -58,7 +58,6 @@ public class ImmutableInstruction35ms extends ImmutableInstruction implements In
int registerG,
int vtableIndex) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerCount = Preconditions.check35cRegisterCount(registerCount);
this.registerC = (registerCount>0) ? Preconditions.checkNibbleRegister(registerC) : 0;
this.registerD = (registerCount>1) ? Preconditions.checkNibbleRegister(registerD) : 0;

View File

@ -54,7 +54,6 @@ public class ImmutableInstruction3rc extends ImmutableInstruction implements Ins
int registerCount,
@Nonnull Reference reference) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.startRegister = Preconditions.checkShortRegister(startRegister);
this.registerCount = Preconditions.checkRegisterRangeCount(registerCount);
this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);

View File

@ -51,7 +51,6 @@ public class ImmutableInstruction3rmi extends ImmutableInstruction implements In
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);

View File

@ -51,7 +51,6 @@ public class ImmutableInstruction3rms extends ImmutableInstruction implements In
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);

View File

@ -48,7 +48,6 @@ public class ImmutableInstruction51l extends ImmutableInstruction implements Ins
int registerA,
long literal) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkByteRegister(registerA);
this.literal = literal;
}

View File

@ -49,6 +49,7 @@ public interface BuilderInstruction extends Instruction {
@Nonnull protected final Opcode opcode;
public BaseBuilderInstruction(@Nonnull Opcode opcode) {
Preconditions.checkFormat(opcode, getFormat());
this.opcode = opcode;
}
@ -103,7 +104,6 @@ public interface BuilderInstruction extends Instruction {
int verificationError,
@Nonnull BuilderReference reference) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.verificationError = Preconditions.checkVerificationError(verificationError);
this.reference = Preconditions.checkReference(opcode.referenceType, reference);
}
@ -130,7 +130,6 @@ public interface BuilderInstruction extends Instruction {
int registerA,
@Nonnull BuilderReference reference) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkByteRegister(registerA);
this.reference = Preconditions.checkReference(opcode.referenceType, reference);
}
@ -183,7 +182,6 @@ public interface BuilderInstruction extends Instruction {
int registerB,
@Nonnull BuilderReference reference) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkNibbleRegister(registerA);
this.registerB = Preconditions.checkNibbleRegister(registerB);
this.reference = Preconditions.checkReference(opcode.referenceType, reference);
@ -236,7 +234,6 @@ public interface BuilderInstruction extends Instruction {
int registerA,
@Nonnull BuilderReference reference) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerA = Preconditions.checkByteRegister(registerA);
this.reference = Preconditions.checkReference(opcode.referenceType, reference);
}
@ -285,7 +282,6 @@ public interface BuilderInstruction extends Instruction {
int registerG,
@Nonnull BuilderReference reference) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.registerCount = Preconditions.check35cRegisterCount(registerCount);
this.registerC = (registerCount>0) ? Preconditions.checkNibbleRegister(registerC) : 0;
this.registerD = (registerCount>1) ? Preconditions.checkNibbleRegister(registerD) : 0;
@ -319,8 +315,6 @@ public interface BuilderInstruction extends Instruction {
int registerCount,
@Nonnull BuilderReference reference) {
super(opcode);
Preconditions.checkFormat(opcode, FORMAT);
this.startRegister = Preconditions.checkShortRegister(startRegister);
this.registerCount = Preconditions.checkRegisterRangeCount(registerCount);
this.reference = Preconditions.checkReference(opcode.referenceType, reference);