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()));
}
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;
}
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();
}
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);
}
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();
}
}
Aggregations