PlainInsnpublic final class PlainInsn extends Insn Plain instruction, which has no embedded data and which cannot possibly
throw an exception. |
Constructors Summary |
---|
public PlainInsn(Rop opcode, SourcePosition position, RegisterSpec result, RegisterSpecList sources)Constructs an instance.
super(opcode, position, result, sources);
switch (opcode.getBranchingness()) {
case Rop.BRANCH_SWITCH:
case Rop.BRANCH_THROW: {
throw new IllegalArgumentException("bogus branchingness");
}
}
if (result != null && opcode.getBranchingness() != Rop.BRANCH_NONE) {
// move-result-pseudo is required here
throw new IllegalArgumentException
("can't mix branchingness with result");
}
| public PlainInsn(Rop opcode, SourcePosition position, RegisterSpec result, RegisterSpec source)Constructs a single-source instance.
this(opcode, position, result, RegisterSpecList.make(source));
|
Methods Summary |
---|
public void | accept(Visitor visitor){@inheritDoc}
visitor.visitPlainInsn(this);
| public com.android.dx.rop.type.TypeList | getCatches(){@inheritDoc}
return StdTypeList.EMPTY;
| public Insn | withAddedCatch(com.android.dx.rop.type.Type type){@inheritDoc}
throw new UnsupportedOperationException("unsupported");
| public Insn | withNewRegisters(RegisterSpec result, RegisterSpecList sources){@inheritDoc}
return new PlainInsn(getOpcode(), getPosition(),
result,
sources);
| public Insn | withRegisterOffset(int delta){@inheritDoc}
return new PlainInsn(getOpcode(), getPosition(),
getResult().withOffset(delta),
getSources().withOffset(delta));
| public Insn | withSourceLiteral(){@inheritDoc}
RegisterSpecList sources = getSources();
int szSources = sources.size();
if (szSources == 0) {
return this;
}
TypeBearer lastType = sources.get(szSources - 1).getTypeBearer();
if (!lastType.isConstant()) {
// Check for reverse subtraction, where first source is constant
TypeBearer firstType = sources.get(0).getTypeBearer();
if (szSources == 2 && firstType.isConstant()) {
Constant cst = (Constant) firstType;
RegisterSpecList newSources = sources.withoutFirst();
Rop newRop = Rops.ropFor(getOpcode().getOpcode(), getResult(),
newSources, cst);
return new PlainCstInsn(newRop, getPosition(), getResult(),
newSources, cst);
}
return this;
} else {
Constant cst = (Constant) lastType;
RegisterSpecList newSources = sources.withoutLast();
Rop newRop;
try {
// Check for constant subtraction and flip it to be addition
int opcode = getOpcode().getOpcode();
if (opcode == RegOps.SUB && cst instanceof CstInteger) {
opcode = RegOps.ADD;
cst = CstInteger.make(-((CstInteger)cst).getValue());
}
newRop = Rops.ropFor(opcode, getResult(), newSources, cst);
} catch (IllegalArgumentException ex) {
// There's no rop for this case
return this;
}
return new PlainCstInsn(newRop, getPosition(),
getResult(), newSources, cst);
}
|
|