@Override public void caseLookupSwitchStmt(LookupSwitchStmt stmt) { exprV.setOrigStmt(stmt); constantV.setOrigStmt(stmt); // create payload that references the switch's targets List<IntConstant> keyValues = stmt.getLookupValues(); int[] keys = new int[keyValues.size()]; for (int i = 0; i < keys.length; i++) { keys[i] = keyValues.get(i).value; } List<Unit> targets = stmt.getTargets(); SparseSwitchPayload payload = new SparseSwitchPayload(keys, targets); switchPayloads.add(payload); // create sparse-switch instruction that references the payload Value key = stmt.getKey(); Stmt defaultTarget = (Stmt) stmt.getDefaultTarget(); if (defaultTarget == stmt) throw new RuntimeException("Looping switch block detected"); addInsn(buildSwitchInsn(Opcode.SPARSE_SWITCH, key, defaultTarget, payload, stmt), stmt); }
public void caseLookupSwitchStmt(LookupSwitchStmt stmt) { p.openBlock(); String keyVarName = printValueAssignment(stmt.getKey(), "key"); p.println("List<IntConstant> lookupValues = new LinkedList<IntConstant>();"); int i=0; for(IntConstant c: (List<IntConstant>)stmt.getLookupValues()) { vtp.suggestVariableName("lookupValue"+i); c.apply(vtp); i++; p.println("lookupValues.add(lookupValue"+i+");"); } p.println("List<Unit> targets = new LinkedList<Unit>();"); for(Unit u : stmt.getTargets()) { String nameOfJumpTarget = nameOfJumpTarget(u); p.println("targets.add("+nameOfJumpTarget+")"); } Unit defaultTarget = stmt.getDefaultTarget(); p.println("Unit defaultTarget=" + defaultTarget.toString() + ";"); printStmt(stmt, keyVarName, "lookupValues", "targets", "defaultTarget"); p.closeBlock(); }
public void caseLookupSwitchStmt(LookupSwitchStmt stmt) { Value key = stmt.getKey(); if (key instanceof Local) { if (!ClassHierarchy.v().typeNode(((Local) key).getType()) .hasAncestor_1(ClassHierarchy.v().INT)) { if (fix) { stmt.setKey(insertCast((Local) key, IntType.v(), stmt)); } else { error("Type Error(18)"); } } } }
public void caseLookupSwitchStmt(LookupSwitchStmt stmt) { if (uses) { Value key = stmt.getKey(); if (key instanceof Local) { resolver.typeVariable((Local) key).addParent(resolver.INT); } } }
public void caseLookupSwitchStmt(LookupSwitchStmt stmt) { if (uses) { Value key = stmt.getKey(); if (key instanceof Local) { resolver.typeVariable((Local) key).addParent(resolver.typeVariable(IntType.v())); } } }
protected void internalTransform(Body b, String phaseName, Map<String,String> options) { Iterator<Unit> it = b.getUnits().snapshotIterator(); while (it.hasNext()) { Unit u = it.next(); if (u instanceof LookupSwitchStmt) { LookupSwitchStmt sw = (LookupSwitchStmt) u; if (sw.getTargetCount() == 0 && sw.getDefaultTarget() != null) b.getUnits().swapWith(sw, Jimple.v().newGotoStmt(sw.getDefaultTarget())); } } }
private void convertLookupSwitchInsn(LookupSwitchInsnNode insn) { StackFrame frame = getFrame(insn); if (units.containsKey(insn)) { frame.mergeIn(pop()); return; } Operand key = popImmediate(); UnitBox dflt = Jimple.v().newStmtBox(null); List<UnitBox> targets = new ArrayList<UnitBox>(insn.labels.size()); labels.put(insn.dflt, dflt); for (LabelNode ln : insn.labels) { UnitBox box = Jimple.v().newStmtBox(null); targets.add(box); labels.put(ln, box); } List<IntConstant> keys = new ArrayList<IntConstant>(insn.keys.size()); for (Integer i : insn.keys) keys.add(IntConstant.v(i)); LookupSwitchStmt lss = Jimple.v().newLookupSwitchStmt(key.stackOrValue(), keys, targets, dflt); key.addBox(lss.getKeyBox()); frame.in(key); frame.boxes(lss.getKeyBox()); setUnit(insn, lss); }
/** * DOC * * @see soot.jimple.StmtSwitch#caseLookupSwitchStmt(soot.jimple.LookupSwitchStmt) */ @Override public void caseLookupSwitchStmt(LookupSwitchStmt stmt) { // TODO: Consider reaction // stmt.getKey().apply(valueSwitch); // for (int i = 0; i < stmt.getTargetCount(); i++) { // stmt.getTarget(i).apply(valueSwitch); // } }
@Override public void caseLookupSwitchStmt(LookupSwitchStmt stmt) { logger.fine("\n > > > Lookup switch statement identified < < <"); valueSwitch.callingStmt = stmt; logger.finest("Use and def boxes of SwitchStmt: " + stmt.getUseAndDefBoxes().toString()); // Check for all values in the condition if they are a constant value // or if they are stored in a local. In the second case the local is // added // to a list for the locals. List<ValueBox> valueList = stmt.getUseBoxes(); ArrayList<Local> localList = new ArrayList<Local>(); for (ValueBox v : valueList) { Value val = v.getValue(); if (val instanceof Local) { localList.add((Local) val); logger.fine("New local added to local-list of SwitchStmt: " + val); } } int localListLength = localList.size(); Local[] arguments = new Local[localListLength]; for (int i = 0; i < localListLength; i++) { arguments[i] = localList.get(i); } JimpleInjector.checkCondition(stmt, arguments); }
@Override public void caseLookupSwitchStmt(LookupSwitchStmt stmt) { logger.fine("\n > > > Lookup switch statement identified < < <"); logger.finest("Use and def boxes of SwitchStmt: " + stmt.getUseAndDefBoxes().toString()); // Check for all values in the condition if they are a constant value // or if they are stored in a local. In the second case the local is // added // to a list for the locals. List<ValueBox> valueList = stmt.getUseBoxes(); ArrayList<Local> localList = new ArrayList<Local>(); for (ValueBox v : valueList) { Value val = v.getValue(); if (val instanceof Local) { localList.add((Local) val); logger.fine("New local added to local-list of SwitchStmt: " + val); } } int localListLength = localList.size(); Local[] arguments = new Local[localListLength]; for (int i = 0; i < localListLength; i++) { arguments[i] = localList.get(i); } JimpleInjector.checkCondition(stmt, arguments); }
@Override public void caseLookupSwitchStmt(LookupSwitchStmt stmt) { throw new RuntimeException("todo"); }
public void caseLookupSwitchStmt(LookupSwitchStmt stmt) { stmt.setKey(this.uv.visit(stmt.getKey(), IntType.v(), stmt)); }
@Override public void caseLookupSwitchStmt(LookupSwitchStmt s) { result = result.add(mightThrow(s.getKey())); }
@Override public void caseLookupSwitchStmt(LookupSwitchStmt stmt) { handleBranch(stmt.getKey(), new LookupSwitchProgramCounterTrigger(stmt)); }
public LookupSwitchProgramCounterTrigger(LookupSwitchStmt stmt) { this.stmt = stmt; }
public final LookupSwitchStmt getLookupSwitchStmt() { return stmt; }
/** * Method, which should process the given statement of type * {@link LookupSwitchStmt}, but is not implemented in the current version * of this method. If method will be called an exception is thrown. * * @param stmt * Statement that should be processed to check for security * violations. * @see soot.jimple.StmtSwitch#caseLookupSwitchStmt(soot.jimple.LookupSwitchStmt) * @throws UnimplementedSwitchException * Method throws always this exception, because the method is * not implemented. */ @Override public void caseLookupSwitchStmt(LookupSwitchStmt stmt) { throw new SwitchException(getMsg("exception.analysis.switch.not_implemented", stmt.toString(), getSourceLine(), stmt.getClass().getSimpleName(), this.getClass().getSimpleName())); }