use of com.taobao.android.dx.rop.type.TypeBearer in project atlas by alibaba.
the class OneLocalsArray method annotate.
/** @inheritDoc */
public void annotate(ExceptionWithContext ex) {
for (int i = 0; i < locals.length; i++) {
TypeBearer type = locals[i];
String s = (type == null) ? "<invalid>" : type.toString();
ex.addContext("locals[" + Hex.u2(i) + "]: " + s);
}
}
use of com.taobao.android.dx.rop.type.TypeBearer in project atlas by alibaba.
the class OneLocalsArray method toHuman.
/** {@inheritDoc*/
public String toHuman() {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < locals.length; i++) {
TypeBearer type = locals[i];
String s = (type == null) ? "<invalid>" : type.toString();
sb.append("locals[" + Hex.u2(i) + "]: " + s + "\n");
}
return sb.toString();
}
use of com.taobao.android.dx.rop.type.TypeBearer in project atlas by alibaba.
the class OneLocalsArray method getCategory1.
/** @inheritDoc */
public TypeBearer getCategory1(int idx) {
TypeBearer result = get(idx);
Type type = result.getType();
if (type.isUninitialized()) {
return throwSimException(idx, "uninitialized instance");
}
if (type.isCategory2()) {
return throwSimException(idx, "category-2");
}
return result;
}
use of com.taobao.android.dx.rop.type.TypeBearer in project atlas by alibaba.
the class ExecutionStack method change.
/**
* Changes an element already on a stack. This method is useful in limited
* contexts, particularly when merging two instances. As such, it places
* the following restriction on its behavior: You may only replace
* values with other values of the same category.
*
* @param n {@code >= 0;} which element to change, where {@code 0} is
* the top element of the stack
* @param type {@code non-null;} type of the new value
* @throws SimException thrown if {@code n >= size()} or
* the action is otherwise prohibited
*/
public void change(int n, TypeBearer type) {
throwIfImmutable();
try {
type = type.getFrameType();
} catch (NullPointerException ex) {
// Elucidate the exception.
throw new NullPointerException("type == null");
}
int idx = stackPtr - n - 1;
TypeBearer orig = stack[idx];
if ((orig == null) || (orig.getType().getCategory() != type.getType().getCategory())) {
throwSimException("incompatible substitution: " + stackElementString(orig) + " -> " + stackElementString(type));
}
stack[idx] = type;
}
use of com.taobao.android.dx.rop.type.TypeBearer in project atlas by alibaba.
the class Merger method mergeLocals.
/**
* Merges two locals arrays. If the merged result is the same as the first
* argument, then return the first argument (not a copy).
*
* @param locals1 {@code non-null;} a locals array
* @param locals2 {@code non-null;} another locals array
* @return {@code non-null;} the result of merging the two locals arrays
*/
public static OneLocalsArray mergeLocals(OneLocalsArray locals1, OneLocalsArray locals2) {
if (locals1 == locals2) {
// Easy out.
return locals1;
}
int sz = locals1.getMaxLocals();
OneLocalsArray result = null;
if (locals2.getMaxLocals() != sz) {
throw new SimException("mismatched maxLocals values");
}
for (int i = 0; i < sz; i++) {
TypeBearer tb1 = locals1.getOrNull(i);
TypeBearer tb2 = locals2.getOrNull(i);
TypeBearer resultType = mergeType(tb1, tb2);
if (resultType != tb1) {
/*
* We only need to do anything when the result differs
* from what is in the first array, since that's what the
* result gets initialized to.
*/
if (result == null) {
result = locals1.copy();
}
if (resultType == null) {
result.invalidate(i);
} else {
result.set(i, resultType);
}
}
}
if (result == null) {
return locals1;
}
result.setImmutable();
return result;
}
Aggregations