Package com.google.gwt.dev.jjs.ast

Examples of com.google.gwt.dev.jjs.ast.JPrimitiveType


        // Assume a long type.
        JType coerceTo = longType;

        // But double / float takes precedence over long.
        JPrimitiveType floatType = program.getTypePrimitiveFloat();
        JPrimitiveType doubleType = program.getTypePrimitiveDouble();
        // See if the lhs can coerce the rhs
        if ((lhsType == floatType || lhsType == doubleType)) {
          coerceTo = lhsType;
        }
        if (x.getOp().isAssignment()) {
View Full Code Here


      if (targetType != longType && argType != longType) {
        return arg;
      }
      if (arg instanceof JValueLiteral && targetType instanceof JPrimitiveType) {
        // Attempt to coerce the literal.
        JPrimitiveType primitiveType = (JPrimitiveType) targetType;
        JValueLiteral coerced = primitiveType.coerceLiteral((JValueLiteral) arg);
        if (coerced != null) {
          return coerced;
        }
      }
      // Synthesize a cast to long to force explicit conversion.
View Full Code Here

    /**
     * Handle special rescues needed implicitly to support concat.
     */
    private void rescueByConcat(JType type) {
      JClassType stringType = program.getTypeJavaLangString();
      JPrimitiveType charType = program.getTypePrimitiveChar();
      if (type instanceof JReferenceType && type != stringType
          && type != program.getTypeNull()) {
        /*
         * Any reference types (except String, which works by default) that take
         * part in a concat must rescue java.lang.Object.toString().
View Full Code Here

        /*
         * See JLS 5.1.3: if a cast narrows from one type to another, we must
         * call a narrowing conversion function. EXCEPTION: we currently have no
         * way to narrow double to float, so don't bother.
         */
        JPrimitiveType tByte = program.getTypePrimitiveByte();
        JPrimitiveType tChar = program.getTypePrimitiveChar();
        JPrimitiveType tShort = program.getTypePrimitiveShort();
        JPrimitiveType tInt = program.getTypePrimitiveInt();
        JPrimitiveType tLong = program.getTypePrimitiveLong();
        JPrimitiveType tFloat = program.getTypePrimitiveFloat();
        JPrimitiveType tDouble = program.getTypePrimitiveDouble();
        JType fromType = expr.getType();

        String methodName = null;

        if (tLong == fromType && tLong != toType) {
View Full Code Here

    /**
     * Handle special rescues needed implicitly to support concat.
     */
    private void rescueByConcat(JType type) {
      JPrimitiveType charType = program.getTypePrimitiveChar();
      JClassType stringType = program.getTypeJavaLangString();
      if (type instanceof JReferenceType
          && !program.typeOracle.canTriviallyCast((JReferenceType) type,
              stringType) && type != program.getTypeNull()) {
        /*
 
View Full Code Here

        // Assume a long type.
        JType coerceTo = longType;

        // But double / float takes precedence over long.
        JPrimitiveType floatType = program.getTypePrimitiveFloat();
        JPrimitiveType doubleType = program.getTypePrimitiveDouble();
        // See if the lhs can coerce the rhs
        if ((lhsType == floatType || lhsType == doubleType)) {
          coerceTo = lhsType;
        }
        if (op.isAssignment()) {
View Full Code Here

        ctx.replaceMe(newExpr);
      }
    }

    private JExpression coerceToString(JExpression expr) {
      final JPrimitiveType typePrimitiveChar = program.getTypePrimitiveChar();
      final JPrimitiveType typePrimitiveLong = program.getTypePrimitiveLong();

      if (expr instanceof JLongLiteral) {
        // Replace the literal by a string containing the literal.
        long longValue = ((JLongLiteral) expr).getValue();
        return program.getStringLiteral(expr.getSourceInfo(), String.valueOf(longValue));
View Full Code Here

      return false;
    }

    private JMethod getStringValueOfCharMethod() {
      JPrimitiveType charType = program.getTypePrimitiveChar();
      JClassType stringType = program.getTypeJavaLangString();
      if (stringValueOfChar != null) {
        return stringValueOfChar;
      }
View Full Code Here

    /**
     * Handle special rescues needed implicitly to support concat.
     */
    private void rescueByConcat(JType type) {
      JPrimitiveType charType = program.getTypePrimitiveChar();
      JClassType stringType = program.getTypeJavaLangString();
      if (type instanceof JReferenceType
          && !program.typeOracle.canTriviallyCast((JReferenceType) type, stringType)
          && type != program.getTypeNull()) {
        /*
 
View Full Code Here

    if (type == exp.getType()) {
      return exp;
    }
    if ((type instanceof JPrimitiveType) && (exp instanceof JValueLiteral)) {
      // Statically evaluate casting literals.
      JPrimitiveType typePrim = (JPrimitiveType) type;
      JValueLiteral expLit = (JValueLiteral) exp;
      JValueLiteral casted = typePrim.coerceLiteral(expLit);
      if (casted != null) {
        return casted;
      }
    }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.jjs.ast.JPrimitiveType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.