/**
  * Get all non-constructor, non-class-initializer methods declared by a class and all its
  * superclasses if their name is equal to the specified name.
  *
  * @param cls the class
  * @param name the name
  */
 private Collection<IMethod> getAllNormalPublicMethods(IClass cls, Atom name) {
   Collection<IMethod> result = HashSetFactory.make();
   Collection<IMethod> allMethods = null;
   allMethods = cls.getAllMethods();
   for (IMethod m : allMethods) {
     if (!m.isInit() && !m.isClinit() && m.isPublic() && m.getSelector().getName().equals(name)) {
       result.add(m);
     }
   }
   return result;
 }
示例#2
0
  public static Iterable<Entrypoint> makePrimordialPublicEntrypoints(
      AnalysisScope scope, ClassHierarchy cha, String pkg) {
    final HashSet<Entrypoint> result = HashSetFactory.make();
    for (IClass clazz : cha) {

      if (clazz.getName().toString().indexOf(pkg) != -1
          && !clazz.isInterface()
          && !clazz.isAbstract()) {
        for (IMethod method : clazz.getDeclaredMethods()) {
          if (method.isPublic() && !method.isAbstract()) {
            System.out.println("Entry:" + method.getReference());
            result.add(new DefaultEntrypoint(method, cha));
          }
        }
      }
    }
    return new Iterable<Entrypoint>() {
      @Override
      public Iterator<Entrypoint> iterator() {
        return result.iterator();
      }
    };
  }
示例#3
0
 /** @param method An arbitrary method declared on a template class annotated with `@Capsule`. */
 public static boolean isProcedure(IMethod method) {
   assert isCapsuleTemplate(method.getDeclaringClass());
   return method.isPublic() == true // Only a capsule's public methods are procedures.
       && isSpecialCapsuleDecl(method) == false; // Don't count special decls as procedures.
 }