Package jadx.core.dex.instructions.args

Examples of jadx.core.dex.instructions.args.RegisterArg


  private static boolean checkIterableForEach(MethodNode mth, LoopRegion loopRegion, IfCondition condition) {
    List<RegisterArg> condArgs = condition.getRegisterArgs();
    if (condArgs.size() != 1) {
      return false;
    }
    RegisterArg iteratorArg = condArgs.get(0);
    SSAVar sVar = iteratorArg.getSVar();
    if (sVar == null || sVar.isUsedInPhi()) {
      return false;
    }
    List<RegisterArg> useList = sVar.getUseList();
    InsnNode assignInsn = iteratorArg.getAssignInsn();
    if (useList.size() != 2
        || assignInsn == null
        || !checkInvoke(assignInsn, null, "iterator()Ljava/util/Iterator;", 0)) {
      return false;
    }
    InsnArg iterableArg = assignInsn.getArg(0);
    InsnNode hasNextCall = useList.get(0).getParentInsn();
    InsnNode nextCall = useList.get(1).getParentInsn();
    if (!checkInvoke(hasNextCall, "java.util.Iterator", "hasNext()Z", 0)
        || !checkInvoke(nextCall, "java.util.Iterator", "next()Ljava/lang/Object;", 0)) {
      return false;
    }
    List<InsnNode> toSkip = new LinkedList<InsnNode>();
    RegisterArg iterVar = nextCall.getResult();
    if (nextCall.contains(AFlag.WRAPPED)) {
      InsnArg wrapArg = BlockUtils.searchWrappedInsnParent(mth, nextCall);
      if (wrapArg != null) {
        InsnNode parentInsn = wrapArg.getParentInsn();
        if (parentInsn.getType() != InsnType.CHECK_CAST) {
View Full Code Here


    for (int i = 0; i < size; i++) {
      InsnNode insn = insns.get(i);
      if (insn.getResult() == null) {
        return false;
      }
      RegisterArg res = insn.getResult();
      if (res.getSVar().getUseCount() > 1) {
        return false;
      }
      boolean found = false;
      // search result arg in other insns
      for (int j = i + 1; j < size; j++) {
View Full Code Here

      unbindInsn(mth, rem);
    }
  }

  public static void unbindInsn(MethodNode mth, InsnNode insn) {
    RegisterArg r = insn.getResult();
    if (r != null && r.getSVar() != null) {
      mth.removeSVar(r.getSVar());
    }
    for (InsnArg arg : insn.getArguments()) {
      unbindArgUsage(mth, arg);
    }
    insn.add(AFlag.INCONSISTENT_CODE);
View Full Code Here

    insn.add(AFlag.INCONSISTENT_CODE);
  }

  public static void unbindArgUsage(MethodNode mth, InsnArg arg) {
    if (arg instanceof RegisterArg) {
      RegisterArg reg = (RegisterArg) arg;
      SSAVar sVar = reg.getSVar();
      if (sVar != null) {
        sVar.removeUse(reg);
      }
    } else if (arg instanceof InsnWrapArg) {
      InsnWrapArg wrap = (InsnWrapArg) arg;
View Full Code Here

      throw new CodegenException("Unknown arg type " + arg);
    }
  }

  public void assignVar(CodeWriter code, InsnNode insn) throws CodegenException {
    RegisterArg arg = insn.getResult();
    if (insn.contains(AFlag.DECLARE_VAR)) {
      declareVar(code, arg);
    } else {
      addArg(code, arg, false);
    }
View Full Code Here

      // remap args
      InsnArg[] regs = new InsnArg[callMthNode.getRegsCount()];
      List<RegisterArg> callArgs = callMthNode.getArguments(true);
      for (int i = 0; i < callArgs.size(); i++) {
        InsnArg arg = insn.getArg(i);
        RegisterArg callArg = callArgs.get(i);
        regs[callArg.getRegNum()] = arg;
      }
      // replace args
      List<RegisterArg> inlArgs = new ArrayList<RegisterArg>();
      inl.getRegisterArgs(inlArgs);
      Map<RegisterArg, InsnArg> toRevert = new HashMap<RegisterArg, InsnArg>();
View Full Code Here

  private void addMethodArguments(CodeWriter argsCode, List<RegisterArg> args) {
    MethodParameters paramsAnnotation = mth.get(AType.ANNOTATION_MTH_PARAMETERS);
    int i = 0;
    for (Iterator<RegisterArg> it = args.iterator(); it.hasNext(); ) {
      RegisterArg arg = it.next();

      // add argument annotation
      if (paramsAnnotation != null) {
        annotationGen.addForParameter(argsCode, paramsAnnotation, i);
      }
      if (!it.hasNext() && mth.getAccessFlags().isVarArgs()) {
        // change last array argument to varargs
        ArgType type = arg.getType();
        if (type.isArray()) {
          ArgType elType = type.getArrayElement();
          classGen.useType(argsCode, elType);
          argsCode.add("...");
        } else {
          LOG.warn(ErrorsCounter.formatErrorMsg(mth, "Last argument in varargs method not array"));
          classGen.useType(argsCode, arg.getType());
        }
      } else {
        classGen.useType(argsCode, arg.getType());
      }
      argsCode.add(' ');
      argsCode.add(nameGen.assignArg(arg));

      i++;
View Full Code Here

      } else {
        replaceInsn(block, insnNumber, co);
        if (co.isNewInstance()) {
          InsnNode newInstInsn = removeAssignChain(instArgAssignInsn, remover, InsnType.NEW_INSTANCE);
          if (newInstInsn != null) {
            RegisterArg instArg = newInstInsn.getResult();
            RegisterArg resultArg = co.getResult();
            if (!resultArg.equals(instArg)) {
              // replace all usages of 'instArg' with result of this constructor instruction
              for (RegisterArg useArg : new ArrayList<RegisterArg>(instArg.getSVar().getUseList())) {
                RegisterArg dup = resultArg.duplicate();
                InsnNode parentInsn = useArg.getParentInsn();
                parentInsn.replaceArg(useArg, dup);
                dup.setParentInsn(parentInsn);
                resultArg.getSVar().use(dup);
              }
            }
          }
        }
View Full Code Here

    InsnType type = insn.getType();
    if (type == insnType) {
      return insn;
    }
    if (type == InsnType.MOVE) {
      RegisterArg arg = (RegisterArg) insn.getArg(0);
      return removeAssignChain(arg.getAssignInsn(), remover, insnType);
    }
    return null;
  }
View Full Code Here

    List<InsnNode> blockInsns = block.getInstructions();
    if (!blockInsns.isEmpty()) {
      InsnNode insn = blockInsns.get(0);
      if (insn.getType() == InsnType.MOVE_EXCEPTION) {
        // result arg used both in this insn and exception handler,
        RegisterArg resArg = insn.getResult();
        ArgType type = excHandler.isCatchAll() ? ArgType.THROWABLE : excHandler.getCatchType().getType();
        String name = excHandler.isCatchAll() ? "th" : "e";
        if (resArg.getName() == null) {
          resArg.setName(name);
        }
        SSAVar sVar = insn.getResult().getSVar();
        if (sVar.getUseCount() == 0) {
          excHandler.setArg(new NamedArg(name, type));
          InstructionRemover.remove(mth, block, 0);
View Full Code Here

TOP

Related Classes of jadx.core.dex.instructions.args.RegisterArg

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.