@Internal public class BlockStatementRewriter extends Object implements CodeRewriter
This rewriter only deals with functions without return values. Functions with return values
should have been converted by ReturnValueRewriter
. Also, this rewriter will not extract
blocks containing return
statements for correctness.
Before
public class Example {
int b;
int c;
public void myFun(int a) {
int counter = 10;
while (counter > 0) {
int localA = a + 1000;
System.out.println(localA);
if (a > 0) {
b = a * 2;
c = b * 2;
System.out.println(b);
} else {
b = a * 3;
System.out.println(b);
}
counter--;
}
}
}
After
public class Example {
int b;
int c;
public void myFun(int a) {
int counter = 10;
while (counter > 0) {
myFun_rewriteGroup1(a);
counter--;
}
}
void myFun_rewriteGroup1(int a) {
myFun_whileBody0_0(a);
if (a > 0) {
myFun_whileBody0_0_ifBody0(a);
} else {
myFun_whileBody0_0_ifBody1(a);
}
}
void myFun_whileBody0_0(int a) {
int localA = a + 1000;
System.out.println(localA);
}
void myFun_whileBody0_0_ifBody1(int a) {
b = a * 3;
System.out.println(b);
}
void myFun_whileBody0_0_ifBody0(int a) {
b = a * 2;
c = b * 2;
System.out.println(b);
}
}
Constructor and Description |
---|
BlockStatementRewriter(String code,
long maxMethodLength) |
public BlockStatementRewriter(String code, long maxMethodLength)
public String rewrite()
rewrite
in interface CodeRewriter
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.