Search in sources :

Example 66 with CstString

use of com.android.dx.rop.cst.CstString in project J2ME-Loader by nikita36078.

the class StringIdsSection method intern.

/**
 * Interns an element into this instance.
 *
 * @param string {@code non-null;} the string to intern
 * @return {@code non-null;} the interned string
 */
public synchronized StringIdItem intern(StringIdItem string) {
    if (string == null) {
        throw new NullPointerException("string == null");
    }
    throwIfPrepared();
    CstString value = string.getValue();
    StringIdItem already = strings.get(value);
    if (already != null) {
        return already;
    }
    strings.put(value, string);
    return string;
}
Also used : CstString(com.android.dx.rop.cst.CstString)

Example 67 with CstString

use of com.android.dx.rop.cst.CstString in project J2ME-Loader by nikita36078.

the class Annotation method add.

/**
 * Add an element to the set of (name, value) pairs for this instance.
 * It is an error to call this method if there is a preexisting element
 * with the same name.
 *
 * @param pair {@code non-null;} the (name, value) pair to add to this instance
 */
public void add(NameValuePair pair) {
    throwIfImmutable();
    if (pair == null) {
        throw new NullPointerException("pair == null");
    }
    CstString name = pair.getName();
    if (elements.get(name) != null) {
        throw new IllegalArgumentException("name already added: " + name);
    }
    elements.put(name, pair);
}
Also used : CstString(com.android.dx.rop.cst.CstString)

Example 68 with CstString

use of com.android.dx.rop.cst.CstString in project J2ME-Loader by nikita36078.

the class ThrowingCstInsn method getInlineString.

/**
 * {@inheritDoc}
 */
@Override
public String getInlineString() {
    Constant cst = getConstant();
    String constantString = cst.toHuman();
    if (cst instanceof CstString) {
        constantString = ((CstString) cst).toQuoted();
    }
    return constantString + " " + ThrowingInsn.toCatchString(catches);
}
Also used : Constant(com.android.dx.rop.cst.Constant) CstString(com.android.dx.rop.cst.CstString) CstString(com.android.dx.rop.cst.CstString)

Example 69 with CstString

use of com.android.dx.rop.cst.CstString in project J2ME-Loader by nikita36078.

the class EscapeAnalysis method insertExceptionThrow.

/**
 * Replaces instructions that trigger an ArrayIndexOutofBounds exception
 * with an actual throw of the exception.
 *
 * @param insn {@code non-null;} instruction causing the exception
 * @param index {@code non-null;} index value that is out of bounds
 * @param deletedInsns {@code non-null;} set of instructions marked for
 * deletion
 */
private void insertExceptionThrow(SsaInsn insn, RegisterSpec index, HashSet<SsaInsn> deletedInsns) {
    // Create a new ArrayIndexOutOfBoundsException
    CstType exception = new CstType(Exceptions.TYPE_ArrayIndexOutOfBoundsException);
    insertThrowingInsnBefore(insn, RegisterSpecList.EMPTY, null, RegOps.NEW_INSTANCE, exception);
    // Add a successor block with a move result pseudo for the exception
    SsaBasicBlock currBlock = insn.getBlock();
    SsaBasicBlock newBlock = currBlock.insertNewSuccessor(currBlock.getPrimarySuccessor());
    SsaInsn newInsn = newBlock.getInsns().get(0);
    RegisterSpec newReg = RegisterSpec.make(ssaMeth.makeNewSsaReg(), exception);
    insertPlainInsnBefore(newInsn, RegisterSpecList.EMPTY, newReg, RegOps.MOVE_RESULT_PSEUDO, null);
    // Add another successor block to initialize the exception
    SsaBasicBlock newBlock2 = newBlock.insertNewSuccessor(newBlock.getPrimarySuccessor());
    SsaInsn newInsn2 = newBlock2.getInsns().get(0);
    CstNat newNat = new CstNat(new CstString("<init>"), new CstString("(I)V"));
    CstMethodRef newRef = new CstMethodRef(exception, newNat);
    insertThrowingInsnBefore(newInsn2, RegisterSpecList.make(newReg, index), null, RegOps.INVOKE_DIRECT, newRef);
    deletedInsns.add(newInsn2);
    // Add another successor block to throw the new exception
    SsaBasicBlock newBlock3 = newBlock2.insertNewSuccessor(newBlock2.getPrimarySuccessor());
    SsaInsn newInsn3 = newBlock3.getInsns().get(0);
    insertThrowingInsnBefore(newInsn3, RegisterSpecList.make(newReg), null, RegOps.THROW, null);
    newBlock3.replaceSuccessor(newBlock3.getPrimarySuccessorIndex(), ssaMeth.getExitBlock().getIndex());
    deletedInsns.add(newInsn3);
}
Also used : CstNat(com.android.dx.rop.cst.CstNat) CstType(com.android.dx.rop.cst.CstType) CstString(com.android.dx.rop.cst.CstString) CstMethodRef(com.android.dx.rop.cst.CstMethodRef) RegisterSpec(com.android.dx.rop.code.RegisterSpec)

Aggregations

CstString (com.android.dx.rop.cst.CstString)69 CstType (com.android.dx.rop.cst.CstType)29 Constant (com.android.dx.rop.cst.Constant)25 ByteArray (com.android.dx.util.ByteArray)15 ConstantPool (com.android.dx.rop.cst.ConstantPool)12 ParseException (com.android.dx.cf.iface.ParseException)10 NameValuePair (com.android.dx.rop.annotation.NameValuePair)10 RegisterSpec (com.android.dx.rop.code.RegisterSpec)10 CstFieldRef (com.android.dx.rop.cst.CstFieldRef)10 CstNat (com.android.dx.rop.cst.CstNat)10 Annotation (com.android.dx.rop.annotation.Annotation)8 Type (com.android.dx.rop.type.Type)8 CstAnnotation (com.android.dx.rop.cst.CstAnnotation)6 CstMethodRef (com.android.dx.rop.cst.CstMethodRef)6 Attribute (com.android.dx.cf.iface.Attribute)5 ClassDefItem (com.android.dx.dex.file.ClassDefItem)5 CstInsn (com.android.dx.dex.code.CstInsn)4 AnnotationsList (com.android.dx.rop.annotation.AnnotationsList)4 LocalItem (com.android.dx.rop.code.LocalItem)4 RegisterSpecList (com.android.dx.rop.code.RegisterSpecList)4