コード例 #1
0
 protected void process(ClassType clazz, Set<ClassMemberSignature> done) {
   for (CodeSignature cs : clazz.fixturesLookup()) {
     cs.getAbstractSyntax().translate(done);
   }
   for (CodeSignature cs : clazz.getTests()) {
     cs.getAbstractSyntax().translate(done);
   }
 }
コード例 #2
0
  /**
   * Auxiliary method that translates into Kitten bytecode all class members that are referenced
   * from the given block and the blocks reachable from it.
   *
   * @param block the block
   * @param done the class member signatures already translated
   * @param blocksDone the blocks that have been already processed
   */
  protected void translateReferenced(
      Block block, Set<ClassMemberSignature> done, Set<Block> blocksDone) {
    // if we already processed the block, we return immediately
    if (!blocksDone.add(block)) return;

    for (BytecodeList cursor = block.getBytecode(); cursor != null; cursor = cursor.getTail()) {
      Bytecode h = cursor.getHead();

      if (h instanceof GETFIELD) {
        FieldSignature field = ((GETFIELD) h).getField();
        this.process(field.getDefiningClass(), done);
        done.add(field);
      } else if (h instanceof PUTFIELD) {
        FieldSignature field = ((PUTFIELD) h).getField();
        this.process(field.getDefiningClass(), done);
        done.add(field);
      } else if (h instanceof CALL)
        for (CodeSignature callee : ((CALL) h).getDynamicTargets()) {
          this.process(callee.getDefiningClass(), done);
          callee.getAbstractSyntax().translate(done);
        }
    }

    // we continue with the following blocks
    for (Block follow : block.getFollows()) translateReferenced(follow, done, blocksDone);
  }