Rename Mutex to DeprecatedMutex
[WebKit-https.git] / Source / JavaScriptCore / parser / ResultType.h
index 27b8112..ad86c98 100644 (file)
@@ -32,8 +32,7 @@ namespace JSC {
         friend struct OperandTypes;
 
         typedef char Type;
-        static const Type TypeReusable = 1;
-        static const Type TypeInt32    = 2;
+        static const Type TypeInt32 = 1;
         
         static const Type TypeMaybeNumber = 0x04;
         static const Type TypeMaybeString = 0x08;
@@ -48,11 +47,6 @@ namespace JSC {
         {
         }
         
-        bool isReusable()
-        {
-            return m_type & TypeReusable;
-        }
-
         bool isInt32()
         {
             return m_type & TypeInt32;
@@ -68,6 +62,11 @@ namespace JSC {
             return (m_type & TypeBits) == TypeMaybeString;
         }
 
+        bool definitelyIsBoolean()
+        {
+            return (m_type & TypeBits) == TypeMaybeBool;
+        }
+
         bool mightBeNumber()
         {
             return m_type & TypeMaybeNumber;
@@ -93,19 +92,14 @@ namespace JSC {
             return ResultType(TypeMaybeNumber);
         }
         
-        static ResultType numberTypeCanReuse()
-        {
-            return ResultType(TypeReusable | TypeMaybeNumber);
-        }
-        
-        static ResultType numberTypeCanReuseIsInt32()
+        static ResultType numberTypeIsInt32()
         {
-            return ResultType(TypeReusable | TypeInt32 | TypeMaybeNumber);
+            return ResultType(TypeInt32 | TypeMaybeNumber);
         }
         
-        static ResultType stringOrNumberTypeCanReuse()
+        static ResultType stringOrNumberType()
         {
-            return ResultType(TypeReusable | TypeMaybeNumber | TypeMaybeString);
+            return ResultType(TypeMaybeNumber | TypeMaybeString);
         }
         
         static ResultType stringType()
@@ -121,15 +115,28 @@ namespace JSC {
         static ResultType forAdd(ResultType op1, ResultType op2)
         {
             if (op1.definitelyIsNumber() && op2.definitelyIsNumber())
-                return numberTypeCanReuse();
+                return numberType();
             if (op1.definitelyIsString() || op2.definitelyIsString())
                 return stringType();
-            return stringOrNumberTypeCanReuse();
+            return stringOrNumberType();
         }
-        
+
+        // Unlike in C, a logical op produces the value of the
+        // last expression evaluated (and not true or false).
+        static ResultType forLogicalOp(ResultType op1, ResultType op2)
+        {
+            if (op1.definitelyIsBoolean() && op2.definitelyIsBoolean())
+                return booleanType();
+            if (op1.definitelyIsNumber() && op2.definitelyIsNumber())
+                return numberType();
+            if (op1.definitelyIsString() && op2.definitelyIsString())
+                return stringType();
+            return unknownType();
+        }
+
         static ResultType forBitOp()
         {
-            return numberTypeCanReuseIsInt32();
+            return numberTypeIsInt32();
         }
 
     private: