Projects STRLCPY jadx Commits e4dde3f4
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■
    jadx-core/src/main/java/jadx/api/JadxDecompiler.java
    skipped 30 lines
    31 31  /**
    32 32   * Jadx API usage example:
    33 33   * <pre><code>
    34  - * Decompiler jadx = new Decompiler();
     34 + * JadxDecompiler jadx = new JadxDecompiler();
    35 35   * jadx.loadFile(new File("classes.dex"));
    36 36   * jadx.setOutputDir(new File("out"));
    37 37   * jadx.save();
    skipped 183 lines
  • ■ ■ ■ ■
    jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
    skipped 100 lines
    101 101   if (f.isStatic()) {
    102 102   staticField(code, f.getField());
    103 103   } else {
    104  - instanceField(code, f.getField(), f.getRegisterArg());
     104 + instanceField(code, f.getField(), f.getInstanceArg());
    105 105   }
    106 106   } else {
    107 107   throw new CodegenException("Unknown arg type " + arg);
    skipped 689 lines
  • ■ ■ ■ ■ ■ ■
    jadx-core/src/main/java/jadx/core/dex/instructions/args/FieldArg.java
    skipped 5 lines
    6 6  public final class FieldArg extends RegisterArg {
    7 7   
    8 8   private final FieldInfo field;
    9  - // regArg equal 'null' for static fields
    10  - private final RegisterArg regArg;
     9 + // instArg equal 'null' for static fields
     10 + private final InsnArg instArg;
    11 11   
    12  - public FieldArg(FieldInfo field, RegisterArg reg) {
     12 + public FieldArg(FieldInfo field, InsnArg reg) {
    13 13   super(-1);
    14  - this.regArg = reg;
     14 + this.instArg = reg;
    15 15   this.field = field;
    16 16   }
    17 17   
    skipped 1 lines
    19 19   return field;
    20 20   }
    21 21   
    22  - public RegisterArg getRegisterArg() {
    23  - return regArg;
     22 + public InsnArg getInstanceArg() {
     23 + return instArg;
    24 24   }
    25 25   
    26 26   public boolean isStatic() {
    27  - return regArg == null;
     27 + return instArg == null;
    28 28   }
    29 29   
    30 30   @Override
    skipped 23 lines
    54 54   if (!field.equals(fieldArg.field)) {
    55 55   return false;
    56 56   }
    57  - if (regArg != null ? !regArg.equals(fieldArg.regArg) : fieldArg.regArg != null) {
     57 + if (instArg != null ? !instArg.equals(fieldArg.instArg) : fieldArg.instArg != null) {
    58 58   return false;
    59 59   }
    60 60   return true;
    skipped 3 lines
    64 64   public int hashCode() {
    65 65   int result = super.hashCode();
    66 66   result = 31 * result + field.hashCode();
    67  - result = 31 * result + (regArg != null ? regArg.hashCode() : 0);
     67 + result = 31 * result + (instArg != null ? instArg.hashCode() : 0);
    68 68   return result;
    69 69   }
    70 70   
    skipped 6 lines
  • ■ ■ ■ ■ ■
    jadx-core/src/main/java/jadx/core/dex/visitors/SimplifyVisitor.java
    skipped 13 lines
    14 14  import jadx.core.dex.instructions.args.InsnArg;
    15 15  import jadx.core.dex.instructions.args.InsnWrapArg;
    16 16  import jadx.core.dex.instructions.args.LiteralArg;
    17  -import jadx.core.dex.instructions.args.RegisterArg;
    18 17  import jadx.core.dex.instructions.mods.ConstructorInsn;
    19 18  import jadx.core.dex.nodes.BlockNode;
    20 19  import jadx.core.dex.nodes.InsnNode;
    skipped 165 lines
    186 185   return null;
    187 186   }
    188 187   try {
    189  - RegisterArg reg = null;
     188 + InsnArg reg = null;
    190 189   if (getType == InsnType.IGET) {
    191  - reg = ((RegisterArg) get.getArg(0));
     190 + reg = get.getArg(0);
    192 191   }
    193 192   FieldArg fArg = new FieldArg(field, reg);
    194 193   if (reg != null) {
    skipped 36 lines
  • ■ ■ ■ ■ ■ ■
    jadx-core/src/main/java/jadx/core/utils/InstructionRemover.java
    skipped 2 lines
    3 3  import jadx.core.Consts;
    4 4  import jadx.core.dex.attributes.AFlag;
    5 5  import jadx.core.dex.instructions.args.InsnArg;
     6 +import jadx.core.dex.instructions.args.InsnWrapArg;
    6 7  import jadx.core.dex.instructions.args.RegisterArg;
    7 8  import jadx.core.dex.instructions.args.SSAVar;
    8 9  import jadx.core.dex.nodes.BlockNode;
    skipped 56 lines
    65 66   mth.removeSVar(r.getSVar());
    66 67   }
    67 68   for (InsnArg arg : insn.getArguments()) {
    68  - if (arg instanceof RegisterArg) {
    69  - RegisterArg reg = (RegisterArg) arg;
    70  - SSAVar sVar = reg.getSVar();
    71  - if (sVar != null) {
    72  - sVar.removeUse(reg);
    73  - }
     69 + unbindArgUsage(mth, arg);
     70 + }
     71 + insn.add(AFlag.INCONSISTENT_CODE);
     72 + }
     73 + 
     74 + public static void unbindArgUsage(MethodNode mth, InsnArg arg) {
     75 + if (arg instanceof RegisterArg) {
     76 + RegisterArg reg = (RegisterArg) arg;
     77 + SSAVar sVar = reg.getSVar();
     78 + if (sVar != null) {
     79 + sVar.removeUse(reg);
    74 80   }
     81 + } else if (arg instanceof InsnWrapArg) {
     82 + InsnWrapArg wrap = (InsnWrapArg) arg;
     83 + unbindInsn(mth, wrap.getWrapInsn());
    75 84   }
    76  - insn.add(AFlag.INCONSISTENT_CODE);
    77 85   }
    78 86   
    79 87   // Don't use 'insns.removeAll(toRemove)' because it will remove instructions by content
    skipped 42 lines
  • ■ ■ ■ ■
    jadx-core/src/test/java/jadx/tests/internal/TestFieldIncrement.java jadx-core/src/test/java/jadx/tests/internal/arith/TestFieldIncrement.java
    1  -package jadx.tests.internal;
     1 +package jadx.tests.internal.arith;
    2 2   
    3 3  import jadx.api.InternalJadxTest;
    4 4  import jadx.core.dex.nodes.ClassNode;
    skipped 38 lines
  • ■ ■ ■ ■ ■ ■
    jadx-core/src/test/java/jadx/tests/internal/arith/TestFieldIncrement2.java
     1 +package jadx.tests.internal.arith;
     2 + 
     3 +import jadx.api.InternalJadxTest;
     4 +import jadx.core.dex.nodes.ClassNode;
     5 + 
     6 +import org.junit.Test;
     7 + 
     8 +import static org.hamcrest.CoreMatchers.containsString;
     9 +import static org.junit.Assert.assertThat;
     10 + 
     11 +public class TestFieldIncrement2 extends InternalJadxTest {
     12 + 
     13 + class A {
     14 + int f = 5;
     15 + }
     16 + 
     17 + public static class TestCls {
     18 + public A a;
     19 + 
     20 + public void test1(int n) {
     21 + this.a.f = this.a.f + n;
     22 + }
     23 + 
     24 + public void test2(int n) {
     25 + this.a.f *= n;
     26 + }
     27 + }
     28 + 
     29 + @Test
     30 + public void test() {
     31 + ClassNode cls = getClassNode(TestCls.class);
     32 + String code = cls.getCode().toString();
     33 + System.out.println(code);
     34 + 
     35 + assertThat(code, containsString("this.a.f += n;"));
     36 + assertThat(code, containsString("a.f *= n;"));
     37 + // TODO
     38 + // assertThat(code, containsString("this.a.f *= n;"));
     39 + }
     40 +}
     41 + 
Please wait...
Page is in error, reload to recover