use of com.android.dx.rop.type.Type in project J2ME-Loader by nikita36078.
the class TypeListItem method writeTo0.
/**
* {@inheritDoc}
*/
@Override
protected void writeTo0(DexFile file, AnnotatedOutput out) {
TypeIdsSection typeIds = file.getTypeIds();
int sz = list.size();
if (out.annotates()) {
out.annotate(0, offsetString() + " type_list");
out.annotate(HEADER_SIZE, " size: " + Hex.u4(sz));
for (int i = 0; i < sz; i++) {
Type one = list.getType(i);
int idx = typeIds.indexOf(one);
out.annotate(ELEMENT_SIZE, " " + Hex.u2(idx) + " // " + one.toHuman());
}
}
out.writeInt(sz);
for (int i = 0; i < sz; i++) {
out.writeShort(typeIds.indexOf(list.getType(i)));
}
}
use of com.android.dx.rop.type.Type in project J2ME-Loader by nikita36078.
the class RegisterSpec method intersect.
/**
* Returns an instance that is the intersection between this instance
* and the given one, if any. The intersection is defined as follows:
*
* <ul>
* <li>If {@code other} is {@code null}, then the result
* is {@code null}.
* <li>If the register numbers don't match, then the intersection
* is {@code null}. Otherwise, the register number of the
* intersection is the same as the one in the two instances.</li>
* <li>If the types returned by {@code getType()} are not
* {@code equals()}, then the intersection is null.</li>
* <li>If the type bearers returned by {@code getTypeBearer()}
* are {@code equals()}, then the intersection's type bearer
* is the one from this instance. Otherwise, the intersection's
* type bearer is the {@code getType()} of this instance.</li>
* <li>If the locals are {@code equals()}, then the local info
* of the intersection is the local info of this instance. Otherwise,
* the local info of the intersection is {@code null}.</li>
* </ul>
*
* @param other {@code null-ok;} instance to intersect with (or {@code null})
* @param localPrimary whether local variables are primary to the
* intersection; if {@code true}, then the only non-null
* results occur when registers being intersected have equal local
* infos (or both have {@code null} local infos)
* @return {@code null-ok;} the intersection
*/
public RegisterSpec intersect(RegisterSpec other, boolean localPrimary) {
if (this == other) {
// Easy out.
return this;
}
if ((other == null) || (reg != other.getReg())) {
return null;
}
LocalItem resultLocal = ((local == null) || !local.equals(other.getLocalItem())) ? null : local;
boolean sameName = (resultLocal == local);
if (localPrimary && !sameName) {
return null;
}
Type thisType = getType();
Type otherType = other.getType();
// Note: Types are always interned.
if (thisType != otherType) {
return null;
}
TypeBearer resultTypeBearer = type.equals(other.getTypeBearer()) ? type : thisType;
if ((resultTypeBearer == type) && sameName) {
// It turns out that the intersection is "this" after all.
return this;
}
return (resultLocal == null) ? make(reg, resultTypeBearer) : make(reg, resultTypeBearer, resultLocal);
}
use of com.android.dx.rop.type.Type in project J2ME-Loader by nikita36078.
the class RegisterSpec method withSimpleType.
/**
* Returns an instance that is identical to this one, except that
* the type bearer is replaced by the actual underlying type
* (thereby stripping off non-type information) with any
* initialization information stripped away as well.
*
* @return {@code non-null;} an appropriately-constructed instance
*/
public RegisterSpec withSimpleType() {
TypeBearer orig = type;
Type newType;
if (orig instanceof Type) {
newType = (Type) orig;
} else {
newType = orig.getType();
}
if (newType.isUninitialized()) {
newType = newType.getInitializedType();
}
if (newType == orig) {
return this;
}
return makeLocalOptional(reg, newType, local);
}
use of com.android.dx.rop.type.Type in project J2ME-Loader by nikita36078.
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.android.dx.rop.type.Type in project J2ME-Loader by nikita36078.
the class Rop method toString.
/**
* {@inheritDoc}
*/
@Override
public String toString() {
StringBuffer sb = new StringBuffer(40);
sb.append("Rop{");
sb.append(RegOps.opName(opcode));
if (result != Type.VOID) {
sb.append(" ");
sb.append(result);
} else {
sb.append(" .");
}
sb.append(" <-");
int sz = sources.size();
if (sz == 0) {
sb.append(" .");
} else {
for (int i = 0; i < sz; i++) {
sb.append(' ');
sb.append(sources.getType(i));
}
}
if (isCallLike) {
sb.append(" call");
}
sz = exceptions.size();
if (sz != 0) {
sb.append(" throws");
for (int i = 0; i < sz; i++) {
sb.append(' ');
Type one = exceptions.getType(i);
if (one == Type.THROWABLE) {
sb.append("<any>");
} else {
sb.append(exceptions.getType(i));
}
}
} else {
switch(branchingness) {
case BRANCH_NONE:
sb.append(" flows");
break;
case BRANCH_RETURN:
sb.append(" returns");
break;
case BRANCH_GOTO:
sb.append(" gotos");
break;
case BRANCH_IF:
sb.append(" ifs");
break;
case BRANCH_SWITCH:
sb.append(" switches");
break;
default:
sb.append(" " + Hex.u1(branchingness));
break;
}
}
sb.append('}');
return sb.toString();
}
Aggregations