< prev index next >
src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/BinaryNode.java
Print this page
*** 68,78 ****
TokenType.SUB,
TokenType.ASSIGN_ADD,
TokenType.ASSIGN_DIV,
TokenType.ASSIGN_MOD,
TokenType.ASSIGN_MUL,
! TokenType.ASSIGN_SUB
})));
/**
* Constructor
*
--- 68,80 ----
TokenType.SUB,
TokenType.ASSIGN_ADD,
TokenType.ASSIGN_DIV,
TokenType.ASSIGN_MOD,
TokenType.ASSIGN_MUL,
! TokenType.ASSIGN_SUB,
! TokenType.SHR,
! TokenType.ASSIGN_SHR
})));
/**
* Constructor
*
*** 194,206 ****
// We can statically figure out that this is a string if either operand is a string. In this case, use
// CHARSEQUENCE to prevent it from being proactively flattened.
return Type.CHARSEQUENCE;
}
final Type widestOperandType = Type.widest(undefinedToNumber(booleanToInt(lhsType)), undefinedToNumber(booleanToInt(rhsType)));
! if(widestOperandType == Type.INT) {
! return Type.LONG;
! } else if (widestOperandType.isNumeric()) {
return Type.NUMBER;
}
// We pretty much can't know what it will be statically. Must presume OBJECT conservatively, as we can end
// up getting either a string or an object when adding something + object, e.g.:
// 1 + {} == "1[object Object]", but
--- 196,206 ----
// We can statically figure out that this is a string if either operand is a string. In this case, use
// CHARSEQUENCE to prevent it from being proactively flattened.
return Type.CHARSEQUENCE;
}
final Type widestOperandType = Type.widest(undefinedToNumber(booleanToInt(lhsType)), undefinedToNumber(booleanToInt(rhsType)));
! if (widestOperandType.isNumeric()) {
return Type.NUMBER;
}
// We pretty much can't know what it will be statically. Must presume OBJECT conservatively, as we can end
// up getting either a string or an object when adding something + object, e.g.:
// 1 + {} == "1[object Object]", but
*** 208,218 ****
// 1 + {valueOf: function() { return "2" }} == "12".
return Type.OBJECT;
}
case SHR:
case ASSIGN_SHR:
! return Type.LONG;
case ASSIGN_SAR:
case ASSIGN_SHL:
case BIT_AND:
case BIT_OR:
case BIT_XOR:
--- 208,218 ----
// 1 + {valueOf: function() { return "2" }} == "12".
return Type.OBJECT;
}
case SHR:
case ASSIGN_SHR:
! return Type.NUMBER;
case ASSIGN_SAR:
case ASSIGN_SHL:
case BIT_AND:
case BIT_OR:
case BIT_XOR:
*** 237,250 ****
final Type lhsType = lhs.getType();
final Type rhsType = rhs.getType();
if(lhsType == Type.BOOLEAN && rhsType == Type.BOOLEAN) {
return Type.INT;
}
- final Type widestOperandType = Type.widest(booleanToInt(lhsType), booleanToInt(rhsType));
- if(widestOperandType == Type.INT) {
- return Type.LONG;
- }
return Type.NUMBER;
}
case VOID: {
return Type.UNDEFINED;
}
--- 237,246 ----
*** 563,572 ****
--- 559,571 ----
}
final Type widest = getWidestOperationType();
if(type == null) {
return widest;
}
+ if (tokenType() == TokenType.ASSIGN_SHR || tokenType() == TokenType.SHR) {
+ return type;
+ }
return Type.narrowest(widest, Type.widest(type, Type.widest(lhs.getType(), rhs.getType())));
}
private static Type decideType(final Type lhsType, final Type rhsType) {
// Compare this to getWidestOperationType() for ADD and ASSIGN_ADD cases. There's some similar logic, but these
< prev index next >