use of com.google.devtools.j2objc.ast.ParenthesizedExpression in project j2objc by google.
the class TreeConverter method convertParenthesizedExpression.
private static TreeNode convertParenthesizedExpression(org.eclipse.jdt.core.dom.ParenthesizedExpression node) {
ParenthesizedExpression newNode = new ParenthesizedExpression();
convertExpression(node, newNode);
return newNode.setExpression((Expression) TreeConverter.convert(node.getExpression()));
}
use of com.google.devtools.j2objc.ast.ParenthesizedExpression in project j2objc by google.
the class Autoboxer method endVisit.
@Override
public void endVisit(CastExpression node) {
TypeMirror castType = node.getTypeMirror();
Expression expr = node.getExpression();
TypeMirror exprType = expr.getTypeMirror();
if (castType.getKind().isPrimitive() && !exprType.getKind().isPrimitive()) {
if (typeUtil.isAssignable(exprType, typeUtil.getJavaNumber().asType())) {
// Casting a Number object to a primitive, convert to value method.
unbox(expr, (PrimitiveType) castType);
} else {
// Casting an object to a primitive. Convert the cast type to the wrapper
// so that we do a proper cast check, as Java would.
castType = typeUtil.boxedClass((PrimitiveType) castType).asType();
node.setType(Type.newType(castType));
boxOrUnboxExpression(expr, castType);
}
} else {
boxOrUnboxExpression(expr, castType);
}
Expression newExpr = node.getExpression();
if (newExpr != expr) {
TreeNode parent = node.getParent();
if (parent instanceof ParenthesizedExpression) {
parent.replaceWith(TreeUtil.remove(newExpr));
} else {
node.replaceWith(TreeUtil.remove(newExpr));
}
}
}
Aggregations