use of com.taobao.android.dx.rop.cst.Constant in project atlas by alibaba.
the class DalvInsnList method getOutsSize.
/**
* Gets the size of the outgoing arguments area required by this
* method. This is equal to the largest argument word count of any
* method referred to by this instance.
*
* @return {@code >= 0;} the required outgoing arguments size
*/
public int getOutsSize() {
int sz = size();
int result = 0;
for (int i = 0; i < sz; i++) {
DalvInsn insn = (DalvInsn) get0(i);
if (!(insn instanceof CstInsn)) {
continue;
}
Constant cst = ((CstInsn) insn).getConstant();
if (!(cst instanceof CstBaseMethodRef)) {
continue;
}
boolean isStatic = (insn.getOpcode().getFamily() == Opcodes.INVOKE_STATIC);
int count = ((CstBaseMethodRef) cst).getParameterWordCount(isStatic);
if (count > result) {
result = count;
}
}
return result;
}
use of com.taobao.android.dx.rop.cst.Constant in project atlas by alibaba.
the class Form21c method isCompatible.
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
if (!(insn instanceof CstInsn)) {
return false;
}
RegisterSpecList regs = insn.getRegisters();
RegisterSpec reg;
switch(regs.size()) {
case 1:
{
reg = regs.get(0);
break;
}
case 2:
{
/*
* This format is allowed for ops that are effectively
* 2-arg but where the two args are identical.
*/
reg = regs.get(0);
if (reg.getReg() != regs.get(1).getReg()) {
return false;
}
break;
}
default:
{
return false;
}
}
if (!unsignedFitsInByte(reg.getReg())) {
return false;
}
CstInsn ci = (CstInsn) insn;
int cpi = ci.getIndex();
Constant cst = ci.getConstant();
if (!unsignedFitsInShort(cpi)) {
return false;
}
return (cst instanceof CstType) || (cst instanceof CstFieldRef) || (cst instanceof CstString);
}
use of com.taobao.android.dx.rop.cst.Constant in project atlas by alibaba.
the class Form21h method isCompatible.
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
RegisterSpecList regs = insn.getRegisters();
if (!((insn instanceof CstInsn) && (regs.size() == 1) && unsignedFitsInByte(regs.get(0).getReg()))) {
return false;
}
CstInsn ci = (CstInsn) insn;
Constant cst = ci.getConstant();
if (!(cst instanceof CstLiteralBits)) {
return false;
}
CstLiteralBits cb = (CstLiteralBits) cst;
// Where the high bits are depends on the category of the target.
if (regs.get(0).getCategory() == 1) {
int bits = cb.getIntBits();
return ((bits & 0xffff) == 0);
} else {
long bits = cb.getLongBits();
return ((bits & 0xffffffffffffL) == 0);
}
}
use of com.taobao.android.dx.rop.cst.Constant in project atlas by alibaba.
the class Form22c method isCompatible.
/** {@inheritDoc} */
@Override
public boolean isCompatible(DalvInsn insn) {
RegisterSpecList regs = insn.getRegisters();
if (!((insn instanceof CstInsn) && (regs.size() == 2) && unsignedFitsInNibble(regs.get(0).getReg()) && unsignedFitsInNibble(regs.get(1).getReg()))) {
return false;
}
CstInsn ci = (CstInsn) insn;
int cpi = ci.getIndex();
if (!unsignedFitsInShort(cpi)) {
return false;
}
Constant cst = ci.getConstant();
return (cst instanceof CstType) || (cst instanceof CstFieldRef);
}
use of com.taobao.android.dx.rop.cst.Constant in project atlas by alibaba.
the class ClassDataItem method makeStaticValuesConstant.
/**
* Gets a {@link CstArray} corresponding to {@link #staticValues} if
* it contains any non-zero non-{@code null} values.
*
* @return {@code null-ok;} the corresponding constant or {@code null} if
* there are no values to encode
*/
private CstArray makeStaticValuesConstant() {
// First sort the statics into their final order.
Collections.sort(staticFields);
/*
* Get the size of staticValues minus any trailing zeros/nulls (both
* nulls per se as well as instances of CstKnownNull).
*/
int size = staticFields.size();
while (size > 0) {
EncodedField field = staticFields.get(size - 1);
Constant cst = staticValues.get(field);
if (cst instanceof CstLiteralBits) {
// Note: CstKnownNull extends CstLiteralBits.
if (((CstLiteralBits) cst).getLongBits() != 0) {
break;
}
} else if (cst != null) {
break;
}
size--;
}
if (size == 0) {
return null;
}
// There is something worth encoding, so build up a result.
CstArray.List list = new CstArray.List(size);
for (int i = 0; i < size; i++) {
EncodedField field = staticFields.get(i);
Constant cst = staticValues.get(field);
if (cst == null) {
cst = Zeroes.zeroFor(field.getRef().getType());
}
list.set(i, cst);
}
list.setImmutable();
return new CstArray(list);
}
Aggregations