calculateResolveType() is much more expensive than checking if an
expression is an integer literal, so swap the conditions around.
Signed-off-by: Graham <gpe@openrs2.dev>
Some character literals are treated as integers by Fernflower, as the
complement operator always evaluates to an integer, even if its operand
is a character. This is fine, but ComplementTransformer removes some
complement transformers - leaving integer literals where Fernflower
would normally insert a character literal.
This transformer converts complemented integers to char literals in some
cases where it makes sense (it is difficult to perform this
transformation across every type of expression in JavaParser).
Signed-off-by: Graham <gpe@openrs2.dev>
Unfortunately we can't use the compiler to guarantee k isn't changed,
though making it internal will help. When the JVM (and Kotlin) get value
types, we might be able to improve on this (e.g. by making it an inline
class of four integers).
Signed-off-by: Graham <gpe@openrs2.dev>
This commit improves support for simplifying a series of multiple
additions/subtractions and doing so in a single pass.
Signed-off-by: Graham <gpe@openrs2.dev>
This commit makes two changes:
* Uses the is operator instead of the isXXX methods provided by
JavaParser, allowing smart casts to be used.
* Wraps unsupported expressions with a unary minus expression, rather
than throwing an exception.
Signed-off-by: Graham <gpe@openrs2.dev>
This commit updates the tests to ensure all combinations of 0-7 bytes of
leading/trailing blocks of unencrypted bytes work correctly with all
test vectors.
Signed-off-by: Graham <gpe@openrs2.dev>
We could use LocalVariableTable in theory, but it's more complicated as
we'd need to do live variable analysis and type inference. It's much
easier to leave that for the decompiler.
Signed-off-by: Graham <gpe@openrs2.dev>
The next commit will introduce an ArgRef class which uses a MemberRef
directly, rather than a MemberRef partition.
Signed-off-by: Graham <gpe@openrs2.dev>