예제 #1
0
파일: JjsUtils.java 프로젝트: uddata/gwt
 /**
  * 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();
 }
예제 #2
0
파일: JjsUtils.java 프로젝트: uddata/gwt
 public static void replaceMethodBody(JMethod method, JExpression returnValue) {
   JMethodBody body = (JMethodBody) method.getBody();
   JBlock block = body.getBlock();
   block.clear();
   block.addStmt(returnValue.makeReturnStatement());
 }