26 #define HAVE_FLOAT_H 0
47 #include "operations.h"
52 bool KJS::isNaN(
double d)
57 bool KJS::isInf(
double d)
62 bool KJS::isPosInf(
double d)
64 return ( isinf(d) && d > 0 );
67 bool KJS::isNegInf(
double d)
69 return ( isinf(d) && d < 0 );
79 if (t1 == UndefinedType || t1 == NullType)
85 if ( isNaN( d1 ) || isNaN( d2 ) )
91 if (t1 == BooleanType)
95 return (v1.imp() == v2.imp());
99 if ((t1 == NullType && t2 == UndefinedType) || (t1 == UndefinedType && t2 == NullType))
101 if (t1 == NumberType && t2 == StringType) {
103 return equal(exec,v1, n2);
105 if ((t1 == StringType && t2 == NumberType) || t1 == BooleanType) {
107 return equal(exec,n1, v2);
109 if (t2 == BooleanType) {
111 return equal(exec,v1, n2);
113 if ((t1 == StringType || t1 == NumberType) && t2 >= ObjectType) {
115 return equal(exec,v1, p2);
117 if (t1 >= ObjectType && (t2 == StringType || t2 == NumberType)) {
119 return equal(exec,p1, v2);
132 if (t1 == UndefinedType || t1 == NullType)
134 if (t1 == NumberType) {
137 if (isNaN(n1) || isNaN(n2))
143 }
else if (t1 == StringType) {
145 }
else if (t2 == BooleanType) {
148 if (v1.imp() == v2.imp())
160 if (p1.
type() == StringType && p2.
type() == StringType)
165 if ( isNaN( n1 ) || isNaN( n2 ) )
170 if ( isPosInf( n1 ) )
172 if ( isPosInf( n2 ) )
174 if ( isNegInf( n2 ) )
176 if ( isNegInf( n1 ) )
178 return (n1 < n2) ? 1 : 0;
181 int KJS::maxInt(
int d1,
int d2)
183 return (d1 > d2) ? d1 : d2;
186 int KJS::minInt(
int d1,
int d2)
188 return (d1 < d2) ? d1 : d2;
195 Type preferred = oper ==
'+' ? UnspecifiedType : NumberType;
199 if ((p1.
type() == StringType || p2.
type() == StringType) && oper ==
'+') {
225 else if (oper ==
'/')
228 result = fmod(n1, n2);
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)
double toNumber(ExecState *exec) const
Performs the ToNumber type conversion operation on this value (ECMA 9.3)
Represents an primitive String value.
Value toPrimitive(ExecState *exec, Type preferredType=UnspecifiedType) const
Performs the ToPrimitive type conversion operation on this value (ECMA 9.1)
UString toString(ExecState *exec) const
Performs the ToString type conversion operation on this value (ECMA 9.8)
Represents the current state of script execution.