use of com.taobao.android.dx.rop.cst.CstString in project atlas by alibaba.
the class TypeIdItem method writeTo.
/** {@inheritDoc} */
@Override
public void writeTo(DexFile file, AnnotatedOutput out) {
CstType type = getDefiningClass();
CstString descriptor = type.getDescriptor();
int idx = file.getStringIds().indexOf(descriptor);
if (out.annotates()) {
out.annotate(0, indexString() + ' ' + descriptor.toHuman());
out.annotate(4, " descriptor_idx: " + Hex.u4(idx));
}
out.writeInt(idx);
}
use of com.taobao.android.dx.rop.cst.CstString in project atlas by alibaba.
the class AnnotationItem method annotateTo.
/**
* Write a (listing file) annotation for this instance to the given
* output, that consumes no bytes of output. This is for annotating
* a reference to this instance at the point of the reference.
*
* @param out {@code non-null;} where to output to
* @param prefix {@code non-null;} prefix for each line of output
*/
public void annotateTo(AnnotatedOutput out, String prefix) {
out.annotate(0, prefix + "visibility: " + annotation.getVisibility().toHuman());
out.annotate(0, prefix + "type: " + annotation.getType().toHuman());
for (NameValuePair pair : annotation.getNameValuePairs()) {
CstString name = pair.getName();
Constant value = pair.getValue();
out.annotate(0, prefix + name.toHuman() + ": " + ValueEncoder.constantToHuman(value));
}
}
use of com.taobao.android.dx.rop.cst.CstString in project atlas by alibaba.
the class AnnotationUtils method makeSignature.
/**
* Constructs a standard {@code Signature} annotation.
*
* @param signature {@code non-null;} the signature string
* @return {@code non-null;} the annotation
*/
public static Annotation makeSignature(CstString signature) {
Annotation result = new Annotation(SIGNATURE_TYPE, SYSTEM);
/*
* Split the string into pieces that are likely to be common
* across many signatures and the rest of the file.
*/
String raw = signature.getString();
int rawLength = raw.length();
ArrayList<String> pieces = new ArrayList<String>(20);
for (int at = 0; at < rawLength; ) /*at*/
{
char c = raw.charAt(at);
int endAt = at + 1;
if (c == 'L') {
// Scan to ';' or '<'. Consume ';' but not '<'.
while (endAt < rawLength) {
c = raw.charAt(endAt);
if (c == ';') {
endAt++;
break;
} else if (c == '<') {
break;
}
endAt++;
}
} else {
// Scan to 'L' without consuming it.
while (endAt < rawLength) {
c = raw.charAt(endAt);
if (c == 'L') {
break;
}
endAt++;
}
}
pieces.add(raw.substring(at, endAt));
at = endAt;
}
int size = pieces.size();
CstArray.List list = new CstArray.List(size);
for (int i = 0; i < size; i++) {
list.set(i, new CstString(pieces.get(i)));
}
list.setImmutable();
result.put(new NameValuePair(VALUE_STRING, new CstArray(list)));
result.setImmutable();
return result;
}
use of com.taobao.android.dx.rop.cst.CstString in project atlas by alibaba.
the class Main method computeReferencedResources.
private void computeReferencedResources() {
for (Item genericItem : outputDex.getFieldIds().items()) {
FieldIdItem item = (FieldIdItem) genericItem;
CstType fieldClass = item.getDefiningClass();
CstString fieldName = item.getRef().getNat().getName();
if (fieldClass.getClassType().getDescriptor().contains("/R$")) {
// We ignore the name of the containing class for simplicity.
resourceNames.add(fieldName.getString());
}
}
}
use of com.taobao.android.dx.rop.cst.CstString in project atlas by alibaba.
the class OutputFinisher method addConstants.
/**
* Helper for {@link #getAllConstants} which adds all the info for
* a single {@code RegisterSpec}.
*
* @param result {@code non-null;} result set to add to
* @param spec {@code null-ok;} register spec to add
*/
private static void addConstants(HashSet<Constant> result, RegisterSpec spec) {
if (spec == null) {
return;
}
LocalItem local = spec.getLocalItem();
CstString name = local.getName();
CstString signature = local.getSignature();
Type type = spec.getType();
if (type != Type.KNOWN_NULL) {
result.add(CstType.intern(type));
}
if (name != null) {
result.add(name);
}
if (signature != null) {
result.add(signature);
}
}
Aggregations