proj_name
stringclasses 131
values | relative_path
stringlengths 30
228
| class_name
stringlengths 1
68
| func_name
stringlengths 1
48
| masked_class
stringlengths 78
9.82k
| func_body
stringlengths 46
9.61k
| len_input
int64 29
2.01k
| len_output
int64 14
1.94k
| total
int64 55
2.05k
| relevant_context
stringlengths 0
38.4k
|
|---|---|---|---|---|---|---|---|---|---|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/TrapMinimizer.java
|
TrapMinimizer
|
internalTransform
|
class TrapMinimizer extends TrapTransformer {
public TrapMinimizer(Singletons.Global g) {
}
public static TrapMinimizer v() {
return soot.G.v().soot_dexpler_TrapMinimizer();
}
@Override
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {<FILL_FUNCTION_BODY>}
}
|
// If we have less then two traps, there's nothing to do here
if (b.getTraps().size() == 0) {
return;
}
ExceptionalUnitGraph eug = ExceptionalUnitGraphFactory.createExceptionalUnitGraph(b, DalvikThrowAnalysis.v(),
Options.v().omit_excepting_unit_edges());
Set<Unit> unitsWithMonitor = getUnitsWithMonitor(eug);
Map<Trap, List<Trap>> replaceTrapBy = new HashMap<Trap, List<Trap>>(b.getTraps().size());
boolean updateTrap = false;
for (Trap tr : b.getTraps()) {
List<Trap> newTraps = new ArrayList<Trap>(); // will contain the new
// traps
Unit firstTrapStmt = tr.getBeginUnit(); // points to the first unit
// in the trap
boolean goesToHandler = false; // true if there is an edge from the
// unit to the handler of the
// current trap
updateTrap = false;
for (Unit u = tr.getBeginUnit(); u != tr.getEndUnit(); u = b.getUnits().getSuccOf(u)) {
if (goesToHandler) {
goesToHandler = false;
} else {
// if the previous unit has no exceptional edge to the
// handler,
// update firstTrapStmt to point to the current unit
firstTrapStmt = u;
}
// If this is the catch-all block and the current unit has an,
// active monitor, we need to keep the block
if (tr.getException().getName().equals("java.lang.Throwable") && unitsWithMonitor.contains(u)) {
goesToHandler = true;
}
// check if the current unit has an edge to the current trap's
// handler
if (!goesToHandler) {
if (DalvikThrowAnalysis.v().mightThrow(u).catchableAs(tr.getException().getType())) {
// We need to be careful here. The ExceptionalUnitGraph
// will
// always give us an edge from the predecessor of the
// excepting
// unit to the handler. This predecessor, however, does
// not need
// to be inside the new minimized catch block.
for (ExceptionDest<Unit> ed : eug.getExceptionDests(u)) {
if (ed.getTrap() == tr) {
goesToHandler = true;
break;
}
}
}
}
if (!goesToHandler) {
// if the current unit does not have an edge to the current
// trap's handler,
// add a new trap starting at firstTrapStmt ending at the
// unit before the
// current unit 'u'.
updateTrap = true;
if (firstTrapStmt == u) {
// updateTrap to true
continue;
}
Trap t = Jimple.v().newTrap(tr.getException(), firstTrapStmt, u, tr.getHandlerUnit());
newTraps.add(t);
} else {
// if the current unit has an edge to the current trap's
// handler,
// add a trap if the current trap has been updated before
// and if the
// next unit is outside the current trap.
if (b.getUnits().getSuccOf(u) == tr.getEndUnit() && updateTrap) {
Trap t = Jimple.v().newTrap(tr.getException(), firstTrapStmt, tr.getEndUnit(), tr.getHandlerUnit());
newTraps.add(t);
}
}
}
// if updateTrap is true, the current trap has to be replaced by the
// set of newly created traps
// (this set can be empty if the trap covers only instructions that
// cannot throw any exceptions)
if (updateTrap) {
replaceTrapBy.put(tr, newTraps);
}
}
// replace traps where necessary
for (Trap k : replaceTrapBy.keySet()) {
b.getTraps().insertAfter(replaceTrapBy.get(k), k); // we must keep
// the order
b.getTraps().remove(k);
}
| 116
| 1,097
| 1,213
|
<methods>public non-sealed void <init>() ,public Set<soot.Unit> getUnitsWithMonitor(soot.toolkits.graph.UnitGraph) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/AgetInstruction.java
|
AgetInstruction
|
jimplify
|
class AgetInstruction extends DexlibAbstractInstruction {
public AgetInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) throws InvalidDalvikBytecodeException {<FILL_FUNCTION_BODY>}
@Override
boolean overridesRegister(int register) {
OneRegisterInstruction i = (OneRegisterInstruction) instruction;
int dest = i.getRegisterA();
return register == dest;
}
}
|
if (!(instruction instanceof Instruction23x)) {
throw new IllegalArgumentException("Expected Instruction23x but got: " + instruction.getClass());
}
Instruction23x aGetInstr = (Instruction23x) instruction;
int dest = aGetInstr.getRegisterA();
Local arrayBase = body.getRegisterLocal(aGetInstr.getRegisterB());
Local index = body.getRegisterLocal(aGetInstr.getRegisterC());
ArrayRef arrayRef = Jimple.v().newArrayRef(arrayBase, index);
Local l = body.getRegisterLocal(dest);
AssignStmt assign = Jimple.v().newAssignStmt(l, arrayRef);
if (aGetInstr.getOpcode() == Opcode.AGET_OBJECT) {
assign.addTag(new ObjectOpTag());
}
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
DalvikTyper.v().addConstraint(assign.getLeftOpBox(), assign.getRightOpBox());
DalvikTyper.v().setType(arrayRef.getIndexBox(), IntType.v(), true);
}
| 142
| 322
| 464
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public org.jf.dexlib2.iface.instruction.Instruction getInstruction() ,public int getLineNumber() ,public soot.Unit getUnit() ,public Set<soot.Type> introducedTypes() ,public abstract void jimplify(soot.dexpler.DexBody) ,public void setLineNumber(int) <variables>protected final non-sealed int codeAddress,protected final non-sealed org.jf.dexlib2.iface.instruction.Instruction instruction,protected int lineNumber,protected soot.Unit unit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/AputInstruction.java
|
AputInstruction
|
jimplify
|
class AputInstruction extends FieldInstruction {
public AputInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {<FILL_FUNCTION_BODY>}
@Override
protected Type getTargetType(DexBody body) {
Instruction23x aPutInstr = (Instruction23x) instruction;
Type t = body.getRegisterLocal(aPutInstr.getRegisterB()).getType();
if (t instanceof ArrayType) {
return ((ArrayType) t).getElementType();
} else {
return UnknownType.v();
}
}
}
|
if (!(instruction instanceof Instruction23x)) {
throw new IllegalArgumentException("Expected Instruction23x but got: " + instruction.getClass());
}
Instruction23x aPutInstr = (Instruction23x) instruction;
int source = aPutInstr.getRegisterA();
Local arrayBase = body.getRegisterLocal(aPutInstr.getRegisterB());
Local index = body.getRegisterLocal(aPutInstr.getRegisterC());
ArrayRef arrayRef = Jimple.v().newArrayRef(arrayBase, index);
Local sourceValue = body.getRegisterLocal(source);
AssignStmt assign = getAssignStmt(body, sourceValue, arrayRef);
if (aPutInstr.getOpcode() == Opcode.APUT_OBJECT) {
assign.addTag(new ObjectOpTag());
}
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
DalvikTyper.v().addConstraint(assign.getLeftOpBox(), assign.getRightOpBox());
DalvikTyper.v().setType(arrayRef.getIndexBox(), IntType.v(), true);
}
| 181
| 320
| 501
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public Set<soot.Type> introducedTypes() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/Binop2addrInstruction.java
|
Binop2addrInstruction
|
getExpression
|
class Binop2addrInstruction extends TaggedInstruction {
public Binop2addrInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {
if (!(instruction instanceof Instruction12x)) {
throw new IllegalArgumentException("Expected Instruction12x but got: " + instruction.getClass());
}
Instruction12x binOp2AddrInstr = (Instruction12x) instruction;
int dest = binOp2AddrInstr.getRegisterA();
Local source1 = body.getRegisterLocal(binOp2AddrInstr.getRegisterA());
Local source2 = body.getRegisterLocal(binOp2AddrInstr.getRegisterB());
Value expr = getExpression(source1, source2);
AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), expr);
assign.addTag(getTag());
setUnit(assign);
addTags(assign);
body.add(assign);
/*
* if (IDalvikTyper.ENABLE_DVKTYPER) { BinopExpr bexpr = (BinopExpr)expr; short op = instruction.getOpcode().value;
* DalvikTyper.v().setType(bexpr.getOp1Box(), op1BinType[op-0xb0], true); DalvikTyper.v().setType(bexpr.getOp2Box(),
* op2BinType[op-0xb0], true); DalvikTyper.v().setType(assign.getLeftOpBox(), resBinType[op-0xb0], false); }
*/
}
private Value getExpression(Local source1, Local source2) {<FILL_FUNCTION_BODY>}
@Override
boolean overridesRegister(int register) {
TwoRegisterInstruction i = (TwoRegisterInstruction) instruction;
int dest = i.getRegisterA();
return register == dest;
}
}
|
Opcode opcode = instruction.getOpcode();
switch (opcode) {
case ADD_LONG_2ADDR:
setTag(new LongOpTag());
return Jimple.v().newAddExpr(source1, source2);
case ADD_FLOAT_2ADDR:
setTag(new FloatOpTag());
return Jimple.v().newAddExpr(source1, source2);
case ADD_DOUBLE_2ADDR:
setTag(new DoubleOpTag());
return Jimple.v().newAddExpr(source1, source2);
case ADD_INT_2ADDR:
setTag(new IntOpTag());
return Jimple.v().newAddExpr(source1, source2);
case SUB_LONG_2ADDR:
setTag(new LongOpTag());
return Jimple.v().newSubExpr(source1, source2);
case SUB_FLOAT_2ADDR:
setTag(new FloatOpTag());
return Jimple.v().newSubExpr(source1, source2);
case SUB_DOUBLE_2ADDR:
setTag(new DoubleOpTag());
return Jimple.v().newSubExpr(source1, source2);
case SUB_INT_2ADDR:
setTag(new IntOpTag());
return Jimple.v().newSubExpr(source1, source2);
case MUL_LONG_2ADDR:
setTag(new LongOpTag());
return Jimple.v().newMulExpr(source1, source2);
case MUL_FLOAT_2ADDR:
setTag(new FloatOpTag());
return Jimple.v().newMulExpr(source1, source2);
case MUL_DOUBLE_2ADDR:
setTag(new DoubleOpTag());
return Jimple.v().newMulExpr(source1, source2);
case MUL_INT_2ADDR:
setTag(new IntOpTag());
return Jimple.v().newMulExpr(source1, source2);
case DIV_LONG_2ADDR:
setTag(new LongOpTag());
return Jimple.v().newDivExpr(source1, source2);
case DIV_FLOAT_2ADDR:
setTag(new FloatOpTag());
return Jimple.v().newDivExpr(source1, source2);
case DIV_DOUBLE_2ADDR:
setTag(new DoubleOpTag());
return Jimple.v().newDivExpr(source1, source2);
case DIV_INT_2ADDR:
setTag(new IntOpTag());
return Jimple.v().newDivExpr(source1, source2);
case REM_LONG_2ADDR:
setTag(new LongOpTag());
return Jimple.v().newRemExpr(source1, source2);
case REM_FLOAT_2ADDR:
setTag(new FloatOpTag());
return Jimple.v().newRemExpr(source1, source2);
case REM_DOUBLE_2ADDR:
setTag(new DoubleOpTag());
return Jimple.v().newRemExpr(source1, source2);
case REM_INT_2ADDR:
setTag(new IntOpTag());
return Jimple.v().newRemExpr(source1, source2);
case AND_LONG_2ADDR:
setTag(new LongOpTag());
return Jimple.v().newAndExpr(source1, source2);
case AND_INT_2ADDR:
setTag(new IntOpTag());
return Jimple.v().newAndExpr(source1, source2);
case OR_LONG_2ADDR:
setTag(new LongOpTag());
return Jimple.v().newOrExpr(source1, source2);
case OR_INT_2ADDR:
setTag(new IntOpTag());
return Jimple.v().newOrExpr(source1, source2);
case XOR_LONG_2ADDR:
setTag(new LongOpTag());
return Jimple.v().newXorExpr(source1, source2);
case XOR_INT_2ADDR:
setTag(new IntOpTag());
return Jimple.v().newXorExpr(source1, source2);
case SHL_LONG_2ADDR:
setTag(new LongOpTag());
return Jimple.v().newShlExpr(source1, source2);
case SHL_INT_2ADDR:
setTag(new IntOpTag());
return Jimple.v().newShlExpr(source1, source2);
case SHR_LONG_2ADDR:
setTag(new LongOpTag());
return Jimple.v().newShrExpr(source1, source2);
case SHR_INT_2ADDR:
setTag(new IntOpTag());
return Jimple.v().newShrExpr(source1, source2);
case USHR_LONG_2ADDR:
setTag(new LongOpTag());
return Jimple.v().newUshrExpr(source1, source2);
case USHR_INT_2ADDR:
setTag(new IntOpTag());
return Jimple.v().newUshrExpr(source1, source2);
default:
throw new RuntimeException("Invalid Opcode: " + opcode);
}
| 528
| 1,380
| 1,908
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public soot.tagkit.Tag getTag() ,public void setTag(soot.tagkit.Tag) <variables>private soot.tagkit.Tag instructionTag
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/BinopInstruction.java
|
BinopInstruction
|
getExpression
|
class BinopInstruction extends TaggedInstruction {
public BinopInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {
if (!(instruction instanceof Instruction23x)) {
throw new IllegalArgumentException("Expected Instruction23x but got: " + instruction.getClass());
}
Instruction23x binOpInstr = (Instruction23x) instruction;
int dest = binOpInstr.getRegisterA();
Local source1 = body.getRegisterLocal(binOpInstr.getRegisterB());
Local source2 = body.getRegisterLocal(binOpInstr.getRegisterC());
Value expr = getExpression(source1, source2);
AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), expr);
assign.addTag(getTag());
setUnit(assign);
addTags(assign);
body.add(assign);
/*
* if (IDalvikTyper.ENABLE_DVKTYPER) { int op = (int)instruction.getOpcode().value; BinopExpr bexpr = (BinopExpr)expr;
* JAssignStmt jassign = (JAssignStmt)assign; DalvikTyper.v().setType(bexpr.getOp1Box(), op1BinType[op-0x90], true);
* DalvikTyper.v().setType(bexpr.getOp2Box(), op2BinType[op-0x90], true); DalvikTyper.v().setType(jassign.leftBox,
* resBinType[op-0x90], false); }
*/
}
private Value getExpression(Local source1, Local source2) {<FILL_FUNCTION_BODY>}
@Override
boolean overridesRegister(int register) {
ThreeRegisterInstruction i = (ThreeRegisterInstruction) instruction;
int dest = i.getRegisterA();
return register == dest;
}
}
|
Opcode opcode = instruction.getOpcode();
switch (opcode) {
case ADD_LONG:
setTag(new LongOpTag());
return Jimple.v().newAddExpr(source1, source2);
case ADD_FLOAT:
setTag(new FloatOpTag());
return Jimple.v().newAddExpr(source1, source2);
case ADD_DOUBLE:
setTag(new DoubleOpTag());
return Jimple.v().newAddExpr(source1, source2);
case ADD_INT:
setTag(new IntOpTag());
return Jimple.v().newAddExpr(source1, source2);
case SUB_LONG:
setTag(new LongOpTag());
return Jimple.v().newSubExpr(source1, source2);
case SUB_FLOAT:
setTag(new FloatOpTag());
return Jimple.v().newSubExpr(source1, source2);
case SUB_DOUBLE:
setTag(new DoubleOpTag());
return Jimple.v().newSubExpr(source1, source2);
case SUB_INT:
setTag(new IntOpTag());
return Jimple.v().newSubExpr(source1, source2);
case MUL_LONG:
setTag(new LongOpTag());
return Jimple.v().newMulExpr(source1, source2);
case MUL_FLOAT:
setTag(new FloatOpTag());
return Jimple.v().newMulExpr(source1, source2);
case MUL_DOUBLE:
setTag(new DoubleOpTag());
return Jimple.v().newMulExpr(source1, source2);
case MUL_INT:
setTag(new IntOpTag());
return Jimple.v().newMulExpr(source1, source2);
case DIV_LONG:
setTag(new LongOpTag());
return Jimple.v().newDivExpr(source1, source2);
case DIV_FLOAT:
setTag(new FloatOpTag());
return Jimple.v().newDivExpr(source1, source2);
case DIV_DOUBLE:
setTag(new DoubleOpTag());
return Jimple.v().newDivExpr(source1, source2);
case DIV_INT:
setTag(new IntOpTag());
return Jimple.v().newDivExpr(source1, source2);
case REM_LONG:
setTag(new LongOpTag());
return Jimple.v().newRemExpr(source1, source2);
case REM_FLOAT:
setTag(new FloatOpTag());
return Jimple.v().newRemExpr(source1, source2);
case REM_DOUBLE:
setTag(new DoubleOpTag());
return Jimple.v().newRemExpr(source1, source2);
case REM_INT:
setTag(new IntOpTag());
return Jimple.v().newRemExpr(source1, source2);
case AND_LONG:
setTag(new LongOpTag());
return Jimple.v().newAndExpr(source1, source2);
case AND_INT:
setTag(new IntOpTag());
return Jimple.v().newAndExpr(source1, source2);
case OR_LONG:
setTag(new LongOpTag());
return Jimple.v().newOrExpr(source1, source2);
case OR_INT:
setTag(new IntOpTag());
return Jimple.v().newOrExpr(source1, source2);
case XOR_LONG:
setTag(new LongOpTag());
return Jimple.v().newXorExpr(source1, source2);
case XOR_INT:
setTag(new IntOpTag());
return Jimple.v().newXorExpr(source1, source2);
case SHL_LONG:
setTag(new LongOpTag());
return Jimple.v().newShlExpr(source1, source2);
case SHL_INT:
setTag(new IntOpTag());
return Jimple.v().newShlExpr(source1, source2);
case SHR_LONG:
setTag(new LongOpTag());
return Jimple.v().newShrExpr(source1, source2);
case SHR_INT:
setTag(new IntOpTag());
return Jimple.v().newShrExpr(source1, source2);
case USHR_LONG:
setTag(new LongOpTag());
return Jimple.v().newUshrExpr(source1, source2);
case USHR_INT:
setTag(new IntOpTag());
return Jimple.v().newUshrExpr(source1, source2);
default:
throw new RuntimeException("Invalid Opcode: " + opcode);
}
| 539
| 1,252
| 1,791
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public soot.tagkit.Tag getTag() ,public void setTag(soot.tagkit.Tag) <variables>private soot.tagkit.Tag instructionTag
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/BinopLitInstruction.java
|
BinopLitInstruction
|
getExpression
|
class BinopLitInstruction extends TaggedInstruction {
public BinopLitInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {
if (!(instruction instanceof Instruction22s) && !(instruction instanceof Instruction22b)) {
throw new IllegalArgumentException("Expected Instruction22s or Instruction22b but got: " + instruction.getClass());
}
NarrowLiteralInstruction binOpLitInstr = (NarrowLiteralInstruction) this.instruction;
int dest = ((TwoRegisterInstruction) instruction).getRegisterA();
int source = ((TwoRegisterInstruction) instruction).getRegisterB();
Local source1 = body.getRegisterLocal(source);
IntConstant constant = IntConstant.v(binOpLitInstr.getNarrowLiteral());
Value expr = getExpression(source1, constant);
AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), expr);
assign.addTag(getTag());
setUnit(assign);
addTags(assign);
body.add(assign);
/*
* if (IDalvikTyper.ENABLE_DVKTYPER) { Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
*
* int op = (int)instruction.getOpcode().value; if (op >= 0xd8) { op -= 0xd8; } else { op -= 0xd0; } BinopExpr bexpr =
* (BinopExpr)expr; //body.dvkTyper.setType((op == 1) ? bexpr.getOp2Box() : bexpr.getOp1Box(), op1BinType[op]);
* DalvikTyper.v().setType(((JAssignStmt)assign).leftBox, op1BinType[op], false);
*
* }
*/
}
@SuppressWarnings("fallthrough")
private Value getExpression(Local source1, Value source2) {<FILL_FUNCTION_BODY>}
@Override
boolean overridesRegister(int register) {
TwoRegisterInstruction i = (TwoRegisterInstruction) instruction;
int dest = i.getRegisterA();
return register == dest;
}
}
|
Opcode opcode = instruction.getOpcode();
switch (opcode) {
case ADD_INT_LIT16:
setTag(new IntOpTag());
case ADD_INT_LIT8:
setTag(new IntOpTag());
return Jimple.v().newAddExpr(source1, source2);
case RSUB_INT:
setTag(new IntOpTag());
case RSUB_INT_LIT8:
setTag(new IntOpTag());
return Jimple.v().newSubExpr(source2, source1);
case MUL_INT_LIT16:
setTag(new IntOpTag());
case MUL_INT_LIT8:
setTag(new IntOpTag());
return Jimple.v().newMulExpr(source1, source2);
case DIV_INT_LIT16:
setTag(new IntOpTag());
case DIV_INT_LIT8:
setTag(new IntOpTag());
return Jimple.v().newDivExpr(source1, source2);
case REM_INT_LIT16:
setTag(new IntOpTag());
case REM_INT_LIT8:
setTag(new IntOpTag());
return Jimple.v().newRemExpr(source1, source2);
case AND_INT_LIT8:
setTag(new IntOpTag());
case AND_INT_LIT16:
setTag(new IntOpTag());
return Jimple.v().newAndExpr(source1, source2);
case OR_INT_LIT16:
setTag(new IntOpTag());
case OR_INT_LIT8:
setTag(new IntOpTag());
return Jimple.v().newOrExpr(source1, source2);
case XOR_INT_LIT16:
setTag(new IntOpTag());
case XOR_INT_LIT8:
setTag(new IntOpTag());
return Jimple.v().newXorExpr(source1, source2);
case SHL_INT_LIT8:
setTag(new IntOpTag());
return Jimple.v().newShlExpr(source1, source2);
case SHR_INT_LIT8:
setTag(new IntOpTag());
return Jimple.v().newShrExpr(source1, source2);
case USHR_INT_LIT8:
setTag(new IntOpTag());
return Jimple.v().newUshrExpr(source1, source2);
default:
throw new RuntimeException("Invalid Opcode: " + opcode);
}
| 611
| 677
| 1,288
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public soot.tagkit.Tag getTag() ,public void setTag(soot.tagkit.Tag) <variables>private soot.tagkit.Tag instructionTag
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/CastInstruction.java
|
CastInstruction
|
jimplify
|
class CastInstruction extends TaggedInstruction {
public CastInstruction(Instruction instruction, int codeAddress) {
super(instruction, codeAddress);
}
@Override
public void jimplify(DexBody body) {<FILL_FUNCTION_BODY>}
/**
* Return the appropriate target type for the covered opcodes.
*
* Note: the tag represents the original type before the cast. The cast type is not lost in Jimple and can be retrieved by
* calling the getCastType() method.
*/
private Type getTargetType() {
Opcode opcode = instruction.getOpcode();
switch (opcode) {
case INT_TO_BYTE:
setTag(new IntOpTag());
return ByteType.v();
case INT_TO_CHAR:
setTag(new IntOpTag());
return CharType.v();
case INT_TO_SHORT:
setTag(new IntOpTag());
return ShortType.v();
case LONG_TO_INT:
setTag(new LongOpTag());
return IntType.v();
case DOUBLE_TO_INT:
setTag(new DoubleOpTag());
return IntType.v();
case FLOAT_TO_INT:
setTag(new FloatOpTag());
return IntType.v();
case INT_TO_LONG:
setTag(new IntOpTag());
return LongType.v();
case DOUBLE_TO_LONG:
setTag(new DoubleOpTag());
return LongType.v();
case FLOAT_TO_LONG:
setTag(new FloatOpTag());
return LongType.v();
case LONG_TO_FLOAT:
setTag(new LongOpTag());
return FloatType.v();
case DOUBLE_TO_FLOAT:
setTag(new DoubleOpTag());
return FloatType.v();
case INT_TO_FLOAT:
setTag(new IntOpTag());
return FloatType.v();
case INT_TO_DOUBLE:
setTag(new IntOpTag());
return DoubleType.v();
case FLOAT_TO_DOUBLE:
setTag(new FloatOpTag());
return DoubleType.v();
case LONG_TO_DOUBLE:
setTag(new LongOpTag());
return DoubleType.v();
default:
throw new RuntimeException("Invalid Opcode: " + opcode);
}
}
@Override
boolean overridesRegister(int register) {
TwoRegisterInstruction i = (TwoRegisterInstruction) instruction;
int dest = i.getRegisterA();
return register == dest;
}
}
|
TwoRegisterInstruction i = (TwoRegisterInstruction) instruction;
int dest = i.getRegisterA();
int source = i.getRegisterB();
Type targetType = getTargetType();
CastExpr cast = Jimple.v().newCastExpr(body.getRegisterLocal(source), targetType);
AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), cast);
assign.addTag(getTag());
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
DalvikTyper.v().setType(assign.getLeftOpBox(), cast.getType(), false);
// DalvikTyper.v().captureAssign((JAssignStmt)assign, op);
}
| 698
| 215
| 913
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public soot.tagkit.Tag getTag() ,public void setTag(soot.tagkit.Tag) <variables>private soot.tagkit.Tag instructionTag
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/CheckCastInstruction.java
|
CheckCastInstruction
|
jimplify
|
class CheckCastInstruction extends DexlibAbstractInstruction {
public CheckCastInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {<FILL_FUNCTION_BODY>}
@Override
public Set<Type> introducedTypes() {
ReferenceInstruction i = (ReferenceInstruction) instruction;
Set<Type> types = new HashSet<Type>();
types.add(DexType.toSoot((TypeReference) i.getReference()));
return types;
}
}
|
if (!(instruction instanceof Instruction21c)) {
throw new IllegalArgumentException("Expected Instruction21c but got: " + instruction.getClass());
}
Instruction21c checkCastInstr = (Instruction21c) instruction;
Local castValue = body.getRegisterLocal(checkCastInstr.getRegisterA());
Type checkCastType = DexType.toSoot((TypeReference) checkCastInstr.getReference());
CastExpr castExpr = Jimple.v().newCastExpr(castValue, checkCastType);
// generate "x = (Type) x"
// splitter will take care of the rest
AssignStmt assign = Jimple.v().newAssignStmt(castValue, castExpr);
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
DalvikTyper.v().setType(assign.getLeftOpBox(), checkCastType, false);
}
| 156
| 261
| 417
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public org.jf.dexlib2.iface.instruction.Instruction getInstruction() ,public int getLineNumber() ,public soot.Unit getUnit() ,public Set<soot.Type> introducedTypes() ,public abstract void jimplify(soot.dexpler.DexBody) ,public void setLineNumber(int) <variables>protected final non-sealed int codeAddress,protected final non-sealed org.jf.dexlib2.iface.instruction.Instruction instruction,protected int lineNumber,protected soot.Unit unit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/CmpInstruction.java
|
CmpInstruction
|
jimplify
|
class CmpInstruction extends TaggedInstruction {
public CmpInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {<FILL_FUNCTION_BODY>}
@Override
boolean overridesRegister(int register) {
ThreeRegisterInstruction i = (ThreeRegisterInstruction) instruction;
int dest = i.getRegisterA();
return register == dest;
}
}
|
if (!(instruction instanceof Instruction23x)) {
throw new IllegalArgumentException("Expected Instruction23x but got: " + instruction.getClass());
}
Instruction23x cmpInstr = (Instruction23x) instruction;
int dest = cmpInstr.getRegisterA();
Local first = body.getRegisterLocal(cmpInstr.getRegisterB());
Local second = body.getRegisterLocal(cmpInstr.getRegisterC());
// Expr cmpExpr;
// Type type = null
Opcode opcode = instruction.getOpcode();
Expr cmpExpr = null;
Type type = null;
switch (opcode) {
case CMPL_DOUBLE:
setTag(new DoubleOpTag());
type = DoubleType.v();
cmpExpr = Jimple.v().newCmplExpr(first, second);
break;
case CMPL_FLOAT:
setTag(new FloatOpTag());
type = FloatType.v();
cmpExpr = Jimple.v().newCmplExpr(first, second);
break;
case CMPG_DOUBLE:
setTag(new DoubleOpTag());
type = DoubleType.v();
cmpExpr = Jimple.v().newCmpgExpr(first, second);
break;
case CMPG_FLOAT:
setTag(new FloatOpTag());
type = FloatType.v();
cmpExpr = Jimple.v().newCmpgExpr(first, second);
break;
case CMP_LONG:
setTag(new LongOpTag());
type = LongType.v();
cmpExpr = Jimple.v().newCmpExpr(first, second);
break;
default:
throw new RuntimeException("no opcode for CMP: " + opcode);
}
AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), cmpExpr);
assign.addTag(getTag());
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
getTag().getName();
BinopExpr bexpr = (BinopExpr) cmpExpr;
DalvikTyper.v().setType(bexpr.getOp1Box(), type, true);
DalvikTyper.v().setType(bexpr.getOp2Box(), type, true);
DalvikTyper.v().setType(((JAssignStmt) assign).getLeftOpBox(), IntType.v(), false);
}
| 132
| 676
| 808
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public soot.tagkit.Tag getTag() ,public void setTag(soot.tagkit.Tag) <variables>private soot.tagkit.Tag instructionTag
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/ConditionalJumpInstruction.java
|
ConditionalJumpInstruction
|
getComparisonExpr
|
class ConditionalJumpInstruction extends JumpInstruction implements DeferableInstruction {
public ConditionalJumpInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
/**
* Return an if statement depending on the instruction.
*/
protected abstract IfStmt ifStatement(DexBody body);
public void jimplify(DexBody body) {
// check if target instruction has been jimplified
DexlibAbstractInstruction ins = getTargetInstruction(body);
if (ins != null && ins.getUnit() != null) {
IfStmt s = ifStatement(body);
body.add(s);
setUnit(s);
} else {
// set marker unit to swap real gotostmt with otherwise
body.addDeferredJimplification(this);
markerUnit = Jimple.v().newNopStmt();
unit = markerUnit;
// beginUnit = markerUnit;
// endUnit = markerUnit;
// beginUnit = markerUnit;
body.add(markerUnit);
// Unit end = Jimple.v().newNopStmt();
// body.add(end);
// endUnit = end;
}
}
// DalvikTyper.v() here?
public void deferredJimplify(DexBody body) {
IfStmt s = ifStatement(body);
body.getBody().getUnits().swapWith(markerUnit, s); // insertAfter(s, markerUnit);
setUnit(s);
}
/**
* Get comparison expression depending on opcode against zero or null.
*
* If the register is used as an object this will create a comparison with null, not zero.
*
* @param body
* the containing DexBody
* @param reg
* the register to compare against zero.
*/
protected ConditionExpr getComparisonExpr(DexBody body, int reg) {
Local one = body.getRegisterLocal(reg);
return getComparisonExpr(one, IntConstant.v(0));
}
/**
* Get comparison expression depending on opcode between two immediates
*
* @param one
* first immediate
* @param other
* second immediate
* @throws RuntimeException
* if this is not a IfTest or IfTestz instruction.
*/
protected ConditionExpr getComparisonExpr(Immediate one, Immediate other) {<FILL_FUNCTION_BODY>}
}
|
Opcode opcode = instruction.getOpcode();
switch (opcode) {
case IF_EQ:
case IF_EQZ:
return Jimple.v().newEqExpr(one, other);
case IF_NE:
case IF_NEZ:
return Jimple.v().newNeExpr(one, other);
case IF_LT:
case IF_LTZ:
return Jimple.v().newLtExpr(one, other);
case IF_GE:
case IF_GEZ:
return Jimple.v().newGeExpr(one, other);
case IF_GT:
case IF_GTZ:
return Jimple.v().newGtExpr(one, other);
case IF_LE:
case IF_LEZ:
return Jimple.v().newLeExpr(one, other);
default:
throw new RuntimeException("Instruction is not an IfTest(z) instruction.");
}
| 628
| 239
| 867
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) <variables>protected soot.Unit markerUnit,protected soot.dexpler.instructions.DexlibAbstractInstruction targetInstruction
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/ConstClassInstruction.java
|
ConstClassInstruction
|
jimplify
|
class ConstClassInstruction extends DexlibAbstractInstruction {
public ConstClassInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {<FILL_FUNCTION_BODY>}
@Override
boolean overridesRegister(int register) {
OneRegisterInstruction i = (OneRegisterInstruction) instruction;
int dest = i.getRegisterA();
return register == dest;
}
@Override
public Set<Type> introducedTypes() {
ReferenceInstruction i = (ReferenceInstruction) instruction;
Set<Type> types = new HashSet<Type>();
types.add(DexType.toSoot((TypeReference) i.getReference()));
return types;
}
}
|
if (!(instruction instanceof Instruction21c)) {
throw new IllegalArgumentException("Expected Instruction21c but got: " + instruction.getClass());
}
ReferenceInstruction constClass = (ReferenceInstruction) this.instruction;
TypeReference tidi = (TypeReference) (constClass.getReference());
Constant cst = ClassConstant.v(tidi.getType());
int dest = ((OneRegisterInstruction) instruction).getRegisterA();
AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), cst);
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
// DalvikTyper.v().captureAssign((JAssignStmt)assign, op); //TODO:
// classtype could be null!
DalvikTyper.v().setType(assign.getLeftOpBox(), cst.getType(), false);
}
| 209
| 262
| 471
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public org.jf.dexlib2.iface.instruction.Instruction getInstruction() ,public int getLineNumber() ,public soot.Unit getUnit() ,public Set<soot.Type> introducedTypes() ,public abstract void jimplify(soot.dexpler.DexBody) ,public void setLineNumber(int) <variables>protected final non-sealed int codeAddress,protected final non-sealed org.jf.dexlib2.iface.instruction.Instruction instruction,protected int lineNumber,protected soot.Unit unit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/ConstStringInstruction.java
|
ConstStringInstruction
|
jimplify
|
class ConstStringInstruction extends DexlibAbstractInstruction {
public ConstStringInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {<FILL_FUNCTION_BODY>}
@Override
boolean overridesRegister(int register) {
OneRegisterInstruction i = (OneRegisterInstruction) instruction;
int dest = i.getRegisterA();
return register == dest;
}
}
|
int dest = ((OneRegisterInstruction) instruction).getRegisterA();
String s;
if (instruction instanceof Instruction21c) {
Instruction21c i = (Instruction21c) instruction;
s = ((StringReference) (i.getReference())).getString();
} else if (instruction instanceof Instruction31c) {
Instruction31c i = (Instruction31c) instruction;
s = ((StringReference) (i.getReference())).getString();
} else {
throw new IllegalArgumentException("Expected Instruction21c or Instruction31c but got neither.");
}
StringConstant sc = StringConstant.v(s);
AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), sc);
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
DalvikTyper.v().setType(assign.getLeftOpBox(), sc.getType(), false);
}
| 133
| 271
| 404
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public org.jf.dexlib2.iface.instruction.Instruction getInstruction() ,public int getLineNumber() ,public soot.Unit getUnit() ,public Set<soot.Type> introducedTypes() ,public abstract void jimplify(soot.dexpler.DexBody) ,public void setLineNumber(int) <variables>protected final non-sealed int codeAddress,protected final non-sealed org.jf.dexlib2.iface.instruction.Instruction instruction,protected int lineNumber,protected soot.Unit unit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/ExecuteInlineInstruction.java
|
ExecuteInlineInstruction
|
getUsedRegistersNums
|
class ExecuteInlineInstruction extends MethodInvocationInstruction implements OdexInstruction {
private Method targetMethod = null;
public ExecuteInlineInstruction(Instruction instruction, int codeAddress) {
super(instruction, codeAddress);
}
@Override
public void deOdex(DexFile parentFile, Method method, ClassPath cp) {
if (!(parentFile instanceof DexBackedOdexFile)) {
throw new RuntimeException("ODEX instruction in non-ODEX file");
}
DexBackedOdexFile odexFile = (DexBackedOdexFile) parentFile;
InlineMethodResolver inlineMethodResolver = InlineMethodResolver.createInlineMethodResolver(odexFile.getOdexVersion());
MethodAnalyzer analyzer = new MethodAnalyzer(cp, method, inlineMethodResolver, false);
targetMethod = inlineMethodResolver.resolveExecuteInline(new AnalyzedInstruction(analyzer, instruction, -1, -1));
}
@Override
public void jimplify(DexBody body) {
int acccessFlags = targetMethod.getAccessFlags();
if (AccessFlags.STATIC.isSet(acccessFlags)) {
jimplifyStatic(body);
} else if (AccessFlags.PRIVATE.isSet(acccessFlags)) {
jimplifySpecial(body);
} else {
jimplifyVirtual(body);
}
}
/**
* Return the indices used in this instruction.
*
* @return a list of register indices
*/
protected List<Integer> getUsedRegistersNums() {<FILL_FUNCTION_BODY>}
}
|
if (instruction instanceof Instruction35mi) {
return getUsedRegistersNums((Instruction35mi) instruction);
} else if (instruction instanceof Instruction3rmi) {
return getUsedRegistersNums((Instruction3rmi) instruction);
}
throw new RuntimeException("Instruction is not an ExecuteInline");
| 418
| 89
| 507
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public void finalize(soot.dexpler.DexBody, soot.dexpler.instructions.DexlibAbstractInstruction) ,public Set<soot.Type> introducedTypes() <variables>protected soot.jimple.AssignStmt assign,protected soot.jimple.InvokeExpr invocation
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/FieldInstruction.java
|
FieldInstruction
|
sourceRegister
|
class FieldInstruction extends DexlibAbstractInstruction {
public FieldInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
/**
* Return a static SootFieldRef for a dexlib FieldReference.
*
* @param item
* the dexlib FieldReference.
*/
protected SootFieldRef getStaticSootFieldRef(FieldReference fref) {
return getSootFieldRef(fref, true);
}
/**
* Return a SootFieldRef for a dexlib FieldReference.
*
* @param item
* the dexlib FieldReference.
*/
protected SootFieldRef getSootFieldRef(FieldReference fref) {
return getSootFieldRef(fref, false);
}
/**
* Return a SootFieldRef for a dexlib FieldReference.
*
* @param item
* the dexlib FieldReference.
* @param isStatic
* if the FieldRef should be static
*/
private SootFieldRef getSootFieldRef(FieldReference fref, boolean isStatic) {
String className = dottedClassName(fref.getDefiningClass());
SootClass sc = SootResolver.v().makeClassRef(className);
return Scene.v().makeFieldRef(sc, fref.getName(), DexType.toSoot(fref.getType()), isStatic);
}
/**
* Check if the field type equals the type of the value that will be stored in the field. A cast expression has to be
* introduced for the unequal case.
*
* @return assignment statement which hold a cast or not depending on the types of the operation
*/
protected AssignStmt getAssignStmt(DexBody body, Local sourceValue, ConcreteRef instanceField) {
AssignStmt assign;
// Type targetType = getTargetType(body);
// if(targetType != UnknownType.v() && targetType != sourceValue.getType() && ! (targetType instanceof RefType)) {
// CastExpr castExpr = Jimple.v().newCastExpr(sourceValue, targetType);
// Local local = body.generateLocal(targetType);
// assign = Jimple.v().newAssignStmt(local, castExpr);
// body.add(assign);
// beginUnit = assign;
// assign = Jimple.v().newAssignStmt(instanceField, local);
// }
// else {
assign = Jimple.v().newAssignStmt(instanceField, sourceValue);
// }
return assign;
}
@Override
boolean isUsedAsFloatingPoint(DexBody body, int register) {
return sourceRegister() == register && isFloatLike(getTargetType(body));
}
/**
* Return the source register for this instruction.
*/
private int sourceRegister() {<FILL_FUNCTION_BODY>}
/**
* Return the target type for put instructions.
*
* Putters should override this.
*
* @param body
* the body containing this instruction
*/
protected Type getTargetType(DexBody body) {
return UnknownType.v();
}
@Override
public Set<Type> introducedTypes() {
Set<Type> types = new HashSet<Type>();
// Aput instructions don't have references
if (!(instruction instanceof ReferenceInstruction)) {
return types;
}
ReferenceInstruction i = (ReferenceInstruction) instruction;
FieldReference field = (FieldReference) i.getReference();
types.add(DexType.toSoot(field.getType()));
types.add(DexType.toSoot(field.getDefiningClass()));
return types;
}
}
|
// I hate smali's API ..
if (instruction instanceof Instruction23x) {
return ((Instruction23x) instruction).getRegisterA();
} else if (instruction instanceof Instruction22c) {
return ((Instruction22c) instruction).getRegisterA();
} else if (instruction instanceof Instruction21c) {
return ((Instruction21c) instruction).getRegisterA();
} else {
throw new RuntimeException("Instruction is not a instance, array or static op");
}
| 960
| 135
| 1,095
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public org.jf.dexlib2.iface.instruction.Instruction getInstruction() ,public int getLineNumber() ,public soot.Unit getUnit() ,public Set<soot.Type> introducedTypes() ,public abstract void jimplify(soot.dexpler.DexBody) ,public void setLineNumber(int) <variables>protected final non-sealed int codeAddress,protected final non-sealed org.jf.dexlib2.iface.instruction.Instruction instruction,protected int lineNumber,protected soot.Unit unit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/FillArrayDataInstruction.java
|
FillArrayDataInstruction
|
computeDataOffsets
|
class FillArrayDataInstruction extends PseudoInstruction {
private static final Logger logger = LoggerFactory.getLogger(FillArrayDataInstruction.class);
public FillArrayDataInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {
if (!(instruction instanceof Instruction31t)) {
throw new IllegalArgumentException("Expected Instruction31t but got: " + instruction.getClass());
}
Instruction31t fillArrayInstr = (Instruction31t) instruction;
int destRegister = fillArrayInstr.getRegisterA();
int offset = fillArrayInstr.getCodeOffset();
int targetAddress = codeAddress + offset;
Instruction referenceTable = body.instructionAtAddress(targetAddress).instruction;
if (!(referenceTable instanceof ArrayPayload)) {
throw new RuntimeException("Address " + targetAddress + "refers to an invalid PseudoInstruction.");
}
ArrayPayload arrayTable = (ArrayPayload) referenceTable;
// NopStmt nopStmtBeginning = Jimple.v().newNopStmt();
// body.add(nopStmtBeginning);
Local arrayReference = body.getRegisterLocal(destRegister);
List<Number> elements = arrayTable.getArrayElements();
int numElements = elements.size();
Stmt firstAssign = null;
for (int i = 0; i < numElements; i++) {
ArrayRef arrayRef = Jimple.v().newArrayRef(arrayReference, IntConstant.v(i));
NumericConstant element = getArrayElement(elements.get(i), body, destRegister);
if (element == null) {
break;
}
AssignStmt assign = Jimple.v().newAssignStmt(arrayRef, element);
addTags(assign);
body.add(assign);
if (i == 0) {
firstAssign = assign;
}
}
if (firstAssign == null) { // if numElements == 0. Is it possible?
firstAssign = Jimple.v().newNopStmt();
body.add(firstAssign);
}
// NopStmt nopStmtEnd = Jimple.v().newNopStmt();
// body.add(nopStmtEnd);
// defineBlock(nopStmtBeginning, nopStmtEnd);
setUnit(firstAssign);
}
private NumericConstant getArrayElement(Number element, DexBody body, int arrayRegister) {
List<DexlibAbstractInstruction> instructions = body.instructionsBefore(this);
Set<Integer> usedRegisters = new HashSet<Integer>();
usedRegisters.add(arrayRegister);
Type elementType = null;
Outer: for (DexlibAbstractInstruction i : instructions) {
if (usedRegisters.isEmpty()) {
break;
}
for (int reg : usedRegisters) {
if (i instanceof NewArrayInstruction) {
NewArrayInstruction newArrayInstruction = (NewArrayInstruction) i;
Instruction22c instruction22c = (Instruction22c) newArrayInstruction.instruction;
if (instruction22c.getRegisterA() == reg) {
ArrayType arrayType = (ArrayType) DexType.toSoot((TypeReference) instruction22c.getReference());
elementType = arrayType.getElementType();
break Outer;
}
}
}
// // look for obsolete registers
// for (int reg : usedRegisters) {
// if (i.overridesRegister(reg)) {
// usedRegisters.remove(reg);
// break; // there can't be more than one obsolete
// }
// }
// look for new registers
for (int reg : usedRegisters) {
int newRegister = i.movesToRegister(reg);
if (newRegister != -1) {
usedRegisters.add(newRegister);
usedRegisters.remove(reg);
break; // there can't be more than one new
}
}
}
if (elementType == null) {
// throw new InternalError("Unable to find array type to type array elements!");
logger.warn("Unable to find array type to type array elements! Array was not defined! (obfuscated bytecode?)");
return null;
}
NumericConstant value;
if (elementType instanceof BooleanType) {
value = IntConstant.v(element.intValue());
IntConstant ic = (IntConstant) value;
if (ic.value != 0) {
value = IntConstant.v(1);
}
} else if (elementType instanceof ByteType) {
value = IntConstant.v(element.byteValue());
} else if (elementType instanceof CharType || elementType instanceof ShortType) {
value = IntConstant.v(element.shortValue());
} else if (elementType instanceof DoubleType) {
value = DoubleConstant.v(Double.longBitsToDouble(element.longValue()));
} else if (elementType instanceof FloatType) {
value = FloatConstant.v(Float.intBitsToFloat(element.intValue()));
} else if (elementType instanceof IntType) {
value = IntConstant.v(element.intValue());
} else if (elementType instanceof LongType) {
value = LongConstant.v(element.longValue());
} else {
throw new RuntimeException("Invalid Array Type occured in FillArrayDataInstruction: " + elementType);
}
return value;
}
@Override
public void computeDataOffsets(DexBody body) {<FILL_FUNCTION_BODY>}
}
|
if (!(instruction instanceof Instruction31t)) {
throw new IllegalArgumentException("Expected Instruction31t but got: " + instruction.getClass());
}
Instruction31t fillArrayInstr = (Instruction31t) instruction;
int offset = fillArrayInstr.getCodeOffset();
int targetAddress = codeAddress + offset;
Instruction referenceTable = body.instructionAtAddress(targetAddress).instruction;
if (!(referenceTable instanceof ArrayPayload)) {
throw new RuntimeException("Address 0x" + Integer.toHexString(targetAddress)
+ " refers to an invalid PseudoInstruction (" + referenceTable.getClass() + ").");
}
ArrayPayload arrayTable = (ArrayPayload) referenceTable;
int numElements = arrayTable.getArrayElements().size();
int widthElement = arrayTable.getElementWidth();
int size = (widthElement * numElements) / 2; // addresses are on 16bits
// From org.jf.dexlib.Code.Format.ArrayDataPseudoInstruction we learn
// that there are 6 bytes after the magic number that we have to jump.
// 6 bytes to jump = address + 3
//
// out.writeByte(0x00); // magic
// out.writeByte(0x03); // number
// out.writeShort(elementWidth); // 2 bytes
// out.writeInt(elementCount); // 4 bytes
// out.write(encodedValues);
//
setDataFirstByte(targetAddress + 3); // address for 16 bits elements not 8 bits
setDataLastByte(targetAddress + 3 + size);// - 1);
setDataSize(size);
// TODO: how to handle this with dexlib2 ?
// ByteArrayAnnotatedOutput out = new ByteArrayAnnotatedOutput();
// arrayTable.write(out, targetAddress);
//
// byte[] outa = out.getArray();
// byte[] data = new byte[outa.length-6];
// for (int i=6; i<outa.length; i++) {
// data[i-6] = outa[i];
// }
// setData (data);
| 1,473
| 561
| 2,034
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public abstract void computeDataOffsets(soot.dexpler.DexBody) ,public byte[] getData() ,public int getDataFirstByte() ,public int getDataLastByte() ,public int getDataSize() ,public boolean isLoaded() ,public void setLoaded(boolean) <variables>protected byte[] data,protected int dataFirstByte,protected int dataLastByte,protected int dataSize,protected boolean loaded
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/FilledArrayInstruction.java
|
FilledArrayInstruction
|
finalize
|
class FilledArrayInstruction extends DexlibAbstractInstruction implements DanglingInstruction {
public FilledArrayInstruction(Instruction instruction, int codeAddress) {
super(instruction, codeAddress);
}
public void finalize(DexBody body, DexlibAbstractInstruction successor) {<FILL_FUNCTION_BODY>}
@Override
public Set<Type> introducedTypes() {
ReferenceInstruction i = (ReferenceInstruction) instruction;
Set<Type> types = new HashSet<Type>();
types.add(DexType.toSoot((TypeReference) i.getReference()));
return types;
}
}
|
// // defer final jimplification to move result
// if (successor instanceof MoveResultInstruction) {
// MoveResultInstruction i = (MoveResultInstruction)successor;
// i.setLocalToMove(arrayLocal);
// if (lineNumber != -1)
// i.setTag(new SourceLineNumberTag(lineNumber));
// }
| 166
| 94
| 260
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public org.jf.dexlib2.iface.instruction.Instruction getInstruction() ,public int getLineNumber() ,public soot.Unit getUnit() ,public Set<soot.Type> introducedTypes() ,public abstract void jimplify(soot.dexpler.DexBody) ,public void setLineNumber(int) <variables>protected final non-sealed int codeAddress,protected final non-sealed org.jf.dexlib2.iface.instruction.Instruction instruction,protected int lineNumber,protected soot.Unit unit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/GotoInstruction.java
|
GotoInstruction
|
jimplify
|
class GotoInstruction extends JumpInstruction implements DeferableInstruction {
public GotoInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
public void jimplify(DexBody body) {<FILL_FUNCTION_BODY>}
public void deferredJimplify(DexBody body) {
body.getBody().getUnits().insertAfter(gotoStatement(), markerUnit);
}
private GotoStmt gotoStatement() {
GotoStmt go = Jimple.v().newGotoStmt(targetInstruction.getUnit());
setUnit(go);
addTags(go);
return go;
}
}
|
// check if target instruction has been jimplified
if (getTargetInstruction(body).getUnit() != null) {
body.add(gotoStatement());
return;
}
// set marker unit to swap real gotostmt with otherwise
body.addDeferredJimplification(this);
markerUnit = Jimple.v().newNopStmt();
addTags(markerUnit);
unit = markerUnit;
body.add(markerUnit);
| 180
| 119
| 299
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) <variables>protected soot.Unit markerUnit,protected soot.dexpler.instructions.DexlibAbstractInstruction targetInstruction
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/IfTestInstruction.java
|
IfTestInstruction
|
ifStatement
|
class IfTestInstruction extends ConditionalJumpInstruction {
public IfTestInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
protected IfStmt ifStatement(DexBody body) {<FILL_FUNCTION_BODY>}
}
|
Instruction22t i = (Instruction22t) instruction;
Local one = body.getRegisterLocal(i.getRegisterA());
Local other = body.getRegisterLocal(i.getRegisterB());
BinopExpr condition = getComparisonExpr(one, other);
IfStmt jif = Jimple.v().newIfStmt(condition, targetInstruction.getUnit());
// setUnit() is called in ConditionalJumpInstruction
addTags(jif);
if (IDalvikTyper.ENABLE_DVKTYPER) {
// Debug.printDbg(IDalvikTyper.DEBUG, "constraint if: "+ jif +" condition: "+ condition);
DalvikTyper.v().addConstraint(condition.getOp1Box(), condition.getOp2Box());
}
return jif;
| 81
| 214
| 295
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public void deferredJimplify(soot.dexpler.DexBody) ,public void jimplify(soot.dexpler.DexBody) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/IgetInstruction.java
|
IgetInstruction
|
overridesRegister
|
class IgetInstruction extends FieldInstruction {
public IgetInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {
TwoRegisterInstruction i = (TwoRegisterInstruction) instruction;
int dest = i.getRegisterA();
int object = i.getRegisterB();
FieldReference f = (FieldReference) ((ReferenceInstruction) instruction).getReference();
final Jimple jimple = Jimple.v();
InstanceFieldRef r = jimple.newInstanceFieldRef(body.getRegisterLocal(object), getSootFieldRef(f));
AssignStmt assign = jimple.newAssignStmt(body.getRegisterLocal(dest), r);
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
DalvikTyper.v().setType(assign.getLeftOpBox(), r.getType(), false);
}
}
@Override
boolean overridesRegister(int register) {<FILL_FUNCTION_BODY>}
}
|
TwoRegisterInstruction i = (TwoRegisterInstruction) instruction;
int dest = i.getRegisterA();
return register == dest;
| 302
| 37
| 339
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public Set<soot.Type> introducedTypes() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/InstanceOfInstruction.java
|
InstanceOfInstruction
|
overridesRegister
|
class InstanceOfInstruction extends DexlibAbstractInstruction {
public InstanceOfInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {
Instruction22c i = (Instruction22c) instruction;
int dest = i.getRegisterA();
int source = i.getRegisterB();
Type t = DexType.toSoot((TypeReference) (i.getReference()));
InstanceOfExpr e = Jimple.v().newInstanceOfExpr(body.getRegisterLocal(source), t);
AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), e);
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
// DalvikTyper.v().?
}
}
@Override
boolean overridesRegister(int register) {<FILL_FUNCTION_BODY>}
@Override
public Set<Type> introducedTypes() {
ReferenceInstruction i = (ReferenceInstruction) instruction;
Set<Type> types = new HashSet<Type>();
types.add(DexType.toSoot((TypeReference) i.getReference()));
return types;
}
}
|
TwoRegisterInstruction i = (TwoRegisterInstruction) instruction;
int dest = i.getRegisterA();
return register == dest;
| 356
| 37
| 393
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public org.jf.dexlib2.iface.instruction.Instruction getInstruction() ,public int getLineNumber() ,public soot.Unit getUnit() ,public Set<soot.Type> introducedTypes() ,public abstract void jimplify(soot.dexpler.DexBody) ,public void setLineNumber(int) <variables>protected final non-sealed int codeAddress,protected final non-sealed org.jf.dexlib2.iface.instruction.Instruction instruction,protected int lineNumber,protected soot.Unit unit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/InvokePolymorphicInstruction.java
|
InvokePolymorphicInstruction
|
jimplify
|
class InvokePolymorphicInstruction extends MethodInvocationInstruction {
public InvokePolymorphicInstruction(Instruction instruction, int codeAddress) {
super(instruction, codeAddress);
}
/*
* Instruction Format for invoke-polymorphic invoke-polymorphic MH.invoke, prototype, {mh, [args]} - MH.invoke - a method
* handle (i.e. MethodReference in dexlib2) for either the method invoke or invokeExact - prototype - a description of the
* types for the arguments being passed into invoke or invokeExact and their return type - {mh, [args]} - A list of one or
* more arguments included in the instruction. The first argument (mh) is always a reference to the MethodHandle object
* that invoke or invokeExact is called on. The remaining arguments are references to the objects passed into the call to
* invoke or invokeExact. This is similar to how invoke-virtual functions.
*
* The invoke-polymorphic instruction behaves similar to how reflection functions from a coder standpoint it is just
* faster. The actual function being called depends on how the mh object is constructed at runtime (i.e. the method name,
* parameter types and number, return type, and calling object). The prototype included in invoke-polymorphic reflects the
* types of the arguments passed into invoke or invokeExact and should match the the types of the parameters of the actual
* method being invoked from a class hierarchy standpoint. However, they are included mainly so the VM knows the types of
* the variables being passed into the invoke and invokeExact method for sizing purposes (i.e. so the data can be read
* properly). The actual parameter types for the method invoked is determined at runtime.
*
* From a static analysis standpoint there is no way to tell exactly what method is being called using the
* invoke-polymorphic instruction. A more complex context sensitive analysis would be required to determine the exact
* method being called. A less complex analysis could be performed to determine all possible methods that could be invoked
* by this instruction. However, neither of these options should really be performed when translating dex to bytecode.
* Instead, they should be performed later on a per-analysis basis. As there is no equivalent instruction to
* invoke-polymorphic in normal Java bytecode, we simply translate the instruction to a normal invoke-virtual instruction
* where invoke or invokeExact is the method being called, mh is the object it is being called on, and args are the
* arguments for the method call if any. This decision does lose the prototype data included in the instruction; however,
* as described above it does not really aid us in determining the method being called and resolving the method being
* called can still be done using other data in the code.
*
* See https://www.pnfsoftware.com/blog/android-o-and-dex-version-38-new-dalvik-opcodes-to-support-dynamic-invocation/ for
* more information on this instruction and the class lang/invoke/Transformers.java for examples of invoke-polymorhpic
* instructions whose prototype will does not match the actual method being invoked.
*/
@Override
public void jimplify(DexBody body) {<FILL_FUNCTION_BODY>}
}
|
SootMethodRef ref = getVirtualSootMethodRef();
if (ref.declaringClass().isInterface()) {
ref = getInterfaceSootMethodRef();
}
// The invoking object will always be included in the parameter types here
List<Local> temp = buildParameters(body,
((MethodProtoReference) ((DualReferenceInstruction) instruction).getReference2()).getParameterTypes(), false);
List<Local> parms = temp.subList(1, temp.size());
Local invoker = temp.get(0);
// Only box the arguments into an array if there are arguments and if they are not
// already in some kind of array
if (parms.size() > 0 && !(parms.size() == 1 && parms.get(0) instanceof ArrayType)) {
Body b = body.getBody();
PatchingChain<Unit> units = b.getUnits();
// Return type for invoke and invokeExact is Object and paramater type is Object[]
RefType rf = Scene.v().getObjectType();
Local newArrL = new JimpleLocal("$u" + (b.getLocalCount() + 1), ArrayType.v(rf, 1));
b.getLocals().add(newArrL);
JAssignStmt newArr = new JAssignStmt(newArrL, new JNewArrayExpr(rf, IntConstant.v(parms.size())));
units.add(newArr);
int i = 0;
for (Local l : parms) {
units.add(new JAssignStmt(new JArrayRef(newArrL, IntConstant.v(i)), l));
i++;
}
parms = Arrays.asList(newArrL);
}
if (ref.declaringClass().isInterface()) {
invocation = Jimple.v().newInterfaceInvokeExpr(invoker, ref, parms);
} else {
invocation = Jimple.v().newVirtualInvokeExpr(invoker, ref, parms);
}
body.setDanglingInstruction(this);
| 806
| 527
| 1,333
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public void finalize(soot.dexpler.DexBody, soot.dexpler.instructions.DexlibAbstractInstruction) ,public Set<soot.Type> introducedTypes() <variables>protected soot.jimple.AssignStmt assign,protected soot.jimple.InvokeExpr invocation
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/IputInstruction.java
|
IputInstruction
|
jimplify
|
class IputInstruction extends FieldInstruction {
public IputInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {<FILL_FUNCTION_BODY>}
@Override
protected Type getTargetType(DexBody body) {
FieldReference f = (FieldReference) ((ReferenceInstruction) instruction).getReference();
return DexType.toSoot(f.getType());
}
}
|
TwoRegisterInstruction i = (TwoRegisterInstruction) instruction;
int source = i.getRegisterA();
int object = i.getRegisterB();
FieldReference f = (FieldReference) ((ReferenceInstruction) instruction).getReference();
InstanceFieldRef instanceField = Jimple.v().newInstanceFieldRef(body.getRegisterLocal(object), getSootFieldRef(f));
Local sourceValue = body.getRegisterLocal(source);
AssignStmt assign = getAssignStmt(body, sourceValue, instanceField);
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
// Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ assign);
DalvikTyper.v().setType(assign.getRightOpBox(), instanceField.getType(), true);
}
| 135
| 231
| 366
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public Set<soot.Type> introducedTypes() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/JumpInstruction.java
|
JumpInstruction
|
getTargetInstruction
|
class JumpInstruction extends DexlibAbstractInstruction {
protected DexlibAbstractInstruction targetInstruction;
protected Unit markerUnit;
public JumpInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
protected DexlibAbstractInstruction getTargetInstruction(DexBody body) {<FILL_FUNCTION_BODY>}
}
|
int offset = ((OffsetInstruction) instruction).getCodeOffset();
int targetAddress = codeAddress + offset;
targetInstruction = body.instructionAtAddress(targetAddress);
return targetInstruction;
| 102
| 53
| 155
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public org.jf.dexlib2.iface.instruction.Instruction getInstruction() ,public int getLineNumber() ,public soot.Unit getUnit() ,public Set<soot.Type> introducedTypes() ,public abstract void jimplify(soot.dexpler.DexBody) ,public void setLineNumber(int) <variables>protected final non-sealed int codeAddress,protected final non-sealed org.jf.dexlib2.iface.instruction.Instruction instruction,protected int lineNumber,protected soot.Unit unit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/MonitorExitInstruction.java
|
MonitorExitInstruction
|
jimplify
|
class MonitorExitInstruction extends DexlibAbstractInstruction {
public MonitorExitInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {<FILL_FUNCTION_BODY>}
}
|
int reg = ((OneRegisterInstruction) instruction).getRegisterA();
Local object = body.getRegisterLocal(reg);
ExitMonitorStmt exitMonitorStmt = Jimple.v().newExitMonitorStmt(object);
setUnit(exitMonitorStmt);
addTags(exitMonitorStmt);
body.add(exitMonitorStmt);
if (IDalvikTyper.ENABLE_DVKTYPER) {
// Debug.printDbg(IDalvikTyper.DEBUG, "constraint: "+ exitMonitorStmt);
DalvikTyper.v().setType(exitMonitorStmt.getOpBox(), RefType.v("java.lang.Object"), true);
}
| 80
| 176
| 256
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public org.jf.dexlib2.iface.instruction.Instruction getInstruction() ,public int getLineNumber() ,public soot.Unit getUnit() ,public Set<soot.Type> introducedTypes() ,public abstract void jimplify(soot.dexpler.DexBody) ,public void setLineNumber(int) <variables>protected final non-sealed int codeAddress,protected final non-sealed org.jf.dexlib2.iface.instruction.Instruction instruction,protected int lineNumber,protected soot.Unit unit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/MoveInstruction.java
|
MoveInstruction
|
overridesRegister
|
class MoveInstruction extends DexlibAbstractInstruction {
public MoveInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {
TwoRegisterInstruction i = (TwoRegisterInstruction) instruction;
int dest = i.getRegisterA();
int source = i.getRegisterB();
AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), body.getRegisterLocal(source));
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
DalvikTyper.v().addConstraint(assign.getLeftOpBox(), assign.getRightOpBox());
}
}
@Override
int movesRegister(int register) {
TwoRegisterInstruction i = (TwoRegisterInstruction) instruction;
int dest = i.getRegisterA();
int source = i.getRegisterB();
if (register == source) {
return dest;
}
return -1;
}
@Override
int movesToRegister(int register) {
TwoRegisterInstruction i = (TwoRegisterInstruction) instruction;
int dest = i.getRegisterA();
int source = i.getRegisterB();
if (register == dest) {
return source;
}
return -1;
}
@Override
boolean overridesRegister(int register) {<FILL_FUNCTION_BODY>}
}
|
TwoRegisterInstruction i = (TwoRegisterInstruction) instruction;
int dest = i.getRegisterA();
return register == dest;
| 404
| 37
| 441
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public org.jf.dexlib2.iface.instruction.Instruction getInstruction() ,public int getLineNumber() ,public soot.Unit getUnit() ,public Set<soot.Type> introducedTypes() ,public abstract void jimplify(soot.dexpler.DexBody) ,public void setLineNumber(int) <variables>protected final non-sealed int codeAddress,protected final non-sealed org.jf.dexlib2.iface.instruction.Instruction instruction,protected int lineNumber,protected soot.Unit unit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/MoveResultInstruction.java
|
MoveResultInstruction
|
jimplify
|
class MoveResultInstruction extends DexlibAbstractInstruction {
// private Local local;
// private Expr expr;
public MoveResultInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {<FILL_FUNCTION_BODY>}
// public void setLocalToMove(Local l) {
// local = l;
// }
// public void setExpr(Expr e) {
// expr = e;
// }
@Override
boolean overridesRegister(int register) {
OneRegisterInstruction i = (OneRegisterInstruction) instruction;
int dest = i.getRegisterA();
return register == dest;
}
}
|
// if (local != null && expr != null)
// throw new RuntimeException("Both local and expr are set to move.");
int dest = ((OneRegisterInstruction) instruction).getRegisterA();
// if (local != null)
// assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), local);
// else if (expr != null)
// assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), expr);
// else
// throw new RuntimeException("Neither local and expr are set to move.");
AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), body.getStoreResultLocal());
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
JAssignStmt jassign = (JAssignStmt) assign;
DalvikTyper.v().addConstraint(assign.getLeftOpBox(), assign.getRightOpBox());
}
| 199
| 279
| 478
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public org.jf.dexlib2.iface.instruction.Instruction getInstruction() ,public int getLineNumber() ,public soot.Unit getUnit() ,public Set<soot.Type> introducedTypes() ,public abstract void jimplify(soot.dexpler.DexBody) ,public void setLineNumber(int) <variables>protected final non-sealed int codeAddress,protected final non-sealed org.jf.dexlib2.iface.instruction.Instruction instruction,protected int lineNumber,protected soot.Unit unit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/NewArrayInstruction.java
|
NewArrayInstruction
|
jimplify
|
class NewArrayInstruction extends DexlibAbstractInstruction {
public NewArrayInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {<FILL_FUNCTION_BODY>}
@Override
boolean overridesRegister(int register) {
TwoRegisterInstruction i = (TwoRegisterInstruction) instruction;
int dest = i.getRegisterA();
return register == dest;
}
@Override
public Set<Type> introducedTypes() {
ReferenceInstruction i = (ReferenceInstruction) instruction;
Set<Type> types = new HashSet<Type>();
types.add(DexType.toSoot((TypeReference) i.getReference()));
return types;
}
}
|
if (!(instruction instanceof Instruction22c)) {
throw new IllegalArgumentException("Expected Instruction22c but got: " + instruction.getClass());
}
Instruction22c newArray = (Instruction22c) instruction;
int dest = newArray.getRegisterA();
Value size = body.getRegisterLocal(newArray.getRegisterB());
Type t = DexType.toSoot((TypeReference) newArray.getReference());
// NewArrayExpr needs the ElementType as it increases the array dimension by 1
Type arrayType = ((ArrayType) t).getElementType();
NewArrayExpr newArrayExpr = Jimple.v().newNewArrayExpr(arrayType, size);
Local l = body.getRegisterLocal(dest);
AssignStmt assign = Jimple.v().newAssignStmt(l, newArrayExpr);
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
DalvikTyper.v().setType(newArrayExpr.getSizeBox(), IntType.v(), true);
DalvikTyper.v().setType(assign.getLeftOpBox(), newArrayExpr.getType(), false);
}
| 209
| 321
| 530
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public org.jf.dexlib2.iface.instruction.Instruction getInstruction() ,public int getLineNumber() ,public soot.Unit getUnit() ,public Set<soot.Type> introducedTypes() ,public abstract void jimplify(soot.dexpler.DexBody) ,public void setLineNumber(int) <variables>protected final non-sealed int codeAddress,protected final non-sealed org.jf.dexlib2.iface.instruction.Instruction instruction,protected int lineNumber,protected soot.Unit unit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/NewInstanceInstruction.java
|
NewInstanceInstruction
|
overridesRegister
|
class NewInstanceInstruction extends DexlibAbstractInstruction {
public NewInstanceInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {
Instruction21c i = (Instruction21c) instruction;
int dest = i.getRegisterA();
String className = dottedClassName(((TypeReference) (i.getReference())).toString());
RefType type = RefType.v(className);
NewExpr n = Jimple.v().newNewExpr(type);
AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), n);
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
// DalvikTyper.v().captureAssign((JAssignStmt)assign, op); // TODO: ref. type may be null!
DalvikTyper.v().setType(assign.getLeftOpBox(), type, false);
}
}
@Override
boolean overridesRegister(int register) {<FILL_FUNCTION_BODY>}
@Override
public Set<Type> introducedTypes() {
ReferenceInstruction i = (ReferenceInstruction) instruction;
Set<Type> types = new HashSet<Type>();
types.add(DexType.toSoot((TypeReference) i.getReference()));
return types;
}
}
|
OneRegisterInstruction i = (OneRegisterInstruction) instruction;
int dest = i.getRegisterA();
return register == dest;
| 391
| 37
| 428
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public org.jf.dexlib2.iface.instruction.Instruction getInstruction() ,public int getLineNumber() ,public soot.Unit getUnit() ,public Set<soot.Type> introducedTypes() ,public abstract void jimplify(soot.dexpler.DexBody) ,public void setLineNumber(int) <variables>protected final non-sealed int codeAddress,protected final non-sealed org.jf.dexlib2.iface.instruction.Instruction instruction,protected int lineNumber,protected soot.Unit unit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/PackedSwitchInstruction.java
|
PackedSwitchInstruction
|
switchStatement
|
class PackedSwitchInstruction extends SwitchInstruction {
public PackedSwitchInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
protected Stmt switchStatement(DexBody body, Instruction targetData, Local key) {<FILL_FUNCTION_BODY>}
@Override
public void computeDataOffsets(DexBody body) {
}
}
|
PackedSwitchPayload i = (PackedSwitchPayload) targetData;
List<? extends SwitchElement> seList = i.getSwitchElements();
// the default target always follows the switch statement
int defaultTargetAddress = codeAddress + instruction.getCodeUnits();
Unit defaultTarget = body.instructionAtAddress(defaultTargetAddress).getUnit();
List<IntConstant> lookupValues = new ArrayList<IntConstant>();
List<Unit> targets = new ArrayList<Unit>();
for (SwitchElement se : seList) {
lookupValues.add(IntConstant.v(se.getKey()));
int offset = se.getOffset();
targets.add(body.instructionAtAddress(codeAddress + offset).getUnit());
}
LookupSwitchStmt switchStmt = Jimple.v().newLookupSwitchStmt(key, lookupValues, targets, defaultTarget);
setUnit(switchStmt);
if (IDalvikTyper.ENABLE_DVKTYPER) {
DalvikTyper.v().setType(switchStmt.getKeyBox(), IntType.v(), true);
}
return switchStmt;
| 111
| 286
| 397
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public void deferredJimplify(soot.dexpler.DexBody) ,public void jimplify(soot.dexpler.DexBody) <variables>protected soot.Unit markerUnit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/PseudoInstruction.java
|
PseudoInstruction
|
getDataLastByte
|
class PseudoInstruction extends DexlibAbstractInstruction {
public PseudoInstruction(Instruction instruction, int codeAddress) {
super(instruction, codeAddress);
}
protected int dataFirstByte = -1;
protected int dataLastByte = -1;
protected int dataSize = -1;
protected byte[] data = null;
protected boolean loaded = false;
public boolean isLoaded() {
return loaded;
}
public void setLoaded(boolean loaded) {
this.loaded = loaded;
}
public byte[] getData() {
return data;
}
protected void setData(byte[] data) {
this.data = data;
}
public int getDataFirstByte() {
if (dataFirstByte == -1) {
throw new RuntimeException("Error: dataFirstByte was not set!");
}
return dataFirstByte;
}
protected void setDataFirstByte(int dataFirstByte) {
this.dataFirstByte = dataFirstByte;
}
public int getDataLastByte() {<FILL_FUNCTION_BODY>}
protected void setDataLastByte(int dataLastByte) {
this.dataLastByte = dataLastByte;
}
public int getDataSize() {
if (dataSize == -1) {
throw new RuntimeException("Error: dataFirstByte was not set!");
}
return dataSize;
}
protected void setDataSize(int dataSize) {
this.dataSize = dataSize;
}
public abstract void computeDataOffsets(DexBody body);
}
|
if (dataLastByte == -1) {
throw new RuntimeException("Error: dataLastByte was not set!");
}
return dataLastByte;
| 415
| 42
| 457
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public org.jf.dexlib2.iface.instruction.Instruction getInstruction() ,public int getLineNumber() ,public soot.Unit getUnit() ,public Set<soot.Type> introducedTypes() ,public abstract void jimplify(soot.dexpler.DexBody) ,public void setLineNumber(int) <variables>protected final non-sealed int codeAddress,protected final non-sealed org.jf.dexlib2.iface.instruction.Instruction instruction,protected int lineNumber,protected soot.Unit unit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/ReturnInstruction.java
|
ReturnInstruction
|
jimplify
|
class ReturnInstruction extends DexlibAbstractInstruction {
public ReturnInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {<FILL_FUNCTION_BODY>}
}
|
Instruction11x returnInstruction = (Instruction11x) this.instruction;
Local l = body.getRegisterLocal(returnInstruction.getRegisterA());
ReturnStmt returnStmt = Jimple.v().newReturnStmt(l);
setUnit(returnStmt);
addTags(returnStmt);
body.add(returnStmt);
if (IDalvikTyper.ENABLE_DVKTYPER) {
// DalvikTyper.v().addConstraint(returnStmt.getOpBox(), new
// ImmediateBox(Jimple.body.getBody().getMethod().getReturnType()));
DalvikTyper.v().setType(returnStmt.getOpBox(), body.getBody().getMethod().getReturnType(), true);
}
| 78
| 200
| 278
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public org.jf.dexlib2.iface.instruction.Instruction getInstruction() ,public int getLineNumber() ,public soot.Unit getUnit() ,public Set<soot.Type> introducedTypes() ,public abstract void jimplify(soot.dexpler.DexBody) ,public void setLineNumber(int) <variables>protected final non-sealed int codeAddress,protected final non-sealed org.jf.dexlib2.iface.instruction.Instruction instruction,protected int lineNumber,protected soot.Unit unit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/SgetInstruction.java
|
SgetInstruction
|
jimplify
|
class SgetInstruction extends FieldInstruction {
public SgetInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {<FILL_FUNCTION_BODY>}
@Override
boolean overridesRegister(int register) {
OneRegisterInstruction i = (OneRegisterInstruction) instruction;
int dest = i.getRegisterA();
return register == dest;
}
}
|
int dest = ((OneRegisterInstruction) instruction).getRegisterA();
FieldReference f = (FieldReference) ((ReferenceInstruction) instruction).getReference();
StaticFieldRef r = Jimple.v().newStaticFieldRef(getStaticSootFieldRef(f));
AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), r);
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
DalvikTyper.v().setType(assign.getLeftOpBox(), r.getType(), false);
}
| 130
| 169
| 299
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public Set<soot.Type> introducedTypes() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/SparseSwitchInstruction.java
|
SparseSwitchInstruction
|
computeDataOffsets
|
class SparseSwitchInstruction extends SwitchInstruction {
public SparseSwitchInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
protected Stmt switchStatement(DexBody body, Instruction targetData, Local key) {
SparseSwitchPayload i = (SparseSwitchPayload) targetData;
List<? extends SwitchElement> seList = i.getSwitchElements();
// the default target always follows the switch statement
int defaultTargetAddress = codeAddress + instruction.getCodeUnits();
Unit defaultTarget = body.instructionAtAddress(defaultTargetAddress).getUnit();
List<IntConstant> lookupValues = new ArrayList<IntConstant>();
List<Unit> targets = new ArrayList<Unit>();
for (SwitchElement se : seList) {
lookupValues.add(IntConstant.v(se.getKey()));
int offset = se.getOffset();
targets.add(body.instructionAtAddress(codeAddress + offset).getUnit());
}
LookupSwitchStmt switchStmt = Jimple.v().newLookupSwitchStmt(key, lookupValues, targets, defaultTarget);
setUnit(switchStmt);
addTags(switchStmt);
if (IDalvikTyper.ENABLE_DVKTYPER) {
DalvikTyper.v().setType(switchStmt.getKeyBox(), IntType.v(), true);
}
return switchStmt;
}
@Override
public void computeDataOffsets(DexBody body) {<FILL_FUNCTION_BODY>}
}
|
// System.out.println("class of instruction: "+ instruction.getClass());
// int offset = ((OffsetInstruction) instruction).getCodeOffset();
// int targetAddress = codeAddress + offset;
// Instruction targetData = body.instructionAtAddress(targetAddress).instruction;
// SparseSwitchPayload ssInst = (SparseSwitchPayload) targetData;
// List<? extends SwitchElement> targetAddresses = ssInst.getSwitchElements();
// int size = targetAddresses.size() * 2; // @ are on 32bits
//
// // From org.jf.dexlib.Code.Format.SparseSwitchDataPseudoInstruction we learn
// // that there are 2 bytes after the magic number that we have to jump.
// // 2 bytes to jump = address + 1
// //
// // out.writeByte(0x00); // magic
// // out.writeByte(0x02); // number
// // out.writeShort(targets.length); // 2 bytes
// // out.writeInt(firstKey);
//
// setDataFirstByte (targetAddress + 1);
// setDataLastByte (targetAddress + 1 + size - 1);
// setDataSize (size);
//
// ByteArrayAnnotatedOutput out = new ByteArrayAnnotatedOutput();
// ssInst.write(out, targetAddress);
//
// byte[] outa = out.getArray();
// byte[] data = new byte[outa.length-2];
// for (int i=2; i<outa.length; i++) {
// data[i-2] = outa[i];
// }
// setData (data);
| 403
| 429
| 832
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public void deferredJimplify(soot.dexpler.DexBody) ,public void jimplify(soot.dexpler.DexBody) <variables>protected soot.Unit markerUnit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/SputInstruction.java
|
SputInstruction
|
jimplify
|
class SputInstruction extends FieldInstruction {
public SputInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {<FILL_FUNCTION_BODY>}
@Override
protected Type getTargetType(DexBody body) {
FieldReference f = (FieldReference) ((ReferenceInstruction) instruction).getReference();
return DexType.toSoot(f.getType());
}
}
|
int source = ((OneRegisterInstruction) instruction).getRegisterA();
FieldReference f = (FieldReference) ((ReferenceInstruction) instruction).getReference();
StaticFieldRef instanceField = Jimple.v().newStaticFieldRef(getStaticSootFieldRef(f));
Local sourceValue = body.getRegisterLocal(source);
AssignStmt assign = getAssignStmt(body, sourceValue, instanceField);
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
DalvikTyper.v().setType(assign.getRightOpBox(), instanceField.getType(), true);
}
| 135
| 178
| 313
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public Set<soot.Type> introducedTypes() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/TaggedInstruction.java
|
TaggedInstruction
|
getTag
|
class TaggedInstruction extends DexlibAbstractInstruction {
private Tag instructionTag = null;
public TaggedInstruction(Instruction instruction, int codeAddress) {
super(instruction, codeAddress);
}
public void setTag(Tag t) {
instructionTag = t;
}
public Tag getTag() {<FILL_FUNCTION_BODY>}
}
|
if (instructionTag == null) {
throw new RuntimeException(
"Must tag instruction first! (0x" + Integer.toHexString(codeAddress) + ": " + instruction + ")");
}
return instructionTag;
| 101
| 62
| 163
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public org.jf.dexlib2.iface.instruction.Instruction getInstruction() ,public int getLineNumber() ,public soot.Unit getUnit() ,public Set<soot.Type> introducedTypes() ,public abstract void jimplify(soot.dexpler.DexBody) ,public void setLineNumber(int) <variables>protected final non-sealed int codeAddress,protected final non-sealed org.jf.dexlib2.iface.instruction.Instruction instruction,protected int lineNumber,protected soot.Unit unit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/ThrowInstruction.java
|
ThrowInstruction
|
jimplify
|
class ThrowInstruction extends DexlibAbstractInstruction {
public ThrowInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {<FILL_FUNCTION_BODY>}
}
|
Instruction11x throwInstruction = (Instruction11x) instruction;
ThrowStmt throwStmt = Jimple.v().newThrowStmt(body.getRegisterLocal(throwInstruction.getRegisterA()));
setUnit(throwStmt);
addTags(throwStmt);
body.add(throwStmt);
if (IDalvikTyper.ENABLE_DVKTYPER) {
DalvikTyper.v().setType(throwStmt.getOpBox(), RefType.v("java.lang.Throwable"), true);
}
| 80
| 144
| 224
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public org.jf.dexlib2.iface.instruction.Instruction getInstruction() ,public int getLineNumber() ,public soot.Unit getUnit() ,public Set<soot.Type> introducedTypes() ,public abstract void jimplify(soot.dexpler.DexBody) ,public void setLineNumber(int) <variables>protected final non-sealed int codeAddress,protected final non-sealed org.jf.dexlib2.iface.instruction.Instruction instruction,protected int lineNumber,protected soot.Unit unit
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/instructions/UnopInstruction.java
|
UnopInstruction
|
overridesRegister
|
class UnopInstruction extends TaggedInstruction {
public UnopInstruction(Instruction instruction, int codeAdress) {
super(instruction, codeAdress);
}
@Override
public void jimplify(DexBody body) {
if (!(instruction instanceof Instruction12x)) {
throw new IllegalArgumentException("Expected Instruction12x but got: " + instruction.getClass());
}
Instruction12x cmpInstr = (Instruction12x) instruction;
int dest = cmpInstr.getRegisterA();
Local source = body.getRegisterLocal(cmpInstr.getRegisterB());
Value expr = getExpression(source);
AssignStmt assign = Jimple.v().newAssignStmt(body.getRegisterLocal(dest), expr);
assign.addTag(getTag());
setUnit(assign);
addTags(assign);
body.add(assign);
if (IDalvikTyper.ENABLE_DVKTYPER) {
/*
* int op = (int)instruction.getOpcode().value; //DalvikTyper.v().captureAssign((JAssignStmt)assign, op); JAssignStmt
* jass = (JAssignStmt)assign; DalvikTyper.v().setType((expr instanceof JCastExpr) ? ((JCastExpr) expr).getOpBox() :
* ((UnopExpr) expr).getOpBox(), opUnType[op - 0x7b], true); DalvikTyper.v().setType(jass.leftBox, resUnType[op -
* 0x7b], false);
*/
}
}
/**
* Return the appropriate Jimple Expression according to the OpCode
*/
private Value getExpression(Local source) {
Opcode opcode = instruction.getOpcode();
switch (opcode) {
case NEG_INT:
setTag(new IntOpTag());
return Jimple.v().newNegExpr(source);
case NEG_LONG:
setTag(new LongOpTag());
return Jimple.v().newNegExpr(source);
case NEG_FLOAT:
setTag(new FloatOpTag());
return Jimple.v().newNegExpr(source);
case NEG_DOUBLE:
setTag(new DoubleOpTag());
return Jimple.v().newNegExpr(source);
case NOT_LONG:
setTag(new LongOpTag());
return getNotLongExpr(source);
case NOT_INT:
setTag(new IntOpTag());
return getNotIntExpr(source);
default:
throw new RuntimeException("Invalid Opcode: " + opcode);
}
}
/**
* returns bitwise negation of an integer
*
* @param source
* @return
*/
private Value getNotIntExpr(Local source) {
return Jimple.v().newXorExpr(source, IntConstant.v(-1));
}
/**
* returns bitwise negation of a long
*
* @param source
* @return
*/
private Value getNotLongExpr(Local source) {
return Jimple.v().newXorExpr(source, LongConstant.v(-1l));
}
@Override
boolean overridesRegister(int register) {<FILL_FUNCTION_BODY>}
@Override
boolean isUsedAsFloatingPoint(DexBody body, int register) {
int source = ((TwoRegisterInstruction) instruction).getRegisterB();
Opcode opcode = instruction.getOpcode();
switch (opcode) {
case NEG_FLOAT:
case NEG_DOUBLE:
return source == register;
default:
return false;
}
}
}
|
TwoRegisterInstruction i = (TwoRegisterInstruction) instruction;
int dest = i.getRegisterA();
return register == dest;
| 974
| 37
| 1,011
|
<methods>public void <init>(org.jf.dexlib2.iface.instruction.Instruction, int) ,public soot.tagkit.Tag getTag() ,public void setTag(soot.tagkit.Tag) <variables>private soot.tagkit.Tag instructionTag
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/typing/DalvikTyper.java
|
Constraint
|
typeUntypedConstrantInDiv
|
class Constraint {
ValueBox l;
ValueBox r;
public Constraint(ValueBox l, ValueBox r) {
this.l = l;
this.r = r;
}
@Override
public String toString() {
return l + " < " + r;
}
}
// this is needed because UnuesedStatementTransformer checks types in the div expressions
public void typeUntypedConstrantInDiv(final Body b) {<FILL_FUNCTION_BODY>
|
for (Unit u : b.getUnits()) {
StmtSwitch sw = new StmtSwitch() {
@Override
public void caseBreakpointStmt(BreakpointStmt stmt) {
// TODO Auto-generated method stub
}
@Override
public void caseInvokeStmt(InvokeStmt stmt) {
changeUntypedConstantsInInvoke(stmt.getInvokeExpr());
}
@Override
public void caseAssignStmt(AssignStmt stmt) {
if (stmt.getRightOp() instanceof NewArrayExpr) {
NewArrayExpr nae = (NewArrayExpr) stmt.getRightOp();
if (nae.getSize() instanceof UntypedConstant) {
UntypedIntOrFloatConstant uc = (UntypedIntOrFloatConstant) nae.getSize();
nae.setSize(uc.defineType(IntType.v()));
}
} else if (stmt.getRightOp() instanceof InvokeExpr) {
changeUntypedConstantsInInvoke((InvokeExpr) stmt.getRightOp());
} else if (stmt.getRightOp() instanceof CastExpr) {
CastExpr ce = (CastExpr) stmt.getRightOp();
if (ce.getOp() instanceof UntypedConstant) {
UntypedConstant uc = (UntypedConstant) ce.getOp();
// check incoming primitive type
for (Tag t : stmt.getTags()) {
// Debug.printDbg("assign primitive type from stmt tag: ", stmt, t);
if (t instanceof IntOpTag) {
ce.setOp(uc.defineType(IntType.v()));
return;
} else if (t instanceof FloatOpTag) {
ce.setOp(uc.defineType(FloatType.v()));
return;
} else if (t instanceof DoubleOpTag) {
ce.setOp(uc.defineType(DoubleType.v()));
return;
} else if (t instanceof LongOpTag) {
ce.setOp(uc.defineType(LongType.v()));
return;
}
}
// 0 -> null
ce.setOp(uc.defineType(RefType.v("java.lang.Object")));
}
}
if (stmt.containsArrayRef()) {
ArrayRef ar = stmt.getArrayRef();
if ((ar.getIndex() instanceof UntypedConstant)) {
UntypedIntOrFloatConstant uc = (UntypedIntOrFloatConstant) ar.getIndex();
ar.setIndex(uc.toIntConstant());
}
}
Value r = stmt.getRightOp();
if (r instanceof DivExpr || r instanceof RemExpr) {
// DivExpr de = (DivExpr) r;
for (Tag t : stmt.getTags()) {
// Debug.printDbg("div stmt tag: ", stmt, t);
if (t instanceof IntOpTag) {
checkExpr(r, IntType.v());
return;
} else if (t instanceof FloatOpTag) {
checkExpr(r, FloatType.v());
return;
} else if (t instanceof DoubleOpTag) {
checkExpr(r, DoubleType.v());
return;
} else if (t instanceof LongOpTag) {
checkExpr(r, LongType.v());
return;
}
}
}
}
@Override
public void caseIdentityStmt(IdentityStmt stmt) {
// TODO Auto-generated method stub
}
@Override
public void caseEnterMonitorStmt(EnterMonitorStmt stmt) {
// TODO Auto-generated method stub
}
@Override
public void caseExitMonitorStmt(ExitMonitorStmt stmt) {
// TODO Auto-generated method stub
}
@Override
public void caseGotoStmt(GotoStmt stmt) {
// TODO Auto-generated method stub
}
@Override
public void caseIfStmt(IfStmt stmt) {
// TODO Auto-generated method stub
}
@Override
public void caseLookupSwitchStmt(LookupSwitchStmt stmt) {
// TODO Auto-generated method stub
}
@Override
public void caseNopStmt(NopStmt stmt) {
// TODO Auto-generated method stub
}
@Override
public void caseRetStmt(RetStmt stmt) {
// TODO Auto-generated method stub
}
@Override
public void caseReturnStmt(ReturnStmt stmt) {
if (stmt.getOp() instanceof UntypedConstant) {
UntypedConstant uc = (UntypedConstant) stmt.getOp();
Type type = b.getMethod().getReturnType();
stmt.setOp(uc.defineType(type));
}
}
@Override
public void caseReturnVoidStmt(ReturnVoidStmt stmt) {
// TODO Auto-generated method stub
}
@Override
public void caseTableSwitchStmt(TableSwitchStmt stmt) {
// TODO Auto-generated method stub
}
@Override
public void caseThrowStmt(ThrowStmt stmt) {
if (stmt.getOp() instanceof UntypedConstant) {
UntypedConstant uc = (UntypedConstant) stmt.getOp();
stmt.setOp(uc.defineType(RefType.v("java.lang.Object")));
}
}
@Override
public void defaultCase(Object obj) {
// TODO Auto-generated method stub
}
};
u.apply(sw);
}
| 133
| 1,461
| 1,594
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/typing/UntypedIntOrFloatConstant.java
|
UntypedIntOrFloatConstant
|
defineType
|
class UntypedIntOrFloatConstant extends UntypedConstant {
/**
*
*/
private static final long serialVersionUID = 4413439694269487822L;
public final int value;
private UntypedIntOrFloatConstant(int value) {
this.value = value;
}
public static UntypedIntOrFloatConstant v(int value) {
return new UntypedIntOrFloatConstant(value);
}
@Override
public boolean equals(Object c) {
return c instanceof UntypedIntOrFloatConstant && ((UntypedIntOrFloatConstant) c).value == this.value;
}
/** Returns a hash code for this DoubleConstant object. */
@Override
public int hashCode() {
return (int) (value ^ (value >>> 32));
}
public FloatConstant toFloatConstant() {
return FloatConstant.v(Float.intBitsToFloat((int) value));
}
public IntConstant toIntConstant() {
return IntConstant.v(value);
}
@Override
public Value defineType(Type t) {<FILL_FUNCTION_BODY>}
}
|
if (t instanceof FloatType) {
return this.toFloatConstant();
} else if (t instanceof IntType || t instanceof CharType || t instanceof BooleanType || t instanceof ByteType
|| t instanceof ShortType) {
return this.toIntConstant();
} else {
if (value == 0 && t instanceof RefLikeType) {
return NullConstant.v();
}
// if the value is only used in a if to compare against another integer, then use default type of integer
if (t == null) {
return this.toIntConstant();
}
throw new RuntimeException("error: expected Float type or Int-like type. Got " + t);
}
| 317
| 169
| 486
|
<methods>public non-sealed void <init>() ,public void apply(soot.util.Switch) ,public abstract soot.Value defineType(soot.Type) ,public soot.Type getType() <variables>private static final long serialVersionUID
|
soot-oss_soot
|
soot/src/main/java/soot/dexpler/typing/UntypedLongOrDoubleConstant.java
|
UntypedLongOrDoubleConstant
|
equals
|
class UntypedLongOrDoubleConstant extends UntypedConstant {
/**
*
*/
private static final long serialVersionUID = -3970057807907204253L;
public final long value;
private UntypedLongOrDoubleConstant(long value) {
this.value = value;
}
public static UntypedLongOrDoubleConstant v(long value) {
return new UntypedLongOrDoubleConstant(value);
}
@Override
public boolean equals(Object c) {<FILL_FUNCTION_BODY>}
/** Returns a hash code for this DoubleConstant object. */
@Override
public int hashCode() {
return (int) (value ^ (value >>> 32));
}
public DoubleConstant toDoubleConstant() {
return DoubleConstant.v(Double.longBitsToDouble(value));
}
public LongConstant toLongConstant() {
return LongConstant.v(value);
}
@Override
public Value defineType(Type t) {
if (t instanceof DoubleType) {
return this.toDoubleConstant();
} else if (t instanceof LongType) {
return this.toLongConstant();
} else {
throw new RuntimeException("error: expected Double type or Long type. Got " + t);
}
}
}
|
return c instanceof UntypedLongOrDoubleConstant && ((UntypedLongOrDoubleConstant) c).value == this.value;
| 352
| 35
| 387
|
<methods>public non-sealed void <init>() ,public void apply(soot.util.Switch) ,public abstract soot.Value defineType(soot.Type) ,public soot.Type getType() <variables>private static final long serialVersionUID
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/DotnetClassConstant.java
|
DotnetClassConstant
|
convertDotnetClassToJvmDescriptor
|
class DotnetClassConstant extends ClassConstant {
private DotnetClassConstant(String s) {
super(convertDotnetClassToJvmDescriptor(s));
}
/**
* Convert Dotnet Class to Java Descriptor https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3
*
* @param s
* class to convert
* @return converted to descriptor
*/
private static String convertDotnetClassToJvmDescriptor(String s) {<FILL_FUNCTION_BODY>}
public static DotnetClassConstant v(String value) {
return new DotnetClassConstant(value);
}
// In this case, equals should be structural equality.
@Override
public boolean equals(Object c) {
return (c instanceof ClassConstant && ((ClassConstant) c).value.equals(this.value));
}
}
|
try {
return "L" + s.replace(".", "/").replace("+", "$") + ";";
} catch (Exception e) {
throw new RuntimeException("Cannot convert Dotnet class \"" + s + "\" to JVM Descriptor: " + e);
}
| 243
| 73
| 316
|
<methods>public void apply(soot.util.Switch) ,public boolean equals(java.lang.Object) ,public static soot.jimple.ClassConstant fromType(soot.Type) ,public soot.Type getType() ,public java.lang.String getValue() ,public int hashCode() ,public boolean isRefType() ,public java.lang.String toInternalString() ,public soot.Type toSootType() ,public java.lang.String toString() ,public static soot.jimple.ClassConstant v(java.lang.String) <variables>public final non-sealed java.lang.String value
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/instructions/CatchFilterHandlerBody.java
|
CatchFilterHandlerBody
|
isExitStmt
|
class CatchFilterHandlerBody {
private final ProtoIlInstructions.IlTryCatchHandlerMsg handlerMsg;
// Base Exception (System.Exception) which will throw and is assigned to this local
private final Local exceptionVar;
// statement where to jump is condition does not fulfill
private final Unit nopStmtEnd;
private final DotnetBody dotnetBody;
public CatchFilterHandlerBody(DotnetBody dotnetBody, ProtoIlInstructions.IlTryCatchHandlerMsg handlerMsg,
Local exceptionVar, Unit nopStmtEnd) {
this.dotnetBody = dotnetBody;
this.handlerMsg = handlerMsg;
this.exceptionVar = exceptionVar;
this.nopStmtEnd = nopStmtEnd;
}
public Body getFilterHandlerBody(Value generalExceptionVariable) {
Body jb = new JimpleBody();
// Exception object / class - add as identity stmt to jimple body
AssignStmt assignStmt = Jimple.v().newAssignStmt(exceptionVar, generalExceptionVariable);
jb.getUnits().add(assignStmt);
NopStmt filterCondFalseNop = Jimple.v().newNopStmt(); // jump to end of handler
CilBlockContainer handlerFilterContainerBlock
= new CilBlockContainer(handlerMsg.getFilter(), dotnetBody, CilBlockContainer.BlockContainerKind.CATCH_FILTER);
Body handlerFilterContainerBlockBody = handlerFilterContainerBlock.jimplify();
CilBlockContainer handlerBlock
= new CilBlockContainer(handlerMsg.getBody(), dotnetBody, CilBlockContainer.BlockContainerKind.CATCH_HANDLER);
Body handlerBody = handlerBlock.jimplify();
// replace return stmts with if/goto to skip handler or execute
ArrayList<Unit> tmpToInsert = new ArrayList<>();
for (Unit unit : handlerFilterContainerBlockBody.getUnits()) {
if (unit instanceof ReturnStmt) {
tmpToInsert.add(unit);
}
}
// will only run once or not at all
for (Unit returnStmt : tmpToInsert) {
// get return value and check if 0
Value returnValue = ((ReturnStmt) returnStmt).getOp();
ConditionExpr cond = Jimple.v().newEqExpr(returnValue, IntConstant.v(0));
IfStmt ifRetCondStmt = Jimple.v().newIfStmt(cond, filterCondFalseNop); // if ret==0 ignore handler
// jump to end of filter instructions - cond true
GotoStmt gotoHandlerBodyCondTrueStmt = Jimple.v().newGotoStmt(handlerBody.getUnits().getFirst());
handlerFilterContainerBlockBody.getUnits().insertAfter(gotoHandlerBodyCondTrueStmt, returnStmt);
handlerFilterContainerBlockBody.getUnits().swapWith(returnStmt, ifRetCondStmt);
dotnetBody.blockEntryPointsManager.swapGotoEntryUnit(ifRetCondStmt, returnStmt);
}
jb.getUnits().addAll(handlerFilterContainerBlockBody.getUnits());
// handler body
if (lastStmtIsNotReturn(handlerBody)) {
// if last stmt is not return, insert goto stmt, to go to end whole block
handlerBody.getUnits().add(Jimple.v().newGotoStmt(nopStmtEnd));
}
jb.getLocals().addAll(handlerBody.getLocals());
jb.getUnits().addAll(handlerBody.getUnits());
jb.getTraps().addAll(handlerBody.getTraps());
// add nop at the end of handler, where filter can jump to
jb.getUnits().add(filterCondFalseNop);
return jb;
}
private static boolean lastStmtIsNotReturn(Body jb) {
return !isExitStmt(jb.getUnits().getLast());
}
/**
* Check if given unit "exists a method"
*
* @param unit
* @return
*/
private static boolean isExitStmt(Unit unit) {<FILL_FUNCTION_BODY>}
}
|
return unit instanceof ReturnStmt || unit instanceof ReturnVoidStmt || unit instanceof ThrowStmt;
| 1,055
| 27
| 1,082
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/instructions/CatchHandlerBody.java
|
CatchHandlerBody
|
getBody
|
class CatchHandlerBody {
// variable which contains thrown exception
private final Local exceptionVariable;
// method body of this handler
private final ProtoIlInstructions.IlTryCatchHandlerMsg handlerMsg;
private final DotnetBody dotnetBody;
private final SootClass exceptionClass = Scene.v().getSootClass(DotnetBasicTypes.SYSTEM_EXCEPTION);
// Jimple Body of TryCatch Try part
private final Body tryBody;
private final Unit exceptionIdentityStmt;
private final List<Unit> nopsToReplaceWithGoto;
public CatchHandlerBody(Local exceptionVariable, ProtoIlInstructions.IlTryCatchHandlerMsg handlerMsg,
DotnetBody dotnetBody, Body tryBody, Unit exceptionIdentityStmt, List<Unit> nopsToReplaceWithGoto) {
this.exceptionVariable = exceptionVariable;
this.handlerMsg = handlerMsg;
this.dotnetBody = dotnetBody;
this.tryBody = tryBody;
this.exceptionIdentityStmt = exceptionIdentityStmt;
this.nopsToReplaceWithGoto = nopsToReplaceWithGoto;
}
public Local getExceptionVariable() {
return exceptionVariable;
}
public Body getBody() {<FILL_FUNCTION_BODY>}
private boolean lastStmtIsNotReturn(Body handlerBody) {
if (handlerBody.getUnits().size() == 0) {
return true;
}
return !isExitStmt(handlerBody.getUnits().getLast());
}
private static boolean isExitStmt(Unit unit) {
return unit instanceof ReturnStmt || unit instanceof ReturnVoidStmt || unit instanceof ThrowStmt;
}
}
|
Body jb = new JimpleBody();
// handler body
Unit excStmt = Jimple.v().newIdentityStmt(exceptionVariable, Jimple.v().newCaughtExceptionRef());
jb.getUnits().add(excStmt);
CilBlockContainer handlerBlock
= new CilBlockContainer(handlerMsg.getBody(), dotnetBody, CilBlockContainer.BlockContainerKind.CATCH_HANDLER);
Body handlerBody = handlerBlock.jimplify();
if (lastStmtIsNotReturn(handlerBody)) {
// if last stmt is not return, insert goto stmt
NopStmt nopStmt = Jimple.v().newNopStmt();
handlerBody.getUnits().add(nopStmt);
nopsToReplaceWithGoto.add(nopStmt);
}
jb.getLocals().addAll(handlerBody.getLocals());
jb.getUnits().addAll(handlerBody.getUnits());
jb.getTraps().addAll(handlerBody.getTraps());
Trap trap = Jimple.v().newTrap(Scene.v().getSootClass(exceptionVariable.getType().toString()),
tryBody.getUnits().getFirst(), tryBody.getUnits().getLast(), excStmt);
jb.getTraps().add(trap);
// Add trap for exception in catch blocks
Trap trapCatchThrow
= Jimple.v().newTrap(exceptionClass, excStmt, handlerBody.getUnits().getLast(), exceptionIdentityStmt);
jb.getTraps().add(trapCatchThrow);
return jb;
| 430
| 424
| 854
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/instructions/CilCastClassUnBoxInstruction.java
|
CilCastClassUnBoxInstruction
|
jimplifyExpr
|
class CilCastClassUnBoxInstruction extends AbstractCilnstruction {
public CilCastClassUnBoxInstruction(ProtoIlInstructions.IlInstructionMsg instruction, DotnetBody dotnetBody,
CilBlock cilBlock) {
super(instruction, dotnetBody, cilBlock);
}
@Override
public void jimplify(Body jb) {
throw new NoStatementInstructionException(instruction);
}
@Override
public Value jimplifyExpr(Body jb) {<FILL_FUNCTION_BODY>}
}
|
Type type = DotnetTypeFactory.toSootType(instruction.getType());
CilInstruction cilExpr = CilInstructionFactory.fromInstructionMsg(instruction.getArgument(), dotnetBody, cilBlock);
Value argument = cilExpr.jimplifyExpr(jb);
return Jimple.v().newCastExpr(argument, type);
| 144
| 93
| 237
|
<methods>public void <init>(ProtoIlInstructions.IlInstructionMsg, soot.dotnet.members.method.DotnetBody, soot.dotnet.instructions.CilBlock) <variables>protected final non-sealed soot.dotnet.instructions.CilBlock cilBlock,protected final non-sealed soot.dotnet.members.method.DotnetBody dotnetBody,protected final non-sealed ProtoIlInstructions.IlInstructionMsg instruction
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/instructions/CilCkFiniteInstruction.java
|
CilCkFiniteInstruction
|
jimplify
|
class CilCkFiniteInstruction extends AbstractCilnstruction {
public CilCkFiniteInstruction(ProtoIlInstructions.IlInstructionMsg instruction, DotnetBody dotnetBody,
CilBlock cilBlock) {
super(instruction, dotnetBody, cilBlock);
}
@Override
public void jimplify(Body jb) {<FILL_FUNCTION_BODY>}
@Override
public Value jimplifyExpr(Body jb) {
throw new NoExpressionInstructionException(instruction);
}
}
|
CilInstruction cilExpr = CilInstructionFactory.fromInstructionMsg(instruction.getArgument(), dotnetBody, cilBlock);
Value argument = cilExpr.jimplifyExpr(jb);
DoubleConstant posInfinity = DoubleConstant.v(Double.POSITIVE_INFINITY);
DoubleConstant negInfinity = DoubleConstant.v(Double.NEGATIVE_INFINITY);
// infinity conditions
EqExpr eqPosInfExpr = Jimple.v().newEqExpr(argument, posInfinity);
EqExpr eqNegInfExpr = Jimple.v().newEqExpr(argument, negInfinity);
NeExpr eqNaNExpr = Jimple.v().newNeExpr(argument, argument);
// if value is infinity, throw exception
SootClass exceptionClass = Scene.v().getSootClass(DotnetBasicTypes.SYSTEM_ARITHMETICEXCEPTION);
Local tmpLocalVar = dotnetBody.variableManager.localGenerator.generateLocal(exceptionClass.getType());
ThrowStmt throwStmt = Jimple.v().newThrowStmt(tmpLocalVar);
// if true throw exception
jb.getUnits().add(Jimple.v().newIfStmt(eqPosInfExpr, throwStmt));
jb.getUnits().add(Jimple.v().newIfStmt(eqNegInfExpr, throwStmt));
jb.getUnits().add(Jimple.v().newIfStmt(eqNaNExpr, throwStmt));
// if false goto
NopStmt nopStmt = Jimple.v().newNopStmt();
jb.getUnits().add(Jimple.v().newGotoStmt(nopStmt));
jb.getUnits().add(throwStmt);
jb.getUnits().add(nopStmt);
| 144
| 470
| 614
|
<methods>public void <init>(ProtoIlInstructions.IlInstructionMsg, soot.dotnet.members.method.DotnetBody, soot.dotnet.instructions.CilBlock) <variables>protected final non-sealed soot.dotnet.instructions.CilBlock cilBlock,protected final non-sealed soot.dotnet.members.method.DotnetBody dotnetBody,protected final non-sealed ProtoIlInstructions.IlInstructionMsg instruction
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/instructions/CilCompInstruction.java
|
CilCompInstruction
|
jimplifyExpr
|
class CilCompInstruction extends AbstractCilnstruction {
public CilCompInstruction(ProtoIlInstructions.IlInstructionMsg instruction, DotnetBody dotnetBody, CilBlock cilBlock) {
super(instruction, dotnetBody, cilBlock);
}
@Override
public void jimplify(Body jb) {
throw new NoStatementInstructionException(instruction);
}
@Override
public Value jimplifyExpr(Body jb) {<FILL_FUNCTION_BODY>}
}
|
Value left = CilInstructionFactory.fromInstructionMsg(instruction.getLeft(), dotnetBody, cilBlock).jimplifyExpr(jb);
left = inlineCastExpr(left);
Value right = CilInstructionFactory.fromInstructionMsg(instruction.getRight(), dotnetBody, cilBlock).jimplifyExpr(jb);
right = inlineCastExpr(right);
IlComparisonKind comparisonKind = instruction.getComparisonKind();
if (right instanceof BinopExpr && left instanceof Constant) {
if (comparisonKind == IlComparisonKind.Equality || comparisonKind == IlComparisonKind.Inequality) {
Value tempRight = right;
right = left;
left = tempRight;
}
}
if (left instanceof BinopExpr && right instanceof IntConstant) {
boolean expectedValueTrue;
IntConstant c = (IntConstant) right;
if (c.value == 0) {
expectedValueTrue = false;
} else if (c.value == 1) {
expectedValueTrue = true;
} else {
throw new RuntimeException("Missing case for c.value");
}
if (comparisonKind == IlComparisonKind.Inequality) {
expectedValueTrue = !expectedValueTrue;
}
if (expectedValueTrue) {
return left;
} else {
BinopExpr binop = (BinopExpr) left;
if (left instanceof EqExpr) {
return Jimple.v().newNeExpr(binop.getOp1(), binop.getOp2());
}
if (left instanceof NeExpr) {
return Jimple.v().newEqExpr(binop.getOp1(), binop.getOp2());
}
if (left instanceof LtExpr) {
return Jimple.v().newGeExpr(binop.getOp1(), binop.getOp2());
}
if (left instanceof LeExpr) {
return Jimple.v().newGtExpr(binop.getOp1(), binop.getOp2());
}
if (left instanceof GeExpr) {
return Jimple.v().newLtExpr(binop.getOp1(), binop.getOp2());
}
if (left instanceof GtExpr) {
return Jimple.v().newLeExpr(binop.getOp1(), binop.getOp2());
} else {
return null;
}
}
}
switch (comparisonKind) {
case Equality:
return Jimple.v().newEqExpr(left, right);
case Inequality:
return Jimple.v().newNeExpr(left, right);
case LessThan:
return Jimple.v().newLtExpr(left, right);
case LessThanOrEqual:
return Jimple.v().newLeExpr(left, right);
case GreaterThan:
return Jimple.v().newGtExpr(left, right);
case GreaterThanOrEqual:
return Jimple.v().newGeExpr(left, right);
default:
return null;
}
| 136
| 771
| 907
|
<methods>public void <init>(ProtoIlInstructions.IlInstructionMsg, soot.dotnet.members.method.DotnetBody, soot.dotnet.instructions.CilBlock) <variables>protected final non-sealed soot.dotnet.instructions.CilBlock cilBlock,protected final non-sealed soot.dotnet.members.method.DotnetBody dotnetBody,protected final non-sealed ProtoIlInstructions.IlInstructionMsg instruction
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/instructions/CilDefaultValueInstruction.java
|
CilDefaultValueInstruction
|
jimplifyExpr
|
class CilDefaultValueInstruction extends AbstractNewObjInstanceInstruction {
public CilDefaultValueInstruction(ProtoIlInstructions.IlInstructionMsg instruction, DotnetBody dotnetBody,
CilBlock cilBlock) {
super(instruction, dotnetBody, cilBlock);
}
@Override
public void jimplify(Body jb) {
throw new NoStatementInstructionException(instruction);
}
@Override
public Value jimplifyExpr(Body jb) {<FILL_FUNCTION_BODY>}
}
|
// RefType refType = RefType.v(i.getType().getFullname());
// return Jimple.v().newNewExpr(refType);
SootClass clazz = Scene.v().getSootClass(instruction.getType().getFullname());
NewExpr newExpr = Jimple.v().newNewExpr(clazz.getType());
methodRef = Scene.v().makeConstructorRef(clazz, new ArrayList<>());
listOfArgs = new ArrayList<>();
return newExpr;
| 141
| 131
| 272
|
<methods>public void <init>(ProtoIlInstructions.IlInstructionMsg, soot.dotnet.members.method.DotnetBody, soot.dotnet.instructions.CilBlock) ,public List<soot.Local> getListOfArgs() ,public soot.SootMethodRef getMethodRef() ,public void resolveCallConstructorBody(soot.Body, soot.Local) <variables>protected List<soot.Local> listOfArgs,protected soot.SootMethodRef methodRef
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/instructions/CilIfInstruction.java
|
CilIfInstruction
|
jimplify
|
class CilIfInstruction extends AbstractCilnstruction {
public CilIfInstruction(ProtoIlInstructions.IlInstructionMsg instruction, DotnetBody dotnetBody, CilBlock cilBlock) {
super(instruction, dotnetBody, cilBlock);
}
@Override
public void jimplify(Body jb) {<FILL_FUNCTION_BODY>}
@Override
public Value jimplifyExpr(Body jb) {
throw new NoExpressionInstructionException(instruction);
}
}
|
CilInstruction cilExpr = CilInstructionFactory.fromInstructionMsg(instruction.getCondition(), dotnetBody, cilBlock);
Value condition = cilExpr.jimplifyExpr(jb);
// if condition only accepts ConditionExpr and not JimpleLocals
Value eqExpr;
if (condition instanceof ConditionExpr) {
eqExpr = condition;
} else {
// Store expression to local variable and check if true in second instruction
Local tmpLocalCond = dotnetBody.variableManager.localGenerator.generateLocal(condition.getType());
jb.getUnits().add(Jimple.v().newAssignStmt(tmpLocalCond, condition));
eqExpr = Jimple.v().newEqExpr(tmpLocalCond, IntConstant.v(1));
}
// for such cases in ILSpy AST as: if (comp.i4(ldloc capacity == ldloc num5)) leave IL_0000 (nop)
CilInstruction trueInstruction
= CilInstructionFactory.fromInstructionMsg(instruction.getTrueInst(), dotnetBody, cilBlock);
Unit trueInstruct = Jimple.v().newNopStmt(); // dummy stmt replace later
IfStmt ifStmt = Jimple.v().newIfStmt(eqExpr, trueInstruct);
jb.getUnits().add(ifStmt);
String target
= trueInstruction instanceof CilLeaveInstruction ? "RETURNLEAVE" : instruction.getTrueInst().getTargetLabel();
// dotnetBody.blockEntryPointsManager.gotoTargetsInBody.put(trueInstruct, target);
cilBlock.getDeclaredBlockContainer().blockEntryPointsManager.gotoTargetsInBody.put(trueInstruct, target);
| 136
| 437
| 573
|
<methods>public void <init>(ProtoIlInstructions.IlInstructionMsg, soot.dotnet.members.method.DotnetBody, soot.dotnet.instructions.CilBlock) <variables>protected final non-sealed soot.dotnet.instructions.CilBlock cilBlock,protected final non-sealed soot.dotnet.members.method.DotnetBody dotnetBody,protected final non-sealed ProtoIlInstructions.IlInstructionMsg instruction
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/instructions/CilInstructionFactory.java
|
CilInstructionFactory
|
fromInstructionMsg
|
class CilInstructionFactory {
private static final Logger logger = LoggerFactory.getLogger(CilInstructionFactory.class);
public static CilInstruction fromInstructionMsg(ProtoIlInstructions.IlInstructionMsg instruction, DotnetBody dotnetBody,
CilBlock cilBlock) {<FILL_FUNCTION_BODY>}
}
|
if (instruction == null) {
throw new RuntimeException("Cannot instantiate null instruction!");
}
switch (instruction.getOpCode()) {
case CALL:
case CALLVIRT:
// e.g. System.Object..ctor call
return new CilCallVirtInstruction(instruction, dotnetBody, cilBlock);
case LEAVE:
// return (void)
return new CilLeaveInstruction(instruction, dotnetBody, cilBlock);
case STLOC:
return new CilStLocInstruction(instruction, dotnetBody, cilBlock);
case STOBJ:
return new CilStObjInstruction(instruction, dotnetBody, cilBlock);
case NOP:
return new CilNopInstruction(instruction, dotnetBody, cilBlock);
case BRANCH:
return new CilBranchInstruction(instruction, dotnetBody, cilBlock);
case IF_INSTRUCTION:
return new CilIfInstruction(instruction, dotnetBody, cilBlock);
case TRY_CATCH:
return new CilTryCatchInstruction(instruction, dotnetBody, cilBlock);
case TRY_FINALLY:
return new CilTryFinallyInstruction(instruction, dotnetBody, cilBlock);
case TRY_FAULT:
return new CilTryFaultInstruction(instruction, dotnetBody, cilBlock);
case RETHROW:
return new CilRethrowInstruction(instruction, dotnetBody, cilBlock);
case THROW:
return new CilThrowInstruction(instruction, dotnetBody, cilBlock);
case DEBUG_BREAK:
return new CilDebugBreakInstruction(instruction, dotnetBody, cilBlock);
case SWITCH:
return new CilSwitchInstruction(instruction, dotnetBody, cilBlock);
case CK_FINITE:
return new CilCkFiniteInstruction(instruction, dotnetBody, cilBlock);
case LDLOCA:
case LDLOC:
return new CilLdLocInstruction(instruction, dotnetBody, cilBlock);
case LDC_I4:
return new CilLdcI4Instruction(instruction, dotnetBody, cilBlock);
case LDC_I8:
return new CilLdcI8Instruction(instruction, dotnetBody, cilBlock);
case LDC_R4:
return new CilLdcR4Instruction(instruction, dotnetBody, cilBlock);
case LDC_R8:
return new CilLdcR8Instruction(instruction, dotnetBody, cilBlock);
case LDSTR:
return new CilLdStrInstruction(instruction, dotnetBody, cilBlock);
case LDSFLDA:
return new CilLdsFldaInstruction(instruction, dotnetBody, cilBlock);
case LDFLDA:
return new CilLdFldaInstruction(instruction, dotnetBody, cilBlock);
case LDOBJ:
return fromInstructionMsg(instruction.getTarget(), dotnetBody, cilBlock);
// return new CilLdObjInstruction(instruction, dotnetBody);
case NEWOBJ:
return new CilNewObjInstruction(instruction, dotnetBody, cilBlock);
case BINARY_NUMERIC_INSTRUCTION:
return new CilBinaryNumericInstruction(instruction, dotnetBody, cilBlock);
case COMP:
return new CilCompInstruction(instruction, dotnetBody, cilBlock);
case LDNULL:
return new CilLdNullInstruction(instruction, dotnetBody, cilBlock);
case LDLEN:
return new CilLdLenInstruction(instruction, dotnetBody, cilBlock);
case CONV:
return new CilConvInstruction(instruction, dotnetBody, cilBlock);
case NEWARR:
return new CilNewArrInstruction(instruction, dotnetBody, cilBlock);
case LDELEMA:
return new CilLdElemaInstruction(instruction, dotnetBody, cilBlock);
case ISINST:
return new CilIsInstInstruction(instruction, dotnetBody, cilBlock);
case CASTCLASS:
case BOX:
case UNBOX:
case UNBOXANY:
return new CilCastClassUnBoxInstruction(instruction, dotnetBody, cilBlock);
case NOT:
return new CilNotInstruction(instruction, dotnetBody, cilBlock);
case DEFAULT_VALUE:
return new CilDefaultValueInstruction(instruction, dotnetBody, cilBlock);
case LD_MEMBER_TOKEN:
return new CilLdMemberTokenInstruction(instruction, dotnetBody, cilBlock);
case LD_TYPE_TOKEN:
return new CilLdTypeTokenInstruction(instruction, dotnetBody, cilBlock);
case LOC_ALLOC:
return new CilLocAllocInstruction(instruction, dotnetBody, cilBlock);
case LD_FTN:
case LD_VIRT_FTN:
return new CilLdFtnInstruction(instruction, dotnetBody, cilBlock);
case MK_REF_ANY:
case REF_ANY_VAL:
return new CilRefAnyInstruction(instruction, dotnetBody, cilBlock);
case REF_ANY_TYPE:
return new CilRefTypeInstruction(instruction, dotnetBody, cilBlock);
case SIZE_OF:
return new CilSizeOfInstruction(instruction, dotnetBody, cilBlock);
default:
throw new IllegalArgumentException("Opcode " + instruction.getOpCode().name() + " is not implemented!");
}
| 89
| 1,508
| 1,597
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/instructions/CilLdElemaInstruction.java
|
CilLdElemaInstruction
|
jimplifyExpr
|
class CilLdElemaInstruction extends AbstractCilnstruction {
public CilLdElemaInstruction(ProtoIlInstructions.IlInstructionMsg instruction, DotnetBody dotnetBody, CilBlock cilBlock) {
super(instruction, dotnetBody, cilBlock);
if (instruction.getIndicesCount() > 1) {
isMultiArrayRef = true;
}
}
private boolean isMultiArrayRef = false;
private final List<Value> indices = new ArrayList<>();
/**
* Base array value/local from where to load element
*/
private Value baseArrayLocal;
@Override
public void jimplify(Body jb) {
throw new NoStatementInstructionException(instruction);
}
@Override
public Value jimplifyExpr(Body jb) {<FILL_FUNCTION_BODY>}
public boolean isMultiArrayRef() {
return isMultiArrayRef;
}
public Value getBaseArrayLocal() {
return baseArrayLocal;
}
public List<Value> getIndices() {
return indices;
}
/**
* Resolve Jimple Body, rollout array access dimension for dimension and return new rValue
*
* @param jb
* Jimple Body where to insert the rewritten statements
*/
public Value resolveRewriteMultiArrAccess(Body jb) {
// can only be >1
int size = getIndices().size();
Local lLocalVar;
Local rLocalVar = null;
for (int z = 0; z < size; z++) {
ArrayRef arrayRef;
if (z == 0) {
arrayRef = Jimple.v().newArrayRef(getBaseArrayLocal(), getIndices().get(z));
} else {
arrayRef = Jimple.v().newArrayRef(rLocalVar, getIndices().get(z));
}
Type arrayType = arrayRef.getType();
lLocalVar = dotnetBody.variableManager.localGenerator.generateLocal(arrayType);
AssignStmt assignStmt = Jimple.v().newAssignStmt(lLocalVar, arrayRef);
jb.getUnits().add(assignStmt);
rLocalVar = lLocalVar;
}
return rLocalVar;
}
}
|
CilInstruction cilExpr = CilInstructionFactory.fromInstructionMsg(instruction.getArray(), dotnetBody, cilBlock);
baseArrayLocal = cilExpr.jimplifyExpr(jb);
if (instruction.getIndicesCount() == 1) {
Value ind
= CilInstructionFactory.fromInstructionMsg(instruction.getIndices(0), dotnetBody, cilBlock).jimplifyExpr(jb);
Value index = ind instanceof Immediate ? ind : DotnetBodyVariableManager.inlineLocals(ind, jb);
return Jimple.v().newArrayRef(baseArrayLocal, index);
}
// if is multiArrayRef
for (ProtoIlInstructions.IlInstructionMsg ind : instruction.getIndicesList()) {
Value indExpr = CilInstructionFactory.fromInstructionMsg(ind, dotnetBody, cilBlock).jimplifyExpr(jb);
Value index = indExpr instanceof Immediate ? indExpr : DotnetBodyVariableManager.inlineLocals(indExpr, jb);
indices.add(index);
}
// only temporary - MultiArrayRef is rewritten later in in StLoc with the resolveRewriteMultiArrAccess instruction
return Jimple.v().newArrayRef(baseArrayLocal, indices.get(0));
| 594
| 324
| 918
|
<methods>public void <init>(ProtoIlInstructions.IlInstructionMsg, soot.dotnet.members.method.DotnetBody, soot.dotnet.instructions.CilBlock) <variables>protected final non-sealed soot.dotnet.instructions.CilBlock cilBlock,protected final non-sealed soot.dotnet.members.method.DotnetBody dotnetBody,protected final non-sealed ProtoIlInstructions.IlInstructionMsg instruction
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/instructions/CilLdFldaInstruction.java
|
CilLdFldaInstruction
|
jimplifyExpr
|
class CilLdFldaInstruction extends AbstractCilnstruction {
public CilLdFldaInstruction(ProtoIlInstructions.IlInstructionMsg instruction, DotnetBody dotnetBody, CilBlock cilBlock) {
super(instruction, dotnetBody, cilBlock);
}
@Override
public void jimplify(Body jb) {
throw new NoStatementInstructionException(instruction);
}
@Override
public Value jimplifyExpr(Body jb) {<FILL_FUNCTION_BODY>}
}
|
// ldflda is only non-static
SootClass declaringClass = SootResolver.v().makeClassRef(instruction.getField().getDeclaringType().getFullname());
SootFieldRef fieldRef = Scene.v().makeFieldRef(declaringClass, instruction.getField().getName(),
DotnetTypeFactory.toSootType(instruction.getField().getType()), false);
CilInstruction cilExpr = CilInstructionFactory.fromInstructionMsg(instruction.getTarget(), dotnetBody, cilBlock);
Value target = cilExpr.jimplifyExpr(jb);
return Jimple.v().newInstanceFieldRef(target, fieldRef);
| 144
| 174
| 318
|
<methods>public void <init>(ProtoIlInstructions.IlInstructionMsg, soot.dotnet.members.method.DotnetBody, soot.dotnet.instructions.CilBlock) <variables>protected final non-sealed soot.dotnet.instructions.CilBlock cilBlock,protected final non-sealed soot.dotnet.members.method.DotnetBody dotnetBody,protected final non-sealed ProtoIlInstructions.IlInstructionMsg instruction
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/instructions/CilLdLenInstruction.java
|
CilLdLenInstruction
|
jimplifyExpr
|
class CilLdLenInstruction extends AbstractCilnstruction {
public CilLdLenInstruction(ProtoIlInstructions.IlInstructionMsg instruction, DotnetBody dotnetBody, CilBlock cilBlock) {
super(instruction, dotnetBody, cilBlock);
}
@Override
public void jimplify(Body jb) {
throw new NoStatementInstructionException(instruction);
}
@Override
public Value jimplifyExpr(Body jb) {<FILL_FUNCTION_BODY>}
}
|
CilInstruction cilExpr = CilInstructionFactory.fromInstructionMsg(instruction.getArray(), dotnetBody, cilBlock);
Value arr = cilExpr.jimplifyExpr(jb);
if (!(arr instanceof Immediate)) {
throw new RuntimeException("LdLen: Given value is no Immediate!");
}
return Jimple.v().newLengthExpr(arr);
| 140
| 102
| 242
|
<methods>public void <init>(ProtoIlInstructions.IlInstructionMsg, soot.dotnet.members.method.DotnetBody, soot.dotnet.instructions.CilBlock) <variables>protected final non-sealed soot.dotnet.instructions.CilBlock cilBlock,protected final non-sealed soot.dotnet.members.method.DotnetBody dotnetBody,protected final non-sealed ProtoIlInstructions.IlInstructionMsg instruction
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/instructions/CilLeaveInstruction.java
|
CilLeaveInstruction
|
jimplify
|
class CilLeaveInstruction extends AbstractCilnstruction {
public CilLeaveInstruction(ProtoIlInstructions.IlInstructionMsg instruction, DotnetBody dotnetBody, CilBlock cilBlock) {
super(instruction, dotnetBody, cilBlock);
}
@Override
public void jimplify(Body jb) {<FILL_FUNCTION_BODY>}
@Override
public Value jimplifyExpr(Body jb) {
throw new NoExpressionInstructionException(instruction);
}
}
|
// void
if (instruction.getValueInstruction().getOpCode().equals(ProtoIlInstructions.IlInstructionMsg.IlOpCode.NOP)) {
jb.getUnits().add(Jimple.v().newReturnVoidStmt());
} else {
CilInstruction cilValueExpr
= CilInstructionFactory.fromInstructionMsg(instruction.getValueInstruction(), dotnetBody, cilBlock);
Value value = cilValueExpr.jimplifyExpr(jb);
// if sth like return new Obj, rewrite value to tmp variable
if (cilValueExpr instanceof AbstractNewObjInstanceInstruction) {
// CilStLocInstruction stLocInstruction = new CilStLocInstruction(instruction, dotnetBody);
// stLocInstruction.jimplify(jb);
Local tmpVariable = dotnetBody.variableManager.localGenerator.generateLocal(value.getType());
AssignStmt assignStmt = Jimple.v().newAssignStmt(tmpVariable, value);
jb.getUnits().add(assignStmt);
((AbstractNewObjInstanceInstruction) cilValueExpr).resolveCallConstructorBody(jb, tmpVariable);
ReturnStmt ret = Jimple.v().newReturnStmt(tmpVariable);
jb.getUnits().add(ret);
return;
}
// Jimple grammar does not allow returning static, instead assign to tmp variable
// if System.Array.Empty of CilCallVirtInstruction (newExpr), rewrite
if (!(value instanceof Immediate)) {
// CilStLocInstruction stLocInstruction = new CilStLocInstruction(instruction, dotnetBody);
// stLocInstruction.jimplify(jb);
Local tmpVariable = dotnetBody.variableManager.localGenerator.generateLocal(value.getType());
AssignStmt assignStmt = Jimple.v().newAssignStmt(tmpVariable, value);
jb.getUnits().add(assignStmt);
ReturnStmt ret = Jimple.v().newReturnStmt(tmpVariable);
jb.getUnits().add(ret);
return;
}
ReturnStmt ret = Jimple.v().newReturnStmt(value);
jb.getUnits().add(ret);
}
| 138
| 578
| 716
|
<methods>public void <init>(ProtoIlInstructions.IlInstructionMsg, soot.dotnet.members.method.DotnetBody, soot.dotnet.instructions.CilBlock) <variables>protected final non-sealed soot.dotnet.instructions.CilBlock cilBlock,protected final non-sealed soot.dotnet.members.method.DotnetBody dotnetBody,protected final non-sealed ProtoIlInstructions.IlInstructionMsg instruction
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/instructions/CilNewArrInstruction.java
|
CilNewArrInstruction
|
jimplifyExpr
|
class CilNewArrInstruction extends AbstractCilnstruction {
public CilNewArrInstruction(ProtoIlInstructions.IlInstructionMsg instruction, DotnetBody dotnetBody, CilBlock cilBlock) {
super(instruction, dotnetBody, cilBlock);
}
@Override
public void jimplify(Body jb) {
throw new NoStatementInstructionException(instruction);
}
@Override
public Value jimplifyExpr(Body jb) {<FILL_FUNCTION_BODY>}
}
|
Type type = DotnetTypeFactory.toSootType(instruction.getType().getFullname());
List<Value> sizesOfArr = new ArrayList<>();
for (ProtoIlInstructions.IlInstructionMsg index : instruction.getIndicesList()) {
CilInstruction cilExpr = CilInstructionFactory.fromInstructionMsg(index, dotnetBody, cilBlock);
Value value = cilExpr.jimplifyExpr(jb);
Value val = value instanceof Immediate ? value : DotnetBodyVariableManager.inlineLocals(value, jb);
sizesOfArr.add(val);
}
// if only one dim array
if (sizesOfArr.size() == 1) {
return Jimple.v().newNewArrayExpr(type, sizesOfArr.get(0));
}
ArrayType arrayType = ArrayType.v(type, sizesOfArr.size());
return Jimple.v().newNewMultiArrayExpr(arrayType, sizesOfArr);
| 140
| 254
| 394
|
<methods>public void <init>(ProtoIlInstructions.IlInstructionMsg, soot.dotnet.members.method.DotnetBody, soot.dotnet.instructions.CilBlock) <variables>protected final non-sealed soot.dotnet.instructions.CilBlock cilBlock,protected final non-sealed soot.dotnet.members.method.DotnetBody dotnetBody,protected final non-sealed ProtoIlInstructions.IlInstructionMsg instruction
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/instructions/CilSizeOfInstruction.java
|
CilSizeOfInstruction
|
jimplifyExpr
|
class CilSizeOfInstruction extends AbstractCilnstruction {
public CilSizeOfInstruction(ProtoIlInstructions.IlInstructionMsg instruction, DotnetBody dotnetBody, CilBlock cilBlock) {
super(instruction, dotnetBody, cilBlock);
}
@Override
public void jimplify(Body jb) {
throw new NoStatementInstructionException(instruction);
}
@Override
public Value jimplifyExpr(Body jb) {<FILL_FUNCTION_BODY>}
}
|
String typeName = instruction.getType().getFullname();
// // generate dummy local with ClassConstant - may not needed
// LocalGenerator localGenerator = new LocalGenerator(jb);
// Local tmpLocalVar = localGenerator.generateLocal(RefType.v("System.Object"));
// Unit stmt = Jimple.v().newAssignStmt(tmpLocalVar, DotnetClassConstant.v(typeName));
// jb.getUnits().add(stmt);
SootClass clazz = Scene.v().getSootClass(DotnetBasicTypes.SYSTEM_RUNTIME_INTEROPSERVICES_MARSHAL);
// SootMethod method = clazz.getMethod("SizeOf",
// Collections.singletonList(Scene.v().getRefType(DotnetBasicTypes.SYSTEM_OBJECT)));
SootMethodRef methodRef = Scene.v().makeMethodRef(clazz, "SizeOf",
Collections.singletonList(Scene.v().getRefType(DotnetBasicTypes.SYSTEM_OBJECT)), IntType.v(), true);
return Jimple.v().newStaticInvokeExpr(methodRef, DotnetClassConstant.v(typeName));
| 138
| 301
| 439
|
<methods>public void <init>(ProtoIlInstructions.IlInstructionMsg, soot.dotnet.members.method.DotnetBody, soot.dotnet.instructions.CilBlock) <variables>protected final non-sealed soot.dotnet.instructions.CilBlock cilBlock,protected final non-sealed soot.dotnet.members.method.DotnetBody dotnetBody,protected final non-sealed ProtoIlInstructions.IlInstructionMsg instruction
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/instructions/CilStLocInstruction.java
|
CilStLocInstruction
|
jimplify
|
class CilStLocInstruction extends AbstractCilnstruction {
public CilStLocInstruction(ProtoIlInstructions.IlInstructionMsg instruction, DotnetBody dotnetBody, CilBlock cilBlock) {
super(instruction, dotnetBody, cilBlock);
}
@Override
public void jimplify(Body jb) {<FILL_FUNCTION_BODY>}
@Override
public Value jimplifyExpr(Body jb) {
throw new NoExpressionInstructionException(instruction);
}
}
|
CilInstruction cilExpr
= CilInstructionFactory.fromInstructionMsg(instruction.getValueInstruction(), dotnetBody, cilBlock);
Value value = cilExpr.jimplifyExpr(jb);
// if rvalue is isinst, change to instanceof semantic, see description of opcode
if (cilExpr instanceof CilIsInstInstruction) {
CilIsInstInstruction isInst = (CilIsInstInstruction) cilExpr;
Local variable = dotnetBody.variableManager.addOrGetVariable(instruction.getVariable(), jb);
isInst.resolveRewritingIsInst(jb, variable, value);
return;
}
// rewrite multi array to Jimple semantic, see description of opcode
if (cilExpr instanceof CilLdElemaInstruction && ((CilLdElemaInstruction) cilExpr).isMultiArrayRef()) {
CilLdElemaInstruction newArrInstruction = (CilLdElemaInstruction) cilExpr;
value = newArrInstruction.resolveRewriteMultiArrAccess(jb);
}
Local variable = dotnetBody.variableManager.addOrGetVariable(instruction.getVariable(), value.getType(), jb);
// cast for validation
if (cilExpr instanceof CilCallVirtInstruction) {
List<Pair<Local, Local>> locals = ((CilCallVirtInstruction) cilExpr).getLocalsToCastForCall();
if (locals.size() != 0) {
for (Pair<Local, Local> pair : locals) {
CastExpr castExpr = Jimple.v().newCastExpr(pair.getO1(), pair.getO2().getType());
AssignStmt assignStmt = Jimple.v().newAssignStmt(pair.getO2(), castExpr);
jb.getUnits().add(assignStmt);
}
}
}
// create this cast, to validate successfully
if (value instanceof Local && !variable.getType().toString().equals(value.getType().toString())
&& dotnetBody.variableManager.localsToCastContains(((Local) value).getName())) {
value = Jimple.v().newCastExpr(value, variable.getType());
}
// for validation, because array = obj, where array typeof byte[] and obj typeof System.Object
if (value instanceof Local && value.getType().toString().equals(DotnetBasicTypes.SYSTEM_OBJECT)
&& !variable.getType().toString().equals(DotnetBasicTypes.SYSTEM_OBJECT)) {
value = Jimple.v().newCastExpr(value, variable.getType());
}
AssignStmt astm = Jimple.v().newAssignStmt(variable, value);
jb.getUnits().add(astm);
// if new Obj also add call of constructor, see description of opcode
if (cilExpr instanceof AbstractNewObjInstanceInstruction) {
((AbstractNewObjInstanceInstruction) cilExpr).resolveCallConstructorBody(jb, variable);
}
| 138
| 769
| 907
|
<methods>public void <init>(ProtoIlInstructions.IlInstructionMsg, soot.dotnet.members.method.DotnetBody, soot.dotnet.instructions.CilBlock) <variables>protected final non-sealed soot.dotnet.instructions.CilBlock cilBlock,protected final non-sealed soot.dotnet.members.method.DotnetBody dotnetBody,protected final non-sealed ProtoIlInstructions.IlInstructionMsg instruction
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/instructions/CilSwitchInstruction.java
|
CilSwitchInstruction
|
jimplify
|
class CilSwitchInstruction extends AbstractCilnstruction {
public CilSwitchInstruction(ProtoIlInstructions.IlInstructionMsg instruction, DotnetBody dotnetBody, CilBlock cilBlock) {
super(instruction, dotnetBody, cilBlock);
}
@Override
public void jimplify(Body jb) {<FILL_FUNCTION_BODY>}
@Override
public Value jimplifyExpr(Body jb) {
throw new NoExpressionInstructionException(instruction);
}
}
|
CilInstruction cilExpr = CilInstructionFactory.fromInstructionMsg(instruction.getKeyInstr(), dotnetBody, cilBlock);
Value key = cilExpr.jimplifyExpr(jb);
int lowIndex = (int) instruction.getSwitchSections(0).getLabel();
int highIndex = (int) instruction.getSwitchSections(instruction.getSwitchSectionsCount() - 1).getLabel();
// default target
Unit defaultInstruct = Jimple.v().newNopStmt(); // dummy
switch (instruction.getDefaultInst().getOpCode()) {
case BRANCH:
cilBlock.getDeclaredBlockContainer().blockEntryPointsManager.gotoTargetsInBody.put(defaultInstruct,
instruction.getDefaultInst().getTargetLabel());
break;
case LEAVE:
if (cilBlock.getDeclaredBlockContainer().isChildBlockContainer()
&& !instruction.getDefaultInst().getTargetLabel().equals("IL_0000")) {
defaultInstruct = cilBlock.getDeclaredBlockContainer().getSkipBlockContainerStmt(); // if child blockcontainer,
// jump to end of it
} else {
dotnetBody.blockEntryPointsManager.gotoTargetsInBody.put(defaultInstruct, "RETURNLEAVE");
}
break;
default:
throw new RuntimeException(
"CilSwitchInstruction: Opcode " + instruction.getDefaultInst().getOpCode().name() + " not implemented!");
}
List<Unit> targets = new ArrayList<>();
for (ProtoIlInstructions.IlSwitchSectionMsg section : instruction.getSwitchSectionsList()) {
NopStmt nopStmt = Jimple.v().newNopStmt(); // dummy target
switch (section.getTargetInstr().getOpCode()) {
case BRANCH:
targets.add(nopStmt);
// dotnetBody.blockEntryPointsManager.gotoTargetsInBody.put(nopStmt, section.getTargetInstr().getTargetLabel());
cilBlock.getDeclaredBlockContainer().blockEntryPointsManager.gotoTargetsInBody.put(nopStmt,
section.getTargetInstr().getTargetLabel());
break;
case LEAVE:
if (cilBlock.getDeclaredBlockContainer().isChildBlockContainer()
&& !section.getTargetInstr().getTargetLabel().equals("IL_0000")) {
targets.add(cilBlock.getDeclaredBlockContainer().getSkipBlockContainerStmt());
} else {
targets.add(nopStmt);
// dotnetBody.blockEntryPointsManager.gotoTargetsInBody.put(nopStmt, "END_" +
// section.getTargetInstr().getTargetLabel());
dotnetBody.blockEntryPointsManager.gotoTargetsInBody.put(nopStmt, "RETURNLEAVE");
}
break;
default:
throw new RuntimeException(
"CilSwitchInstruction: Opcode " + section.getTargetInstr().getOpCode().name() + " not implemented!");
}
}
TableSwitchStmt tableSwitchStmt = Jimple.v().newTableSwitchStmt(key, lowIndex, highIndex, targets, defaultInstruct);
jb.getUnits().add(tableSwitchStmt);
| 136
| 830
| 966
|
<methods>public void <init>(ProtoIlInstructions.IlInstructionMsg, soot.dotnet.members.method.DotnetBody, soot.dotnet.instructions.CilBlock) <variables>protected final non-sealed soot.dotnet.instructions.CilBlock cilBlock,protected final non-sealed soot.dotnet.members.method.DotnetBody dotnetBody,protected final non-sealed ProtoIlInstructions.IlInstructionMsg instruction
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/instructions/CilTryCatchInstruction.java
|
CilTryCatchInstruction
|
jimplify
|
class CilTryCatchInstruction extends AbstractCilnstruction {
public CilTryCatchInstruction(ProtoIlInstructions.IlInstructionMsg instruction, DotnetBody dotnetBody,
CilBlock cilBlock) {
super(instruction, dotnetBody, cilBlock);
}
@Override
public void jimplify(Body jb) {<FILL_FUNCTION_BODY>}
@Override
public Value jimplifyExpr(Body jb) {
throw new NoExpressionInstructionException(instruction);
}
}
|
List<Unit> nopsToReplaceWithGoto = new ArrayList<>();
final SootClass exceptionClass = Scene.v().getSootClass(DotnetBasicTypes.SYSTEM_EXCEPTION);
NopStmt gotoEndTryCatchBlockNop = Jimple.v().newNopStmt();
// try block
CilBlockContainer tryContainer
= new CilBlockContainer(instruction.getTryBlock(), dotnetBody, CilBlockContainer.BlockContainerKind.TRY);
Body tryContainerBlock = tryContainer.jimplify();
if (CilBlockContainer.LastStmtIsNotReturn(tryContainerBlock)) {
// if last stmt is not return, insert goto stmt
NopStmt nopStmt = Jimple.v().newNopStmt();
tryContainerBlock.getUnits().add(nopStmt);
nopsToReplaceWithGoto.add(nopStmt);
}
jb.getLocals().addAll(tryContainerBlock.getLocals());
jb.getUnits().addAll(tryContainerBlock.getUnits());
jb.getTraps().addAll(tryContainerBlock.getTraps());
// add boilerplate code, due to blocks in CIL and no blocks in Jimple
// add block - after exception not caught in catch block
// generate new local with caught exception ref - add to jb afterwards due to traps
Local uncaughtExceptionVar = dotnetBody.variableManager.localGenerator.generateLocal(exceptionClass.getType());
Unit exceptionIdentityStmt = Jimple.v().newIdentityStmt(uncaughtExceptionVar, Jimple.v().newCaughtExceptionRef());
// handlers
List<ProtoIlInstructions.IlTryCatchHandlerMsg> protoHandlersList = instruction.getHandlersList();
List<CatchFilterHandlerBody> handlersWithFilterList = new ArrayList<>();
List<CatchHandlerBody> handlersList = new ArrayList<>();
CatchHandlerBody systemExceptionHandler = null;
for (ProtoIlInstructions.IlTryCatchHandlerMsg handlerMsg : protoHandlersList) {
// Exception object / class - add as identity stmt to jimple body
Local exceptionVar = dotnetBody.variableManager.addOrGetVariable(handlerMsg.getVariable(), jb);
if (handlerMsg.getHasFilter()) {
CatchFilterHandlerBody filterHandler
= new CatchFilterHandlerBody(dotnetBody, handlerMsg, exceptionVar, gotoEndTryCatchBlockNop);
handlersWithFilterList.add(filterHandler);
continue;
}
CatchHandlerBody handler = new CatchHandlerBody(exceptionVar, handlerMsg, dotnetBody, tryContainerBlock,
exceptionIdentityStmt, nopsToReplaceWithGoto);
handlersList.add(handler);
if (handlerMsg.getVariable().getType().getFullname().equals(DotnetBasicTypes.SYSTEM_EXCEPTION)) {
systemExceptionHandler = handler;
}
}
for (CatchHandlerBody handlerBody : handlersList) {
Body body = handlerBody.getBody();
if (handlerBody == systemExceptionHandler) {
Map<Trap, Unit> tmpTrapEnds = new HashMap<>();
for (Trap trap : body.getTraps()) {
tmpTrapEnds.put(trap, trap.getEndUnit());
}
for (CatchFilterHandlerBody filterHandler : handlersWithFilterList) {
Local eVar = systemExceptionHandler.getExceptionVariable();
Body filterHandlerBody = filterHandler.getFilterHandlerBody(eVar);
body.getUnits().insertAfter(filterHandlerBody.getUnits(), body.getUnits().getFirst());
body.getTraps().addAll(filterHandlerBody.getTraps());
}
for (Map.Entry<Trap, Unit> trapMap : tmpTrapEnds.entrySet()) {
trapMap.getKey().setEndUnit(trapMap.getValue());
}
}
jb.getUnits().addAll(body.getUnits());
jb.getTraps().addAll(body.getTraps());
}
// If System.Exception catch not declared, add this trap, if any other exception then declared one was thrown
if (systemExceptionHandler == null) {
jb.getTraps().add(Jimple.v().newTrap(exceptionClass, tryContainerBlock.getUnits().getFirst(),
tryContainerBlock.getUnits().getLast(), exceptionIdentityStmt));
}
// --- add boilerplate code (uncaught exceptions in catch) to jimple body: add identity and throw stmt
jb.getUnits().add(exceptionIdentityStmt);
// TryFilter
if (systemExceptionHandler == null) {
for (CatchFilterHandlerBody filterHandler : handlersWithFilterList) {
Body filterHandlerBody = filterHandler.getFilterHandlerBody(uncaughtExceptionVar);
jb.getUnits().addAll(filterHandlerBody.getUnits());
jb.getTraps().addAll(filterHandlerBody.getTraps());
}
}
jb.getUnits().add(Jimple.v().newThrowStmt(uncaughtExceptionVar));
// add nop for goto end of try/catch block
jb.getUnits().add(gotoEndTryCatchBlockNop);
for (Unit nop : nopsToReplaceWithGoto) {
GotoStmt gotoStmt = Jimple.v().newGotoStmt(gotoEndTryCatchBlockNop);
jb.getUnits().swapWith(nop, gotoStmt);
}
| 142
| 1,419
| 1,561
|
<methods>public void <init>(ProtoIlInstructions.IlInstructionMsg, soot.dotnet.members.method.DotnetBody, soot.dotnet.instructions.CilBlock) <variables>protected final non-sealed soot.dotnet.instructions.CilBlock cilBlock,protected final non-sealed soot.dotnet.members.method.DotnetBody dotnetBody,protected final non-sealed ProtoIlInstructions.IlInstructionMsg instruction
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/instructions/CilTryFinallyInstruction.java
|
CilTryFinallyInstruction
|
jimplify
|
class CilTryFinallyInstruction extends AbstractCilnstruction {
public CilTryFinallyInstruction(ProtoIlInstructions.IlInstructionMsg instruction, DotnetBody dotnetBody,
CilBlock cilBlock) {
super(instruction, dotnetBody, cilBlock);
}
@Override
public void jimplify(Body jb) {<FILL_FUNCTION_BODY>}
@Override
public Value jimplifyExpr(Body jb) {
throw new NoExpressionInstructionException(instruction);
}
}
|
// try block
CilBlockContainer tryContainer
= new CilBlockContainer(instruction.getTryBlock(), dotnetBody, CilBlockContainer.BlockContainerKind.TRY);
Body tryContainerBlock = tryContainer.jimplify();
// finally block
CilBlockContainer finallyBlockContainer
= new CilBlockContainer(instruction.getFinallyBlock(), dotnetBody, CilBlockContainer.BlockContainerKind.FINALLY);
Body finallyBlockContainerBody = finallyBlockContainer.jimplify();
// add finally block to all cases
tryContainerBlock.getLocals().addAll(finallyBlockContainerBody.getLocals());
// Restore endunits to original one, due to insert call
Map<Trap, Unit> tmpTrapEnds = new HashMap<>();
// store all endUnits of traps, due to insertion of finally blocks. Afterwards change back to ori. endUnit
for (Trap trap : tryContainerBlock.getTraps()) {
tmpTrapEnds.put(trap, trap.getEndUnit());
}
ArrayList<Unit> tmpUnits = new ArrayList<>();
for (Unit unit : tryContainerBlock.getUnits()) {
if (CilBlockContainer.isExitStmt(unit)) {
tmpUnits.add(unit);
}
}
for (Unit unit : tmpUnits) {
// Set dummy method
finallyBlockContainerBody.setMethod(new SootMethod("", new ArrayList<>(), RefType.v("")));
Body cloneFinallyBlock = (Body) finallyBlockContainerBody.clone(true);
tryContainerBlock.getUnits().insertBefore(cloneFinallyBlock.getUnits(), unit);
// tryContainerBlock.getLocals().addAll(cloneFinallyBlock.getLocals());
tryContainerBlock.getTraps().addAll(cloneFinallyBlock.getTraps());
}
for (Map.Entry<Trap, Unit> trapMap : tmpTrapEnds.entrySet()) {
trapMap.getKey().setEndUnit(trapMap.getValue());
}
jb.getLocals().addAll(tryContainerBlock.getLocals());
jb.getUnits().addAll(tryContainerBlock.getUnits());
jb.getTraps().addAll(tryContainerBlock.getTraps());
| 140
| 574
| 714
|
<methods>public void <init>(ProtoIlInstructions.IlInstructionMsg, soot.dotnet.members.method.DotnetBody, soot.dotnet.instructions.CilBlock) <variables>protected final non-sealed soot.dotnet.instructions.CilBlock cilBlock,protected final non-sealed soot.dotnet.members.method.DotnetBody dotnetBody,protected final non-sealed ProtoIlInstructions.IlInstructionMsg instruction
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/members/AbstractDotnetMember.java
|
AbstractDotnetMember
|
checkRewriteCilSpecificMember
|
class AbstractDotnetMember implements DotnetTypeMember {
/**
* If we have specific return or assignment characteristics, rewrite it (mostly reftypes) Due to the different eco system
* of .NET and unsafe methods
*
* @param declaringClass
* @param fieldMethodName
* @return
*/
public static Value checkRewriteCilSpecificMember(SootClass declaringClass, String fieldMethodName) {<FILL_FUNCTION_BODY>}
}
|
/*
* Normally System.String.Empty == Reftype(System.String), because is string, lead to errors in validation With this
* fix: System.String.Empty == StringConstant
*/
if (declaringClass.getName().equals(DotnetBasicTypes.SYSTEM_STRING) && fieldMethodName.equals("Empty")) {
return StringConstant.v("");
}
/*
* If System.Array.Empty, normal RefType(System.Array) Problem with System.Type[] = System.Array.Empty With this fix
* null constant
*/
if (declaringClass.getName().equals(DotnetBasicTypes.SYSTEM_ARRAY) && fieldMethodName.equals("Empty")) {
// return Jimple.v().newNewExpr(RefType.v(DotnetBasicTypes.SYSTEM_ARRAY));
return NullConstant.v();
}
return null;
| 125
| 222
| 347
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/members/DotnetField.java
|
DotnetField
|
makeSootField
|
class DotnetField extends AbstractDotnetMember {
private final ProtoAssemblyAllTypes.FieldDefinition protoField;
public DotnetField(ProtoAssemblyAllTypes.FieldDefinition protoField) {
this.protoField = protoField;
}
public SootField makeSootField() {<FILL_FUNCTION_BODY>}
}
|
int modifier = toSootModifier(protoField);
Type type = DotnetTypeFactory.toSootType(protoField.getType());
String name = protoField.getName();
return new SootField(name, type, modifier);
| 89
| 65
| 154
|
<methods>public non-sealed void <init>() ,public static soot.Value checkRewriteCilSpecificMember(soot.SootClass, java.lang.String) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/members/method/BlockEntryPointsManager.java
|
BlockEntryPointsManager
|
swapGotoEntriesInJBody
|
class BlockEntryPointsManager {
/**
* Every method contains blocks of instructions targeted with a label. These are stored while visiting blocks and used
* afterwards to swap the goto values.
*/
private final HashMap<String, Unit> methodBlockEntryPoints = new HashMap<>();
/**
* first goto targets are nop stmts, mapped to the real entry point string_names. These are swapped afterwards with the
* real goto values, after all method blocks are visited.
*/
public final HashMap<Unit, String> gotoTargetsInBody = new HashMap<>();
public void putBlockEntryPoint(String blockName, Unit entryUnit) {
methodBlockEntryPoints.put(blockName, entryUnit);
}
public Unit getBlockEntryPoint(String blockName) {
return methodBlockEntryPoints.get(blockName);
}
/**
* After producing Jimple Body, swap all target branches (label to stmt)
*
* @param jb
*/
public void swapGotoEntriesInJBody(Body jb) {<FILL_FUNCTION_BODY>}
/**
* Swap two elements (out of the chain)
*
* @param in
* @param out
*/
public void swapGotoEntryUnit(Unit in, Unit out) {
for (Map.Entry<String, Unit> set : methodBlockEntryPoints.entrySet()) {
if (set.getValue() == out) {
set.setValue(in);
}
}
}
}
|
// if there is a target branch with return leave instruction add RETURNVALUE Target with end instruction
// e.g. if (comp.i4(ldloc capacity == ldloc num5)) leave IL_0000 (nop)
methodBlockEntryPoints.put("RETURNLEAVE", jb.getUnits().getLast());
// change goto / if goto targets to real targets
for (Unit unit : jb.getUnits()) {
if (unit instanceof GotoStmt) {
String entryPointString = gotoTargetsInBody.get(((GotoStmt) unit).getTarget());
if (entryPointString == null) {
continue;
}
Unit unitToSwap = methodBlockEntryPoints.get(entryPointString);
if (unitToSwap == null) {
continue;
}
((GotoStmt) unit).setTarget(unitToSwap);
}
if (unit instanceof IfStmt) {
String entryPointString = gotoTargetsInBody.get(((IfStmt) unit).getTarget());
if (entryPointString == null) {
continue;
}
Unit unitToSwap = methodBlockEntryPoints.get(entryPointString);
if (unitToSwap == null) {
continue;
}
((IfStmt) unit).setTarget(unitToSwap);
}
if (unit instanceof TableSwitchStmt) {
TableSwitchStmt tableSwitchStmt = (TableSwitchStmt) unit;
// swap all targets from nop to selected target
List<Unit> targets = tableSwitchStmt.getTargets();
for (int i = 0; i < targets.size(); i++) {
Unit target = targets.get(i);
String entryPointString = gotoTargetsInBody.get(target);
if (entryPointString == null) {
continue;
}
Unit unitToSwap = methodBlockEntryPoints.get(entryPointString);
if (unitToSwap == null) {
continue;
}
tableSwitchStmt.setTarget(i, unitToSwap);
}
// swap default target
String entryPointStringDefault = gotoTargetsInBody.get(tableSwitchStmt.getDefaultTarget());
if (entryPointStringDefault == null) {
continue;
}
Unit unitToSwap = methodBlockEntryPoints.get(entryPointStringDefault);
if (unitToSwap == null) {
continue;
}
tableSwitchStmt.setDefaultTarget(unitToSwap);
}
}
| 385
| 640
| 1,025
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/members/method/DotnetBody.java
|
DotnetBody
|
jimplify
|
class DotnetBody {
private final ProtoIlInstructions.IlFunctionMsg ilFunctionMsg;
private JimpleBody jb;
public BlockEntryPointsManager blockEntryPointsManager;
public DotnetBodyVariableManager variableManager;
/**
* Get method signature of this method body
*
* @return method signature
*/
public DotnetMethod getDotnetMethodSig() {
return dotnetMethodSig;
}
private final DotnetMethod dotnetMethodSig;
public DotnetBody(DotnetMethod methodSignature, ProtoIlInstructions.IlFunctionMsg ilFunctionMsg) {
this.dotnetMethodSig = methodSignature;
this.ilFunctionMsg = ilFunctionMsg;
blockEntryPointsManager = new BlockEntryPointsManager();
}
public void jimplify(JimpleBody jb) {<FILL_FUNCTION_BODY>}
private void addThisStmt() {
if (dotnetMethodSig.isStatic()) {
return;
}
RefType thisType = dotnetMethodSig.getDeclaringClass().getType();
Local l = Jimple.v().newLocal("this", thisType);
IdentityStmt identityStmt = Jimple.v().newIdentityStmt(l, Jimple.v().newThisRef(thisType));
this.jb.getLocals().add(l);
this.jb.getUnits().add(identityStmt);
}
/**
* Due to three address code, inline cast expr
*
* @param v
* @return
*/
public static Value inlineCastExpr(Value v) {
if (v instanceof Immediate) {
return v;
}
if (v instanceof CastExpr) {
return inlineCastExpr(((CastExpr) v).getOp());
}
return v;
}
public static JimpleBody getEmptyJimpleBody(SootMethod m) {
JimpleBody b = Jimple.v().newBody(m);
resolveEmptyJimpleBody(b, m);
return b;
}
public static void resolveEmptyJimpleBody(JimpleBody b, SootMethod m) {
// if not static add this stmt
if (!m.isStatic()) {
RefType thisType = m.getDeclaringClass().getType();
Local l = Jimple.v().newLocal("this", thisType);
IdentityStmt identityStmt = Jimple.v().newIdentityStmt(l, Jimple.v().newThisRef(thisType));
b.getLocals().add(l);
b.getUnits().add(identityStmt);
}
// parameters
for (int i = 0; i < m.getParameterCount(); i++) {
Type parameterType = m.getParameterType(i);
Local paramLocal = Jimple.v().newLocal("arg" + i, parameterType);
b.getLocals().add(paramLocal);
b.getUnits().add(Jimple.v().newIdentityStmt(paramLocal, Jimple.v().newParameterRef(parameterType, i)));
}
LocalGenerator lg = Scene.v().createLocalGenerator(b);
b.getUnits().add(Jimple.v().newThrowStmt(lg.generateLocal(soot.RefType.v("java.lang.Throwable"))));
if (m.getReturnType() instanceof VoidType) {
b.getUnits().add(Jimple.v().newReturnVoidStmt());
} else if (m.getReturnType() instanceof PrimType) {
b.getUnits().add(Jimple.v().newReturnStmt(DotnetTypeFactory.initType(m.getReturnType())));
} else {
b.getUnits().add(Jimple.v().newReturnStmt(NullConstant.v()));
}
}
}
|
this.jb = jb;
variableManager = new DotnetBodyVariableManager(this, this.jb);
// resolve initial variable assignments
addThisStmt();
variableManager.fillMethodParameter();
variableManager.addInitLocalVariables(ilFunctionMsg.getVariablesList());
// Resolve .NET Method Body -> BlockContainer -> Block -> IL Instruction
CilBlockContainer blockContainer = new CilBlockContainer(ilFunctionMsg.getBody(), this);
Body b = blockContainer.jimplify();
this.jb.getUnits().addAll(b.getUnits());
this.jb.getTraps().addAll(b.getTraps());
blockEntryPointsManager.swapGotoEntriesInJBody(this.jb);
| 981
| 199
| 1,180
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/members/method/DotnetBodyVariableManager.java
|
DotnetBodyVariableManager
|
addOrGetVariable
|
class DotnetBodyVariableManager {
private final DotnetBody dotnetBody;
private final Body mainJb;
public final LocalGenerator localGenerator;
private final HashSet<String> localsToCast = new HashSet<>();
public DotnetBodyVariableManager(DotnetBody dotnetBody, Body mainJb) {
this.dotnetBody = dotnetBody;
this.mainJb = mainJb;
localGenerator = new DefaultLocalGenerator(mainJb);
}
/**
* Add parameters of the .NET method to the Jimple Body
*/
public void fillMethodParameter() {
DotnetMethod dotnetMethodSig = dotnetBody.getDotnetMethodSig();
fillMethodParameter(mainJb, dotnetMethodSig.getParameterDefinitions());
}
/**
* Add parameters of the .NET method to the Jimple Body
*
* @param jb
* @param parameters
*/
public void fillMethodParameter(Body jb, List<ProtoAssemblyAllTypes.ParameterDefinition> parameters) {
// parameters
for (int i = 0; i < parameters.size(); i++) {
ProtoAssemblyAllTypes.ParameterDefinition parameter = parameters.get(i);
Local paramLocal
= Jimple.v().newLocal(parameter.getParameterName(), DotnetTypeFactory.toSootType(parameter.getType()));
jb.getLocals().add(paramLocal);
jb.getUnits().add(Jimple.v().newIdentityStmt(paramLocal,
Jimple.v().newParameterRef(DotnetTypeFactory.toSootType(parameter.getType()), i)));
}
}
/**
* Add and Initialize all known variables/locals at the beginning
*
* @param variableMsgList
*/
public void addInitLocalVariables(List<ProtoIlInstructions.IlVariableMsg> variableMsgList) {
List<ProtoIlInstructions.IlVariableMsg> initLocalValueTypes = new ArrayList<>();
for (ProtoIlInstructions.IlVariableMsg v : variableMsgList) {
if (v.getVariableKind() != ProtoIlInstructions.IlVariableMsg.IlVariableKind.LOCAL) {
continue;
}
addOrGetVariable(v, this.mainJb);
if (v.getHasInitialValue()) {
initLocalValueTypes.add(v);
}
// for unsafe methods, where no definition is used
if (!(v.getType().getFullname().equals(DotnetBasicTypes.SYSTEM_OBJECT))) {
initLocalValueTypes.add(v);
}
}
initLocalVariables(initLocalValueTypes);
}
private void initLocalVariables(List<ProtoIlInstructions.IlVariableMsg> locals) {
for (ProtoIlInstructions.IlVariableMsg v : locals) {
if (v.getVariableKind() != ProtoIlInstructions.IlVariableMsg.IlVariableKind.LOCAL) {
continue;
}
Local variable = addOrGetVariable(v, this.mainJb);
if (variable.getType() instanceof PrimType) {
AssignStmt assignStmt = Jimple.v().newAssignStmt(variable, DotnetTypeFactory.initType(variable));
mainJb.getUnits().add(assignStmt);
continue;
}
if (variable.getType() instanceof ArrayType) {
AssignStmt assignStmt = Jimple.v().newAssignStmt(variable, NullConstant.v());
mainJb.getUnits().add(assignStmt);
continue;
}
// In general, structs are classes inherited by System.ValueType
// Normally, structs are not instantiated with new obj, but while visiting default_value instruction a pseudo
// constructor is called
// create new valuetype "object"
AssignStmt assignStmt
= Jimple.v().newAssignStmt(variable, Jimple.v().newNewExpr(RefType.v(v.getType().getFullname())));
mainJb.getUnits().add(assignStmt);
}
}
/**
* Add or get variable/local of this method body
*
* @param v
* @param jbTmp
* @return
*/
public Local addOrGetVariable(ProtoIlInstructions.IlVariableMsg v, Body jbTmp) {
return addOrGetVariable(v, null, jbTmp);
}
/**
* Type of local is got by the protoVariableMsg but in some cases we need to define the type of the local
*
* @param v
* @param type
* @param jbTmp
* @return
*/
public Local addOrGetVariable(ProtoIlInstructions.IlVariableMsg v, Type type, Body jbTmp) {<FILL_FUNCTION_BODY>}
public void addLocalVariable(Local local) {
if (this.mainJb.getLocals().contains(local)) {
return;
}
this.mainJb.getLocals().add(local);
}
/**
* Recursively get value of a locals chain
*
* @param v
* @param jb
* @return
*/
public static Value inlineLocals(Value v, Body jb) {
Unit unit = jb.getUnits().stream().filter(x -> x instanceof JAssignStmt && ((JAssignStmt) x).getLeftOp().equals(v))
.findFirst().orElse(null);
if (unit instanceof AssignStmt) {
if (((AssignStmt) unit).getRightOp() instanceof JimpleLocal) {
return inlineLocals(((JAssignStmt) unit).getRightOp(), jb);
} else if (((AssignStmt) unit).getRightOp() instanceof CastExpr) {
CastExpr ce = (CastExpr) ((AssignStmt) unit).getRightOp();
return inlineLocals(ce.getOp(), jb);
} else {
return ((AssignStmt) unit).getRightOp();
}
}
return null;
}
/**
* Sometimes we need to cast locals to fulfill the validation. In this case we add them to this set and cast them later on
*
* @param local
*/
public void addLocalsToCast(String local) {
localsToCast.add(local);
}
public boolean localsToCastContains(String local) {
return localsToCast.contains(local);
}
}
|
if (v == null) {
return null;
}
if (v.getName().equals("this")) {
return this.mainJb.getThisLocal();
}
if (this.mainJb.getLocals().stream().anyMatch(x -> x.getName().equals(v.getName()))) {
return this.mainJb.getLocals().stream().filter(x -> x.getName().equals(v.getName())).findFirst().orElse(null);
}
Type localType = (type == null || type instanceof UnknownType || type instanceof NullType)
? DotnetTypeFactory.toSootType(v.getType())
: DotnetTypeFactory.toSootType(type); // deprecated JimpleToDotnetType(type)
Local newLocal = Jimple.v().newLocal(v.getName(), localType);
this.mainJb.getLocals().add(newLocal);
if (jbTmp != null && jbTmp != this.mainJb) {
jbTmp.getLocals().add(newLocal); // dummy due to clone method
}
return newLocal;
| 1,655
| 294
| 1,949
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/members/method/DotnetMethodParameter.java
|
DotnetMethodParameter
|
toSootTypeParamsList
|
class DotnetMethodParameter {
/**
* Converts list of proto .NET method parameter definitions to a list of SootTypes
*
* @param parameterList
* @return
*/
public static List<Type> toSootTypeParamsList(List<ProtoAssemblyAllTypes.ParameterDefinition> parameterList) {<FILL_FUNCTION_BODY>}
}
|
List<Type> types = new ArrayList<>();
for (ProtoAssemblyAllTypes.ParameterDefinition parameter : parameterList) {
Type type = DotnetTypeFactory.toSootType(parameter.getType());
types.add(type);
}
return types;
| 94
| 69
| 163
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/specifications/DotnetModifier.java
|
DotnetModifier
|
toSootModifier
|
class DotnetModifier {
public static int toSootModifier(ProtoAssemblyAllTypes.TypeDefinition protoType) {
int modifier = convertAccessibility(protoType.getAccessibility());
if (protoType.getIsAbstract()) {
modifier |= Modifier.ABSTRACT;
}
if (protoType.getIsStatic()) {
modifier |= Modifier.STATIC;
}
if (protoType.getIsSealed()) {
modifier |= Modifier.FINAL;
}
if (protoType.getTypeKind().equals(ProtoAssemblyAllTypes.TypeKindDef.INTERFACE)) {
modifier |= Modifier.INTERFACE;
}
if (protoType.getTypeKind().equals(ProtoAssemblyAllTypes.TypeKindDef.ENUM)) {
modifier |= Modifier.ENUM;
}
return modifier;
}
public static int toSootModifier(ProtoAssemblyAllTypes.MethodDefinition methodDefinition) {
int modifier = convertAccessibility(methodDefinition.getAccessibility());
if (methodDefinition.getIsAbstract()) {
modifier |= Modifier.ABSTRACT;
}
if (methodDefinition.getIsStatic()) {
modifier |= Modifier.STATIC;
}
// cannot do this due to hiding property of c#
// if (!methodDefinition.getIsVirtual())
// modifier |= Modifier.FINAL;
if (methodDefinition.getIsSealed()) {
modifier |= Modifier.FINAL;
}
if (methodDefinition.getIsExtern()) {
modifier |= Modifier.NATIVE;
}
return modifier;
}
public static int toSootModifier(ProtoAssemblyAllTypes.FieldDefinition fieldDefinition) {<FILL_FUNCTION_BODY>}
private static int convertAccessibility(ProtoAssemblyAllTypes.Accessibility accessibility) {
int modifier = 0;
switch (accessibility) {
case PRIVATE:
modifier |= Modifier.PRIVATE;
break;
case INTERNAL:
case PROTECTED_AND_INTERNAL:
case PROTECTED_OR_INTERNAL:
case PUBLIC:
modifier |= Modifier.PUBLIC;
break;
case PROTECTED:
modifier |= Modifier.PROTECTED;
break;
}
return modifier;
}
}
|
int modifier = convertAccessibility(fieldDefinition.getAccessibility());
if (fieldDefinition.getIsAbstract() || fieldDefinition.getIsVirtual()) {
modifier |= Modifier.ABSTRACT;
}
if (fieldDefinition.getIsStatic()) {
modifier |= Modifier.STATIC;
}
if (fieldDefinition.getIsReadOnly()) {
modifier |= Modifier.FINAL;
}
return modifier;
| 614
| 118
| 732
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/dotnet/types/DotnetFakeLdFtnType.java
|
DotnetFakeLdFtnType
|
makeMethod
|
class DotnetFakeLdFtnType {
// Define static fake method
private static final String FAKE_LDFTN_METHOD_NAME = "FakeLdFtn";
/**
* If LdFtn instruction, rewrite and resolve fake Soot class
*
* @param sootClass
* @return
*/
public static IInitialResolver.Dependencies resolve(SootClass sootClass) {
IInitialResolver.Dependencies deps = new IInitialResolver.Dependencies();
SootClass superClass = SootResolver.v().makeClassRef(DotnetBasicTypes.SYSTEM_OBJECT);
deps.typesToHierarchy.add(superClass.getType());
sootClass.setSuperclass(superClass);
int classModifier = 0;
classModifier |= Modifier.PUBLIC;
classModifier |= Modifier.STATIC;
sootClass.setModifiers(classModifier);
// add fake method
int modifier = 0;
modifier |= Modifier.PUBLIC;
modifier |= Modifier.STATIC;
modifier |= Modifier.NATIVE;
SootMethod m = Scene.v().makeSootMethod(FAKE_LDFTN_METHOD_NAME, new ArrayList<>(),
DotnetTypeFactory.toSootType(DotnetBasicTypes.SYSTEM_INTPTR), modifier);
sootClass.addMethod(m);
return deps;
}
/**
* Make fake method for CIL instruction LdFtn, which returns an IntPtr Workaround for difference in CIL and Java bytecode
*
* @return
*/
public static Value makeMethod() {<FILL_FUNCTION_BODY>}
}
|
SootClass clazz = Scene.v().getSootClass(DotnetBasicTypes.FAKE_LDFTN);
// arguments which are passed to this function
List<Local> argsVariables = new ArrayList<>();
// method-parameters (signature)
List<Type> methodParams = new ArrayList<>();
SootMethodRef methodRef = Scene.v().makeMethodRef(clazz, FAKE_LDFTN_METHOD_NAME, methodParams,
DotnetTypeFactory.toSootType(DotnetBasicTypes.SYSTEM_INTPTR), true);
return Jimple.v().newStaticInvokeExpr(methodRef, argsVariables);
| 439
| 168
| 607
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/grimp/PrecedenceTest.java
|
PrecedenceTest
|
needsBrackets
|
class PrecedenceTest {
public static boolean needsBrackets(ValueBox subExprBox, Value expr) {<FILL_FUNCTION_BODY>}
public static boolean needsBracketsRight(ValueBox subExprBox, Value expr) {
Value sub = subExprBox.getValue();
if (!(sub instanceof Precedence)) {
return false;
}
Precedence subP = (Precedence) sub;
Precedence exprP = (Precedence) expr;
return subP.getPrecedence() <= exprP.getPrecedence();
}
}
|
Value sub = subExprBox.getValue();
if (!(sub instanceof Precedence)) {
return false;
}
Precedence subP = (Precedence) sub;
Precedence exprP = (Precedence) expr;
return subP.getPrecedence() < exprP.getPrecedence();
| 150
| 87
| 237
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/grimp/internal/AbstractGrimpIntBinopExpr.java
|
AbstractGrimpIntBinopExpr
|
toString
|
class AbstractGrimpIntBinopExpr extends AbstractIntBinopExpr implements Precedence {
public AbstractGrimpIntBinopExpr(Value op1, Value op2) {
this(Grimp.v().newArgBox(op1), Grimp.v().newArgBox(op2));
}
protected AbstractGrimpIntBinopExpr(ValueBox op1Box, ValueBox op2Box) {
super(op1Box, op2Box);
}
@Override
public abstract int getPrecedence();
@Override
public String toString() {<FILL_FUNCTION_BODY>}
}
|
final Value op1 = op1Box.getValue();
String leftOp = op1.toString();
if (op1 instanceof Precedence && ((Precedence) op1).getPrecedence() < getPrecedence()) {
leftOp = "(" + leftOp + ")";
}
final Value op2 = op2Box.getValue();
String rightOp = op2.toString();
if (op2 instanceof Precedence) {
int opPrec = ((Precedence) op2).getPrecedence(), myPrec = getPrecedence();
if ((opPrec < myPrec) || ((opPrec == myPrec) && ((this instanceof SubExpr) || (this instanceof DivExpr)
|| (this instanceof DCmpExpr) || (this instanceof DCmpgExpr) || (this instanceof DCmplExpr)))) {
rightOp = "(" + rightOp + ")";
}
}
return leftOp + getSymbol() + rightOp;
| 162
| 232
| 394
|
<methods>public soot.Type getType() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/grimp/internal/ExprBox.java
|
ExprBox
|
canContainValue
|
class ExprBox extends AbstractValueBox {
public ExprBox(Value value) {
setValue(value);
}
@Override
public boolean canContainValue(Value value) {<FILL_FUNCTION_BODY>}
}
|
return value instanceof Local || value instanceof Constant || value instanceof Expr || value instanceof ConcreteRef;
| 64
| 25
| 89
|
<methods>public non-sealed void <init>() ,public soot.Value getValue() ,public void setValue(soot.Value) ,public void toString(soot.UnitPrinter) ,public java.lang.String toString() <variables>protected soot.Value value
|
soot-oss_soot
|
soot/src/main/java/soot/grimp/internal/GArrayRef.java
|
GArrayRef
|
toString
|
class GArrayRef extends JArrayRef implements Precedence {
public GArrayRef(Value base, Value index) {
super(Grimp.v().newObjExprBox(base), Grimp.v().newExprBox(index));
}
@Override
public int getPrecedence() {
return 950;
}
@Override
public void toString(UnitPrinter up) {<FILL_FUNCTION_BODY>}
@Override
public String toString() {
final Value op1 = getBase();
String leftOp = op1.toString();
if (op1 instanceof Precedence && ((Precedence) op1).getPrecedence() < getPrecedence()) {
leftOp = "(" + leftOp + ")";
}
return leftOp + "[" + getIndex().toString() + "]";
}
@Override
public Object clone() {
return new GArrayRef(Grimp.cloneIfNecessary(getBase()), Grimp.cloneIfNecessary(getIndex()));
}
}
|
final boolean needsBrackets = PrecedenceTest.needsBrackets(baseBox, this);
if (needsBrackets) {
up.literal("(");
}
baseBox.toString(up);
if (needsBrackets) {
up.literal(")");
}
up.literal("[");
indexBox.toString(up);
up.literal("]");
| 268
| 106
| 374
|
<methods>public void <init>(soot.Value, soot.Value) ,public void apply(soot.util.Switch) ,public java.lang.Object clone() ,public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) ,public int equivHashCode() ,public boolean equivTo(java.lang.Object) ,public soot.Value getBase() ,public soot.ValueBox getBaseBox() ,public soot.Value getIndex() ,public soot.ValueBox getIndexBox() ,public soot.Type getType() ,public List<soot.ValueBox> getUseBoxes() ,public void setBase(soot.Local) ,public void setIndex(soot.Value) ,public java.lang.String toString() ,public void toString(soot.UnitPrinter) <variables>protected final non-sealed soot.ValueBox baseBox,protected final non-sealed soot.ValueBox indexBox
|
soot-oss_soot
|
soot/src/main/java/soot/grimp/internal/GCastExpr.java
|
GCastExpr
|
toString
|
class GCastExpr extends AbstractCastExpr implements Precedence {
public GCastExpr(Value op, Type type) {
super(Grimp.v().newExprBox(op), type);
}
@Override
public int getPrecedence() {
return 850;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
@Override
public Object clone() {
return new GCastExpr(Grimp.cloneIfNecessary(getOp()), getCastType());
}
}
|
final Value op = getOp();
String opString = op.toString();
if (op instanceof Precedence && ((Precedence) op).getPrecedence() < getPrecedence()) {
opString = "(" + opString + ")";
}
return "(" + getCastType().toString() + ") " + opString;
| 143
| 86
| 229
|
<methods>public void apply(soot.util.Switch) ,public abstract java.lang.Object clone() ,public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) ,public int equivHashCode() ,public boolean equivTo(java.lang.Object) ,public soot.Type getCastType() ,public soot.Value getOp() ,public soot.ValueBox getOpBox() ,public soot.Type getType() ,public final List<soot.ValueBox> getUseBoxes() ,public void setCastType(soot.Type) ,public void setOp(soot.Value) ,public java.lang.String toString() ,public void toString(soot.UnitPrinter) <variables>protected final non-sealed soot.ValueBox opBox,protected soot.Type type
|
soot-oss_soot
|
soot/src/main/java/soot/grimp/internal/GDynamicInvokeExpr.java
|
GDynamicInvokeExpr
|
toString
|
class GDynamicInvokeExpr extends AbstractInvokeExpr implements DynamicInvokeExpr {
protected final SootMethodRef bsmRef;
protected final ValueBox[] bsmArgBoxes;
protected final int tag;
public GDynamicInvokeExpr(SootMethodRef bootStrapMethodRef, List<? extends Value> bootstrapArgs, SootMethodRef methodRef,
int tag, List<? extends Value> methodArgs) {
super(methodRef, new ValueBox[methodArgs.size()]);
this.bsmRef = bootStrapMethodRef;
this.bsmArgBoxes = new ValueBox[bootstrapArgs.size()];
this.tag = tag;
final Grimp grmp = Grimp.v();
for (ListIterator<? extends Value> it = bootstrapArgs.listIterator(); it.hasNext();) {
Value v = it.next();
this.bsmArgBoxes[it.previousIndex()] = grmp.newExprBox(v);
}
for (ListIterator<? extends Value> it = methodArgs.listIterator(); it.hasNext();) {
Value v = it.next();
this.argBoxes[it.previousIndex()] = grmp.newExprBox(v);
}
}
@Override
public Object clone() {
List<Value> clonedBsmArgs = new ArrayList<Value>(bsmArgBoxes.length);
for (ValueBox box : bsmArgBoxes) {
clonedBsmArgs.add(box.getValue());
}
final int count = getArgCount();
List<Value> clonedArgs = new ArrayList<Value>(count);
for (int i = 0; i < count; i++) {
clonedArgs.add(Grimp.cloneIfNecessary(getArg(i)));
}
return new GDynamicInvokeExpr(bsmRef, clonedBsmArgs, methodRef, tag, clonedArgs);
}
@Override
public int getBootstrapArgCount() {
return bsmArgBoxes.length;
}
@Override
public Value getBootstrapArg(int i) {
return bsmArgBoxes[i].getValue();
}
@Override
public List<Value> getBootstrapArgs() {
List<Value> l = new ArrayList<Value>();
for (ValueBox element : bsmArgBoxes) {
l.add(element.getValue());
}
return l;
}
@Override
public SootMethodRef getBootstrapMethodRef() {
return bsmRef;
}
public SootMethod getBootstrapMethod() {
return bsmRef.resolve();
}
@Override
public int getHandleTag() {
return tag;
}
@Override
public void apply(Switch sw) {
((ExprSwitch) sw).caseDynamicInvokeExpr(this);
}
@Override
public boolean equivTo(Object o) {
if (o instanceof GDynamicInvokeExpr) {
GDynamicInvokeExpr ie = (GDynamicInvokeExpr) o;
if ((this.argBoxes == null ? 0 : this.argBoxes.length) != (ie.argBoxes == null ? 0 : ie.argBoxes.length)
|| this.bsmArgBoxes.length != ie.bsmArgBoxes.length || !this.getMethod().equals(ie.getMethod())
|| !this.methodRef.equals(ie.methodRef) || !this.bsmRef.equals(ie.bsmRef)) {
return false;
}
int i = 0;
for (ValueBox element : this.bsmArgBoxes) {
if (!element.getValue().equivTo(ie.getBootstrapArg(i))) {
return false;
}
i++;
}
if (this.argBoxes != null) {
i = 0;
for (ValueBox element : this.argBoxes) {
if (!element.getValue().equivTo(ie.getArg(i))) {
return false;
}
i++;
}
}
return true;
}
return false;
}
@Override
public int equivHashCode() {
return getBootstrapMethod().equivHashCode() * getMethod().equivHashCode() * 17;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
@Override
public void toString(UnitPrinter up) {
up.literal(Jimple.DYNAMICINVOKE + " \"" + methodRef.name() + "\" <"
+ SootMethod.getSubSignature(""/* no method name here */, methodRef.parameterTypes(), methodRef.returnType())
+ ">(");
if (argBoxes != null) {
for (int i = 0, e = argBoxes.length; i < e; i++) {
if (i != 0) {
up.literal(", ");
}
argBoxes[i].toString(up);
}
}
up.literal(") ");
up.methodRef(bsmRef);
up.literal("(");
for (int i = 0, e = bsmArgBoxes.length; i < e; i++) {
if (i != 0) {
up.literal(", ");
}
bsmArgBoxes[i].toString(up);
}
up.literal(")");
}
}
|
StringBuilder buf = new StringBuilder(Jimple.DYNAMICINVOKE + " \"");
buf.append(methodRef.name()); // quoted method name (can be any UTF8 string)
buf.append("\" <");
buf.append(SootMethod.getSubSignature(""/* no method name here */, methodRef.parameterTypes(), methodRef.returnType()));
buf.append(">(");
if (argBoxes != null) {
for (int i = 0, e = argBoxes.length; i < e; i++) {
if (i != 0) {
buf.append(", ");
}
buf.append(argBoxes[i].getValue().toString());
}
}
buf.append(") ");
buf.append(bsmRef.getSignature());
buf.append('(');
for (int i = 0, e = bsmArgBoxes.length; i < e; i++) {
if (i != 0) {
buf.append(", ");
}
buf.append(bsmArgBoxes[i].getValue().toString());
}
buf.append(')');
return buf.toString();
| 1,395
| 302
| 1,697
|
<methods>public abstract java.lang.Object clone() ,public soot.Value getArg(int) ,public soot.ValueBox getArgBox(int) ,public int getArgCount() ,public List<soot.Value> getArgs() ,public soot.SootMethod getMethod() ,public soot.SootMethodRef getMethodRef() ,public soot.Type getType() ,public List<soot.ValueBox> getUseBoxes() ,public void setArg(int, soot.Value) ,public void setMethodRef(soot.SootMethodRef) <variables>protected final non-sealed soot.ValueBox[] argBoxes,protected soot.SootMethodRef methodRef
|
soot-oss_soot
|
soot/src/main/java/soot/grimp/internal/GNewInvokeExpr.java
|
GNewInvokeExpr
|
equivTo
|
class GNewInvokeExpr extends AbstractInvokeExpr implements NewInvokeExpr, Precedence {
protected RefType type;
public GNewInvokeExpr(RefType type, SootMethodRef methodRef, List<? extends Value> args) {
super(methodRef, new ExprBox[args.size()]);
if (methodRef != null && methodRef.isStatic()) {
throw new RuntimeException("wrong static-ness");
}
this.type = type;
final Grimp grmp = Grimp.v();
for (ListIterator<? extends Value> it = args.listIterator(); it.hasNext();) {
Value v = it.next();
this.argBoxes[it.previousIndex()] = grmp.newExprBox(v);
}
}
@Override
public RefType getBaseType() {
return type;
}
@Override
public void setBaseType(RefType type) {
this.type = type;
}
@Override
public Type getType() {
return type;
}
@Override
public int getPrecedence() {
return 850;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder("new ");
buf.append(type.toString()).append('(');
if (argBoxes != null) {
for (int i = 0, e = argBoxes.length; i < e; i++) {
if (i != 0) {
buf.append(", ");
}
buf.append(argBoxes[i].getValue().toString());
}
}
buf.append(')');
return buf.toString();
}
@Override
public void toString(UnitPrinter up) {
up.literal("new ");
up.type(type);
up.literal("(");
if (argBoxes != null) {
for (int i = 0, e = argBoxes.length; i < e; i++) {
if (i != 0) {
up.literal(", ");
}
argBoxes[i].toString(up);
}
}
up.literal(")");
}
@Override
public void apply(Switch sw) {
((GrimpValueSwitch) sw).caseNewInvokeExpr(this);
}
@Override
public Object clone() {
final int count = getArgCount();
List<Value> clonedArgs = new ArrayList<Value>(count);
for (int i = 0; i < count; i++) {
clonedArgs.add(Grimp.cloneIfNecessary(getArg(i)));
}
return new GNewInvokeExpr(getBaseType(), methodRef, clonedArgs);
}
@Override
public boolean equivTo(Object o) {<FILL_FUNCTION_BODY>}
/** Returns a hash code for this object, consistent with structural equality. */
@Override
public int equivHashCode() {
return getMethod().equivHashCode();
}
}
|
if (o instanceof GNewInvokeExpr) {
GNewInvokeExpr ie = (GNewInvokeExpr) o;
if ((this.argBoxes == null ? 0 : this.argBoxes.length) != (ie.argBoxes == null ? 0 : ie.argBoxes.length)
|| !this.getMethod().equals(ie.getMethod()) || !this.type.equals(ie.type)) {
return false;
}
if (this.argBoxes != null) {
for (int i = 0, e = this.argBoxes.length; i < e; i++) {
if (!this.argBoxes[i].getValue().equivTo(ie.argBoxes[i].getValue())) {
return false;
}
}
}
return true;
}
return false;
| 789
| 214
| 1,003
|
<methods>public abstract java.lang.Object clone() ,public soot.Value getArg(int) ,public soot.ValueBox getArgBox(int) ,public int getArgCount() ,public List<soot.Value> getArgs() ,public soot.SootMethod getMethod() ,public soot.SootMethodRef getMethodRef() ,public soot.Type getType() ,public List<soot.ValueBox> getUseBoxes() ,public void setArg(int, soot.Value) ,public void setMethodRef(soot.SootMethodRef) <variables>protected final non-sealed soot.ValueBox[] argBoxes,protected soot.SootMethodRef methodRef
|
soot-oss_soot
|
soot/src/main/java/soot/grimp/internal/GNewMultiArrayExpr.java
|
GNewMultiArrayExpr
|
clone
|
class GNewMultiArrayExpr extends AbstractNewMultiArrayExpr {
public GNewMultiArrayExpr(ArrayType type, List<? extends Value> sizes) {
super(type, new ValueBox[sizes.size()]);
final Grimp grmp = Grimp.v();
for (ListIterator<? extends Value> it = sizes.listIterator(); it.hasNext();) {
Value v = it.next();
sizeBoxes[it.previousIndex()] = grmp.newExprBox(v);
}
}
@Override
public Object clone() {<FILL_FUNCTION_BODY>}
}
|
final ValueBox[] boxes = this.sizeBoxes;
List<Value> clonedSizes = new ArrayList<Value>(boxes.length);
for (ValueBox vb : boxes) {
clonedSizes.add(Grimp.cloneIfNecessary(vb.getValue()));
}
return new GNewMultiArrayExpr(getBaseType(), clonedSizes);
| 155
| 97
| 252
|
<methods>public void apply(soot.util.Switch) ,public abstract java.lang.Object clone() ,public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) ,public int equivHashCode() ,public boolean equivTo(java.lang.Object) ,public soot.ArrayType getBaseType() ,public soot.Value getSize(int) ,public soot.ValueBox getSizeBox(int) ,public int getSizeCount() ,public List<soot.Value> getSizes() ,public soot.Type getType() ,public final List<soot.ValueBox> getUseBoxes() ,public void setBaseType(soot.ArrayType) ,public void setSize(int, soot.Value) ,public java.lang.String toString() ,public void toString(soot.UnitPrinter) <variables>protected soot.ArrayType baseType,protected final non-sealed soot.ValueBox[] sizeBoxes
|
soot-oss_soot
|
soot/src/main/java/soot/grimp/internal/GShlExpr.java
|
GShlExpr
|
getType
|
class GShlExpr extends AbstractGrimpIntLongBinopExpr implements ShlExpr {
public GShlExpr(Value op1, Value op2) {
super(op1, op2);
}
@Override
public String getSymbol() {
return " << ";
}
@Override
public int getPrecedence() {
return 650;
}
@Override
public void apply(Switch sw) {
((ExprSwitch) sw).caseShlExpr(this);
}
@Override
public Type getType() {<FILL_FUNCTION_BODY>}
@Override
public Object clone() {
return new GShlExpr(Grimp.cloneIfNecessary(getOp1()), Grimp.cloneIfNecessary(getOp2()));
}
}
|
if (isIntLikeType(op2Box.getValue().getType())) {
final Type t1 = op1Box.getValue().getType();
if (isIntLikeType(t1)) {
return IntType.v();
}
final LongType tyLong = LongType.v();
if (tyLong.equals(t1)) {
return tyLong;
}
}
return UnknownType.v();
| 212
| 108
| 320
|
<methods>public abstract int getPrecedence() ,public java.lang.String toString() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/grimp/internal/GShrExpr.java
|
GShrExpr
|
getType
|
class GShrExpr extends AbstractGrimpIntLongBinopExpr implements ShrExpr {
public GShrExpr(Value op1, Value op2) {
super(op1, op2);
}
@Override
public String getSymbol() {
return " >> ";
}
@Override
public int getPrecedence() {
return 650;
}
@Override
public void apply(Switch sw) {
((ExprSwitch) sw).caseShrExpr(this);
}
@Override
public Type getType() {<FILL_FUNCTION_BODY>}
@Override
public Object clone() {
return new GShrExpr(Grimp.cloneIfNecessary(getOp1()), Grimp.cloneIfNecessary(getOp2()));
}
}
|
if (isIntLikeType(op2Box.getValue().getType())) {
final Type t1 = op1Box.getValue().getType();
if (isIntLikeType(t1)) {
return IntType.v();
}
final LongType tyLong = LongType.v();
if (tyLong.equals(t1)) {
return tyLong;
}
}
return UnknownType.v();
| 212
| 108
| 320
|
<methods>public abstract int getPrecedence() ,public java.lang.String toString() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/grimp/internal/GUshrExpr.java
|
GUshrExpr
|
getType
|
class GUshrExpr extends AbstractGrimpIntLongBinopExpr implements UshrExpr {
public GUshrExpr(Value op1, Value op2) {
super(op1, op2);
}
@Override
public String getSymbol() {
return " >>> ";
}
@Override
public int getPrecedence() {
return 650;
}
@Override
public void apply(Switch sw) {
((ExprSwitch) sw).caseUshrExpr(this);
}
@Override
public Type getType() {<FILL_FUNCTION_BODY>}
@Override
public Object clone() {
return new GUshrExpr(Grimp.cloneIfNecessary(getOp1()), Grimp.cloneIfNecessary(getOp2()));
}
}
|
if (isIntLikeType(op2Box.getValue().getType())) {
final Type t1 = op1Box.getValue().getType();
if (isIntLikeType(t1)) {
return IntType.v();
}
final LongType tyLong = LongType.v();
if (tyLong.equals(t1)) {
return LongType.v();
}
}
return UnknownType.v();
| 218
| 110
| 328
|
<methods>public abstract int getPrecedence() ,public java.lang.String toString() <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/grimp/internal/GVirtualInvokeExpr.java
|
GVirtualInvokeExpr
|
toString
|
class GVirtualInvokeExpr extends AbstractVirtualInvokeExpr implements Precedence {
public GVirtualInvokeExpr(Value base, SootMethodRef methodRef, List<? extends Value> args) {
super(Grimp.v().newObjExprBox(base), methodRef, new ValueBox[args.size()]);
final Grimp grmp = Grimp.v();
for (ListIterator<? extends Value> it = args.listIterator(); it.hasNext();) {
Value v = it.next();
this.argBoxes[it.previousIndex()] = grmp.newExprBox(v);
}
}
@Override
public int getPrecedence() {
return 950;
}
@Override
public String toString() {<FILL_FUNCTION_BODY>}
@Override
public void toString(UnitPrinter up) {
final boolean needsBrackets = PrecedenceTest.needsBrackets(baseBox, this);
if (needsBrackets) {
up.literal("(");
}
baseBox.toString(up);
if (needsBrackets) {
up.literal(")");
}
up.literal(".");
up.methodRef(methodRef);
up.literal("(");
if (argBoxes != null) {
for (int i = 0, e = argBoxes.length; i < e; i++) {
if (i != 0) {
up.literal(", ");
}
argBoxes[i].toString(up);
}
}
up.literal(")");
}
@Override
public Object clone() {
final int count = getArgCount();
List<Value> clonedArgs = new ArrayList<Value>(count);
for (int i = 0; i < count; i++) {
clonedArgs.add(Grimp.cloneIfNecessary(getArg(i)));
}
return new GVirtualInvokeExpr(Grimp.cloneIfNecessary(getBase()), methodRef, clonedArgs);
}
}
|
final Value base = getBase();
String baseString = base.toString();
if (base instanceof Precedence && ((Precedence) base).getPrecedence() < getPrecedence()) {
baseString = "(" + baseString + ")";
}
StringBuilder buf = new StringBuilder(baseString);
buf.append('.').append(methodRef.getSignature()).append('(');
if (argBoxes != null) {
for (int i = 0, e = argBoxes.length; i < e; i++) {
if (i != 0) {
buf.append(", ");
}
buf.append(argBoxes[i].getValue().toString());
}
}
buf.append(')');
return buf.toString();
| 532
| 198
| 730
|
<methods>public void apply(soot.util.Switch) ,public void convertToBaf(soot.jimple.JimpleToBafContext, List<soot.Unit>) ,public int equivHashCode() ,public boolean equivTo(java.lang.Object) ,public java.lang.String toString() ,public void toString(soot.UnitPrinter) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/grimp/internal/ObjExprBox.java
|
ObjExprBox
|
canContainValue
|
class ObjExprBox extends ExprBox {
public ObjExprBox(Value value) {
super(value);
}
@Override
public boolean canContainValue(Value value) {<FILL_FUNCTION_BODY>}
}
|
return value instanceof ConcreteRef || value instanceof InvokeExpr || value instanceof NewArrayExpr
|| value instanceof NewMultiArrayExpr || value instanceof Local || value instanceof NullConstant
|| value instanceof StringConstant || value instanceof ClassConstant
|| (value instanceof CastExpr && canContainValue(((CastExpr) value).getOp()));
| 65
| 76
| 141
|
<methods>public void <init>(soot.Value) ,public boolean canContainValue(soot.Value) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/grimp/toolkits/base/ConstructorFolder.java
|
ConstructorFolder
|
internalTransform
|
class ConstructorFolder extends BodyTransformer {
private static final Logger logger = LoggerFactory.getLogger(ConstructorFolder.class);
public ConstructorFolder(Singletons.Global g) {
}
public static ConstructorFolder v() {
return G.v().soot_grimp_toolkits_base_ConstructorFolder();
}
/** This method change all new Obj/<init>(args) pairs to new Obj(args) idioms. */
protected void internalTransform(Body b, String phaseName, Map options) {<FILL_FUNCTION_BODY>}
}
|
GrimpBody body = (GrimpBody) b;
if (Options.v().verbose()) {
logger.debug("[" + body.getMethod().getName() + "] Folding constructors...");
}
Chain units = body.getUnits();
List<Unit> stmtList = new ArrayList<Unit>();
stmtList.addAll(units);
Iterator<Unit> it = stmtList.iterator();
LocalUses localUses = LocalUses.Factory.newLocalUses(b);
/* fold in NewExpr's with specialinvoke's */
while (it.hasNext()) {
Stmt s = (Stmt) it.next();
if (!(s instanceof AssignStmt)) {
continue;
}
/* this should be generalized to ArrayRefs */
Value lhs = ((AssignStmt) s).getLeftOp();
if (!(lhs instanceof Local)) {
continue;
}
Value rhs = ((AssignStmt) s).getRightOp();
if (!(rhs instanceof NewExpr)) {
continue;
}
/*
* TO BE IMPLEMENTED LATER: move any copy of the object reference for lhs down beyond the NewInvokeExpr, with the
* rationale being that you can't modify the object before the constructor call in any case.
*
* Also, do note that any new's (object creation) without corresponding constructors must be dead.
*/
List lu = localUses.getUsesOf(s);
Iterator luIter = lu.iterator();
boolean MadeNewInvokeExpr = false;
while (luIter.hasNext()) {
Unit use = ((UnitValueBoxPair) (luIter.next())).unit;
if (!(use instanceof InvokeStmt)) {
continue;
}
InvokeStmt is = (InvokeStmt) use;
if (!(is.getInvokeExpr() instanceof SpecialInvokeExpr)
|| lhs != ((SpecialInvokeExpr) is.getInvokeExpr()).getBase()) {
continue;
}
SpecialInvokeExpr oldInvoke = ((SpecialInvokeExpr) is.getInvokeExpr());
LinkedList invokeArgs = new LinkedList();
for (int i = 0; i < oldInvoke.getArgCount(); i++) {
invokeArgs.add(oldInvoke.getArg(i));
}
AssignStmt constructStmt = Grimp.v().newAssignStmt((AssignStmt) s);
constructStmt
.setRightOp(Grimp.v().newNewInvokeExpr(((NewExpr) rhs).getBaseType(), oldInvoke.getMethodRef(), invokeArgs));
MadeNewInvokeExpr = true;
use.redirectJumpsToThisTo(constructStmt);
units.insertBefore(constructStmt, use);
units.remove(use);
}
if (MadeNewInvokeExpr) {
units.remove(s);
}
}
| 148
| 765
| 913
|
<methods>public non-sealed void <init>() ,public final void transform(soot.Body, java.lang.String, Map<java.lang.String,java.lang.String>) ,public final void transform(soot.Body, java.lang.String) ,public final void transform(soot.Body) <variables>private static final Map<java.lang.String,java.lang.String> enabledOnlyMap
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/AbstractJimpleBodyBuilder.java
|
AbstractJimpleBodyBuilder
|
ext
|
class AbstractJimpleBodyBuilder {
protected soot.jimple.JimpleBody body;
public void ext(AbstractJimpleBodyBuilder ext) {<FILL_FUNCTION_BODY>}
public AbstractJimpleBodyBuilder ext() {
if (ext == null) {
return this;
}
return ext;
}
private AbstractJimpleBodyBuilder ext = null;
public void base(AbstractJimpleBodyBuilder base) {
this.base = base;
}
public AbstractJimpleBodyBuilder base() {
return base;
}
private AbstractJimpleBodyBuilder base = this;
protected soot.jimple.JimpleBody createJimpleBody(polyglot.ast.Block block, List formals, soot.SootMethod sootMethod) {
return ext().createJimpleBody(block, formals, sootMethod);
}
/*
* protected soot.Value createExpr(polyglot.ast.Expr expr){ return ext().createExpr(expr); }
*/
protected soot.Value createAggressiveExpr(polyglot.ast.Expr expr, boolean reduceAggressively, boolean reverseCondIfNec) {
// System.out.println("in abstract");
return ext().createAggressiveExpr(expr, reduceAggressively, reverseCondIfNec);
}
protected void createStmt(polyglot.ast.Stmt stmt) {
ext().createStmt(stmt);
}
protected boolean needsAccessor(polyglot.ast.Expr expr) {
return ext().needsAccessor(expr);
}
protected soot.Local handlePrivateFieldAssignSet(polyglot.ast.Assign assign) {
return ext().handlePrivateFieldAssignSet(assign);
}
protected soot.Local handlePrivateFieldUnarySet(polyglot.ast.Unary unary) {
return ext().handlePrivateFieldUnarySet(unary);
}
protected soot.Value getAssignRightLocal(polyglot.ast.Assign assign, soot.Local leftLocal) {
return ext().getAssignRightLocal(assign, leftLocal);
}
protected soot.Value getSimpleAssignRightLocal(polyglot.ast.Assign assign) {
return ext().getSimpleAssignRightLocal(assign);
}
protected soot.Local handlePrivateFieldSet(polyglot.ast.Expr expr, soot.Value right, soot.Value base) {
return ext().handlePrivateFieldSet(expr, right, base);
}
protected soot.SootMethodRef getSootMethodRef(polyglot.ast.Call call) {
return ext().getSootMethodRef(call);
}
protected soot.Local generateLocal(soot.Type sootType) {
return ext().generateLocal(sootType);
}
protected soot.Local generateLocal(polyglot.types.Type polyglotType) {
return ext().generateLocal(polyglotType);
}
protected soot.Local getThis(soot.Type sootType) {
return ext().getThis(sootType);
}
protected soot.Value getBaseLocal(polyglot.ast.Receiver receiver) {
return ext().getBaseLocal(receiver);
}
protected soot.Value createLHS(polyglot.ast.Expr expr) {
return ext().createLHS(expr);
}
protected soot.jimple.FieldRef getFieldRef(polyglot.ast.Field field) {
return ext().getFieldRef(field);
}
protected soot.jimple.Constant getConstant(soot.Type sootType, int val) {
return ext().getConstant(sootType, val);
}
}
|
this.ext = ext;
if (ext.ext != null) {
throw new RuntimeException("Extensions created in wrong order.");
}
ext.base = this.base;
| 975
| 50
| 1,025
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/AnonClassInitMethodSource.java
|
AnonClassInitMethodSource
|
getBody
|
class AnonClassInitMethodSource extends soot.javaToJimple.PolyglotMethodSource {
private boolean hasOuterRef;
public void hasOuterRef(boolean b) {
hasOuterRef = b;
}
public boolean hasOuterRef() {
return hasOuterRef;
}
private boolean hasQualifier;
public void hasQualifier(boolean b) {
hasQualifier = b;
}
public boolean hasQualifier() {
return hasQualifier;
}
private boolean inStaticMethod;
public void inStaticMethod(boolean b) {
inStaticMethod = b;
}
public boolean inStaticMethod() {
return inStaticMethod;
}
private boolean isSubType = false;
public void isSubType(boolean b) {
isSubType = b;
}
public boolean isSubType() {
return isSubType;
}
private soot.Type superOuterType = null;
private soot.Type thisOuterType = null;
public void superOuterType(soot.Type t) {
superOuterType = t;
}
public soot.Type superOuterType() {
return superOuterType;
}
public void thisOuterType(soot.Type t) {
thisOuterType = t;
}
public soot.Type thisOuterType() {
return thisOuterType;
}
private polyglot.types.ClassType polyglotType;
public void polyglotType(polyglot.types.ClassType type) {
polyglotType = type;
}
public polyglot.types.ClassType polyglotType() {
return polyglotType;
}
private polyglot.types.ClassType anonType;
public void anonType(polyglot.types.ClassType type) {
anonType = type;
}
public polyglot.types.ClassType anonType() {
return anonType;
}
public soot.Body getBody(soot.SootMethod sootMethod, String phaseName) {<FILL_FUNCTION_BODY>}
private soot.Type outerClassType;
public soot.Type outerClassType() {
return outerClassType;
}
public void outerClassType(soot.Type type) {
outerClassType = type;
}
}
|
AnonInitBodyBuilder aibb = new AnonInitBodyBuilder();
soot.jimple.JimpleBody body = aibb.createBody(sootMethod);
PackManager.v().getPack("jj").apply(body);
return body;
| 641
| 71
| 712
|
<methods>public void <init>() ,public void <init>(polyglot.ast.Block, List#RAW) ,public void addAssertInits(soot.Body) ,public soot.Body getBody(soot.SootMethod, java.lang.String) ,public ArrayList<polyglot.ast.FieldDecl> getFieldInits() ,public ArrayList<soot.SootField> getFinalsList() ,public ArrayList<polyglot.ast.Block> getInitializerBlocks() ,public HashMap#RAW getNewToOuterMap() ,public soot.Local getOuterClassThisInit() ,public ArrayList<polyglot.ast.FieldDecl> getStaticFieldInits() ,public ArrayList<polyglot.ast.Block> getStaticInitializerBlocks() ,public boolean hasAssert() ,public void hasAssert(boolean) ,public void setFieldInits(ArrayList<polyglot.ast.FieldDecl>) ,public void setFinalsList(ArrayList<soot.SootField>) ,public void setInitializerBlocks(ArrayList<polyglot.ast.Block>) ,public void setJBB(soot.javaToJimple.AbstractJimpleBodyBuilder) ,public void setNewToOuterMap(HashMap#RAW) ,public void setOuterClassThisInit(soot.Local) ,public void setStaticFieldInits(ArrayList<polyglot.ast.FieldDecl>) ,public void setStaticInitializerBlocks(ArrayList<polyglot.ast.Block>) <variables>private soot.javaToJimple.AbstractJimpleBodyBuilder ajbb,private polyglot.ast.Block block,private ArrayList<polyglot.ast.FieldDecl> fieldInits,private ArrayList<soot.SootField> finalsList,private List#RAW formals,private boolean hasAssert,private ArrayList<polyglot.ast.Block> initializerBlocks,private HashMap#RAW newToOuterMap,private soot.Local outerClassThisInit,private ArrayList<polyglot.ast.FieldDecl> staticFieldInits,private ArrayList<polyglot.ast.Block> staticInitializerBlocks
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/AnonConstructorFinder.java
|
AnonConstructorFinder
|
enter
|
class AnonConstructorFinder extends polyglot.visit.ContextVisitor {
private static final Logger logger = LoggerFactory.getLogger(AnonConstructorFinder.class);
public AnonConstructorFinder(polyglot.frontend.Job job, polyglot.types.TypeSystem ts, polyglot.ast.NodeFactory nf) {
super(job, ts, nf);
}
public polyglot.visit.NodeVisitor enter(polyglot.ast.Node parent, polyglot.ast.Node n) {<FILL_FUNCTION_BODY>}
}
|
if (n instanceof polyglot.ast.New && ((polyglot.ast.New) n).anonType() != null) {
try {
List<Type> argTypes = new ArrayList<Type>();
for (Iterator it = ((polyglot.ast.New) n).arguments().iterator(); it.hasNext();) {
argTypes.add(((polyglot.ast.Expr) it.next()).type());
}
polyglot.types.ConstructorInstance ci
= typeSystem().findConstructor(((polyglot.ast.New) n).anonType().superType().toClass(), argTypes,
((polyglot.ast.New) n).anonType().superType().toClass());
InitialResolver.v().addToAnonConstructorMap((polyglot.ast.New) n, ci);
} catch (polyglot.types.SemanticException e) {
System.out.println(e.getMessage());
logger.error(e.getMessage(), e);
}
}
return this;
| 149
| 255
| 404
|
<methods>public void <init>(polyglot.frontend.Job, polyglot.types.TypeSystem, polyglot.ast.NodeFactory) ,public polyglot.visit.NodeVisitor begin() ,public polyglot.types.Context context() ,public polyglot.visit.ContextVisitor context(polyglot.types.Context) ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node, polyglot.ast.Node) ,public polyglot.ast.Node leave(polyglot.ast.Node, polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) ,public polyglot.visit.NodeVisitor superEnter(polyglot.ast.Node, polyglot.ast.Node) <variables>protected polyglot.types.Context context,protected polyglot.visit.ContextVisitor outer
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/AnonLocalClassInfo.java
|
AnonLocalClassInfo
|
toString
|
class AnonLocalClassInfo {
private boolean inStaticMethod;
private ArrayList<IdentityKey> finalLocalsAvail;
private ArrayList<IdentityKey> finalLocalsUsed;
public boolean inStaticMethod() {
return inStaticMethod;
}
public void inStaticMethod(boolean b) {
inStaticMethod = b;
}
public ArrayList<IdentityKey> finalLocalsAvail() {
return finalLocalsAvail;
}
public void finalLocalsAvail(ArrayList<IdentityKey> list) {
finalLocalsAvail = list;
}
public ArrayList<IdentityKey> finalLocalsUsed() {
return finalLocalsUsed;
}
public void finalLocalsUsed(ArrayList<IdentityKey> list) {
finalLocalsUsed = list;
}
public String toString() {<FILL_FUNCTION_BODY>}
}
|
StringBuffer sb = new StringBuffer();
sb.append("static: ");
sb.append(inStaticMethod);
sb.append(" finalLocalsAvail: ");
sb.append(finalLocalsAvail);
sb.append(" finalLocalsUsed: ");
sb.append(finalLocalsUsed);
return sb.toString();
| 227
| 87
| 314
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/AssertStmtChecker.java
|
AssertStmtChecker
|
override
|
class AssertStmtChecker extends polyglot.visit.NodeVisitor {
private boolean hasAssert = false;
public boolean isHasAssert() {
return hasAssert;
}
public AssertStmtChecker() {
}
public polyglot.ast.Node override(polyglot.ast.Node parent, polyglot.ast.Node n) {<FILL_FUNCTION_BODY>}
public polyglot.visit.NodeVisitor enter(polyglot.ast.Node parent, polyglot.ast.Node n) {
if (n instanceof polyglot.ast.Assert) {
hasAssert = true;
}
return enter(n);
}
}
|
if ((n instanceof polyglot.ast.ClassDecl)
|| ((n instanceof polyglot.ast.New) && (((polyglot.ast.New) n).anonType() != null))) {
return n;
}
return null;
| 179
| 67
| 246
|
<methods>public void <init>() ,public polyglot.visit.NodeVisitor begin() ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node) ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node, polyglot.ast.Node) ,public void finish() ,public void finish(polyglot.ast.Node) ,public polyglot.ast.Node leave(polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) ,public polyglot.ast.Node leave(polyglot.ast.Node, polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) ,public polyglot.ast.Node override(polyglot.ast.Node) ,public polyglot.ast.Node override(polyglot.ast.Node, polyglot.ast.Node) ,public java.lang.String toString() ,public polyglot.ast.Node visitEdge(polyglot.ast.Node, polyglot.ast.Node) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/ClassLiteralChecker.java
|
ClassLiteralChecker
|
enter
|
class ClassLiteralChecker extends polyglot.visit.NodeVisitor {
private final ArrayList<Node> list;
public ArrayList<Node> getList() {
return list;
}
public ClassLiteralChecker() {
list = new ArrayList<Node>();
}
public polyglot.ast.Node override(polyglot.ast.Node parent, polyglot.ast.Node n) {
if ((n instanceof polyglot.ast.ClassDecl)
|| ((n instanceof polyglot.ast.New) && (((polyglot.ast.New) n).anonType() != null))) {
return n;
}
return null;
}
public polyglot.visit.NodeVisitor enter(polyglot.ast.Node parent, polyglot.ast.Node n) {<FILL_FUNCTION_BODY>}
}
|
if (n instanceof polyglot.ast.ClassLit) {
polyglot.ast.ClassLit lit = (polyglot.ast.ClassLit) n;
// only find ones where type is not primitive
if (!lit.typeNode().type().isPrimitive()) {
list.add(n);
}
}
return enter(n);
| 220
| 95
| 315
|
<methods>public void <init>() ,public polyglot.visit.NodeVisitor begin() ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node) ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node, polyglot.ast.Node) ,public void finish() ,public void finish(polyglot.ast.Node) ,public polyglot.ast.Node leave(polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) ,public polyglot.ast.Node leave(polyglot.ast.Node, polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) ,public polyglot.ast.Node override(polyglot.ast.Node) ,public polyglot.ast.Node override(polyglot.ast.Node, polyglot.ast.Node) ,public java.lang.String toString() ,public polyglot.ast.Node visitEdge(polyglot.ast.Node, polyglot.ast.Node) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/CommaJBB.java
|
CommaJBB
|
createAggressiveExpr
|
class CommaJBB extends AbstractJimpleBodyBuilder {
public CommaJBB() {
// ext(null);
// base(this);
}
/*
* protected soot.Value createExpr(polyglot.ast.Expr expr){ if (expr instanceof soot.javaToJimple.jj.ast.JjComma_c){ return
* getCommaLocal((soot.javaToJimple.jj.ast.JjComma_c)expr); } else { return ext().createExpr(expr); } }
*/
protected soot.Value createAggressiveExpr(polyglot.ast.Expr expr, boolean redAggr, boolean revIfNec) {<FILL_FUNCTION_BODY>}
private soot.Value getCommaLocal(soot.javaToJimple.jj.ast.JjComma_c comma) {
base().createAggressiveExpr(comma.first(), false, false);
soot.Value val = base().createAggressiveExpr(comma.second(), false, false);
return val;
}
}
|
if (expr instanceof soot.javaToJimple.jj.ast.JjComma_c) {
return getCommaLocal((soot.javaToJimple.jj.ast.JjComma_c) expr);
} else {
return ext().createAggressiveExpr(expr, redAggr, revIfNec);
}
| 281
| 94
| 375
|
<methods>public non-sealed void <init>() ,public void base(soot.javaToJimple.AbstractJimpleBodyBuilder) ,public soot.javaToJimple.AbstractJimpleBodyBuilder base() ,public void ext(soot.javaToJimple.AbstractJimpleBodyBuilder) ,public soot.javaToJimple.AbstractJimpleBodyBuilder ext() <variables>private soot.javaToJimple.AbstractJimpleBodyBuilder base,protected soot.jimple.JimpleBody body,private soot.javaToJimple.AbstractJimpleBodyBuilder ext
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/InnerClassInfoFinder.java
|
InnerClassInfoFinder
|
enter
|
class InnerClassInfoFinder extends polyglot.visit.NodeVisitor {
private final ArrayList<Node> localClassDeclList;
private final ArrayList<Node> anonBodyList;
private final ArrayList<Node> memberList;
// private ArrayList declaredInstList;
// private ArrayList usedInstList;
public ArrayList<Node> memberList() {
return memberList;
}
/*
* public ArrayList declaredInstList(){ return declaredInstList; }
*
* public ArrayList usedInstList(){ return usedInstList; }
*/
public ArrayList<Node> localClassDeclList() {
return localClassDeclList;
}
public ArrayList<Node> anonBodyList() {
return anonBodyList;
}
public InnerClassInfoFinder() {
// declFound = null;
localClassDeclList = new ArrayList<Node>();
anonBodyList = new ArrayList<Node>();
memberList = new ArrayList<Node>();
// declaredInstList = new ArrayList();
// usedInstList = new ArrayList();
}
public polyglot.visit.NodeVisitor enter(polyglot.ast.Node parent, polyglot.ast.Node n) {<FILL_FUNCTION_BODY>}
}
|
if (n instanceof polyglot.ast.LocalClassDecl) {
localClassDeclList.add(n);
}
if (n instanceof polyglot.ast.New) {
if (((polyglot.ast.New) n).anonType() != null) {
anonBodyList.add(n);
}
/*
* polyglot.types.ProcedureInstance pi = ((polyglot.ast.New)n).constructorInstance(); if (pi.isPrivate()){
* usedInstList.add(new polyglot.util.IdentityKey(pi)); }
*/
}
if (n instanceof polyglot.ast.ProcedureDecl) {
memberList.add(n);
/*
* polyglot.types.ProcedureInstance pi = ((polyglot.ast.ProcedureDecl)n).procedureInstance(); if
* (pi.flags().isPrivate()){ declaredInstList.add(new polyglot.util.IdentityKey(pi)); }
*/
}
if (n instanceof polyglot.ast.FieldDecl) {
memberList.add(n);
/*
* polyglot.types.FieldInstance fi = ((polyglot.ast.FieldDecl)n).fieldInstance(); if (fi.flags().isPrivate()){
* declaredInstList.add(new polyglot.util.IdentityKey(fi)); }
*/
}
if (n instanceof polyglot.ast.Initializer) {
memberList.add(n);
}
/*
* if (n instanceof polyglot.ast.Field) { polyglot.types.FieldInstance fi = ((polyglot.ast.Field)n).fieldInstance(); if
* (fi.isPrivate()){ usedInstList.add(new polyglot.util.IdentityKey(fi)); } } if (n instanceof polyglot.ast.Call){
* polyglot.types.ProcedureInst pi = ((polyglot.ast.Call)n).methodInstance(); if (pi.isPrivate()){ usedInstList.add(new
* polyglot.util.IdentityKey(pi)); } } if (n instanceof polyglot.ast.ConstructorCall){ polyglot.types.ProcedureInstance
* pi = ((polyglot.ast.ConstructorCall)n).constructorInstance(); if (pi.isPrivate()){ usedInstList.add(new
* polyglot.util.IdentityKey(pi)); } }
*/
return enter(n);
| 316
| 606
| 922
|
<methods>public void <init>() ,public polyglot.visit.NodeVisitor begin() ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node) ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node, polyglot.ast.Node) ,public void finish() ,public void finish(polyglot.ast.Node) ,public polyglot.ast.Node leave(polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) ,public polyglot.ast.Node leave(polyglot.ast.Node, polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) ,public polyglot.ast.Node override(polyglot.ast.Node) ,public polyglot.ast.Node override(polyglot.ast.Node, polyglot.ast.Node) ,public java.lang.String toString() ,public polyglot.ast.Node visitEdge(polyglot.ast.Node, polyglot.ast.Node) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/JavaToJimple.java
|
JavaToJimple
|
initExtInfo
|
class JavaToJimple {
public static final polyglot.frontend.Pass.ID CAST_INSERTION = new polyglot.frontend.Pass.ID("cast-insertion");
public static final polyglot.frontend.Pass.ID STRICTFP_PROP = new polyglot.frontend.Pass.ID("strictfp-prop");
public static final polyglot.frontend.Pass.ID ANON_CONSTR_FINDER = new polyglot.frontend.Pass.ID("anon-constr-finder");
public static final polyglot.frontend.Pass.ID SAVE_AST = new polyglot.frontend.Pass.ID("save-ast");
/**
* sets up the info needed to invoke polyglot
*/
public polyglot.frontend.ExtensionInfo initExtInfo(String fileName, List<String> sourceLocations) {<FILL_FUNCTION_BODY>}
/**
* uses polyglot to compile source and build AST
*/
public polyglot.ast.Node compile(polyglot.frontend.Compiler compiler, String fileName,
polyglot.frontend.ExtensionInfo extInfo) {
SourceLoader source_loader = compiler.sourceExtension().sourceLoader();
try {
FileSource source = new FileSource(new File(fileName));
// This hack is to stop the catch block at the bottom causing an error
// with versions of Polyglot where the constructor above can't throw IOException
// It should be removed as soon as Polyglot 1.3 is no longer supported.
if (false) {
throw new IOException("Bogus exception");
}
SourceJob job = null;
if (compiler.sourceExtension() instanceof soot.javaToJimple.jj.ExtensionInfo) {
soot.javaToJimple.jj.ExtensionInfo jjInfo = (soot.javaToJimple.jj.ExtensionInfo) compiler.sourceExtension();
if (jjInfo.sourceJobMap() != null) {
job = (SourceJob) jjInfo.sourceJobMap().get(source);
}
}
if (job == null) {
job = compiler.sourceExtension().addJob(source);
}
boolean result = false;
result = compiler.sourceExtension().runToCompletion();
if (!result) {
throw new soot.CompilationDeathException(0, "Could not compile");
}
polyglot.ast.Node node = job.ast();
return node;
} catch (IOException e) {
return null;
}
}
}
|
Set<String> source = new HashSet<String>();
ExtensionInfo extInfo = new soot.javaToJimple.jj.ExtensionInfo() {
public List passes(Job job) {
List passes = super.passes(job);
// beforePass(passes, Pass.EXIT_CHECK, new VisitorPass(polyglot.frontend.Pass.FOLD, job, new
// polyglot.visit.ConstantFolder(ts, nf)));
beforePass(passes, Pass.EXIT_CHECK, new VisitorPass(CAST_INSERTION, job, new CastInsertionVisitor(job, ts, nf)));
beforePass(passes, Pass.EXIT_CHECK, new VisitorPass(STRICTFP_PROP, job, new StrictFPPropagator(false)));
beforePass(passes, Pass.EXIT_CHECK,
new VisitorPass(ANON_CONSTR_FINDER, job, new AnonConstructorFinder(job, ts, nf)));
afterPass(passes, Pass.PRE_OUTPUT_ALL, new SaveASTVisitor(SAVE_AST, job, this));
removePass(passes, Pass.OUTPUT);
return passes;
}
};
polyglot.main.Options options = extInfo.getOptions();
options.assertions = true;
options.source_path = new LinkedList<File>();
Iterator<String> it = sourceLocations.iterator();
while (it.hasNext()) {
Object next = it.next();
// System.out.println("adding src loc: "+next.toString());
options.source_path.add(new File(next.toString()));
}
options.source_ext = new String[] { "java" };
options.serialize_type_info = false;
source.add(fileName);
options.source_path.add(new File(fileName).getParentFile());
polyglot.main.Options.global = options;
return extInfo;
| 653
| 503
| 1,156
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/MethodFinalsChecker.java
|
MethodFinalsChecker
|
override
|
class MethodFinalsChecker extends polyglot.visit.NodeVisitor {
private final ArrayList<IdentityKey> inners;
private final ArrayList<IdentityKey> finalLocals;
private final HashMap<IdentityKey, ArrayList<IdentityKey>> typeToLocalsUsed;
private final ArrayList<Node> ccallList;
public HashMap<IdentityKey, ArrayList<IdentityKey>> typeToLocalsUsed() {
return typeToLocalsUsed;
}
public ArrayList<IdentityKey> finalLocals() {
return finalLocals;
}
public ArrayList<IdentityKey> inners() {
return inners;
}
public ArrayList<Node> ccallList() {
return ccallList;
}
public MethodFinalsChecker() {
finalLocals = new ArrayList<IdentityKey>();
inners = new ArrayList<IdentityKey>();
ccallList = new ArrayList<Node>();
typeToLocalsUsed = new HashMap<IdentityKey, ArrayList<IdentityKey>>();
}
public polyglot.ast.Node override(polyglot.ast.Node parent, polyglot.ast.Node n) {<FILL_FUNCTION_BODY>}
public polyglot.visit.NodeVisitor enter(polyglot.ast.Node parent, polyglot.ast.Node n) {
if (n instanceof polyglot.ast.LocalDecl) {
polyglot.ast.LocalDecl ld = (polyglot.ast.LocalDecl) n;
if (ld.flags().isFinal()) {
if (!finalLocals.contains(new polyglot.util.IdentityKey(ld.localInstance()))) {
finalLocals.add(new polyglot.util.IdentityKey(ld.localInstance()));
}
}
}
if (n instanceof polyglot.ast.Formal) {
polyglot.ast.Formal ld = (polyglot.ast.Formal) n;
if (ld.flags().isFinal()) {
if (!finalLocals.contains(new polyglot.util.IdentityKey(ld.localInstance()))) {
finalLocals.add(new polyglot.util.IdentityKey(ld.localInstance()));
}
}
}
if (n instanceof polyglot.ast.ConstructorCall) {
ccallList.add(n);
}
return enter(n);
}
}
|
if (n instanceof polyglot.ast.LocalClassDecl) {
inners.add(new polyglot.util.IdentityKey(((polyglot.ast.LocalClassDecl) n).decl().type()));
polyglot.ast.ClassBody localClassBody = ((polyglot.ast.LocalClassDecl) n).decl().body();
LocalUsesChecker luc = new LocalUsesChecker();
localClassBody.visit(luc);
typeToLocalsUsed.put(new polyglot.util.IdentityKey(((polyglot.ast.LocalClassDecl) n).decl().type()), luc.getLocals());
return n;
} else if (n instanceof polyglot.ast.New) {
if (((polyglot.ast.New) n).anonType() != null) {
inners.add(new polyglot.util.IdentityKey(((polyglot.ast.New) n).anonType()));
polyglot.ast.ClassBody anonClassBody = ((polyglot.ast.New) n).body();
LocalUsesChecker luc = new LocalUsesChecker();
anonClassBody.visit(luc);
typeToLocalsUsed.put(new polyglot.util.IdentityKey(((polyglot.ast.New) n).anonType()), luc.getLocals());
return n;
}
}
return null;
| 599
| 346
| 945
|
<methods>public void <init>() ,public polyglot.visit.NodeVisitor begin() ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node) ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node, polyglot.ast.Node) ,public void finish() ,public void finish(polyglot.ast.Node) ,public polyglot.ast.Node leave(polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) ,public polyglot.ast.Node leave(polyglot.ast.Node, polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) ,public polyglot.ast.Node override(polyglot.ast.Node) ,public polyglot.ast.Node override(polyglot.ast.Node, polyglot.ast.Node) ,public java.lang.String toString() ,public polyglot.ast.Node visitEdge(polyglot.ast.Node, polyglot.ast.Node) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/NestedClassListBuilder.java
|
NestedClassListBuilder
|
enter
|
class NestedClassListBuilder extends polyglot.visit.NodeVisitor {
private final ArrayList<Node> classDeclsList;
private final ArrayList<Node> anonClassBodyList;
private final ArrayList<Node> nestedUsedList;
public ArrayList<Node> getClassDeclsList() {
return classDeclsList;
}
public ArrayList<Node> getAnonClassBodyList() {
return anonClassBodyList;
}
public ArrayList<Node> getNestedUsedList() {
return nestedUsedList;
}
public NestedClassListBuilder() {
classDeclsList = new ArrayList<Node>();
anonClassBodyList = new ArrayList<Node>();
nestedUsedList = new ArrayList<Node>();
}
public polyglot.visit.NodeVisitor enter(polyglot.ast.Node parent, polyglot.ast.Node n) {<FILL_FUNCTION_BODY>}
}
|
if (n instanceof polyglot.ast.New) {
if ((((polyglot.ast.New) n).anonType() != null) && (((polyglot.ast.New) n).body() != null)) {
anonClassBodyList.add(n);
} else if (((polyglot.types.ClassType) ((polyglot.ast.New) n).objectType().type()).isNested()) {
nestedUsedList.add(n);
}
}
if (n instanceof polyglot.ast.ClassDecl) {
if (((polyglot.types.ClassType) ((polyglot.ast.ClassDecl) n).type()).isNested()) {
classDeclsList.add(n);
}
}
return enter(n);
| 240
| 203
| 443
|
<methods>public void <init>() ,public polyglot.visit.NodeVisitor begin() ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node) ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node, polyglot.ast.Node) ,public void finish() ,public void finish(polyglot.ast.Node) ,public polyglot.ast.Node leave(polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) ,public polyglot.ast.Node leave(polyglot.ast.Node, polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) ,public polyglot.ast.Node override(polyglot.ast.Node) ,public polyglot.ast.Node override(polyglot.ast.Node, polyglot.ast.Node) ,public java.lang.String toString() ,public polyglot.ast.Node visitEdge(polyglot.ast.Node, polyglot.ast.Node) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/PrivateFieldSetMethodSource.java
|
PrivateFieldSetMethodSource
|
getBody
|
class PrivateFieldSetMethodSource implements soot.MethodSource {
private final soot.Type fieldType;
private final String fieldName;
private final boolean isStatic;
public PrivateFieldSetMethodSource(soot.Type fieldType, String fieldName, boolean isStatic) {
this.fieldType = fieldType;
this.fieldName = fieldName;
this.isStatic = isStatic;
}
public soot.Body getBody(soot.SootMethod sootMethod, String phaseName) {<FILL_FUNCTION_BODY>}
}
|
soot.Body body = soot.jimple.Jimple.v().newBody(sootMethod);
LocalGenerator lg = Scene.v().createLocalGenerator(body);
soot.Local fieldBase = null;
soot.Local assignLocal = null;
// create parameters
int paramCounter = 0;
Iterator paramIt = sootMethod.getParameterTypes().iterator();
while (paramIt.hasNext()) {
soot.Type sootType = (soot.Type) paramIt.next();
soot.Local paramLocal = lg.generateLocal(sootType);
soot.jimple.ParameterRef paramRef = soot.jimple.Jimple.v().newParameterRef(sootType, paramCounter);
soot.jimple.Stmt stmt = soot.jimple.Jimple.v().newIdentityStmt(paramLocal, paramRef);
body.getUnits().add(stmt);
if (paramCounter == 0) {
fieldBase = paramLocal;
}
assignLocal = paramLocal;
paramCounter++;
}
// create field type local
// soot.Local fieldLocal = lg.generateLocal(fieldType);
// assign local to fieldRef
soot.SootFieldRef field = soot.Scene.v().makeFieldRef(sootMethod.getDeclaringClass(), fieldName, fieldType, isStatic);
soot.jimple.FieldRef fieldRef = null;
if (isStatic) {
fieldRef = soot.jimple.Jimple.v().newStaticFieldRef(field);
} else {
fieldRef = soot.jimple.Jimple.v().newInstanceFieldRef(fieldBase, field);
}
soot.jimple.AssignStmt assign = soot.jimple.Jimple.v().newAssignStmt(fieldRef, assignLocal);
body.getUnits().add(assign);
// return local
soot.jimple.Stmt retStmt = soot.jimple.Jimple.v().newReturnStmt(assignLocal);
body.getUnits().add(retStmt);
return body;
| 141
| 559
| 700
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/PrivateInstancesAvailable.java
|
PrivateInstancesAvailable
|
leave
|
class PrivateInstancesAvailable extends polyglot.visit.NodeVisitor {
private final ArrayList<IdentityKey> list;
public ArrayList<IdentityKey> getList() {
return list;
}
public PrivateInstancesAvailable() {
list = new ArrayList<IdentityKey>();
}
public polyglot.ast.Node leave(polyglot.ast.Node old, polyglot.ast.Node n, polyglot.visit.NodeVisitor visitor) {<FILL_FUNCTION_BODY>}
}
|
if (n instanceof polyglot.ast.FieldDecl) {
polyglot.types.FieldInstance fi = ((polyglot.ast.FieldDecl) n).fieldInstance();
if (fi.flags().isPrivate()) {
list.add(new polyglot.util.IdentityKey(fi));
}
}
if (n instanceof polyglot.ast.ProcedureDecl) {
polyglot.types.ProcedureInstance pi = ((polyglot.ast.ProcedureDecl) n).procedureInstance();
if (pi.flags().isPrivate()) {
list.add(new polyglot.util.IdentityKey(pi));
}
}
return n;
| 133
| 175
| 308
|
<methods>public void <init>() ,public polyglot.visit.NodeVisitor begin() ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node) ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node, polyglot.ast.Node) ,public void finish() ,public void finish(polyglot.ast.Node) ,public polyglot.ast.Node leave(polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) ,public polyglot.ast.Node leave(polyglot.ast.Node, polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) ,public polyglot.ast.Node override(polyglot.ast.Node) ,public polyglot.ast.Node override(polyglot.ast.Node, polyglot.ast.Node) ,public java.lang.String toString() ,public polyglot.ast.Node visitEdge(polyglot.ast.Node, polyglot.ast.Node) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/PrivateMethodAccMethodSource.java
|
PrivateMethodAccMethodSource
|
isCallParamType
|
class PrivateMethodAccMethodSource implements soot.MethodSource {
public PrivateMethodAccMethodSource(polyglot.types.MethodInstance methInst) {
this.methodInst = methInst;
}
private polyglot.types.MethodInstance methodInst;
public void setMethodInst(polyglot.types.MethodInstance mi) {
methodInst = mi;
}
private boolean isCallParamType(soot.Type sootType) {<FILL_FUNCTION_BODY>}
public soot.Body getBody(soot.SootMethod sootMethod, String phaseName) {
soot.Body body = soot.jimple.Jimple.v().newBody(sootMethod);
LocalGenerator lg = Scene.v().createLocalGenerator(body);
soot.Local base = null;
ArrayList methParams = new ArrayList();
ArrayList methParamsTypes = new ArrayList();
// create parameters
Iterator paramIt = sootMethod.getParameterTypes().iterator();
int paramCounter = 0;
while (paramIt.hasNext()) {
soot.Type sootType = (soot.Type) paramIt.next();
soot.Local paramLocal = lg.generateLocal(sootType);
// body.getLocals().add(paramLocal);
soot.jimple.ParameterRef paramRef = soot.jimple.Jimple.v().newParameterRef(sootType, paramCounter);
soot.jimple.Stmt stmt = soot.jimple.Jimple.v().newIdentityStmt(paramLocal, paramRef);
body.getUnits().add(stmt);
if (!isCallParamType(sootType)) {
base = paramLocal;
} else {
methParams.add(paramLocal);
methParamsTypes.add(paramLocal.getType());
}
paramCounter++;
}
// create return type local
soot.Type type = Util.getSootType(methodInst.returnType());
soot.Local returnLocal = null;
if (!(type instanceof soot.VoidType)) {
returnLocal = lg.generateLocal(type);
// body.getLocals().add(returnLocal);
}
// assign local to meth
soot.SootMethodRef meth
= soot.Scene.v().makeMethodRef(((soot.RefType) Util.getSootType(methodInst.container())).getSootClass(),
methodInst.name(), methParamsTypes, Util.getSootType(methodInst.returnType()), methodInst.flags().isStatic());
soot.jimple.InvokeExpr invoke = null;
if (methodInst.flags().isStatic()) {
invoke = soot.jimple.Jimple.v().newStaticInvokeExpr(meth, methParams);
} else {
invoke = soot.jimple.Jimple.v().newSpecialInvokeExpr(base, meth, methParams);
}
soot.jimple.Stmt stmt = null;
if (!(type instanceof soot.VoidType)) {
stmt = soot.jimple.Jimple.v().newAssignStmt(returnLocal, invoke);
} else {
stmt = soot.jimple.Jimple.v().newInvokeStmt(invoke);
}
body.getUnits().add(stmt);
// return local
soot.jimple.Stmt retStmt = null;
if (!(type instanceof soot.VoidType)) {
retStmt = soot.jimple.Jimple.v().newReturnStmt(returnLocal);
} else {
retStmt = soot.jimple.Jimple.v().newReturnVoidStmt();
}
body.getUnits().add(retStmt);
return body;
}
}
|
Iterator it = methodInst.formalTypes().iterator();
while (it.hasNext()) {
soot.Type compareType = Util.getSootType((polyglot.types.Type) it.next());
if (compareType.equals(sootType)) {
return true;
}
}
return false;
| 979
| 86
| 1,065
|
<no_super_class>
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/ReturnStmtChecker.java
|
ReturnStmtChecker
|
leave
|
class ReturnStmtChecker extends polyglot.visit.NodeVisitor {
private boolean hasReturn;
public boolean hasRet() {
return hasReturn;
}
public ReturnStmtChecker() {
hasReturn = false;
}
public polyglot.ast.Node leave(polyglot.ast.Node old, polyglot.ast.Node n, polyglot.visit.NodeVisitor visitor) {<FILL_FUNCTION_BODY>}
}
|
if (n instanceof polyglot.ast.Return) {
hasReturn = true;
}
return n;
| 124
| 34
| 158
|
<methods>public void <init>() ,public polyglot.visit.NodeVisitor begin() ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node) ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node, polyglot.ast.Node) ,public void finish() ,public void finish(polyglot.ast.Node) ,public polyglot.ast.Node leave(polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) ,public polyglot.ast.Node leave(polyglot.ast.Node, polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) ,public polyglot.ast.Node override(polyglot.ast.Node) ,public polyglot.ast.Node override(polyglot.ast.Node, polyglot.ast.Node) ,public java.lang.String toString() ,public polyglot.ast.Node visitEdge(polyglot.ast.Node, polyglot.ast.Node) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/SaveASTVisitor.java
|
SaveASTVisitor
|
run
|
class SaveASTVisitor extends polyglot.frontend.AbstractPass {
private polyglot.frontend.Job job;
private polyglot.frontend.ExtensionInfo extInfo;
public SaveASTVisitor(polyglot.frontend.Pass.ID id, polyglot.frontend.Job job, polyglot.frontend.ExtensionInfo extInfo) {
super(id);
this.job = job;
this.extInfo = extInfo;
}
public boolean run() {<FILL_FUNCTION_BODY>}
}
|
if (extInfo instanceof soot.javaToJimple.jj.ExtensionInfo) {
soot.javaToJimple.jj.ExtensionInfo jjInfo = (soot.javaToJimple.jj.ExtensionInfo) extInfo;
if (jjInfo.sourceJobMap() == null) {
jjInfo.sourceJobMap(new HashMap<Source, Job>());
}
jjInfo.sourceJobMap().put(job.source(), job);
return true;
}
return false;
| 139
| 134
| 273
|
<methods>public void <init>(polyglot.frontend.Pass.ID) ,public long exclusiveTime() ,public polyglot.frontend.Pass.ID id() ,public long inclusiveTime() ,public java.lang.String name() ,public void resetTimers() ,public abstract boolean run() ,public java.lang.String toString() ,public void toggleTimers(boolean) <variables>protected long exclusive_time,protected polyglot.frontend.Pass.ID id,protected long inclusive_time
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/StrictFPPropagator.java
|
StrictFPPropagator
|
leave
|
class StrictFPPropagator extends polyglot.visit.NodeVisitor {
boolean strict = false;
public StrictFPPropagator(boolean val) {
strict = val;
}
public polyglot.visit.NodeVisitor enter(polyglot.ast.Node parent, polyglot.ast.Node n) {
if (n instanceof polyglot.ast.ClassDecl) {
if (((polyglot.ast.ClassDecl) n).flags().isStrictFP()) {
return new StrictFPPropagator(true);
}
}
if (n instanceof polyglot.ast.LocalClassDecl) {
if (((polyglot.ast.LocalClassDecl) n).decl().flags().isStrictFP()) {
return new StrictFPPropagator(true);
}
}
if (n instanceof polyglot.ast.MethodDecl) {
if (((polyglot.ast.MethodDecl) n).flags().isStrictFP()) {
return new StrictFPPropagator(true);
}
}
if (n instanceof polyglot.ast.ConstructorDecl) {
if (((polyglot.ast.ConstructorDecl) n).flags().isStrictFP()) {
return new StrictFPPropagator(true);
}
}
return this;
}
public polyglot.ast.Node leave(polyglot.ast.Node old, polyglot.ast.Node n, polyglot.visit.NodeVisitor nodeVisitor) {<FILL_FUNCTION_BODY>}
}
|
if (n instanceof polyglot.ast.MethodDecl) {
polyglot.ast.MethodDecl decl = (polyglot.ast.MethodDecl) n;
if (strict && !decl.flags().isAbstract() && !decl.flags().isStrictFP()) {
// System.out.println("changing method decl "+decl);
decl = decl.flags(decl.flags().StrictFP());
// System.out.println("changed decl: "+decl);
return decl;
}
}
if (n instanceof polyglot.ast.ConstructorDecl) {
polyglot.ast.ConstructorDecl decl = (polyglot.ast.ConstructorDecl) n;
if (strict && !decl.flags().isAbstract() && !decl.flags().isStrictFP()) {
return decl.flags(decl.flags().StrictFP());
}
}
if (n instanceof polyglot.ast.LocalClassDecl) {
polyglot.ast.LocalClassDecl decl = (polyglot.ast.LocalClassDecl) n;
if (decl.decl().flags().isStrictFP()) {
return decl.decl().flags(decl.decl().flags().clearStrictFP());
}
}
if (n instanceof polyglot.ast.ClassDecl) {
polyglot.ast.ClassDecl decl = (polyglot.ast.ClassDecl) n;
if (decl.flags().isStrictFP()) {
return decl.flags(decl.flags().clearStrictFP());
}
}
return n;
| 396
| 382
| 778
|
<methods>public void <init>() ,public polyglot.visit.NodeVisitor begin() ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node) ,public polyglot.visit.NodeVisitor enter(polyglot.ast.Node, polyglot.ast.Node) ,public void finish() ,public void finish(polyglot.ast.Node) ,public polyglot.ast.Node leave(polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) ,public polyglot.ast.Node leave(polyglot.ast.Node, polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) ,public polyglot.ast.Node override(polyglot.ast.Node) ,public polyglot.ast.Node override(polyglot.ast.Node, polyglot.ast.Node) ,public java.lang.String toString() ,public polyglot.ast.Node visitEdge(polyglot.ast.Node, polyglot.ast.Node) <variables>
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/jj/ast/JjAccessField_c.java
|
JjAccessField_c
|
toString
|
class JjAccessField_c extends Expr_c implements Expr {
private Call getMeth;
private Call setMeth;
private Field field;
public JjAccessField_c(Position pos, Call getMeth, Call setMeth, Field field) {
super(pos);
this.getMeth = getMeth;
this.setMeth = setMeth;
this.field = field;
}
public Call getMeth() {
return getMeth;
}
public Call setMeth() {
return setMeth;
}
public Field field() {
return field;
}
public String toString() {<FILL_FUNCTION_BODY>}
public List acceptCFG(CFGBuilder v, List succs) {
return succs;
}
public Term entry() {
return field.entry();
}
public Node visitChildren(NodeVisitor v) {
visitChild(field, v);
visitChild(getMeth, v);
visitChild(setMeth, v);
return this;
}
}
|
return field + " " + getMeth + " " + setMeth;
| 287
| 22
| 309
|
<methods>public void <init>(polyglot.util.Position) ,public boolean booleanValue() ,public polyglot.ast.Node buildTypes(polyglot.visit.TypeBuilder) throws polyglot.types.SemanticException,public byte byteValue() ,public char charValue() ,public java.lang.Object constantValue() ,public double doubleValue() ,public void dump(polyglot.util.CodeWriter) ,public float floatValue() ,public int intValue() ,public boolean isConstant() ,public long longValue() ,public polyglot.ast.Precedence precedence() ,public void printSubExpr(polyglot.ast.Expr, polyglot.util.CodeWriter, polyglot.visit.PrettyPrinter) ,public void printSubExpr(polyglot.ast.Expr, boolean, polyglot.util.CodeWriter, polyglot.visit.PrettyPrinter) ,public short shortValue() ,public java.lang.String stringValue() ,public polyglot.types.Type type() ,public polyglot.ast.Expr type(polyglot.types.Type) <variables>protected polyglot.types.Type type
|
soot-oss_soot
|
soot/src/main/java/soot/javaToJimple/jj/ast/JjArrayAccessAssign_c.java
|
JjArrayAccessAssign_c
|
childExpectedType
|
class JjArrayAccessAssign_c extends ArrayAccessAssign_c {
public JjArrayAccessAssign_c(Position pos, ArrayAccess left, Operator op, Expr right) {
super(pos, left, op, right);
}
public Type childExpectedType(Expr child, AscriptionVisitor av) {<FILL_FUNCTION_BODY>}
}
|
if (op == SHL_ASSIGN || op == SHR_ASSIGN || op == USHR_ASSIGN) {
return child.type();
}
if (child == right) {
return left.type();
}
return child.type();
| 95
| 71
| 166
|
<methods>public void <init>(polyglot.util.Position, polyglot.ast.ArrayAccess, polyglot.ast.Assign.Operator, polyglot.ast.Expr) ,public polyglot.ast.Term entry() ,public polyglot.ast.Assign left(polyglot.ast.Expr) ,public List#RAW throwTypes(polyglot.types.TypeSystem) ,public boolean throwsArrayStoreException() <variables>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.