use of com.sun.tools.javac.code.Symbol.OperatorSymbol in project ceylon-compiler by ceylon.
the class Attr method visitUnary.
public void visitUnary(JCUnary tree) {
// Attribute arguments.
Type argtype = (JCTree.PREINC <= tree.getTag() && tree.getTag() <= JCTree.POSTDEC) ? attribTree(tree.arg, env, VAR, Type.noType) : chk.checkNonVoid(tree.arg.pos(), attribExpr(tree.arg, env));
// Find operator.
Symbol operator = tree.operator = rs.resolveUnaryOperator(tree.pos(), tree.getTag(), env, argtype);
Type owntype = types.createErrorType(tree.type);
if (operator.kind == MTH && !argtype.isErroneous()) {
owntype = (JCTree.PREINC <= tree.getTag() && tree.getTag() <= JCTree.POSTDEC) ? tree.arg.type : operator.type.getReturnType();
int opc = ((OperatorSymbol) operator).opcode;
// If the argument is constant, fold it.
if (argtype.constValue() != null) {
Type ctype = cfolder.fold1(opc, argtype);
if (ctype != null) {
owntype = cfolder.coerce(ctype, owntype);
// operands are constant identifiers.
if (tree.arg.type.tsym == syms.stringType.tsym) {
tree.arg.type = syms.stringType;
}
}
}
}
result = check(tree, owntype, VAL, pkind, pt);
}
use of com.sun.tools.javac.code.Symbol.OperatorSymbol in project ceylon-compiler by ceylon.
the class Attr method visitBinary.
public void visitBinary(JCBinary tree) {
// Attribute arguments.
Type left = chk.checkNonVoid(tree.lhs.pos(), attribExpr(tree.lhs, env));
Type right = chk.checkNonVoid(tree.lhs.pos(), attribExpr(tree.rhs, env));
// Find operator.
Symbol operator = tree.operator = rs.resolveBinaryOperator(tree.pos(), tree.getTag(), env, left, right);
Type owntype = types.createErrorType(tree.type);
if (operator.kind == MTH && !left.isErroneous() && !right.isErroneous()) {
owntype = operator.type.getReturnType();
int opc = chk.checkOperator(tree.lhs.pos(), (OperatorSymbol) operator, tree.getTag(), left, right);
// If both arguments are constants, fold them.
if (left.constValue() != null && right.constValue() != null) {
Type ctype = cfolder.fold2(opc, left, right);
if (ctype != null) {
owntype = cfolder.coerce(ctype, owntype);
// operands are constant identifiers.
if (tree.lhs.type.tsym == syms.stringType.tsym) {
tree.lhs.type = syms.stringType;
}
if (tree.rhs.type.tsym == syms.stringType.tsym) {
tree.rhs.type = syms.stringType;
}
}
}
// castable to each other, (JLS???).
if ((opc == ByteCodes.if_acmpeq || opc == ByteCodes.if_acmpne)) {
if (!types.isCastable(left, right, new Warner(tree.pos()))) {
log.error(tree.pos(), "incomparable.types", left, right);
}
}
chk.checkDivZero(tree.rhs.pos(), operator, right);
}
result = check(tree, owntype, VAL, pkind, pt);
}
use of com.sun.tools.javac.code.Symbol.OperatorSymbol in project ceylon-compiler by ceylon.
the class Attr method visitAssignop.
public void visitAssignop(JCAssignOp tree) {
// Attribute arguments.
Type owntype = attribTree(tree.lhs, env, VAR, Type.noType);
Type operand = attribExpr(tree.rhs, env);
// Find operator.
Symbol operator = tree.operator = rs.resolveBinaryOperator(tree.pos(), tree.getTag() - JCTree.ASGOffset, env, owntype, operand);
if (operator.kind == MTH && !owntype.isErroneous() && !operand.isErroneous()) {
chk.checkOperator(tree.pos(), (OperatorSymbol) operator, tree.getTag() - JCTree.ASGOffset, owntype, operand);
chk.checkDivZero(tree.rhs.pos(), operator, operand);
chk.checkCastable(tree.rhs.pos(), operator.type.getReturnType(), owntype);
}
result = check(tree, owntype, VAL, pkind, pt);
}
Aggregations