예제 #1
0
 private StringStatus getStringStatus(JReferenceType type) {
   JClassType stringType = program.getTypeJavaLangString();
   if (type.isNullType()) {
     return StringStatus.NULL;
   } else if (program.typeOracle.castSucceedsTrivially(type, stringType)) {
     return StringStatus.STRING;
   } else if (program.typeOracle.castFailsTrivially(type, stringType)) {
     return StringStatus.NOTSTRING;
   } else {
     return StringStatus.UNKNOWN;
   }
 }
예제 #2
0
파일: JjsUtils.java 프로젝트: uddata/gwt
  /** Returns an ast node representing the expression {@code expression != null}. */
  public static JExpression createOptimizedNotNullComparison(
      JProgram program, SourceInfo info, JExpression expression) {
    JReferenceType type = (JReferenceType) expression.getType();
    if (type.isNullType()) {
      return program.getLiteralBoolean(false);
    }

    if (!type.canBeNull()) {
      return createOptimizedMultiExpression(expression, program.getLiteralBoolean(true));
    }

    return new JBinaryOperation(
        info,
        program.getTypePrimitiveBoolean(),
        JBinaryOperator.NEQ,
        expression,
        program.getLiteralNull());
  }