30 #include "simple_number.h"
38 class ValueImpPrivate;
86 ValueImp* ref() {
if (!SimpleNumber::is(
this)) refcount++;
return this; }
87 bool deref() {
if (SimpleNumber::is(
this))
return false;
else return (!--refcount); }
91 void*
operator new(size_t);
92 void operator delete(
void*);
102 void setGcAllowedFast() { _flags |= VI_GCALLOWED; }
106 unsigned int toUInt32(
ExecState *exec)
const;
107 unsigned short toUInt16(
ExecState *exec)
const;
111 Type dispatchType()
const;
112 Value dispatchToPrimitive(
ExecState *exec, Type preferredType = UnspecifiedType)
const;
113 bool dispatchToBoolean(
ExecState *exec)
const;
114 double dispatchToNumber(
ExecState *exec)
const;
116 bool dispatchToUInt32(
unsigned&)
const;
119 unsigned short int refcount;
121 bool isDestroyed()
const {
return _flags & VI_DESTRUCTED; }
124 unsigned short int _flags;
126 virtual Type type()
const = 0;
130 virtual Value toPrimitive(
ExecState *exec, Type preferredType = UnspecifiedType)
const = 0;
131 virtual bool toBoolean(
ExecState *exec)
const = 0;
132 virtual double toNumber(
ExecState *exec)
const = 0;
136 virtual bool toUInt32(
unsigned&)
const;
145 ValueImpPrivate *_vd;
187 ValueImp *imp()
const {
return rep; }
195 Type
type()
const {
return rep->dispatchType(); }
203 bool isA(Type t)
const {
return rep->dispatchType() == t; }
210 Type preferredType = UnspecifiedType)
const
211 {
return rep->dispatchToPrimitive(exec, preferredType); }
256 bool toUInt32(
unsigned& i)
const {
return rep->dispatchToUInt32(i); }
284 friend class UndefinedImp;
309 friend class NullImp;
310 explicit Null(NullImp *v);
333 friend class BooleanImp;
334 explicit Boolean(BooleanImp *v);
357 friend class StringImp;
358 explicit String(StringImp *v);
361 extern const double NaN;
362 extern const double Inf;
374 Number(
long unsigned int l);
376 double value()
const;
377 int intValue()
const;
393 friend class NumberImp;
394 explicit Number(NumberImp *v);
399 #endif // _KJS_VALUE_H_
Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...
Type type() const
Returns the type of value.
Represents an primitive Number value.
bool toBoolean(ExecState *exec) const
Performs the ToBoolean type conversion operation on this value (ECMA 9.2)
unsigned short toUInt16(ExecState *exec) const
Performs the ToUInt16 type conversion operation on this value (ECMA 9.7)
Represents an primitive Null value.
int toInt32(ExecState *exec) const
Performs the ToInt32 type conversion operation on this value (ECMA 9.5)
double toNumber(ExecState *exec) const
Performs the ToNumber type conversion operation on this value (ECMA 9.3)
unsigned int toUInt32(ExecState *exec) const
Performs the ToUInt32 type conversion operation on this value (ECMA 9.6)
Represents an primitive Undefined value.
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.
Represents an primitive String value.
ValueImp is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects i...
Value toPrimitive(ExecState *exec, Type preferredType=UnspecifiedType) const
Performs the ToPrimitive type conversion operation on this value (ECMA 9.1)
Represents an primitive Boolean value.
UString toString(ExecState *exec) const
Performs the ToString type conversion operation on this value (ECMA 9.8)
int toInteger(ExecState *exec) const
Performs the ToInteger type conversion operation on this value (ECMA 9.4)
bool isValid() const
Returns whether or not this is a valid value.
Represents the current state of script execution.