Search in sources :

Example 11 with Type

use of com.android.dx.rop.type.Type in project buck by facebook.

the class CodeItem method addContents.

/** {@inheritDoc} */
public void addContents(DexFile file) {
    MixedItemSection byteData = file.getByteData();
    TypeIdsSection typeIds = file.getTypeIds();
    if (code.hasPositions() || code.hasLocals()) {
        debugInfo = new DebugInfoItem(code, isStatic, ref);
        byteData.add(debugInfo);
    }
    if (code.hasAnyCatches()) {
        for (Type type : code.getCatchTypes()) {
            typeIds.intern(type);
        }
        catches = new CatchStructs(code);
    }
    for (Constant c : code.getInsnConstants()) {
        file.internIfAppropriate(c);
    }
}
Also used : Type(com.android.dx.rop.type.Type) Constant(com.android.dx.rop.cst.Constant)

Example 12 with Type

use of com.android.dx.rop.type.Type in project buck by facebook.

the class CstBaseMethodRef method getPrototype.

/**
     * Gets the prototype of this method as either a
     * {@code static} or instance method. In the case of a
     * {@code static} method, this is the same as the raw
     * prototype. In the case of an instance method, this has an
     * appropriately-typed {@code this} argument as the first
     * one.
     *
     * @param isStatic whether the method should be considered static
     * @return {@code non-null;} the method prototype
     */
public final Prototype getPrototype(boolean isStatic) {
    if (isStatic) {
        return prototype;
    } else {
        if (instancePrototype == null) {
            Type thisType = getDefiningClass().getClassType();
            instancePrototype = prototype.withFirstParameter(thisType);
        }
        return instancePrototype;
    }
}
Also used : Type(com.android.dx.rop.type.Type)

Example 13 with Type

use of com.android.dx.rop.type.Type in project buck by facebook.

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 14 with Type

use of com.android.dx.rop.type.Type in project buck by facebook.

the class RegisterSpec method withSimpleType.

/**
     * Returns an instance that is identical to this one, except that
     * the type bearer is replaced by the actual underlying type
     * (thereby stripping off non-type information) with any
     * initialization information stripped away as well.
     *
     * @return {@code non-null;} an appropriately-constructed instance
     */
public RegisterSpec withSimpleType() {
    TypeBearer orig = type;
    Type newType;
    if (orig instanceof Type) {
        newType = (Type) orig;
    } else {
        newType = orig.getType();
    }
    if (newType.isUninitialized()) {
        newType = newType.getInitializedType();
    }
    if (newType == orig) {
        return this;
    }
    return makeLocalOptional(reg, newType, local);
}
Also used : Type(com.android.dx.rop.type.Type) TypeBearer(com.android.dx.rop.type.TypeBearer)

Example 15 with Type

use of com.android.dx.rop.type.Type in project buck by facebook.

the class Rop method toString.

/** {@inheritDoc} */
@Override
public String toString() {
    StringBuffer sb = new StringBuffer(40);
    sb.append("Rop{");
    sb.append(RegOps.opName(opcode));
    if (result != Type.VOID) {
        sb.append(" ");
        sb.append(result);
    } else {
        sb.append(" .");
    }
    sb.append(" <-");
    int sz = sources.size();
    if (sz == 0) {
        sb.append(" .");
    } else {
        for (int i = 0; i < sz; i++) {
            sb.append(' ');
            sb.append(sources.getType(i));
        }
    }
    if (isCallLike) {
        sb.append(" call");
    }
    sz = exceptions.size();
    if (sz != 0) {
        sb.append(" throws");
        for (int i = 0; i < sz; i++) {
            sb.append(' ');
            Type one = exceptions.getType(i);
            if (one == Type.THROWABLE) {
                sb.append("<any>");
            } else {
                sb.append(exceptions.getType(i));
            }
        }
    } else {
        switch(branchingness) {
            case BRANCH_NONE:
                sb.append(" flows");
                break;
            case BRANCH_RETURN:
                sb.append(" returns");
                break;
            case BRANCH_GOTO:
                sb.append(" gotos");
                break;
            case BRANCH_IF:
                sb.append(" ifs");
                break;
            case BRANCH_SWITCH:
                sb.append(" switches");
                break;
            default:
                sb.append(" " + Hex.u1(branchingness));
                break;
        }
    }
    sb.append('}');
    return sb.toString();
}
Also used : Type(com.android.dx.rop.type.Type)

Aggregations

Type (com.android.dx.rop.type.Type)62 CstType (com.android.dx.rop.cst.CstType)36 StdTypeList (com.android.dx.rop.type.StdTypeList)10 TypeBearer (com.android.dx.rop.type.TypeBearer)10 Constant (com.android.dx.rop.cst.Constant)8 CstString (com.android.dx.rop.cst.CstString)8 RegisterSpec (com.android.dx.rop.code.RegisterSpec)6 TypeList (com.android.dx.rop.type.TypeList)6 BasicBlock (com.android.dx.rop.code.BasicBlock)4 Insn (com.android.dx.rop.code.Insn)4 PlainCstInsn (com.android.dx.rop.code.PlainCstInsn)4 PlainInsn (com.android.dx.rop.code.PlainInsn)4 SourcePosition (com.android.dx.rop.code.SourcePosition)4 ThrowingCstInsn (com.android.dx.rop.code.ThrowingCstInsn)4 ThrowingInsn (com.android.dx.rop.code.ThrowingInsn)4 CstInteger (com.android.dx.rop.cst.CstInteger)4 IntList (com.android.dx.util.IntList)4 ByteArrayByteInput (com.android.dex.util.ByteArrayByteInput)2 ByteInput (com.android.dex.util.ByteInput)2 AttInnerClasses (com.android.dx.cf.attrib.AttInnerClasses)2