Graham
4314aededd
Simplify hasSideEffects() calls in AddSubTransformer
5 years ago
Graham
784b14b66b
Improve safety of ForLoopConditionTransformer
...
Desetude noticed that there are some cases where this transformation is
unsafe - for example: `i > i++`. Skipping the transform if _either_ side
of the comparison has a side effect, rather than _both_ sides, makes it
safe.
5 years ago
Graham
ab75a2f0c9
Add IdentityTransformer
5 years ago
Graham
2e1db9f0b1
Don't swap for loop conditions where both sides have a side effect
5 years ago
Desetude
d8c3f4e31c
Flip > and >= in for loop conditions to < and <= respectively
...
Signed-off-by: Graham <gpe@openrs2.dev>
5 years ago
Graham
d9762d65bc
Fix Kotlin inspections
5 years ago
Graham
575632413a
Add missing private modifier
5 years ago
Graham
7d1dc59d6a
Convert pre-increments to post-increments where possible
5 years ago
Graham
e9a9a8f962
Format with ktlint
5 years ago
Graham
4df5754dac
Include generics in Function cast
...
The Kotlin compiler was happy with the old code, but IDEA wasn't.
Including the generics explicitly in the cast makes both happy.
5 years ago
Graham
77e8b0cdc0
Use top-level Kotlin main() functions
5 years ago
Graham
01ec848d49
Remove blocks in NegativeLiteralTransformer when statement
...
Each case is very simple so I don't think we need to bother with the blocks.
5 years ago
Graham
130a05956e
Convert ExprUtils to Kotlin
5 years ago
Graham
fc00d69539
Convert TypeUtils to Kotlin
5 years ago
Graham
e3baede541
Convert NodeUtils to Kotlin
...
This commit also changes walk() to be an extension function and use reified
generics.
5 years ago
Graham
9f09a81db1
Convert EncloseTransformer to Kotlin
5 years ago
Graham
53160e422d
Convert IfElseTransformer to Kotlin
5 years ago
Graham
9b81c813dd
Convert AstDeobfuscator to Kotlin
5 years ago
Graham
6425a874fd
Convert AddSubTransformer to Kotlin
5 years ago
Graham
e357f07c27
Convert BinaryExprOrderTransformer to Kotlin
5 years ago
Graham
5b032c980f
Convert BitMaskTransformer to Kotlin
5 years ago
Graham
8ac16d722b
Convert ComplementTransformer to Kotlin
5 years ago
Graham
d5cee1b2f5
Make NewInstanceTransformer idempotent
5 years ago
Graham
320a8a7f8a
Convert NewInstanceTransformer to Kotlin
5 years ago
Graham
faec1f1a26
Convert TernaryTransformer to Kotlin
5 years ago
Graham
38a3e752f9
Convert NegativeLiteralTransformer to Kotlin
5 years ago
Graham
ba66c47799
Convert UnencloseTransformer to Kotlin
5 years ago
Graham
fc34f18e92
Convert ValueOfTransformer to Kotlin
5 years ago
Graham
afb52c2e93
Convert Transformer to Kotlin
5 years ago
Graham
bcbf4b6178
Replace newInstance() with getDeclaredConstructor().newInstance()
...
Again, if these are removed from a future JDK we'll need to move this
transform to the bytecode deobfuscator.
5 years ago
Graham
328b122330
Add ValueOfTransformer
...
Might need to move to the bytecode deobfuscator if public boxed type
constructors are removed from future JDKs, but for now it's easier to do
this on the AST level.
5 years ago
Graham
5e46c058cd
Improve structuring of if/else chains ending in a throw or return
5 years ago
Graham
aa7f90ceb6
Prevent if statements in swapped else blocks from incorrectly chaining
5 years ago
Graham
17d9a51669
Use single line comment in IfElseTransformer
5 years ago
Graham
e2b2a77fd8
Remove unused isNot() method
5 years ago
Graham
f69999679e
Add missing clone() calls to ExprUtils.not()
5 years ago
Graham
81f5fcf6dc
Remove EnclosedExpr support from functions that no longer require it
5 years ago
Graham
4e3c5f3d4d
Remove use of deprecated getChildNodesByType method
5 years ago
Graham
828b130906
Always iterate through the JavaParser tree in POSTORDER
...
I think this is less prone to errors than the default order.
5 years ago
Graham
6742120ab6
Simplify else if chains in POSTORDER
...
This prevents us from missing some nested cases.
5 years ago
Graham
a5e9a788e8
Use var in isIf/getIf
5 years ago
Graham
555620887f
Use same heuristic in TernaryTransformer as IfElseTransformer
5 years ago
Graham
f742aba80d
Replace simple if condition swapping heuristic with a smarter one
...
This allows us to change expressions like `!a && !b` to `a || b`. It
isn't perfect, as we will now flip bitwise flag checks (which was one of
the main motivations for the old heuristic).
5 years ago
Graham
e202c4fcb9
Clone if/else arms before swapping them
...
This fixes a bug where some of the later transforms didn't run on the
swapped arms.
5 years ago
Graham
012d5ed0db
Simplify combined shift/mask operations
5 years ago
Graham
7d959ed135
Remove and later re-add brackets to simplify intermediate transforms
5 years ago
Graham
14354a22f3
Transform `-x + y` to `y - x` unless both have side effects
5 years ago
Graham
fcc053270d
Remove NegateExprVisitor
...
It's actually cleaner to do this without one!
5 years ago
Graham
12d3af48dd
Add TernaryTransformer
5 years ago
Graham
eadea9231c
Add AddSubTransformer
5 years ago