/** Clones the current body, making deep copies of the contents. */ @Override public Object clone() { Body b = new JimpleBody(getMethod()); b.importBodyContentsFrom(this); return b; }
/** Inserts usual statements for handling this & parameters into body. */ public void insertIdentityStmts() { insertIdentityStmts(getMethod().getDeclaringClass()); }
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); }
public void caseReturnStmt(ReturnStmt stmt) { stmt.setOp(this.uv.visit(stmt.getOp(), this.jb.getMethod().getReturnType(), stmt)); }
private void handleFinalLocalInits() { ArrayList<SootField> finalsList = ((PolyglotMethodSource) body.getMethod().getSource()).getFinalsList(); if (finalsList == null) { return; } int paramCount = paramRefCount - finalsList.size(); Iterator<SootField> it = finalsList.iterator(); while (it.hasNext()) { soot.SootField sf = it.next(); soot.jimple.FieldRef fieldRef = soot.jimple.Jimple.v().newInstanceFieldRef(specialThisLocal, sf.makeRef()); soot.jimple.AssignStmt stmt = soot.jimple.Jimple.v().newAssignStmt(fieldRef, body.getParameterLocal(paramCount)); body.getUnits().add(stmt); paramCount++; } }
public void caseReturnStmt(ReturnStmt stmt) { if (uses) { if (stmt.getOp() instanceof Local) { resolver.typeVariable((Local) stmt.getOp()).addParent(resolver.typeVariable(stmtBody.getMethod().getReturnType())); } } }
public void caseReturnStmt(ReturnStmt stmt) { if (stmt.getOp() instanceof Local) { if (!hierarchy.typeNode(((Local) stmt.getOp()).getType()) .hasAncestorOrSelf(hierarchy.typeNode(stmtBody.getMethod().getReturnType()))) { if (fix) { stmt.setOp(insertCast((Local) stmt.getOp(), stmtBody.getMethod().getReturnType(), stmt)); } else { error("Type Error(51)"); } } } }
public void caseReturnStmt(ReturnStmt stmt) { if (stmt.getOp() instanceof Local) { if (!hierarchy.typeNode(((Local) stmt.getOp()).getType()) .hasAncestorOrSelf(hierarchy.typeNode(stmtBody.getMethod().getReturnType()))) { if (fix) { stmt.setOp(insertCast((Local) stmt.getOp(), stmtBody.getMethod().getReturnType(), stmt)); } else { error("Type Error(51)"); } } } }
public void caseReturnStmt(ReturnStmt stmt) { if (uses) { if (stmt.getOp() instanceof Local) { resolver.typeVariable((Local) stmt.getOp()).addParent(resolver.typeVariable(stmtBody.getMethod().getReturnType())); } } }
logger.debug("cmp;" + jb.getMethod() + ";" + size + ";" + oldTime + ";" + newTime + ";" + cmp);
public void caseReturnStmt(ReturnStmt stmt) { if (uses) { if (stmt.getOp() instanceof Local) { if (((Local) stmt.getOp()).getType() instanceof IntegerType) { resolver.typeVariable((Local) stmt.getOp()).addParent(resolver.typeVariable(stmtBody.getMethod().getReturnType())); } } } }
/** * Local Class Decl - Local Inner Class */ private void createLocalClassDecl(polyglot.ast.LocalClassDecl cDecl) { BiMap lcMap = InitialResolver.v().getLocalClassMap(); String name = Util.getSootType(cDecl.decl().type()).toString(); if (!InitialResolver.v().hasClassInnerTag(body.getMethod().getDeclaringClass(), name)) { Util.addInnerClassTag(body.getMethod().getDeclaringClass(), name, null, cDecl.decl().name(), Util.getModifier(cDecl.decl().flags())); } }
/** * needs accessors: when field or meth is private and in some other class when field or meth is protected and in */ protected boolean needsAccessor(polyglot.types.MemberInstance inst) { if (inst.flags().isPrivate()) { if (!Util.getSootType(inst.container()).equals(body.getMethod().getDeclaringClass().getType())) { return true; } } else if (inst.flags().isProtected()) { if (Util.getSootType(inst.container()).equals(body.getMethod().getDeclaringClass().getType())) { return false; } soot.SootClass currentClass = body.getMethod().getDeclaringClass(); if (currentClass.getSuperclass().getType().equals(Util.getSootType(inst.container()))) { return false; } while (currentClass.hasOuterClass()) { currentClass = currentClass.getOuterClass(); if (Util.getSootType(inst.container()).equals(currentClass.getType())) { return false; } else if (Util.getSootType(inst.container()).equals(currentClass.getSuperclass().getType())) { return true; } } return false; } return false; }
public void caseReturnStmt(ReturnStmt stmt) { if (stmt.getOp() instanceof Local) { if (((Local) stmt.getOp()).getType() instanceof IntegerType) { if (!ClassHierarchy.v().typeNode(((Local) stmt.getOp()).getType()) .hasAncestor_1(ClassHierarchy.v().typeNode(stmtBody.getMethod().getReturnType()))) { if (fix) { stmt.setOp(insertCast((Local) stmt.getOp(), stmtBody.getMethod().getReturnType(), stmt)); } else { error("Type Error(19)"); } } } } }
/** * 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 void emitLocals() { JimpleBody jb = body; SootMethod m = jb.getMethod(); Collection<Local> jbl = jb.getLocals(); Collection<Unit> jbu = jb.getUnits(); int iloc = 0; if (!m.isStatic()) { Local l = getLocal(iloc++); jbu.add(Jimple.v().newIdentityStmt(l, Jimple.v().newThisRef(m.getDeclaringClass().getType()))); } int nrp = 0; for (Object ot : m.getParameterTypes()) { Type t = (Type) ot; Local l = getLocal(iloc); jbu.add(Jimple.v().newIdentityStmt(l, Jimple.v().newParameterRef(t, nrp++))); if (AsmUtil.isDWord(t)) { iloc += 2; } else { iloc++; } } for (Local l : locals.values()) { jbl.add(l); } }
public soot.Local emitThis(TypeDecl typeDecl) { if(thisName == null) { thisName = newLocal("this", typeDecl.getSootType()); if(body.getMethod().isStatic()) add(Jimple.v().newIdentityStmt(thisName, Jimple.v().newParameterRef(typeDecl.getSootType(), 0))); else add(Jimple.v().newIdentityStmt(thisName, Jimple.v().newThisRef(typeDecl.sootRef()))); } return thisName; }
String fieldName = field.name(); polyglot.ast.Expr initExpr = field.init(); soot.SootClass currentClass = body.getMethod().getDeclaringClass(); soot.SootFieldRef sootField = soot.Scene.v().makeFieldRef(currentClass, fieldName, Util.getSootType(field.type().type()), field.flags().isStatic());
String fieldName = field.name(); polyglot.ast.Expr initExpr = field.init(); soot.SootClass currentClass = body.getMethod().getDeclaringClass(); soot.SootFieldRef sootField = soot.Scene.v().makeFieldRef(currentClass, fieldName, Util.getSootType(field.type().type()), field.flags().isStatic());