Search in sources :

Example 1 with AttConstantValue

use of com.taobao.android.dx.cf.attrib.AttConstantValue in project atlas by alibaba.

the class StdField method getConstantValue.

/** {@inheritDoc} */
public TypedConstant getConstantValue() {
    AttributeList attribs = getAttributes();
    AttConstantValue cval = (AttConstantValue) attribs.findFirst(AttConstantValue.ATTRIBUTE_NAME);
    if (cval == null) {
        return null;
    }
    return cval.getConstantValue();
}
Also used : AttConstantValue(com.taobao.android.dx.cf.attrib.AttConstantValue)

Example 2 with AttConstantValue

use of com.taobao.android.dx.cf.attrib.AttConstantValue in project atlas by alibaba.

the class StdAttributeFactory method constantValue.

/**
     * Parses a {@code ConstantValue} attribute.
     */
private Attribute constantValue(DirectClassFile cf, int offset, int length, ParseObserver observer) {
    if (length != 2) {
        return throwBadLength(2);
    }
    ByteArray bytes = cf.getBytes();
    ConstantPool pool = cf.getConstantPool();
    int idx = bytes.getUnsignedShort(offset);
    TypedConstant cst = (TypedConstant) pool.get(idx);
    Attribute result = new AttConstantValue(cst);
    if (observer != null) {
        observer.parsed(bytes, offset, 2, "value: " + cst);
    }
    return result;
}
Also used : TypedConstant(com.taobao.android.dx.rop.cst.TypedConstant) Attribute(com.taobao.android.dx.cf.iface.Attribute) ConstantPool(com.taobao.android.dx.rop.cst.ConstantPool) ByteArray(com.taobao.android.dx.util.ByteArray) AttConstantValue(com.taobao.android.dx.cf.attrib.AttConstantValue)

Aggregations

AttConstantValue (com.taobao.android.dx.cf.attrib.AttConstantValue)2 Attribute (com.taobao.android.dx.cf.iface.Attribute)1 ConstantPool (com.taobao.android.dx.rop.cst.ConstantPool)1 TypedConstant (com.taobao.android.dx.rop.cst.TypedConstant)1 ByteArray (com.taobao.android.dx.util.ByteArray)1