use of com.android.dx.rop.code.SourcePosition in project J2ME-Loader by nikita36078.
the class BlockAddresses method setupArrays.
/**
* Sets up the address arrays.
*/
private void setupArrays(RopMethod method) {
BasicBlockList blocks = method.getBlocks();
int sz = blocks.size();
for (int i = 0; i < sz; i++) {
BasicBlock one = blocks.get(i);
int label = one.getLabel();
Insn insn = one.getInsns().get(0);
starts[label] = new CodeAddress(insn.getPosition());
SourcePosition pos = one.getLastInsn().getPosition();
lasts[label] = new CodeAddress(pos);
ends[label] = new CodeAddress(pos);
}
}
use of com.android.dx.rop.code.SourcePosition in project J2ME-Loader by nikita36078.
the class Ropper method addReturnBlock.
/**
* Constructs and adds the return block, if necessary. The return
* block merely contains an appropriate {@code return}
* instruction.
*/
private void addReturnBlock() {
Rop returnOp = machine.getReturnOp();
if (returnOp == null) {
/*
* The method being converted never returns normally, so there's
* no need for a return block.
*/
return;
}
SourcePosition returnPos = machine.getReturnPosition();
int label = getSpecialLabel(RETURN);
if (isSynchronized()) {
InsnList insns = new InsnList(1);
Insn insn = new ThrowingInsn(Rops.MONITOR_EXIT, returnPos, RegisterSpecList.make(getSynchReg()), StdTypeList.EMPTY);
insns.set(0, insn);
insns.setImmutable();
int nextLabel = getSpecialLabel(SYNCH_RETURN);
BasicBlock bb = new BasicBlock(label, insns, IntList.makeImmutable(nextLabel), nextLabel);
addBlock(bb, IntList.EMPTY);
label = nextLabel;
}
InsnList insns = new InsnList(1);
TypeList sourceTypes = returnOp.getSources();
RegisterSpecList sources;
if (sourceTypes.size() == 0) {
sources = RegisterSpecList.EMPTY;
} else {
RegisterSpec source = RegisterSpec.make(0, sourceTypes.getType(0));
sources = RegisterSpecList.make(source);
}
Insn insn = new PlainInsn(returnOp, returnPos, null, sources);
insns.set(0, insn);
insns.setImmutable();
BasicBlock bb = new BasicBlock(label, insns, IntList.EMPTY, -1);
addBlock(bb, IntList.EMPTY);
}
use of com.android.dx.rop.code.SourcePosition in project J2ME-Loader by nikita36078.
the class PositionList method make.
/**
* Extracts and returns the source position information out of an
* instruction list.
*
* @param insns {@code non-null;} instructions to convert
* @param howMuch how much information should be included; one of the
* static constants defined by this class
* @return {@code non-null;} the positions list
*/
public static PositionList make(DalvInsnList insns, int howMuch) {
switch(howMuch) {
case NONE:
{
return EMPTY;
}
case LINES:
case IMPORTANT:
{
// Valid.
break;
}
default:
{
throw new IllegalArgumentException("bogus howMuch");
}
}
SourcePosition noInfo = SourcePosition.NO_INFO;
SourcePosition cur = noInfo;
int sz = insns.size();
PositionList.Entry[] arr = new PositionList.Entry[sz];
boolean lastWasTarget = false;
int at = 0;
for (int i = 0; i < sz; i++) {
DalvInsn insn = insns.get(i);
if (insn instanceof CodeAddress) {
lastWasTarget = true;
;
continue;
}
SourcePosition pos = insn.getPosition();
if (pos.equals(noInfo) || pos.sameLine(cur)) {
continue;
}
if ((howMuch == IMPORTANT) && !lastWasTarget) {
continue;
}
cur = pos;
arr[at] = new PositionList.Entry(insn.getAddress(), pos);
at++;
lastWasTarget = false;
}
PositionList result = new PositionList(at);
for (int i = 0; i < at; i++) {
result.set(i, arr[i]);
}
result.setImmutable();
return result;
}
Aggregations