Examples of JCastOperation


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

      return x;
    }
    // Assignment-to-cast-operation, e.g.
    // (Foo) x = foo -> x = foo
    // (Foo) x += foo -> x += foo
    JCastOperation cast = (JCastOperation) x.getLhs();
    return new JBinaryOperation(x.getSourceInfo(), x.getType(), x.getOp(), cast.getExpr(),
            x.getRhs());
  }
View Full Code Here

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

    if (targetType instanceof JReferenceType) {
      assert exp.getType() instanceof JReferenceType;
      targetType = merge((JReferenceType) exp.getType(), (JReferenceType) targetType);
    }
    if (!program.typeOracle.canTriviallyCast(exp.getType(), targetType)) {
      exp = new JCastOperation(exp.getSourceInfo(), targetType, exp);
    }
    return exp;
  }
View Full Code Here

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

        value = accept(new CloneExpressionVisitor().cloneExpression(field.getInitializer()));
        JType fieldType = field.getType().getUnderlyingType();
        assert fieldType instanceof JPrimitiveType || fieldType == program.getTypeJavaLangString()
            : fieldType.getName() + " is not a primitive nor String ";
        if (fieldType != value.getType()) {
          value = new JCastOperation(value.getSourceInfo(), fieldType, value);
        }
        resolveValuesByField.put(field, value);
      }
      return value;
    }
View Full Code Here

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

  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()));
    }
    return op;
  }
View Full Code Here

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

  public void endVisit(JCastOperation x, Context ctx) {
    // JCastOperation doesn't have a settable castType method, so need to
    // create a new one and do a replacement.
    JType remapCastType = remap(x.getCastType());
    if (remapCastType != x.getCastType()) {
      JCastOperation newX = new JCastOperation(x.getSourceInfo(),
                                               remapCastType, x.getExpr());
      ctx.replaceMe(newX);
    }
  }
View Full Code Here

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

        JType type = typeMap.get(x.resolvedType);
        JExpression expression = pop(x.expression);
        if (x.type instanceof NameReference) {
          pop(x.type);
        }
        push(new JCastOperation(info, type, expression));
      } catch (Throwable e) {
        throw translateException(x, e);
      }
    }
View Full Code Here

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

      assert valueOfMethod != null;

      // Add a cast to the correct primitive type if needed.
      JType targetPrimitiveType = typeMap.get(primitiveType);
      if (original.getType() != targetPrimitiveType) {
        original = new JCastOperation(original.getSourceInfo(), targetPrimitiveType, original);
      }

      JMethod boxMethod = typeMap.get(valueOfMethod);
      JMethodCall call = new JMethodCall(original.getSourceInfo(), null, boxMethod);
      call.addArg(original);
View Full Code Here

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

    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

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

    return false;
  }

  @Override
  public boolean visit(JCastOperation x, Context ctx) {
    expression = new JCastOperation(x.getSourceInfo(), x.getCastType(),
        cloneExpression(x.getExpr()));
    return false;
  }
View Full Code Here

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

   * Insert an implicit cast if the types differ; it might get optimized out
   * later, but in some cases it will force correct math evaluation.
   */
  private static JExpression maybeCast(JExpression exp, JType targetType) {
    if (exp.getType() != targetType) {
      exp = new JCastOperation(exp.getSourceInfo(), targetType, exp);
    }
    return exp;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.