private void initAssignments() { for (Unit stmt : this.jb.getUnits()) { if (stmt instanceof DefinitionStmt) { this.initAssignment((DefinitionStmt) stmt); } } }
public void check(Typing tg, IUseVisitor uv) { this.tg = tg; this.uv = uv; if (this.tg == null) { throw new RuntimeException("null typing passed to useChecker"); } for (Iterator<Unit> i = this.jb.getUnits().snapshotIterator(); i.hasNext();) { if (uv.finish()) { return; } i.next().apply(this); } }
private void emitUnits(Unit u) { if (u instanceof UnitContainer) { for (Unit uu : ((UnitContainer) u).units) { emitUnits(uu); } } else { body.getUnits().add(u); } }
private void collect_constraints_3() { ConstraintCollector collector = new ConstraintCollector(this, false); for (Iterator<Unit> stmtIt = stmtBody.getUnits().iterator(); stmtIt.hasNext();) { final Stmt stmt = (Stmt) stmtIt.next(); if (DEBUG) { logger.debug("stmt: "); } collector.collect(stmt, stmtBody); if (DEBUG) { logger.debug("" + stmt); } } }
private void collect_constraints_3() { ConstraintCollectorBV collector = new ConstraintCollectorBV(this, false); for (Iterator<Unit> stmtIt = stmtBody.getUnits().iterator(); stmtIt.hasNext();) { final Stmt stmt = (Stmt) stmtIt.next(); if (DEBUG) { logger.debug("stmt: "); } collector.collect(stmt, stmtBody); if (DEBUG) { logger.debug("" + stmt); } } }
private void collect_constraints_1() { ConstraintCollector collector = new ConstraintCollector(this, true); for (Unit u : stmtBody.getUnits()) { final Stmt stmt = (Stmt) u; if (DEBUG) { logger.debug("stmt: "); } collector.collect(stmt, stmtBody); if (DEBUG) { logger.debug("" + stmt); } } }
private void collect_constraints_1_2() { ConstraintCollector collector = new ConstraintCollector(this, true); for (Iterator<Unit> stmtIt = stmtBody.getUnits().iterator(); stmtIt.hasNext();) { final Stmt stmt = (Stmt) stmtIt.next(); if (DEBUG) { logger.debug("stmt: "); } collector.collect(stmt, stmtBody); if (DEBUG) { logger.debug("" + stmt); } } }
private void collect_constraints_1_2() { ConstraintCollectorBV collector = new ConstraintCollectorBV(this, true); for (Iterator<Unit> stmtIt = stmtBody.getUnits().iterator(); stmtIt.hasNext();) { final Stmt stmt = (Stmt) stmtIt.next(); if (DEBUG) { logger.debug("stmt: "); } collector.collect(stmt, stmtBody); if (DEBUG) { logger.debug("" + stmt); } } }
private void collect_constraints_2() { ConstraintCollector collector = new ConstraintCollector(this, false); for (Unit u : stmtBody.getUnits()) { final Stmt stmt = (Stmt) u; if (DEBUG) { logger.debug("stmt: "); } collector.collect(stmt, stmtBody); if (DEBUG) { logger.debug("" + stmt); } } }
public Body(TypeDecl typeDecl, soot.jimple.JimpleBody body, ASTNode container) { this.typeDecl = typeDecl; this.body = body; chains = new java.util.Stack(); chains.push(body.getUnits()); setLine(container); if(!body.getMethod().isStatic()) emitThis(typeDecl); }
private Local insertCast(Value oldvalue, Type oldtype, Type type, Stmt stmt) { Local newlocal1 = Jimple.v().newLocal("tmp", oldtype); Local newlocal2 = Jimple.v().newLocal("tmp", type); stmtBody.getLocals().add(newlocal1); stmtBody.getLocals().add(newlocal2); Unit u = Util.findFirstNonIdentityUnit(this.stmtBody, stmt); stmtBody.getUnits().insertBefore(Jimple.v().newAssignStmt(newlocal1, oldvalue), u); stmtBody.getUnits().insertBefore(Jimple.v().newAssignStmt(newlocal2, Jimple.v().newCastExpr(newlocal1, type)), u); return newlocal2; } }
/** * adds this field for the outer class */ private void handleOuterClassThisInit(soot.SootMethod sootMethod) { // static inner classes are different SootField this0Field = body.getMethod().getDeclaringClass().getFieldByNameUnsafe("this$0"); if (this0Field != null) { soot.jimple.FieldRef fieldRef = soot.jimple.Jimple.v().newInstanceFieldRef(specialThisLocal, this0Field.makeRef()); soot.jimple.AssignStmt stmt = soot.jimple.Jimple.v().newAssignStmt(fieldRef, outerClassParamLocal); body.getUnits().add(stmt); } }
private soot.Local createToString(soot.Local sb, polyglot.ast.Expr expr) { // invoke toString on local (type StringBuffer) soot.Local newString = lg.generateLocal(soot.RefType.v("java.lang.String")); soot.SootClass classToInvoke2 = soot.Scene.v().getSootClass("java.lang.StringBuffer"); soot.SootMethodRef methodToInvoke2 = soot.Scene.v().makeMethodRef(classToInvoke2, "toString", new ArrayList(), soot.RefType.v("java.lang.String"), false); soot.jimple.VirtualInvokeExpr toStringInvoke = soot.jimple.Jimple.v().newVirtualInvokeExpr(sb, methodToInvoke2); soot.jimple.Stmt lastAssign = soot.jimple.Jimple.v().newAssignStmt(newString, toStringInvoke); body.getUnits().add(lastAssign); Util.addLnPosTags(lastAssign, expr.position()); return newString; }
private Local insertCast(Local oldlocal, Type type, Stmt stmt) { Local newlocal = Jimple.v().newLocal("tmp", type); stmtBody.getLocals().add(newlocal); Unit u = Util.findFirstNonIdentityUnit(this.stmtBody, stmt); stmtBody.getUnits().insertBefore(Jimple.v().newAssignStmt(newlocal, Jimple.v().newCastExpr(oldlocal, type)), u); return newlocal; }
private Local insertCast(Local oldlocal, Type type, Stmt stmt) { Local newlocal = Jimple.v().newLocal("tmp", type); stmtBody.getLocals().add(newlocal); Unit u = Util.findFirstNonIdentityUnit(stmtBody, stmt); stmtBody.getUnits().insertBefore(Jimple.v().newAssignStmt(newlocal, Jimple.v().newCastExpr(oldlocal, type)), u); return newlocal; } }
private Local insertCast(Local oldlocal, Type type, Stmt stmt) { Local newlocal = Jimple.v().newLocal("tmp", type); stmtBody.getLocals().add(newlocal); Unit u = Util.findFirstNonIdentityUnit(stmtBody, stmt); stmtBody.getUnits().insertBefore(Jimple.v().newAssignStmt(newlocal, Jimple.v().newCastExpr(oldlocal, type)), u); return newlocal; } }
private Local insertCastAfter(Local leftlocal, Type lefttype, Type righttype, Stmt stmt) { Local newlocal = Jimple.v().newLocal("tmp", righttype); stmtBody.getLocals().add(newlocal); Unit u = Util.findLastIdentityUnit(this.stmtBody, stmt); stmtBody.getUnits().insertAfter(Jimple.v().newAssignStmt(leftlocal, Jimple.v().newCastExpr(newlocal, lefttype)), u); return newlocal; }
/** * Throw Stmt Creation */ private void createThrow(polyglot.ast.Throw throwStmt) { soot.Value toThrow = base().createAggressiveExpr(throwStmt.expr(), false, false); soot.jimple.ThrowStmt throwSt = soot.jimple.Jimple.v().newThrowStmt(toThrow); body.getUnits().add(throwSt); Util.addLnPosTags(throwSt, throwStmt.position()); Util.addLnPosTags(throwSt.getOpBox(), throwStmt.expr().position()); }
/** * Formal creation - method parameters */ private void createFormal(polyglot.ast.Formal formal, int counter) { soot.Type sootType = Util.getSootType(formal.type().type()); soot.Local formalLocal = createLocal(formal.localInstance()); soot.jimple.ParameterRef paramRef = soot.jimple.Jimple.v().newParameterRef(sootType, counter); paramRefCount++; soot.jimple.Stmt stmt = soot.jimple.Jimple.v().newIdentityStmt(formalLocal, paramRef); body.getUnits().add(stmt); Util.addLnPosTags(((soot.jimple.IdentityStmt) stmt).getRightOpBox(), formal.position()); Util.addLnPosTags(stmt, formal.position()); }
private soot.Value getSimpleAssignLocal(polyglot.ast.Assign assign) { soot.jimple.AssignStmt stmt; soot.Value left = base().createLHS(assign.left()); soot.Value right = base().getSimpleAssignRightLocal(assign); stmt = soot.jimple.Jimple.v().newAssignStmt(left, right); body.getUnits().add(stmt); Util.addLnPosTags(stmt, assign.position()); Util.addLnPosTags(stmt.getRightOpBox(), assign.right().position()); Util.addLnPosTags(stmt.getLeftOpBox(), assign.left().position()); if (left instanceof soot.Local) { return left; } else { return right; } }