Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
30fbf4bc
Commit
30fbf4bc
authored
Apr 24, 2019
by
Ahmed Ashour
Committed by
skylot
Apr 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: better place for removing parenthesis (PR #627)
parent
9645f33c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
22 deletions
+9
-22
ArithOp.java
...ore/src/main/java/jadx/core/dex/instructions/ArithOp.java
+0
-7
InsnArg.java
...rc/main/java/jadx/core/dex/instructions/args/InsnArg.java
+0
-8
PrepareForCodeGen.java
...c/main/java/jadx/core/dex/visitors/PrepareForCodeGen.java
+9
-7
No files found.
jadx-core/src/main/java/jadx/core/dex/instructions/ArithOp.java
View file @
30fbf4bc
...
...
@@ -24,11 +24,4 @@ public enum ArithOp {
public
String
getSymbol
()
{
return
this
.
symbol
;
}
public
boolean
noWrapWith
(
ArithOp
other
)
{
return
(
this
==
ADD
&&
other
==
ADD
)
||
(
this
==
MUL
&&
other
==
MUL
)
||
(
this
==
AND
&&
other
==
AND
)
||
(
this
==
OR
&&
other
==
OR
);
}
}
jadx-core/src/main/java/jadx/core/dex/instructions/args/InsnArg.java
View file @
30fbf4bc
...
...
@@ -9,8 +9,6 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
jadx.core.dex.attributes.AFlag
;
import
jadx.core.dex.instructions.ArithNode
;
import
jadx.core.dex.instructions.InsnType
;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.utils.InsnUtils
;
...
...
@@ -113,12 +111,6 @@ public abstract class InsnArg extends Typed {
insn
.
add
(
AFlag
.
WRAPPED
);
InsnArg
arg
=
wrapArg
(
insn
);
parent
.
setArg
(
i
,
arg
);
if
(
insn
.
getType
()
==
InsnType
.
ARITH
&&
parent
.
getType
()
==
InsnType
.
ARITH
&&
((
ArithNode
)
insn
).
getOp
().
noWrapWith
(((
ArithNode
)
parent
).
getOp
()))
{
insn
.
add
(
AFlag
.
DONT_WRAP
);
}
return
arg
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/PrepareForCodeGen.java
View file @
30fbf4bc
...
...
@@ -42,7 +42,7 @@ public class PrepareForCodeGen extends AbstractVisitor {
}
removeInstructions
(
block
);
checkInline
(
block
);
//
removeParenthesis(block);
removeParenthesis
(
block
);
modifyArith
(
block
);
}
}
...
...
@@ -99,7 +99,7 @@ public class PrepareForCodeGen extends AbstractVisitor {
private
static
void
removeParenthesis
(
BlockNode
block
)
{
for
(
InsnNode
insn
:
block
.
getInstructions
())
{
checkInsn
(
insn
);
removeParenthesis
(
insn
);
}
}
...
...
@@ -107,17 +107,19 @@ public class PrepareForCodeGen extends AbstractVisitor {
* Remove parenthesis for wrapped insn in arith '+' or '-'
* ('(a + b) +c' => 'a + b + c')
*/
private
static
void
checkInsn
(
InsnNode
insn
)
{
private
static
void
removeParenthesis
(
InsnNode
insn
)
{
if
(
insn
.
getType
()
==
InsnType
.
ARITH
)
{
ArithNode
arith
=
(
ArithNode
)
insn
;
ArithOp
op
=
arith
.
getOp
();
if
(
op
==
ArithOp
.
ADD
||
op
==
ArithOp
.
SUB
)
{
if
(
op
==
ArithOp
.
ADD
||
op
==
ArithOp
.
MUL
||
op
==
ArithOp
.
AND
||
op
==
ArithOp
.
OR
)
{
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
InsnArg
arg
=
arith
.
getArg
(
i
);
if
(
arg
.
isInsnWrap
())
{
InsnNode
wrapInsn
=
((
InsnWrapArg
)
arg
).
getWrapInsn
();
wrapInsn
.
add
(
AFlag
.
DONT_WRAP
);
checkInsn
(
wrapInsn
);
if
(
wrapInsn
.
getType
()
==
InsnType
.
ARITH
&&
((
ArithNode
)
wrapInsn
).
getOp
()
==
op
)
{
wrapInsn
.
add
(
AFlag
.
DONT_WRAP
);
}
removeParenthesis
(
wrapInsn
);
}
}
}
...
...
@@ -125,7 +127,7 @@ public class PrepareForCodeGen extends AbstractVisitor {
for
(
InsnArg
arg
:
insn
.
getArguments
())
{
if
(
arg
.
isInsnWrap
())
{
InsnNode
wrapInsn
=
((
InsnWrapArg
)
arg
).
getWrapInsn
();
checkInsn
(
wrapInsn
);
removeParenthesis
(
wrapInsn
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment