void foo() {
int a = bar();
int b = baz();
if (a == 0) {
doSomethingNontrivial();
}
}
I would like to use Mixins to rewrite the function a bit:
void foo() {
int a = bar();
int b = baz();
if (a == 0 || b == 0) {
baz();
}
}
To do this, the best option seems to be a @ModifyVariable on the value of a, but to do that I would need to capture the value of b as well. Currently, this is not possible. If the a == 0 was a method call, it would be possible to use an @Inject just before the comparison and set a to 0 if b is 0, but as the comparison becomes an IF_ICMPEQ it's impossible to target for an injection. @ModifyVariable already examines the LVT to determine the accesses it needs to inject bytecode at, so adding another local capture shouldn't make it any more fragile than it already is.
I have a function with the structure
I would like to use Mixins to rewrite the function a bit:
To do this, the best option seems to be a
@ModifyVariable
on the value ofa
, but to do that I would need to capture the value ofb
as well. Currently, this is not possible. If thea == 0
was a method call, it would be possible to use an@Inject
just before the comparison and seta
to 0 ifb
is 0, but as the comparison becomes anIF_ICMPEQ
it's impossible to target for an injection.@ModifyVariable
already examines the LVT to determine the accesses it needs to inject bytecode at, so adding another local capture shouldn't make it any more fragile than it already is.