/** * Get astubx style method signature. {FullyQualifiedEnclosingType}: {UnqualifiedMethodReturnType} * {methodName} ([{UnqualifiedArgumentType}*]) * * @param mtd Method reference. * @return String Method signature. */ // TODO: handle generics and inner classes private static String getSignature(IMethod mtd) { String classType = mtd.getDeclaringClass().getName().toString().replaceAll("/", "\\.").substring(1); classType = classType.replaceAll("\\$", "\\."); // handle inner class String returnType = mtd.isInit() ? null : getSimpleTypeName(mtd.getReturnType()); String strArgTypes = ""; int argi = mtd.isStatic() ? 0 : 1; // Skip 'this' parameter for (; argi < mtd.getNumberOfParameters(); argi++) { strArgTypes += getSimpleTypeName(mtd.getParameterType(argi)); if (argi < mtd.getNumberOfParameters() - 1) strArgTypes += ", "; } return classType + ":" + (returnType == null ? "void " : returnType + " ") + mtd.getName().toString() + "(" + strArgTypes + ")"; } /**
@Override public Atom getName() { return Atom.findOrCreateUnicodeAtom("c" + yuck); } @Override
private enum Explicit { UNSET, IMPLICIT, EXPLICIT, /** An other target was set for an explicit Intent */ MULTI }
public MicroModel(final IClassHierarchy cha, final AnalysisOptions options, final IAnalysisCacheView cache, Atom target) { super(cha, options, cache); this.target = target; this.name = Atom.concat(Atom.findOrCreateAsciiAtom("start"), target.right(target.rIndex((byte)'/') - 1)); }
public SystemServiceModel(final IClassHierarchy cha, final AnalysisOptions options, final IAnalysisCacheView cache, Atom target) { super(cha, options, cache); if (target == null) { throw new IllegalArgumentException("The target requested to create an SystemServiceModel for was null"); } String sName = target.toString(); String cName = Character.toUpperCase(sName.charAt(0)) + sName.substring(1); this.name = Atom.findOrCreateAsciiAtom("startSystemService" + cName); this.target = target.toString(); }
private static FieldReference makeNonGlobalFieldReference(FieldReference field) { String nonGlobalFieldName = field.getName().toString().substring(7); field = FieldReference.findOrCreate(JavaScriptTypes.Root, Atom.findOrCreateUnicodeAtom(nonGlobalFieldName), JavaScriptTypes.Root); return field; }
private Collection<IMethod> lookupMethods(IClass c) { Collection<IMethod> matching = new LinkedList<>(); Atom atom = Atom.findOrCreateUnicodeAtom(memberName); Descriptor desc = descriptor == null ? null : Descriptor.findOrCreateUTF8(descriptor); Collection<? extends IMethod> allMethods = c.getAllMethods(); for(IMethod m: allMethods) { if(m.getName().equals(atom) && (desc == null || m.getDescriptor().equals(desc))) { matching.add(m); } } return matching; }
@Override public GlobalObjectKey getGlobalObject(Atom language) { assert language.equals(JavaScriptTypes.jsName); return globalObject; }
/** * Optionally add a name for a local variable. */ public void setLocalName(final int number, final String name) { localNames.put(number, Atom.findOrCreateAsciiAtom(name)); }
private Element findOrCreateClrElt(Atom classLoaderName) throws DOMException, UTFDataFormatException { if (clrElt == null) { clrElt = doc.createElement(E_CLASSLOADER); clrElt.setAttribute(A_NAME, classLoaderName.toUnicodeString()); rootElement.appendChild(clrElt); } return clrElt; }
public static Atom concat(byte c, ImmutableByteArray b) { if (b == null) { throw new IllegalArgumentException("b is null"); } return concat(c, b.b); }
public static CGNode findMethod(CallGraph cg, String name) { Atom a = Atom.findOrCreateUnicodeAtom(name); for (CGNode n : cg) { if (n.getMethod().getName().equals(a)) { return n; } } System.err.println("call graph " + cg); Assertions.UNREACHABLE("failed to find method " + name); return null; }
@Override public boolean equals(Object obj) { // using instanceof is OK because Selector is final if (obj instanceof Selector) { Selector other = (Selector) obj; return name.equals(other.name) && descriptor.equals(other.descriptor); } else { return false; } }
public SystemServiceModel(final IClassHierarchy cha, final AnalysisOptions options, final IAnalysisCacheView cache, Atom target) { super(cha, options, cache); if (target == null) { throw new IllegalArgumentException("The target requested to create an SystemServiceModel for was null"); } String sName = target.toString(); String cName = Character.toUpperCase(sName.charAt(0)) + sName.substring(1); this.name = Atom.findOrCreateAsciiAtom("startSystemService" + cName); this.target = target.toString(); }
public MicroModel(final IClassHierarchy cha, final AnalysisOptions options, final IAnalysisCacheView cache, Atom target) { super(cha, options, cache); this.target = target; this.name = Atom.concat(Atom.findOrCreateAsciiAtom("start"), target.right(target.rIndex((byte)'/') - 1)); }
/** * Reduces the Callgraph to only the nodes that we need */ private static CallGraph computeFilteredCallgraph(final CallGraph cg) { final HashSet<Atom> filterSet = new HashSet<>(); final Atom worldClinit = Atom.findOrCreateAsciiAtom("fakeWorldClinit"); filterSet.add(worldClinit); filterSet.add(MethodReference.initAtom); final CallGraphFilter filter = new CallGraphFilter(filterSet); return filter.filter(cg); }
private Element findOrCreateClassElt(Atom classLoaderName, Atom pkg, Atom className) throws UTFDataFormatException { Element classElt = classElts.get(className); if (classElt == null) { Element pkgElt = findOrCreatePkgElt(classLoaderName, pkg); classElt = doc.createElement(E_CLASS); classElt.setAttribute(A_NAME, className.toUnicodeString()); pkgElt.appendChild(classElt); classElts.put(className, classElt); } return classElt; }
public static Atom concat(byte c, ImmutableByteArray b) { if (b == null) { throw new IllegalArgumentException("b is null"); } return concat(c, b.b); }