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);
400 #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.