-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Description
There are some issues like
- Add support for simplifying constant expressions in
PartialEvaluator
#494 - Suggest
SomeListing.of(1, 2, 6, ...).contains(c)
in place ofc == 1 || c == 2 || c == 6 ....
#555
that would benefit from this. The core problem is that (a + b) + c
and c + b + a
are represented differently in the model, even though they are effectively the same.
There are some cases where this is not true, like for a != null && a.getValue() == 5 && b == 3
, where the a != null
must be before the other uses, because of short-circuiting and potential side-effects.
The idea is to introduce a class like this
record BinaryOperatorView(List<CtExpression<?>> operands, BinaryOperatorKind operator) {
// TODO: Maybe save the original expression internally in the class?
}
That can then be used to group operands, when they match certain criteria and join the remainder.
The class would be constructed from a given CtBinaryOperator
. It should ideally support translating a - b + c
to a + (-b) + c
, which can then be optimized if necessary.
Metadata
Metadata
Assignees
Labels
No labels