org.jf.dexlib2.iface.reference.Reference Java Examples

The following examples show how to use org.jf.dexlib2.iface.reference.Reference. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImmutableInstruction35c.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
public ImmutableInstruction35c(@Nonnull Opcode opcode,
                               int registerCount,
                               int registerC,
                               int registerD,
                               int registerE,
                               int registerF,
                               int registerG,
                               @Nonnull Reference reference) {
    super(opcode);
    this.registerCount = Preconditions.check35cRegisterCount(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.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #2
Source File: BuilderInstruction35c.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
public BuilderInstruction35c(@Nonnull Opcode opcode,
                             int registerCount,
                             int registerC,
                             int registerD,
                             int registerE,
                             int registerF,
                             int registerG,
                             @Nonnull Reference reference) {
    super(opcode);
    this.registerCount = Preconditions.check35cRegisterCount(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.reference = reference;
}
 
Example #3
Source File: ImmutableInstruction35c.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
public ImmutableInstruction35c(@Nonnull Opcode opcode,
                               int registerCount,
                               int registerC,
                               int registerD,
                               int registerE,
                               int registerF,
                               int registerG,
                               @Nonnull Reference reference) {
    super(opcode);
    this.registerCount = Preconditions.check35cRegisterCount(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.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #4
Source File: BuilderInstruction35c.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
public BuilderInstruction35c(@Nonnull Opcode opcode,
                             int registerCount,
                             int registerC,
                             int registerD,
                             int registerE,
                             int registerF,
                             int registerG,
                             @Nonnull Reference reference) {
    super(opcode);
    this.registerCount = Preconditions.check35cRegisterCount(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.reference = reference;
}
 
Example #5
Source File: MethodAnalyzer.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
private void analyzeMoveResult(@Nonnull AnalyzedInstruction analyzedInstruction) {
    AnalyzedInstruction previousInstruction = analyzedInstructions.valueAt(analyzedInstruction.instructionIndex-1);
    if (!previousInstruction.instruction.getOpcode().setsResult()) {
        throw new AnalysisException(analyzedInstruction.instruction.getOpcode().name + " must occur after an " +
                "invoke-*/fill-new-array instruction");
    }

    RegisterType resultRegisterType;
    ReferenceInstruction invokeInstruction = (ReferenceInstruction)previousInstruction.instruction;
    Reference reference = invokeInstruction.getReference();

    if (reference instanceof MethodReference) {
        resultRegisterType = RegisterType.getRegisterType(classPath, ((MethodReference)reference).getReturnType());
    } else {
        resultRegisterType = RegisterType.getRegisterType(classPath, (TypeReference)reference);
    }

    setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, resultRegisterType);
}
 
Example #6
Source File: BuilderInstruction35c.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
public BuilderInstruction35c(@Nonnull Opcode opcode,
                             int registerCount,
                             int registerC,
                             int registerD,
                             int registerE,
                             int registerF,
                             int registerG,
                             @Nonnull Reference reference) {
    super(opcode);
    this.registerCount = Preconditions.check35cRegisterCount(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.reference = reference;
}
 
Example #7
Source File: ReferenceFormatter.java    From atlas with Apache License 2.0 6 votes vote down vote up
public static void writeReference(IndentingWriter writer, int referenceType,
                                  Reference reference) throws IOException {
    switch (referenceType) {
        case ReferenceType.STRING:
            writeStringReference(writer, ((StringReference)reference).getString());
            return;
        case ReferenceType.TYPE:
            writer.write(((TypeReference)reference).getType());
            return;
        case ReferenceType.METHOD:
            ReferenceUtil.writeMethodDescriptor(writer, (MethodReference) reference);
            return;
        case ReferenceType.FIELD:
            ReferenceUtil.writeFieldDescriptor(writer, (FieldReference)reference);
            return;
        default:
            throw new IllegalStateException("Unknown reference type");
    }
}
 
Example #8
Source File: MethodAnalyzer.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
private void analyzeMoveResult(@Nonnull AnalyzedInstruction analyzedInstruction) {
    AnalyzedInstruction previousInstruction = analyzedInstructions.valueAt(analyzedInstruction.instructionIndex-1);
    if (!previousInstruction.instruction.getOpcode().setsResult()) {
        throw new AnalysisException(analyzedInstruction.instruction.getOpcode().name + " must occur after an " +
                "invoke-*/fill-new-array instruction");
    }

    RegisterType resultRegisterType;
    ReferenceInstruction invokeInstruction = (ReferenceInstruction)previousInstruction.instruction;
    Reference reference = invokeInstruction.getReference();

    if (reference instanceof MethodReference) {
        resultRegisterType = RegisterType.getRegisterType(classPath, ((MethodReference)reference).getReturnType());
    } else {
        resultRegisterType = RegisterType.getRegisterType(classPath, (TypeReference)reference);
    }

    setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, resultRegisterType);
}
 
Example #9
Source File: ImmutableInstructionFactory.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction35c makeInstruction35c(@Nonnull Opcode opcode,
                                                  int registerCount,
                                                  int registerC,
                                                  int registerD,
                                                  int registerE,
                                                  int registerF,
                                                  int registerG,
                                                  @Nonnull Reference reference) {
    return new ImmutableInstruction35c(opcode, registerCount, registerC, registerD, registerE, registerF, registerG,
            reference);
}
 
Example #10
Source File: BuilderInstruction20bc.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public BuilderInstruction20bc(@Nonnull Opcode opcode,
                                int verificationError,
                                @Nonnull Reference reference) {
    super(opcode);
    this.verificationError = Preconditions.checkVerificationError(verificationError);
    this.reference = reference;
}
 
Example #11
Source File: BuilderInstruction31c.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public BuilderInstruction31c(@Nonnull Opcode opcode,
                             int registerA,
                             @Nonnull Reference reference) {
    super(opcode);
    this.registerA = Preconditions.checkByteRegister(registerA);
    this.reference = reference;
}
 
Example #12
Source File: ImmutableInstruction20bc.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction20bc(@Nonnull Opcode opcode,
                               int verificationError,
                               @Nonnull Reference reference) {
    super(opcode);
    this.verificationError = Preconditions.checkVerificationError(verificationError);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #13
Source File: BuilderInstruction20bc.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public BuilderInstruction20bc(@Nonnull Opcode opcode,
                                int verificationError,
                                @Nonnull Reference reference) {
    super(opcode);
    this.verificationError = Preconditions.checkVerificationError(verificationError);
    this.reference = reference;
}
 
Example #14
Source File: ImmutableInstruction31c.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction31c(@Nonnull Opcode opcode,
                               int registerA,
                               @Nonnull Reference reference) {
    super(opcode);
    this.registerA = Preconditions.checkByteRegister(registerA);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #15
Source File: DexBackedReference.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public static Reference makeReference(@Nonnull DexBackedDexFile dexFile, int referenceType, int referenceIndex) {
    switch (referenceType) {
        case ReferenceType.STRING:
            return new DexBackedStringReference(dexFile, referenceIndex);
        case ReferenceType.TYPE:
            return new DexBackedTypeReference(dexFile, referenceIndex);
        case ReferenceType.METHOD:
            return new DexBackedMethodReference(dexFile, referenceIndex);
        case ReferenceType.FIELD:
            return new DexBackedFieldReference(dexFile, referenceIndex);
        default:
            throw new ExceptionWithContext("Invalid reference type: %d", referenceType);
    }
}
 
Example #16
Source File: ImmutableInstruction22c.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction22c(@Nonnull Opcode opcode,
                               int registerA,
                               int registerB,
                               @Nonnull Reference reference) {
    super(opcode);
    this.registerA = Preconditions.checkNibbleRegister(registerA);
    this.registerB = Preconditions.checkNibbleRegister(registerB);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #17
Source File: ImmutableInstructionFactory.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction35c makeInstruction35c(@Nonnull Opcode opcode,
                                                  int registerCount,
                                                  int registerC,
                                                  int registerD,
                                                  int registerE,
                                                  int registerF,
                                                  int registerG,
                                                  @Nonnull Reference reference) {
    return new ImmutableInstruction35c(opcode, registerCount, registerC, registerD, registerE, registerF, registerG,
            reference);
}
 
Example #18
Source File: ImmutableInstruction22c.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction22c(@Nonnull Opcode opcode,
                               int registerA,
                               int registerB,
                               @Nonnull Reference reference) {
    super(opcode);
    this.registerA = Preconditions.checkNibbleRegister(registerA);
    this.registerB = Preconditions.checkNibbleRegister(registerB);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #19
Source File: BuilderInstruction20bc.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public BuilderInstruction20bc(@Nonnull Opcode opcode,
                                int verificationError,
                                @Nonnull Reference reference) {
    super(opcode);
    this.verificationError = Preconditions.checkVerificationError(verificationError);
    this.reference = reference;
}
 
Example #20
Source File: DexBackedReference.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public static Reference makeReference(@Nonnull DexBackedDexFile dexFile, int referenceType, int referenceIndex) {
    switch (referenceType) {
        case ReferenceType.STRING:
            return new DexBackedStringReference(dexFile, referenceIndex);
        case ReferenceType.TYPE:
            return new DexBackedTypeReference(dexFile, referenceIndex);
        case ReferenceType.METHOD:
            return new DexBackedMethodReference(dexFile, referenceIndex);
        case ReferenceType.FIELD:
            return new DexBackedFieldReference(dexFile, referenceIndex);
        default:
            throw new ExceptionWithContext("Invalid reference type: %d", referenceType);
    }
}
 
Example #21
Source File: BuilderInstruction31c.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public BuilderInstruction31c(@Nonnull Opcode opcode,
                             int registerA,
                             @Nonnull Reference reference) {
    super(opcode);
    this.registerA = Preconditions.checkByteRegister(registerA);
    this.reference = reference;
}
 
Example #22
Source File: ImmutableInstruction31c.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction31c(@Nonnull Opcode opcode,
                               int registerA,
                               @Nonnull Reference reference) {
    super(opcode);
    this.registerA = Preconditions.checkByteRegister(registerA);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #23
Source File: ImmutableInstruction20bc.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction20bc(@Nonnull Opcode opcode,
                               int verificationError,
                               @Nonnull Reference reference) {
    super(opcode);
    this.verificationError = Preconditions.checkVerificationError(verificationError);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #24
Source File: ImmutableInstruction3rc.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction3rc(@Nonnull Opcode opcode,
                               int startRegister,
                               int registerCount,
                               @Nonnull Reference reference) {
    super(opcode);
    this.startRegister = Preconditions.checkShortRegister(startRegister);
    this.registerCount = Preconditions.checkRegisterRangeCount(registerCount);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #25
Source File: InstructionRewriter.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
@Override @Nonnull public Reference getReference() {
    switch (getReferenceType()) {
        case ReferenceType.TYPE:
            return RewriterUtils.rewriteTypeReference(rewriters.getTypeRewriter(),
                    (TypeReference)instruction.getReference());
        case ReferenceType.FIELD:
            return rewriters.getFieldReferenceRewriter().rewrite((FieldReference)instruction.getReference());
        case ReferenceType.METHOD:
            return rewriters.getMethodReferenceRewriter().rewrite((MethodReference)instruction.getReference());
        case ReferenceType.STRING:
            return instruction.getReference();
        default:
            throw new IllegalArgumentException();
    }
}
 
Example #26
Source File: ImmutableInstruction20bc.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction20bc(@Nonnull Opcode opcode,
                               int verificationError,
                               @Nonnull Reference reference) {
    super(opcode);
    this.verificationError = Preconditions.checkVerificationError(verificationError);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #27
Source File: ImmutableInstruction31c.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction31c(@Nonnull Opcode opcode,
                               int registerA,
                               @Nonnull Reference reference) {
    super(opcode);
    this.registerA = Preconditions.checkByteRegister(registerA);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #28
Source File: ImmutableInstructionFactory.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction35c makeInstruction35c(@Nonnull Opcode opcode,
                                                  int registerCount,
                                                  int registerC,
                                                  int registerD,
                                                  int registerE,
                                                  int registerF,
                                                  int registerG,
                                                  @Nonnull Reference reference) {
    return new ImmutableInstruction35c(opcode, registerCount, registerC, registerD, registerE, registerF, registerG,
            reference);
}
 
Example #29
Source File: ImmutableInstruction3rc.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction3rc(@Nonnull Opcode opcode,
                               int startRegister,
                               int registerCount,
                               @Nonnull Reference reference) {
    super(opcode);
    this.startRegister = Preconditions.checkShortRegister(startRegister);
    this.registerCount = Preconditions.checkRegisterRangeCount(registerCount);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #30
Source File: ImmutableInstruction22c.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction22c(@Nonnull Opcode opcode,
                               int registerA,
                               int registerB,
                               @Nonnull Reference reference) {
    super(opcode);
    this.registerA = Preconditions.checkNibbleRegister(registerA);
    this.registerB = Preconditions.checkNibbleRegister(registerB);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}