Exemple #1
0
 /**
  * Returns the ending statement for a method based on an expression. If the return type is void
  * then the ending statement just executes the expression otherwise it returns it.
  */
 public static JStatement makeMethodEndStatement(JType returnType, JExpression expression) {
   // TODO(rluble): Check if something needs to be done here regarding boxing/unboxing/coercions
   // when one of the types of expression and returnType is a boxed type and the other a primitive
   // type or both are primitive of differnent coerceable types. Add the proper tests first.
   return returnType == JPrimitiveType.VOID
       ? expression.makeStatement()
       : expression.makeReturnStatement();
 }
Exemple #2
0
 @Override
 public void endVisit(JDeclarationStatement x, Context ctx) {
   super.endVisit(x, ctx);
   lValues.pop();
   // The variable may have been pruned.
   if (isVariablePruned(x.getVariableRef().getTarget())) {
     JExpression replacement =
         makeReplacementForAssignment(x.getSourceInfo(), x.getVariableRef(), x.getInitializer());
     ctx.replaceMe(replacement.makeStatement());
   }
 }