コード例 #1
0
 @Override
 public void avm2CodeRemoveTraps(
     String path,
     int classIndex,
     boolean isStatic,
     int scriptIndex,
     ABC abc,
     Trait trait,
     int methodInfo,
     MethodBody body)
     throws InterruptedException {
   AVM2Code code = body.getCode();
   code.removeDeadCode(body);
   removeObfuscationIfs(classIndex, isStatic, scriptIndex, abc, body, null);
   removeZeroJumps(code, body);
 }
コード例 #2
0
  protected boolean removeObfuscationIfs(
      int classIndex,
      boolean isStatic,
      int scriptIndex,
      ABC abc,
      MethodBody body,
      AVM2Instruction inlineIns)
      throws InterruptedException {
    AVM2Code code = body.getCode();
    if (code.code.isEmpty()) {
      return false;
    }

    Map<Integer, Object> staticRegs = new HashMap<>();
    if (inlineIns != null && inlineIns.definition instanceof GetLocalTypeIns) {
      staticRegs.put(
          ((GetLocalTypeIns) inlineIns.definition).getRegisterId(inlineIns), Undefined.INSTANCE);
    }

    if (code.code.isEmpty()) {
      return false;
    }

    FixItemCounterStack stack = new FixItemCounterStack();
    LocalDataArea localData = new LocalDataArea();
    localData.operandStack = stack;

    int localReservedCount = body.getLocalReservedCount();
    for (int i = 0; i < code.code.size(); i++) {
      if (Thread.currentThread().isInterrupted()) {
        throw new InterruptedException();
      }

      localData.clear();
      initLocalRegs(localData, localReservedCount, body.max_regs, i == 0);

      if (executeInstructions(
          staticRegs, body, abc, code, localData, i, code.code.size() - 1, null, inlineIns)) {
        code.removeDeadCode(body);
        i--;
      }
    }

    return false;
  }