4#ifndef QV4STATICVALUE_P_H
5#define QV4STATICVALUE_P_H
18#include <qjsnumbercoercion.h>
20#include <QtCore/private/qnumeric_p.h>
21#include <private/qtqmlglobal_p.h>
26#define QV4_NEARLY_ALWAYS_INLINE Q_ALWAYS_INLINE
28#define QV4_NEARLY_ALWAYS_INLINE inline
58 template<
typename Value>
61 template<
typename Value>
64 template<
typename Value>
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
133#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
138 static inline int tagOffset() {
return 0; }
152 setTagValue(quint32(QuickType::Integer), quint32(i));
158 setTagValue(quint32(QuickType::Empty), 0);
259 const quint64 masked = _val & DoubleMask;
260 if (masked >= DoubleDiscriminator)
267 Q_ASSERT((_val & tagBitMask(TagBit::Unmanaged)) == 0);
271 const Type ret = Type(tag());
283 inline bool isEmpty()
const {
return tag() == quint32(ValueTypeInternal::Empty); }
284 inline bool isNull()
const {
return tag() == quint32(ValueTypeInternal::Null); }
285 inline bool isBoolean()
const {
return tag() == quint32(ValueTypeInternal::Boolean); }
286 inline bool isInteger()
const {
return tag() == quint32(ValueTypeInternal::Integer); }
300 return (_val & DoubleMask) >= DoubleDiscriminator;
313 return (_val & NumberMask) >= NumberDiscriminator;
328 return (_val >> IsIntegerOrBool_Shift) == IsIntegerOrBool_Value;
333 return (_val >> IsIntegerConvertible_Shift) == IsIntegerConvertible_Value;
346 switch (QuickType(tag())) {
348 case QuickType::MinusNaN:
356 return isInteger() && int_32() >= 0;
362 const quint64 unmasked = _val ^ EncodeMask;
363 memcpy(&d, &unmasked, 8);
373 _val = (quint64(std::signbit(d) ? QuickType::MinusNaN : QuickType::NaN) << Tag_Shift);
376 memcpy(&_val, &d, 8);
384 if (tag() == quint32(QuickType::Integer))
397 int i = QJSNumberCoercion::toInteger(d);
398 return (i == d && !(d == 0 && std::signbit(d)));
402 if (tag() == quint32(QuickType::Integer))
418 setTagValue(quint32(QuickType::Integer), value());
423 if (integerCompatible())
424 return static_cast<
bool>(int_32());
431 return d && !std::isnan(d);
442 return QJSNumberCoercion::toInteger(doubleValue());
449 Q_UNREACHABLE_RETURN(0);
472 if (i < uint(std::numeric_limits<
int>::max())) {
482 return QJSNumberCoercion::roundTowards0(d);
487 return QJSNumberCoercion::toInteger(d);
499#if QT_POINTER_SIZE == 8
509#if 0
&& defined(Q_OS_ANDROID) && defined(Q_PROCESSOR_ARM_64)
520#elif defined(Q_PROCESSOR_IA64)
526#elif defined(Q_PROCESSOR_SPARC_64)
601#elif QT_POINTER_SIZE == 4
617# error "unsupported pointer size"
635 val = StaticValue::fromDouble(d).asReturnedValue();
642 val = StaticValue::fromUInt32(i).asReturnedValue();
653 template<
typename HeapBase>
654 explicit Encode(HeapBase *o);
658 val = o->asReturnedValue();
673 explicit Encode(
void *);
Combined button and popup list for selecting options.
Q_STATIC_ASSERT(sizeof(CppStackFrame)==sizeof(JSTypesStackFrame))
#define QV4_NEARLY_ALWAYS_INLINE
static ReturnedValue smallestNumber(double d)
constexpr Encode(StaticValue v)
static constexpr ReturnedValue undefined()
constexpr operator ReturnedValue() const
static constexpr ReturnedValue null()
QV4_NEARLY_ALWAYS_INLINE constexpr void setTagValue(quint32 tag, quint32 value)
StaticValue & operator=(ReturnedValue v)
QV4_NEARLY_ALWAYS_INLINE constexpr quint64 rawValue() const
static constexpr quint64 DoubleMask
quint64 quickType() const
static bool integerCompatible(StaticValue a, StaticValue b)
const Value & asValue() const
static StaticValue fromDouble(double d)
bool isManagedOrUndefined() const
static int toInt32(double d)
StaticValue & operator=(const Value &)
static constexpr StaticValue fromBoolean(bool b)
QuickType ValueTypeInternal
constexpr ReturnedValue asReturnedValue() const
static constexpr quint64 NumberDiscriminator
static QV4_NEARLY_ALWAYS_INLINE bool isInt32(double d)
static constexpr quint64 IntOrBoolMask
static double toInteger(double d)
static constexpr quint64 Upper3Mask
static constexpr quint64 IntCompatMask
QV4_NEARLY_ALWAYS_INLINE double doubleValue() const
static constexpr quint64 DoubleDiscriminator
QV4_NEARLY_ALWAYS_INLINE void setDouble(double d)
bool isPositiveInt() const
static constexpr StaticValue fromInt32(int i)
QV4_NEARLY_ALWAYS_INLINE constexpr quint32 value() const
static StaticValue fromUInt32(uint i)
QV4_NEARLY_ALWAYS_INLINE constexpr void setInt_32(int i)
static constexpr quint64 EncodeMask
bool integerCompatible() const
static constexpr quint64 tagBitMask(TagBit bit)
QV4_NEARLY_ALWAYS_INLINE uint uint_32() const
static constexpr quint64 ManagedMask
static constexpr StaticValue emptyValue()
static constexpr quint64 NumberMask
bool tryIntegerConversion()
static constexpr quint64 Lower5Mask
static constexpr quint64 tagValue(quint32 tag, quint32 value)
@ IsIntegerConvertible_Value
@ IsIntegerConvertible_Shift
static unsigned int toUInt32(double d)
static constexpr StaticValue undefinedValue()
QV4_NEARLY_ALWAYS_INLINE constexpr void setRawValue(quint64 raw)
bool isNullOrUndefined() const
constexpr StaticValue(quint64 val)
QV4_NEARLY_ALWAYS_INLINE constexpr quint32 tag() const
bool booleanValue() const
QV4_NEARLY_ALWAYS_INLINE constexpr int int_32() const
ReturnedValue * data_ptr()
static constexpr quint64 ExponentMask
static constexpr StaticValue nullValue()
static bool bothDouble(StaticValue a, StaticValue b)
static constexpr quint64 Top1Mask
QV4_NEARLY_ALWAYS_INLINE constexpr void setTag(quint32 tag)
static constexpr StaticValue fromReturnedValue(ReturnedValue val)
QV4_NEARLY_ALWAYS_INLINE constexpr void setEmpty()
QV4_NEARLY_ALWAYS_INLINE constexpr quint64 & rawValueRef()