Class ReturnValueRewriter

  • All Implemented Interfaces:
    CodeRewriter

    @Internal
    public class ReturnValueRewriter
    extends Object
    implements CodeRewriter
    Rewrite functions with return values by splitting them into two functions and storing the return values into member variables.

    Before

    
     public class Example {
         public int myFun(int a) {
             a += 1;
             return a;
         }
     }
     

    <After

    
     public class Example {
         int myFunReturnValue$0;
    
         public int myFun(int a) {
             myFunImpl(a);
             return myFunReturnValue$0;
         }
    
         void myFunImpl(int a) {
             a += 1;
             {
                 myFunReturnValue$0 = a;
                 return;
             }
         }
     }
     
    • Constructor Detail

      • ReturnValueRewriter

        public ReturnValueRewriter​(String code,
                                   int maxMethodLength)