< prev index next >

src/jdk/nashorn/internal/ir/BinaryNode.java

Print this page

        

@@ -68,11 +68,13 @@
                 TokenType.SUB,
                 TokenType.ASSIGN_ADD,
                 TokenType.ASSIGN_DIV,
                 TokenType.ASSIGN_MOD,
                 TokenType.ASSIGN_MUL,
-                TokenType.ASSIGN_SUB
+                TokenType.ASSIGN_SUB,
+                TokenType.SHR,
+                TokenType.ASSIGN_SHR
             })));
 
     /**
      * Constructor
      *

@@ -194,13 +196,11 @@
                 // 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()) {
+            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,11 +208,11 @@
             // 1 + {valueOf: function() { return "2" }} == "12".
             return Type.OBJECT;
         }
         case SHR:
         case ASSIGN_SHR:
-            return Type.LONG;
+            return Type.NUMBER;
         case ASSIGN_SAR:
         case ASSIGN_SHL:
         case BIT_AND:
         case BIT_OR:
         case BIT_XOR:

@@ -237,14 +237,10 @@
             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;
         }

@@ -563,10 +559,13 @@
         }
         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 >