Search in sources :

Example 71 with CstType

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

the class Form3rc method isCompatible.

/**
 * {@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))) {
        return false;
    }
    RegisterSpecList regs = ci.getRegisters();
    int sz = regs.size();
    return (regs.size() == 0) || (isRegListSequential(regs) && unsignedFitsInShort(regs.get(0).getReg()) && unsignedFitsInByte(regs.getWordCount()));
}
Also used : CstInsn(com.android.dx.dex.code.CstInsn) Constant(com.android.dx.rop.cst.Constant) CstType(com.android.dx.rop.cst.CstType) CstMethodRef(com.android.dx.rop.cst.CstMethodRef) RegisterSpecList(com.android.dx.rop.code.RegisterSpecList)

Example 72 with CstType

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

the class ClassDefsSection method orderItems0.

/**
 * Helper for {@link #orderItems}, which recursively assigns indices
 * to classes.
 *
 * @param type {@code null-ok;} type ref to assign, if any
 * @param idx {@code >= 0;} the next index to assign
 * @param maxDepth maximum recursion depth; if negative, this will
 * throw an exception indicating class definition circularity
 * @return {@code >= 0;} the next index to assign
 */
private int orderItems0(Type type, int idx, int maxDepth) {
    ClassDefItem c = classDefs.get(type);
    if ((c == null) || (c.hasIndex())) {
        return idx;
    }
    if (maxDepth < 0) {
        throw new RuntimeException("class circularity with " + type);
    }
    maxDepth--;
    CstType superclassCst = c.getSuperclass();
    if (superclassCst != null) {
        Type superclass = superclassCst.getClassType();
        idx = orderItems0(superclass, idx, maxDepth);
    }
    TypeList interfaces = c.getInterfaces();
    int sz = interfaces.size();
    for (int i = 0; i < sz; i++) {
        idx = orderItems0(interfaces.getType(i), idx, maxDepth);
    }
    c.setIndex(idx);
    orderedDefs.add(c);
    return idx + 1;
}
Also used : Type(com.android.dx.rop.type.Type) CstType(com.android.dx.rop.cst.CstType) CstType(com.android.dx.rop.cst.CstType) TypeList(com.android.dx.rop.type.TypeList)

Example 73 with CstType

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

the class TypeIdsSection method intern.

/**
 * Interns an element into this instance.
 *
 * @param type {@code non-null;} the type to intern
 * @return {@code non-null;} the interned reference
 */
public synchronized TypeIdItem intern(CstType type) {
    if (type == null) {
        throw new NullPointerException("type == null");
    }
    throwIfPrepared();
    Type typePerSe = type.getClassType();
    TypeIdItem result = typeIds.get(typePerSe);
    if (result == null) {
        result = new TypeIdItem(type);
        typeIds.put(typePerSe, result);
    }
    return result;
}
Also used : Type(com.android.dx.rop.type.Type) CstType(com.android.dx.rop.cst.CstType)

Example 74 with CstType

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

the class TypeIdsSection method get.

/**
 * {@inheritDoc}
 */
@Override
public IndexedItem get(Constant cst) {
    if (cst == null) {
        throw new NullPointerException("cst == null");
    }
    throwIfNotPrepared();
    Type type = ((CstType) cst).getClassType();
    IndexedItem result = typeIds.get(type);
    if (result == null) {
        throw new IllegalArgumentException("not found: " + cst);
    }
    return result;
}
Also used : Type(com.android.dx.rop.type.Type) CstType(com.android.dx.rop.cst.CstType) CstType(com.android.dx.rop.cst.CstType)

Example 75 with CstType

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

the class Annotations method add.

/**
 * Adds an element to this instance. There must not already be an
 * element of the same type.
 *
 * @param annotation {@code non-null;} the element to add
 * @throws IllegalArgumentException thrown if there is a duplicate type
 */
public void add(Annotation annotation) {
    throwIfImmutable();
    if (annotation == null) {
        throw new NullPointerException("annotation == null");
    }
    CstType type = annotation.getType();
    if (annotations.containsKey(type)) {
        throw new IllegalArgumentException("duplicate type: " + type.toHuman());
    }
    annotations.put(type, annotation);
}
Also used : CstType(com.android.dx.rop.cst.CstType)

Aggregations

CstType (com.android.dx.rop.cst.CstType)76 CstString (com.android.dx.rop.cst.CstString)29 Constant (com.android.dx.rop.cst.Constant)28 CstFieldRef (com.android.dx.rop.cst.CstFieldRef)19 CstMethodRef (com.android.dx.rop.cst.CstMethodRef)18 Type (com.android.dx.rop.type.Type)16 RegisterSpecList (com.android.dx.rop.code.RegisterSpecList)12 CstInsn (com.android.dx.dex.code.CstInsn)10 Annotations (com.android.dx.rop.annotation.Annotations)10 RegisterSpec (com.android.dx.rop.code.RegisterSpec)10 CstNat (com.android.dx.rop.cst.CstNat)10 TypeList (com.android.dx.rop.type.TypeList)9 Annotation (com.android.dx.rop.annotation.Annotation)8 ConstantPool (com.android.dx.rop.cst.ConstantPool)8 ByteArray (com.android.dx.util.ByteArray)7 IntList (com.android.dx.util.IntList)7 AttEnclosingMethod (com.android.dx.cf.attrib.AttEnclosingMethod)6 NameValuePair (com.android.dx.rop.annotation.NameValuePair)6 ThrowingCstInsn (com.android.dx.rop.code.ThrowingCstInsn)6 CstInteger (com.android.dx.rop.cst.CstInteger)6