Package jadx.core.dex.instructions

Examples of jadx.core.dex.instructions.InvokeNode


      }

      // check argument types for overloaded methods
      case INVOKE: {
        boolean change = false;
        InvokeNode inv = (InvokeNode) insn;
        MethodInfo callMth = inv.getCallMth();
        MethodNode node = mth.dex().resolveMethod(callMth);
        if (node != null && node.isArgsOverload()) {
          List<ArgType> args = callMth.getArgumentsTypes();
          int j = inv.getArgsCount() - 1;
          for (int i = args.size() - 1; i >= 0; i--) {
            ArgType argType = args.get(i);
            InsnArg insnArg = inv.getArg(j--);
            if (insnArg.isRegister() && !argType.equals(insnArg.getType())) {
              insnArg.setType(argType);
              change = true;
            }
          }
View Full Code Here


    for (RegisterArg useArg : sVar.getUseList()) {
      InsnNode insn = useArg.getParentInsn();
      if (insn != null) {
        InsnType insnType = insn.getType();
        if (insnType == InsnType.INVOKE) {
          InvokeNode inv = (InvokeNode) insn;
          if (inv.getInvokeType() != InvokeType.STATIC
              && inv.getArg(0) == useArg) {
            return true;
          }
        } else if (insnType == InsnType.ARRAY_LENGTH) {
          if (insn.getArg(0) == useArg) {
            return true;
View Full Code Here

          insn.getArg(0).merge(mth.getReturnType());
        }
        break;

      case INVOKE:
        InvokeNode inv = (InvokeNode) insn;
        List<ArgType> types = inv.getCallMth().getArgumentsTypes();
        int count = insn.getArgsCount();
        int k = types.size() == count ? 0 : -1;
        for (int i = 0; i < count; i++) {
          InsnArg arg = insn.getArg(i);
          if (!arg.getType().isTypeKnown()) {
View Full Code Here

  /**
   * Check if instruction is a interface invoke with corresponding parameters.
   */
  private static boolean checkInvoke(InsnNode insn, String declClsFullName, String mthId, int argsCount) {
    if (insn.getType() == InsnType.INVOKE) {
      InvokeNode inv = (InvokeNode) insn;
      MethodInfo callMth = inv.getCallMth();
      if (callMth.getArgsCount() == argsCount
          && callMth.getShortId().equals(mthId)
          && inv.getInvokeType() == InvokeType.INTERFACE) {
        return declClsFullName == null || callMth.getDeclClass().getFullName().equals(declClsFullName);
      }
    }
    return false;
  }
View Full Code Here

    InsnNode invInsn = ((InsnWrapArg) invArg).getWrapInsn();
    InsnNode sgetInsn = ((InsnWrapArg) sgetArg).getWrapInsn();
    if (invInsn.getType() != InsnType.INVOKE || sgetInsn.getType() != InsnType.SGET) {
      return null;
    }
    InvokeNode inv = (InvokeNode) invInsn;
    if (!inv.getCallMth().getShortId().equals("ordinal()I")) {
      return null;
    }
    ClassNode enumCls = mth.dex().resolveClass(inv.getCallMth().getDeclClass());
    if (enumCls == null || !enumCls.isEnum()) {
      return null;
    }
    Object index = ((IndexInsnNode) sgetInsn).getIndex();
    if (!(index instanceof FieldInfo)) {
      return null;
    }
    FieldNode enumMapField = mth.dex().resolveField((FieldInfo) index);
    if (enumMapField == null || !enumMapField.getAccessFlags().isSynthetic()) {
      return null;
    }
    return new EnumMapInfo(inv.getArg(0), enumMapField);
  }
View Full Code Here

  }

  private static void processInvoke(MethodNode mth, BlockNode block, int insnNumber, InstructionRemover remover) {
    ClassNode parentClass = mth.getParentClass();
    InsnNode insn = block.getInstructions().get(insnNumber);
    InvokeNode inv = (InvokeNode) insn;
    MethodInfo callMth = inv.getCallMth();
    if (callMth.isConstructor()) {
      InsnNode instArgAssignInsn = ((RegisterArg) inv.getArg(0)).getAssignInsn();
      ConstructorInsn co = new ConstructorInsn(mth, inv);
      boolean remove = false;
      if (co.isSuper() && (co.getArgsCount() == 0 || parentClass.isEnum())) {
        remove = true;
      } else if (co.isThis() && co.getArgsCount() == 0) {
        MethodNode defCo = parentClass.searchMethodByName(callMth.getShortId());
        if (defCo == null || defCo.isNoCode()) {
          // default constructor not implemented
          remove = true;
        }
      }
      // remove super() call in instance initializer
      if (parentClass.isAnonymous() && mth.isDefaultConstructor() && co.isSuper()) {
        remove = true;
      }
      if (remove) {
        remover.add(insn);
      } 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);
              }
            }
          }
        }
        ConstructorInsn replace = processConstructor(mth, co);
        if (replace != null) {
          replaceInsn(block, insnNumber, replace);
        }
      }
    } else if (inv.getArgsCount() > 0) {
      for (int j = 0; j < inv.getArgsCount(); j++) {
        InsnArg arg = inv.getArg(j);
        if (arg.isLiteral()) {
          FieldNode f = parentClass.getConstFieldByLiteralArg((LiteralArg) arg);
          if (f != null) {
            arg.wrapInstruction(new IndexInsnNode(InsnType.SGET, f.getFieldInfo(), 0));
          }
View Full Code Here

  }

  private static String makeNameFromInsn(InsnNode insn) {
    switch (insn.getType()) {
      case INVOKE:
        InvokeNode inv = (InvokeNode) insn;
        String name = inv.getCallMth().getName();
        if (name.startsWith("get") || name.startsWith("set")) {
          return fromName(name.substring(3));
        }
        if ("iterator".equals(name)) {
          return "it";
View Full Code Here

TOP

Related Classes of jadx.core.dex.instructions.InvokeNode

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.