Search in sources :

Example 11 with Constant

use of com.taobao.android.dx.rop.cst.Constant in project atlas by alibaba.

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.taobao.android.dx.dex.code.CstInsn) Constant(com.taobao.android.dx.rop.cst.Constant) CstType(com.taobao.android.dx.rop.cst.CstType) CstMethodRef(com.taobao.android.dx.rop.cst.CstMethodRef) RegisterSpecList(com.taobao.android.dx.rop.code.RegisterSpecList)

Example 12 with Constant

use of com.taobao.android.dx.rop.cst.Constant in project atlas by alibaba.

the class AnnotationUtils method makeInnerClass.

/**
     * Constructs a standard {@code InnerClass} annotation.
     *
     * @param name {@code null-ok;} the original name of the class, or
     * {@code null} to represent an anonymous class
     * @param accessFlags the original access flags
     * @return {@code non-null;} the annotation
     */
public static Annotation makeInnerClass(CstString name, int accessFlags) {
    Annotation result = new Annotation(INNER_CLASS_TYPE, SYSTEM);
    Constant nameCst = (name != null) ? name : CstKnownNull.THE_ONE;
    result.put(new NameValuePair(NAME_STRING, nameCst));
    result.put(new NameValuePair(ACCESS_FLAGS_STRING, CstInteger.make(accessFlags)));
    result.setImmutable();
    return result;
}
Also used : NameValuePair(com.taobao.android.dx.rop.annotation.NameValuePair) Constant(com.taobao.android.dx.rop.cst.Constant) Annotation(com.taobao.android.dx.rop.annotation.Annotation) CstAnnotation(com.taobao.android.dx.rop.cst.CstAnnotation)

Example 13 with Constant

use of com.taobao.android.dx.rop.cst.Constant in project atlas by alibaba.

the class RegisterSpec method toString0.

/**
     * Helper for {@link #toString} and {@link #toHuman}.
     *
     * @param human whether to be human-oriented
     * @return {@code non-null;} the string form
     */
private String toString0(boolean human) {
    StringBuffer sb = new StringBuffer(40);
    sb.append(regString());
    sb.append(":");
    if (local != null) {
        sb.append(local.toString());
    }
    Type justType = type.getType();
    sb.append(justType);
    if (justType != type) {
        sb.append("=");
        if (human && (type instanceof CstString)) {
            sb.append(((CstString) type).toQuoted());
        } else if (human && (type instanceof Constant)) {
            sb.append(type.toHuman());
        } else {
            sb.append(type);
        }
    }
    return sb.toString();
}
Also used : Type(com.taobao.android.dx.rop.type.Type) Constant(com.taobao.android.dx.rop.cst.Constant) CstString(com.taobao.android.dx.rop.cst.CstString)

Example 14 with Constant

use of com.taobao.android.dx.rop.cst.Constant in project atlas by alibaba.

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.taobao.android.dx.rop.cst.Constant) CstString(com.taobao.android.dx.rop.cst.CstString) CstString(com.taobao.android.dx.rop.cst.CstString)

Example 15 with Constant

use of com.taobao.android.dx.rop.cst.Constant in project atlas by alibaba.

the class ValueEncoder method writeArray.

/**
     * Writes out the encoded form of the given array, that is, as
     * an {@code encoded_array} and not including a
     * {@code value_type} prefix. If the output stream keeps
     * (debugging) annotations and {@code topLevel} is
     * {@code true}, then this method will write (debugging)
     * annotations.
     *
     * @param array {@code non-null;} array instance to write
     * @param topLevel {@code true} iff the given annotation is the
     * top-level annotation or {@code false} if it is a sub-annotation
     * of some other annotation
     */
public void writeArray(CstArray array, boolean topLevel) {
    boolean annotates = topLevel && out.annotates();
    CstArray.List list = ((CstArray) array).getList();
    int size = list.size();
    if (annotates) {
        out.annotate("  size: " + Hex.u4(size));
    }
    out.writeUleb128(size);
    for (int i = 0; i < size; i++) {
        Constant cst = list.get(i);
        if (annotates) {
            out.annotate("  [" + Integer.toHexString(i) + "] " + constantToHuman(cst));
        }
        writeConstant(cst);
    }
    if (annotates) {
        out.endAnnotation();
    }
}
Also used : CstArray(com.taobao.android.dx.rop.cst.CstArray) Constant(com.taobao.android.dx.rop.cst.Constant)

Aggregations

Constant (com.taobao.android.dx.rop.cst.Constant)42 RegisterSpecList (com.taobao.android.dx.rop.code.RegisterSpecList)17 CstType (com.taobao.android.dx.rop.cst.CstType)13 CstInsn (com.taobao.android.dx.dex.code.CstInsn)12 CstString (com.taobao.android.dx.rop.cst.CstString)12 RegisterSpec (com.taobao.android.dx.rop.code.RegisterSpec)10 TypedConstant (com.taobao.android.dx.rop.cst.TypedConstant)10 CstLiteralBits (com.taobao.android.dx.rop.cst.CstLiteralBits)9 CstFieldRef (com.taobao.android.dx.rop.cst.CstFieldRef)6 CstInteger (com.taobao.android.dx.rop.cst.CstInteger)6 Type (com.taobao.android.dx.rop.type.Type)5 NameValuePair (com.taobao.android.dx.rop.annotation.NameValuePair)4 Insn (com.taobao.android.dx.rop.code.Insn)4 PlainInsn (com.taobao.android.dx.rop.code.PlainInsn)4 CstMethodRef (com.taobao.android.dx.rop.cst.CstMethodRef)4 TypeBearer (com.taobao.android.dx.rop.type.TypeBearer)4 Rop (com.taobao.android.dx.rop.code.Rop)3 ThrowingCstInsn (com.taobao.android.dx.rop.code.ThrowingCstInsn)3 ArrayList (java.util.ArrayList)3 CstInsn (com.taobao.android.dx.rop.code.CstInsn)2