/** * create body and make it be active */ private void createBody(soot.SootMethod sootMethod) { body = soot.jimple.Jimple.v().newBody(sootMethod); sootMethod.setActiveBody(body); }
public void outAFullMethodBody(AFullMethodBody node) { JimpleBody jBody = Jimple.v().newBody();
@Override public Body getBody(SootMethod m, String phaseName) { if (!phaseName.equals("jb")) { throw new Error("unsupported body type: " + phaseName); } SootClass tclass = m.getDeclaringClass(); JimpleBody jb = Jimple.v().newBody(m); if (m.getName().equals("<init>")) { getInitBody(tclass, jb); } else if (m.getName().equals("bootstrap$")) { getBootstrapBody(tclass, jb); } else { getInvokeBody(tclass, jb); } // rename locals consistent with JimpleBodyPack LocalNameStandardizer.v().transform(jb); return jb; }
return null; JimpleBody jb = Jimple.v().newBody(m);
/** * Returns an equivalent unbacked JimpleBody of the current Body by eliminating the Phi nodes. * * <p> * Currently available option is "naive-phi-elimination", typically specified in the "shimple" phase (eg, -p shimple * naive-phi-elimination) which skips the dead code elimination and register allocation phase before eliminating Phi nodes. * This can be useful for understanding the effect of analyses. * * <p> * Remember to setActiveBody() if necessary in your SootMethod. * * @see #eliminatePhiNodes() **/ public JimpleBody toJimpleBody() { ShimpleBody sBody = (ShimpleBody) this.clone(); sBody.eliminateNodes(); JimpleBody jBody = Jimple.v().newBody(sBody.getMethod()); jBody.importBodyContentsFrom(sBody); return jBody; }
@Override public Body getBody(SootMethod m, String phaseName) { Body b = Jimple.v().newBody(m); try { // add the body of this code item DexBody dexBody = new DexBody(dexFile, method, declaringClass.getType()); dexBody.jimplify(b, m); } catch (InvalidDalvikBytecodeException e) { String msg = "Warning: Invalid bytecode in method " + m + ": " + e; logger.debug("" + msg); Util.emptyBody(b); Util.addExceptionAfterUnit(b, "java.lang.RuntimeException", b.getUnits().getLast(), "Soot has detected that this method contains invalid Dalvik bytecode," + " which would have throw an exception at runtime. [" + msg + "]"); TypeAssigner.v().transform(b); } m.setActiveBody(b); return m.getActiveBody(); } };
private SootMethod getOrCreateInitializer(SootClass sc, Set<SootField> alreadyInitialized) { SootMethod smInit; // Create a static initializer if we don't already have one smInit = sc.getMethodByNameUnsafe(SootMethod.staticInitializerName); if (smInit == null) { smInit = Scene.v().makeSootMethod(SootMethod.staticInitializerName, Collections.<Type>emptyList(), VoidType.v()); smInit.setActiveBody(Jimple.v().newBody(smInit)); sc.addMethod(smInit); smInit.setModifiers(Modifier.PUBLIC | Modifier.STATIC); } else if (smInit.isPhantom()) { return null; } else { smInit.retrieveActiveBody(); // We need to collect those variables that are already initialized // somewhere for (Unit u : smInit.getActiveBody().getUnits()) { Stmt s = (Stmt) u; for (ValueBox vb : s.getDefBoxes()) { if (vb.getValue() instanceof FieldRef) { alreadyInitialized.add(((FieldRef) vb.getValue()).getField()); } } } } return smInit; }
SootMethod m = Scene.v().makeSootMethod(SootMethod.staticInitializerName, emptyList(), VoidType.v(), Modifier.STATIC); sc.addMethod(m); b = Jimple.v().newBody(m); m.setActiveBody(b); newInit = true; SootMethod m = sc.getMethodByName(SootMethod.staticInitializerName); if (!m.hasActiveBody()) { b = Jimple.v().newBody(m); m.setActiveBody(b); newInit = true;
public soot.Body getBody(soot.SootMethod sootMethod, String phaseName) { soot.Body body = soot.jimple.Jimple.v().newBody(sootMethod); LocalGenerator lg = new LocalGenerator(body);
public soot.Body getBody(soot.SootMethod sootMethod, String phaseName) { soot.Body body = soot.jimple.Jimple.v().newBody(sootMethod); LocalGenerator lg = new LocalGenerator(body);
public soot.Body getBody(soot.SootMethod sootMethod, String phaseName) { soot.Body body = soot.jimple.Jimple.v().newBody(sootMethod); LocalGenerator lg = new LocalGenerator(body);
java.util.List<SootClass> thrownExceptions = new LinkedList<SootClass>(); Body accessorBody = Jimple.v().newBody(); soot.util.Chain accStmts = accessorBody.getUnits(); LocalGenerator lg = new LocalGenerator(accessorBody);
java.util.List<SootClass> thrownExceptions = new LinkedList<SootClass>(); Body accessorBody = Jimple.v().newBody(); soot.util.Chain accStmts = accessorBody.getUnits(); LocalGenerator lg = new LocalGenerator(accessorBody);
public Body getBody(SootMethod m, String phaseName) { JimpleBody jb = Jimple.v().newBody(m);
/** * @ast method * @aspect EmitJimpleRefinements * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/SootJastAddJ/EmitJimpleRefinements.jrag:100 */ public void jimplify2() { if (!generate() || sootMethod().hasActiveBody() || (sootMethod().getSource() != null && (sootMethod().getSource() instanceof soot.coffi.CoffiMethodSource))) return; try { if (hasBlock() && !(hostType().isInterfaceDecl())) { JimpleBody body = Jimple.v().newBody(sootMethod()); sootMethod().setActiveBody(body); Body b = new Body(hostType(), body, this); b.setLine(this); for (int i = 0; i < getNumParameter(); i++) getParameter(i).jimplify2(b); getBlock().jimplify2(b); if (type() instanceof VoidType) b.add(Jimple.v().newReturnVoidStmt()); } } catch (RuntimeException e) { System.err.println("Error generating " + hostType().typeName() + ": " + this); throw e; } }
public soot.Body getBody(soot.SootMethod sootMethod, String phaseName) { soot.Body classBody = soot.jimple.Jimple.v().newBody(sootMethod);
/** * @ast method * @aspect EmitJimple * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/JimpleBackend/EmitJimple.jrag:903 */ public void jimplify2clinit() { SootMethod m = clinit; JimpleBody body = Jimple.v().newBody(m); m.setActiveBody(body); Body b = new Body(this, body, this); for (int i = 0; i < getNumBodyDecl(); i++) { BodyDecl bodyDecl = getBodyDecl(i); if (bodyDecl instanceof FieldDeclaration && bodyDecl.generate()) { FieldDeclaration f = (FieldDeclaration) bodyDecl; if (f.isStatic() && f.hasInit()) { Local l = asLocal(b, f.getInit().type().emitCastTo(b, f.getInit(), f.type()), // AssignConversion f.type().getSootType()); b.setLine(f); b.add(b.newAssignStmt(b.newStaticFieldRef(f.sootRef(), f), l, f)); } } else if (bodyDecl instanceof StaticInitializer && bodyDecl.generate()) { bodyDecl.jimplify2(b); } } b.add(b.newReturnVoidStmt(null)); }
JimpleBody body = Jimple.v().newBody(m); m.setActiveBody(body);
Collections.emptyList(), VoidType.v(), Modifier.STATIC); sootClass.addMethod(staticInitializerMethod); body = Jimple.v().newBody(staticInitializerMethod); staticInitializerMethod.setActiveBody(body); } else {
&& (sootMethod().getSource() instanceof soot.coffi.CoffiMethodSource))) return; JimpleBody body = Jimple.v().newBody(sootMethod()); sootMethod().setActiveBody(body); Body b = new Body(hostType(), body, this);