31 #include "simple_number.h"
39 class ValueImpPrivate;
87 ValueImp* ref() {
if (!SimpleNumber::is(
this)) refcount++;
return this; }
88 bool deref() {
if (SimpleNumber::is(
this))
return false;
else return (!--refcount); }
92 void*
operator new(size_t);
93 void operator delete(
void*);
103 void setGcAllowedFast() { _flags |= VI_GCALLOWED; }
107 unsigned int toUInt32(
ExecState *exec)
const;
108 unsigned short toUInt16(
ExecState *exec)
const;
112 Type dispatchType()
const;
113 Value dispatchToPrimitive(
ExecState *exec, Type preferredType = UnspecifiedType)
const;
114 bool dispatchToBoolean(
ExecState *exec)
const;
115 double dispatchToNumber(
ExecState *exec)
const;
117 bool dispatchToUInt32(
unsigned&)
const;
120 unsigned short int refcount;
122 bool isDestroyed()
const {
return _flags & VI_DESTRUCTED; }
125 unsigned short int _flags;
127 virtual Type type()
const = 0;
131 virtual Value toPrimitive(
ExecState *exec, Type preferredType = UnspecifiedType)
const = 0;
132 virtual bool toBoolean(
ExecState *exec)
const = 0;
133 virtual double toNumber(
ExecState *exec)
const = 0;
137 virtual bool toUInt32(
unsigned&)
const;
146 ValueImpPrivate *_vd;
188 ValueImp *imp()
const {
return rep; }
196 Type
type()
const {
return rep->dispatchType(); }
204 bool isA(Type t)
const {
return rep->dispatchType() == t; }
211 Type preferredType = UnspecifiedType)
const
212 {
return rep->dispatchToPrimitive(exec, preferredType); }
257 bool toUInt32(
unsigned& i)
const {
return rep->dispatchToUInt32(i); }
285 friend class UndefinedImp;
310 friend class NullImp;
311 explicit Null(NullImp *v);
334 friend class BooleanImp;
335 explicit Boolean(BooleanImp *v);
358 friend class StringImp;
359 explicit String(StringImp *v);
362 extern const double NaN;
363 extern const double Inf;
375 Number(
long unsigned int l);
377 double value()
const;
378 int intValue()
const;
394 friend class NumberImp;
395 explicit Number(NumberImp *v);
Represents an primitive Boolean value.
Represents the current state of script execution.
Represents an primitive Null value.
Represents an primitive Number value.
Represents an primitive String value.
Represents an primitive Undefined value.
ValueImp is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects i...
Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents.
UString toString(ExecState *exec) const
Performs the ToString type conversion operation on this value (ECMA 9.8)
bool isA(Type t) const
Checks whether or not the value is of a particular tpye.
bool toUInt32(unsigned &i) const
Checks if we can do a lossless conversion to UInt32.
int toInteger(ExecState *exec) const
Performs the ToInteger type conversion operation on this value (ECMA 9.4)
unsigned int toUInt32(ExecState *exec) const
Performs the ToUInt32 type conversion operation on this value (ECMA 9.6)
int toInt32(ExecState *exec) const
Performs the ToInt32 type conversion operation on this value (ECMA 9.5)
Value toPrimitive(ExecState *exec, Type preferredType=UnspecifiedType) const
Performs the ToPrimitive type conversion operation on this value (ECMA 9.1)
bool toBoolean(ExecState *exec) const
Performs the ToBoolean type conversion operation on this value (ECMA 9.2)
bool isValid() const
Returns whether or not this is a valid value.
Type type() const
Returns the type of value.
unsigned short toUInt16(ExecState *exec) const
Performs the ToUInt16 type conversion operation on this value (ECMA 9.7)
double toNumber(ExecState *exec) const
Performs the ToNumber type conversion operation on this value (ECMA 9.3)