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

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


      if (triviallyTrue) {
        // remove the cast operation
        ctx.replaceMe(x.getExpr());
      } else if (triviallyFalse && toType != program.getTypeNull()) {
        // replace with a magic NULL cast, unless it's already a cast to NULL
        JCastOperation newOp = new JCastOperation(x.getSourceInfo(),
            program.getTypeNull(), x.getExpr());
        ctx.replaceMe(newOp);
      } else {
        // If possible, try to use a narrower cast
        JReferenceType tighterType = getSingleConcreteType(toType);

        if (tighterType != null && tighterType != toType) {
          JCastOperation newOp = new JCastOperation(x.getSourceInfo(),
              tighterType, x.getExpr());
          ctx.replaceMe(newOp);
        }
      }
    }
View Full Code Here


    // no simplification made
    if (original != null) {
      return original;
    }
    return new JCastOperation(info, type, exp);
  }
View Full Code Here

    }

    JExpression processExpression(CastExpression x) {
      SourceInfo info = makeSourceInfo(x);
      JType type = (JType) typeMap.get(x.resolvedType);
      JCastOperation cast = new JCastOperation(info, type,
          dispProcessExpression(x.expression));
      return cast;
    }
View Full Code Here

    private JExpression maybeCast(JType expected, JExpression expression) {
      if (expected != expression.getType()) {
        // Must be a generic; insert a cast operation.
        JReferenceType toType = (JReferenceType) expected;
        return new JCastOperation(expression.getSourceInfo(), toType,
            expression);
      } else {
        return expression;
      }
    }
View Full Code Here

  protected JExpression modifyResultOperation(JBinaryOperation op) {
    JType lhsType = op.getLhs().getType();
    JType rhsType = op.getRhs().getType();
    if (lhsType != rhsType) {
      // first widen binary op to encompass both sides, then add narrow cast
      return new JCastOperation(op.getSourceInfo(), lhsType,
          new JBinaryOperation(op.getSourceInfo(),
              widenType(lhsType, rhsType),
              op.getOp(),
              op.getLhs(), op.getRhs()));
    }
View Full Code Here

       * keep track of 'castOpsToIgnore'.
       */
      if (x.getField() == enumOrdinalField) {
        if (x.getInstance() != null &&
            x.getInstance() instanceof JCastOperation) {
          JCastOperation castOp = (JCastOperation) x.getInstance();
          if (getPossiblyUnderlyingType(castOp.getCastType()) == enumType) {
            JEnumType fromType = getEnumType(castOp.getExpr().getType());
            if (fromType != null) {
              castOpsToIgnore.push(castOp);
            }
          }
        }
View Full Code Here

       * the castOperation's sub-expression.
       */
      if (x.getTarget() == enumOrdinalMethod) {
        if (x.getInstance() != null &&
            x.getInstance() instanceof JCastOperation) {
          JCastOperation castOp = (JCastOperation) x.getInstance();
          if (getPossiblyUnderlyingType(castOp.getCastType()) == enumType) {
            JEnumType fromType = getEnumType(castOp.getExpr().getType());
            if (fromType != null) {
              castOpsToIgnore.push(castOp);
            }
          }
        }
View Full Code Here

             * See if this reference to Enum.ordinal is via a cast from an enum
             * sub-class, that we've already ordinalized to JPrimitiveType.INT.
             * If so, replace the whole cast operation.
             * (see JFieldRef visit method in CannotBeOrdinalAnalyzer above).
             */
            JCastOperation castOp = (JCastOperation) x.getInstance();
            if (getPossiblyUnderlyingType(castOp.getType()) == enumType) {
              if (castOp.getExpr().getType() == JPrimitiveType.INT) {
                ctx.replaceMe(castOp.getExpr());
              }
            }
          }
        }
      }
View Full Code Here

             * See if this reference to Enum.ordinal() is via a cast from an enum
             * sub-class, that we've already ordinalized to JPrimitiveType.INT.
             * If so, replace the whole cast operation.
             * (see JMethodCall visit method in CannotBeOrdinalAnalyzer above).
             */
            JCastOperation castOp = (JCastOperation) x.getInstance();
            if (getPossiblyUnderlyingType(castOp.getType()) == enumType) {
              if (castOp.getExpr().getType() == JPrimitiveType.INT) {
                ctx.replaceMe(castOp.getExpr());
              }
            }
          }
        }
      }
View Full Code Here

    public void endVisit(CastExpression x, BlockScope scope) {
      try {
        SourceInfo info = makeSourceInfo(x);
        JType type = typeMap.get(x.resolvedType);
        JExpression expression = pop(x.expression);
        push(new JCastOperation(info, type, expression));
      } catch (Throwable e) {
        throw translateException(x, e);
      }
    }
View Full Code Here

TOP

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

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.