com.android.dx.dex.code.CstInsn Java Examples

The following examples show how to use com.android.dx.dex.code.CstInsn. 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: Form21s.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 1) &&
          unsignedFitsInByte(regs.get(0).getReg()))) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();

    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }

    CstLiteralBits cb = (CstLiteralBits) cst;

    return cb.fitsInInt() && signedFitsInShort(cb.getIntBits());
}
 
Example #2
Source File: Form31i.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 1) &&
          unsignedFitsInByte(regs.get(0).getReg()))) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();

    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }

    return ((CstLiteralBits) cst).fitsInInt();
}
 
Example #3
Source File: Form21h.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void writeTo(AnnotatedOutput out, DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    CstLiteralBits cb = (CstLiteralBits) ((CstInsn) insn).getConstant();
    short bits;

    // Where the high bits are depends on the category of the target.
    if (regs.get(0).getCategory() == 1) {
        bits = (short) (cb.getIntBits() >>> 16);
    } else {
        bits = (short) (cb.getLongBits() >>> 48);
    }

    write(out, opcodeUnit(insn, regs.get(0).getReg()), bits);
}
 
Example #4
Source File: Form22b.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 2) &&
          unsignedFitsInByte(regs.get(0).getReg()) &&
          unsignedFitsInByte(regs.get(1).getReg()))) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();

    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }

    CstLiteralBits cb = (CstLiteralBits) cst;

    return cb.fitsInInt() && signedFitsInByte(cb.getIntBits());
}
 
Example #5
Source File: Form22s.java    From buck with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 2) &&
          unsignedFitsInNibble(regs.get(0).getReg()) &&
          unsignedFitsInNibble(regs.get(1).getReg()))) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();

    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }

    CstLiteralBits cb = (CstLiteralBits) cst;

    return cb.fitsInInt() && signedFitsInShort(cb.getIntBits());
}
 
Example #6
Source File: Form22c.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 2) &&
          unsignedFitsInNibble(regs.get(0).getReg()) &&
          unsignedFitsInNibble(regs.get(1).getReg()))) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    int cpi = ci.getIndex();

    if (! unsignedFitsInShort(cpi)) {
        return false;
    }

    Constant cst = ci.getConstant();
    return (cst instanceof CstType) ||
        (cst instanceof CstFieldRef);
}
 
Example #7
Source File: Form21h.java    From buck with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void writeTo(AnnotatedOutput out, DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    CstLiteralBits cb = (CstLiteralBits) ((CstInsn) insn).getConstant();
    short bits;

    // Where the high bits are depends on the category of the target.
    if (regs.get(0).getCategory() == 1) {
        bits = (short) (cb.getIntBits() >>> 16);
    } else {
        bits = (short) (cb.getLongBits() >>> 48);
    }

    write(out, opcodeUnit(insn, regs.get(0).getReg()), bits);
}
 
Example #8
Source File: Form21s.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 1) &&
          unsignedFitsInByte(regs.get(0).getReg()))) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();

    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }

    CstLiteralBits cb = (CstLiteralBits) cst;

    return cb.fitsInInt() && signedFitsInShort(cb.getIntBits());
}
 
Example #9
Source File: Form11n.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();

    if (!((insn instanceof CstInsn) &&
          (regs.size() == 1) &&
          unsignedFitsInNibble(regs.get(0).getReg()))) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();

    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }

    CstLiteralBits cb = (CstLiteralBits) cst;

    return cb.fitsInInt() && signedFitsInNibble(cb.getIntBits());
}
 
Example #10
Source File: Form21h.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void writeTo(AnnotatedOutput out, DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    CstLiteralBits cb = (CstLiteralBits) ((CstInsn) insn).getConstant();
    short bits;

    // Where the high bits are depends on the category of the target.
    if (regs.get(0).getCategory() == 1) {
        bits = (short) (cb.getIntBits() >>> 16);
    } else {
        bits = (short) (cb.getLongBits() >>> 48);
    }

    write(out, opcodeUnit(insn, regs.get(0).getReg()), bits);
}
 
Example #11
Source File: Form22b.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 2) &&
          unsignedFitsInByte(regs.get(0).getReg()) &&
          unsignedFitsInByte(regs.get(1).getReg()))) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();

    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }

    CstLiteralBits cb = (CstLiteralBits) cst;

    return cb.fitsInInt() && signedFitsInByte(cb.getIntBits());
}
 
Example #12
Source File: Form22s.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 2) &&
          unsignedFitsInNibble(regs.get(0).getReg()) &&
          unsignedFitsInNibble(regs.get(1).getReg()))) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();

    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }

    CstLiteralBits cb = (CstLiteralBits) cst;

    return cb.fitsInInt() && signedFitsInShort(cb.getIntBits());
}
 
Example #13
Source File: Form11n.java    From buck with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();

    if (!((insn instanceof CstInsn) &&
          (regs.size() == 1) &&
          unsignedFitsInNibble(regs.get(0).getReg()))) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();

    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }

    CstLiteralBits cb = (CstLiteralBits) cst;

    return cb.fitsInInt() && signedFitsInNibble(cb.getIntBits());
}
 
Example #14
Source File: Form31i.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 1) &&
          unsignedFitsInByte(regs.get(0).getReg()))) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();

    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }

    return ((CstLiteralBits) cst).fitsInInt();
}
 
Example #15
Source File: Form22c.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 2) &&
          unsignedFitsInNibble(regs.get(0).getReg()) &&
          unsignedFitsInNibble(regs.get(1).getReg()))) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    int cpi = ci.getIndex();

    if (! unsignedFitsInShort(cpi)) {
        return false;
    }

    Constant cst = ci.getConstant();
    return (cst instanceof CstType) ||
        (cst instanceof CstFieldRef);
}
 
Example #16
Source File: Form35c.java    From buck with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void writeTo(AnnotatedOutput out, DalvInsn insn) {
    int cpi = ((CstInsn) insn).getIndex();
    RegisterSpecList regs = explicitize(insn.getRegisters());
    int sz = regs.size();
    int r0 = (sz > 0) ? regs.get(0).getReg() : 0;
    int r1 = (sz > 1) ? regs.get(1).getReg() : 0;
    int r2 = (sz > 2) ? regs.get(2).getReg() : 0;
    int r3 = (sz > 3) ? regs.get(3).getReg() : 0;
    int r4 = (sz > 4) ? regs.get(4).getReg() : 0;

    write(out,
          opcodeUnit(insn,
                     makeByte(r4, sz)), // encode the fifth operand here
          (short) cpi,
          codeUnit(r0, r1, r2, r3));
}
 
Example #17
Source File: Form35c.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    if (!(insn instanceof CstInsn)) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    int cpi = ci.getIndex();

    if (! unsignedFitsInShort(cpi)) {
        return false;
    }

    Constant cst = ci.getConstant();
    if (!((cst instanceof CstMethodRef) ||
          (cst instanceof CstType) ||
          (cst instanceof CstCallSiteRef))) {
        return false;
    }

    RegisterSpecList regs = ci.getRegisters();
    return (wordCount(regs) >= 0);
}
 
Example #18
Source File: Form35c.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void writeTo(AnnotatedOutput out, DalvInsn insn) {
    int cpi = ((CstInsn) insn).getIndex();
    RegisterSpecList regs = explicitize(insn.getRegisters());
    int sz = regs.size();
    int r0 = (sz > 0) ? regs.get(0).getReg() : 0;
    int r1 = (sz > 1) ? regs.get(1).getReg() : 0;
    int r2 = (sz > 2) ? regs.get(2).getReg() : 0;
    int r3 = (sz > 3) ? regs.get(3).getReg() : 0;
    int r4 = (sz > 4) ? regs.get(4).getReg() : 0;

    write(out,
          opcodeUnit(insn,
                     makeByte(r4, sz)), // encode the fifth operand here
          (short) cpi,
          codeUnit(r0, r1, r2, r3));
}
 
Example #19
Source File: Form21s.java    From Box with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 1) &&
          unsignedFitsInByte(regs.get(0).getReg()))) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();

    if (!(cst instanceof CstLiteralBits)) {
        return false;
    }

    CstLiteralBits cb = (CstLiteralBits) cst;

    return cb.fitsInInt() && signedFitsInShort(cb.getIntBits());
}
 
Example #20
Source File: Form21h.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void writeTo(AnnotatedOutput out, DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    CstLiteralBits cb = (CstLiteralBits) ((CstInsn) insn).getConstant();
    short bits;

    // Where the high bits are depends on the category of the target.
    if (regs.get(0).getCategory() == 1) {
        bits = (short) (cb.getIntBits() >>> 16);
    } else {
        bits = (short) (cb.getLongBits() >>> 48);
    }

    write(out, opcodeUnit(insn, regs.get(0).getReg()), bits);
}
 
Example #21
Source File: Form35c.java    From J2ME-Loader with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    if (!(insn instanceof CstInsn)) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    int cpi = ci.getIndex();

    if (! unsignedFitsInShort(cpi)) {
        return false;
    }

    Constant cst = ci.getConstant();
    if (!((cst instanceof CstMethodRef) ||
          (cst instanceof CstType))) {
        return false;
    }

    RegisterSpecList regs = ci.getRegisters();
    return (wordCount(regs) >= 0);
}
 
Example #22
Source File: Form22s.java    From buck with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public String insnArgString(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    CstLiteralBits value = (CstLiteralBits) ((CstInsn) insn).getConstant();

    return regs.get(0).regString() + ", " + regs.get(1).regString()
        + ", " + literalBitsString(value);
}
 
Example #23
Source File: Form31i.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void writeTo(AnnotatedOutput out, DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    int value =
        ((CstLiteralBits) ((CstInsn) insn).getConstant()).getIntBits();

    write(out, opcodeUnit(insn, regs.get(0).getReg()), value);
}
 
Example #24
Source File: Form3rc.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    if (!(insn instanceof CstInsn)) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    int cpi = ci.getIndex();
    Constant cst = ci.getConstant();

    if (! unsignedFitsInShort(cpi)) {
        return false;
    }

    if (!((cst instanceof CstMethodRef) ||
          (cst instanceof CstType) ||
          (cst instanceof CstCallSiteRef))) {
        return false;
    }

    RegisterSpecList regs = ci.getRegisters();
    int sz = regs.size();

    return (regs.size() == 0) ||
        (isRegListSequential(regs) &&
         unsignedFitsInShort(regs.get(0).getReg()) &&
         unsignedFitsInByte(regs.getWordCount()));
}
 
Example #25
Source File: Form22s.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public String insnArgString(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    CstLiteralBits value = (CstLiteralBits) ((CstInsn) insn).getConstant();

    return regs.get(0).regString() + ", " + regs.get(1).regString()
        + ", " + literalBitsString(value);
}
 
Example #26
Source File: Form31i.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public String insnArgString(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    CstLiteralBits value = (CstLiteralBits) ((CstInsn) insn).getConstant();

    return regs.get(0).regString() + ", " + literalBitsString(value);
}
 
Example #27
Source File: Form3rc.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    if (!(insn instanceof CstInsn)) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    int cpi = ci.getIndex();
    Constant cst = ci.getConstant();

    if (! unsignedFitsInShort(cpi)) {
        return false;
    }

    if (!((cst instanceof CstMethodRef) ||
          (cst instanceof CstType) ||
          (cst instanceof CstCallSiteRef))) {
        return false;
    }

    RegisterSpecList regs = ci.getRegisters();
    int sz = regs.size();

    return (regs.size() == 0) ||
        (isRegListSequential(regs) &&
         unsignedFitsInShort(regs.get(0).getReg()) &&
         unsignedFitsInByte(regs.getWordCount()));
}
 
Example #28
Source File: Form3rc.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void writeTo(AnnotatedOutput out, DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    int cpi = ((CstInsn) insn).getIndex();
    int firstReg = (regs.size() == 0) ? 0 : regs.get(0).getReg();
    int count = regs.getWordCount();

    write(out, opcodeUnit(insn, count), (short) cpi, (short) firstReg);
}
 
Example #29
Source File: Form31c.java    From Box with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void writeTo(AnnotatedOutput out, DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    int cpi = ((CstInsn) insn).getIndex();

    write(out, opcodeUnit(insn, regs.get(0).getReg()), cpi);
}
 
Example #30
Source File: Form51l.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
    RegisterSpecList regs = insn.getRegisters();
    if (!((insn instanceof CstInsn) &&
          (regs.size() == 1) &&
          unsignedFitsInByte(regs.get(0).getReg()))) {
        return false;
    }

    CstInsn ci = (CstInsn) insn;
    Constant cst = ci.getConstant();

    return (cst instanceof CstLiteral64);
}