Search in sources :

Example 1 with AttConstantValue

use of com.android.dx.cf.attrib.AttConstantValue in project buck by facebook.

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.android.dx.cf.attrib.AttConstantValue)

Example 2 with AttConstantValue

use of com.android.dx.cf.attrib.AttConstantValue in project buck by facebook.

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.android.dx.rop.cst.TypedConstant) Attribute(com.android.dx.cf.iface.Attribute) ConstantPool(com.android.dx.rop.cst.ConstantPool) ByteArray(com.android.dx.util.ByteArray) AttConstantValue(com.android.dx.cf.attrib.AttConstantValue)

Aggregations

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