public LocalObjectsAnalysis(InfoFlowAnalysis dfa) { this.dfa = dfa; this.uf = new UseFinder(); this.cg = Scene.v().getCallGraph(); classToClassLocalObjectsAnalysis = new HashMap<SootClass, ClassLocalObjectsAnalysis>(); mloaCache = new HashMap<SootMethod, SmartMethodLocalObjectsAnalysis>(); }
private Set<SootClass> getChildrenOfIncluding(Collection<SootClass> classes) { return Stream .concat(classes.stream().filter(c -> !c.getName().equals("java.lang.Object")) .map(c -> c.isInterface() ? Scene.v().getActiveHierarchy().getImplementersOf(c) : Scene.v().getActiveHierarchy().getSubclassesOf(c)) .flatMap(Collection::stream), classes.stream()) .collect(toSet()); }
@Override protected void internalTransform(String phaseName, Map<String, String> options) { PurityOptions opts = new PurityOptions(options); logger.debug("[AM] Analysing purity"); CallGraph cg = Scene.v().getCallGraph(); // launch the analysis new PurityInterproceduralAnalysis(cg, Scene.v().getEntryPoints().iterator(), opts); } }
private Parm(SootMethod m, int i) { index = i; method = m; Scene.v().getFieldNumberer().add(this); }
/** * Convenience method returning true if this class is a library class. * * @see Scene#getLibraryClasses() */ public boolean isLibraryClass() { return Scene.v().getLibraryClasses().contains(this); }
public synchronized void setDeclaringClass(SootClass sc) { if (sc != null && type instanceof RefLikeType) { Scene.v().getFieldNumberer().add(this); } this.declaringClass = sc; this.sig = null; }
/** * Convenience method returning true if this class is an application class. * * @see Scene#getApplicationClasses() */ public boolean isApplicationClass() { return Scene.v().getApplicationClasses().contains(this); }
public void outAFieldMember(AFieldMember node) { int modifier = 0; Type type = null; String name = null; name = (String) mProductions.removeLast(); type = (Type) mProductions.removeLast(); modifier = processModifiers(node.getModifier()); SootField f = Scene.v().makeSootField(name, type, modifier); mSootClass.addField(f); }
public Value createJimpleConstantValue(cp_info[] constant_pool) { CONSTANT_Class_info cc = (CONSTANT_Class_info) (constant_pool[class_index]); CONSTANT_NameAndType_info cn = (CONSTANT_NameAndType_info) (constant_pool[name_and_type_index]); String className = cc.toString(constant_pool); String nameAndType = cn.toString(constant_pool); String name = nameAndType.substring(0, nameAndType.indexOf(":")); String typeName = nameAndType.substring(nameAndType.indexOf(":") + 1); Type type = Util.v().jimpleTypeOfFieldDescriptor(typeName); return Jimple.v().newStaticFieldRef(Scene.v().makeFieldRef(Scene.v().getSootClass(className), name, type, true)); }
public void outAFullIdentNonvoidType(AFullIdentNonvoidType node) { String tokenString = node.getFullIdentifier().getText(); tokenString = Scene.v().unescapeName(tokenString); tokenString = StringTools.getUnEscapedStringOf(tokenString); mRefTypes.add(tokenString); }
private SootMethodRef toSootMethodRef(Handle methodHandle) { String bsmClsName = AsmUtil.toQualifiedName(methodHandle.getOwner()); SootClass bsmCls = Scene.v().getSootClass(bsmClsName); List<Type> bsmSigTypes = AsmUtil.toJimpleDesc(methodHandle.getDesc()); Type returnType = bsmSigTypes.remove(bsmSigTypes.size() - 1); return Scene.v().makeMethodRef(bsmCls, methodHandle.getName(), bsmSigTypes, returnType, methodHandle.getTag() == MethodHandle.Kind.REF_INVOKE_STATIC.getValue()); }
public void outAStaticInvokeExpr(AStaticInvokeExpr node) { List args; if (node.getArgList() != null) { args = (List) mProductions.removeLast(); } else { args = new ArrayList(); } SootMethodRef method = (SootMethodRef) mProductions.removeLast(); method = Scene.v().makeMethodRef(method.declaringClass(), method.name(), method.parameterTypes(), method.returnType(), true); mProductions.addLast(Jimple.v().newStaticInvokeExpr(method, args)); }
public static void main(String[] args) { // assumes 2 args: Class + Method Scene.v().loadClassAndSupport(args[0]); SootClass sc = Scene.v().getSootClass(args[0]); SootMethod sm = sc.getMethod(args[1]); Body b = sm.retrieveActiveBody(); ShimpleBody sb = Shimple.v().newBody(b); CompleteBlockGraph cfg = new CompleteBlockGraph(sb); SimpleGlobalValueNumberer sgvn = new SimpleGlobalValueNumberer(cfg); System.out.println(sgvn); }
public SootMethod getMethod(String subsignature) { checkLevel(SIGNATURES); NumberedString numberedString = Scene.v().getSubSigNumberer().find(subsignature); if (numberedString == null) { throw new RuntimeException("No method " + subsignature + " in class " + getName()); } return getMethod(numberedString); }
/** * @apilevel internal */ private SootField getSootField_compute(String name, TypeDecl type) { SootField f = Scene.v().makeSootField(name, type.getSootType(), 0); getSootClassDecl().addField(f); return f; }
private SootFieldRef toSootFieldRef(Handle methodHandle) { String bsmClsName = AsmUtil.toQualifiedName(methodHandle.getOwner()); SootClass bsmCls = Scene.v().getSootClass(bsmClsName); Type t = AsmUtil.toJimpleDesc(methodHandle.getDesc()).get(0); int kind = methodHandle.getTag(); return Scene.v().makeFieldRef(bsmCls, methodHandle.getName(), t, kind == MethodHandle.Kind.REF_GET_FIELD_STATIC.getValue() || kind == MethodHandle.Kind.REF_PUT_FIELD_STATIC.getValue()); }
@Override public Map<Unit, Set<Local>> initialSeeds() { return DefaultSeeds.make(Collections.singleton(Scene.v().getMainMethod().getActiveBody().getUnits().getFirst()), zeroValue()); } }
/** * @ast method * @aspect AutoBoxingCodegen * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/Jimple1.5Backend/AutoBoxingCodegen.jrag:83 */ protected soot.Value emitUnboxingOperation(Body b, soot.Value v, ASTNode location) { // Unbox the value on the stack from this Reference type SootMethodRef ref = Scene.v().makeMethodRef(getSootClassDecl(), unboxed().name() + "Value", new ArrayList(), unboxed().getSootType(), false); return b.newVirtualInvokeExpr(asLocal(b, v), ref, new ArrayList(), location); }
/** * @apilevel internal */ private SootFieldRef sootRef_compute() { return Scene.v().makeFieldRef(hostType().getSootClassDecl(), name(), type().getSootType(), isStatic()); }