#ifndef PredictedType_h
#define PredictedType_h
#include "JSValue.h"
namespace JSC {
class Structure;
typedef uint32_t PredictedType;
static const PredictedType PredictNone = 0x00000000; static const PredictedType PredictFinalObject = 0x00000001; static const PredictedType PredictArray = 0x00000002; static const PredictedType PredictFunction = 0x00000008; static const PredictedType PredictInt8Array = 0x00000010; static const PredictedType PredictInt16Array = 0x00000020; static const PredictedType PredictInt32Array = 0x00000040; static const PredictedType PredictUint8Array = 0x00000080; static const PredictedType PredictUint8ClampedArray = 0x00000100; static const PredictedType PredictUint16Array = 0x00000200; static const PredictedType PredictUint32Array = 0x00000400; static const PredictedType PredictFloat32Array = 0x00000800; static const PredictedType PredictFloat64Array = 0x00001000; static const PredictedType PredictObjectOther = 0x00002000; static const PredictedType PredictObjectMask = 0x00003fff; static const PredictedType PredictString = 0x00004000; static const PredictedType PredictCellOther = 0x00008000; static const PredictedType PredictCell = 0x0000ffff; static const PredictedType PredictInt32 = 0x00010000; static const PredictedType PredictDoubleReal = 0x00020000; static const PredictedType PredictDoubleNaN = 0x00040000; static const PredictedType PredictDouble = 0x00060000; static const PredictedType PredictNumber = 0x00070000; static const PredictedType PredictBoolean = 0x00080000; static const PredictedType PredictOther = 0x08000000; static const PredictedType PredictTop = 0x0fffffff; static const PredictedType PredictEmpty = 0x10000000; static const PredictedType PredictEmptyOrTop = 0x1fffffff; static const PredictedType FixedIndexedStorageMask = PredictInt8Array | PredictInt16Array | PredictInt32Array | PredictUint8Array | PredictUint8ClampedArray | PredictUint16Array | PredictUint32Array | PredictFloat32Array | PredictFloat64Array;
typedef bool (*PredictionChecker)(PredictedType);
inline bool isCellPrediction(PredictedType value)
{
return !!(value & PredictCell) && !(value & ~PredictCell);
}
inline bool isObjectPrediction(PredictedType value)
{
return !!(value & PredictObjectMask) && !(value & ~PredictObjectMask);
}
inline bool isFinalObjectPrediction(PredictedType value)
{
return value == PredictFinalObject;
}
inline bool isFinalObjectOrOtherPrediction(PredictedType value)
{
return !!(value & (PredictFinalObject | PredictOther)) && !(value & ~(PredictFinalObject | PredictOther));
}
inline bool isFixedIndexedStorageObjectPrediction(PredictedType value)
{
return !!value && (value & FixedIndexedStorageMask) == value;
}
inline bool isStringPrediction(PredictedType value)
{
return value == PredictString;
}
inline bool isArrayPrediction(PredictedType value)
{
return value == PredictArray;
}
inline bool isFunctionPrediction(PredictedType value)
{
return value == PredictFunction;
}
inline bool isInt8ArrayPrediction(PredictedType value)
{
return value == PredictInt8Array;
}
inline bool isInt16ArrayPrediction(PredictedType value)
{
return value == PredictInt16Array;
}
inline bool isInt32ArrayPrediction(PredictedType value)
{
return value == PredictInt32Array;
}
inline bool isUint8ArrayPrediction(PredictedType value)
{
return value == PredictUint8Array;
}
inline bool isUint8ClampedArrayPrediction(PredictedType value)
{
return value == PredictUint8ClampedArray;
}
inline bool isUint16ArrayPrediction(PredictedType value)
{
return value == PredictUint16Array;
}
inline bool isUint32ArrayPrediction(PredictedType value)
{
return value == PredictUint32Array;
}
inline bool isFloat32ArrayPrediction(PredictedType value)
{
return value == PredictFloat32Array;
}
inline bool isFloat64ArrayPrediction(PredictedType value)
{
return value == PredictFloat64Array;
}
inline bool isActionableIntMutableArrayPrediction(PredictedType value)
{
return isInt8ArrayPrediction(value)
|| isInt16ArrayPrediction(value)
|| isInt32ArrayPrediction(value)
|| isUint8ArrayPrediction(value)
|| isUint8ClampedArrayPrediction(value)
|| isUint16ArrayPrediction(value)
|| isUint32ArrayPrediction(value);
}
inline bool isActionableFloatMutableArrayPrediction(PredictedType value)
{
return isFloat32ArrayPrediction(value)
|| isFloat64ArrayPrediction(value);
}
inline bool isActionableTypedMutableArrayPrediction(PredictedType value)
{
return isActionableIntMutableArrayPrediction(value)
|| isActionableFloatMutableArrayPrediction(value);
}
inline bool isActionableMutableArrayPrediction(PredictedType value)
{
return isArrayPrediction(value)
|| isActionableTypedMutableArrayPrediction(value);
}
inline bool isActionableArrayPrediction(PredictedType value)
{
return isStringPrediction(value)
|| isActionableMutableArrayPrediction(value);
}
inline bool isArrayOrOtherPrediction(PredictedType value)
{
return !!(value & (PredictArray | PredictOther)) && !(value & ~(PredictArray | PredictOther));
}
inline bool isInt32Prediction(PredictedType value)
{
return value == PredictInt32;
}
inline bool isDoubleRealPrediction(PredictedType value)
{
return value == PredictDoubleReal;
}
inline bool isDoublePrediction(PredictedType value)
{
return !!value && (value & PredictDouble) == value;
}
inline bool isNumberPrediction(PredictedType value)
{
return !!(value & PredictNumber) && !(value & ~PredictNumber);
}
inline bool isBooleanPrediction(PredictedType value)
{
return value == PredictBoolean;
}
inline bool isOtherPrediction(PredictedType value)
{
return value == PredictOther;
}
inline bool isEmptyPrediction(PredictedType value)
{
return value == PredictEmpty;
}
const char* predictionToString(PredictedType value);
const char* predictionToAbbreviatedString(PredictedType value);
inline PredictedType mergePredictions(PredictedType left, PredictedType right)
{
return left | right;
}
template<typename T>
inline bool mergePrediction(T& left, PredictedType right)
{
PredictedType newPrediction = static_cast<T>(mergePredictions(static_cast<PredictedType>(left), right));
bool result = newPrediction != static_cast<PredictedType>(left);
left = newPrediction;
return result;
}
PredictedType predictionFromClassInfo(const ClassInfo*);
PredictedType predictionFromStructure(Structure*);
PredictedType predictionFromCell(JSCell*);
PredictedType predictionFromValue(JSValue);
}
#endif // PredictedType_h