]>
git.saurik.com Git - apple/javascriptcore.git/blob - runtime/Operations.cpp
4cb9de505e79660e34eded7ff2af01aeed3e7a5c
2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
3 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
23 #include "Operations.h"
30 #include <wtf/MathExtras.h>
34 bool JSValue::equalSlowCase(ExecState
* exec
, JSValue v1
, JSValue v2
)
36 return equalSlowCaseInline(exec
, v1
, v2
);
39 bool JSValue::strictEqualSlowCase(ExecState
* exec
, JSValue v1
, JSValue v2
)
41 return strictEqualSlowCaseInline(exec
, v1
, v2
);
44 NEVER_INLINE JSValue
jsAddSlowCase(CallFrame
* callFrame
, JSValue v1
, JSValue v2
)
46 // exception for the Date exception in defaultValue()
47 JSValue p1
= v1
.toPrimitive(callFrame
);
48 JSValue p2
= v2
.toPrimitive(callFrame
);
51 return jsString(callFrame
, asString(p1
), p2
.toString(callFrame
));
54 return jsString(callFrame
, p1
.toString(callFrame
), asString(p2
));
56 return jsNumber(p1
.toNumber(callFrame
) + p2
.toNumber(callFrame
));
59 JSValue
jsTypeStringForValue(CallFrame
* callFrame
, JSValue v
)
61 JSGlobalData
& globalData
= callFrame
->globalData();
63 return globalData
.smallStrings
.undefinedString(&globalData
);
65 return globalData
.smallStrings
.booleanString(&globalData
);
67 return globalData
.smallStrings
.numberString(&globalData
);
69 return globalData
.smallStrings
.stringString(&globalData
);
71 // Return "undefined" for objects that should be treated
72 // as null when doing comparisons.
73 if (asObject(v
)->structure()->typeInfo().masqueradesAsUndefined())
74 return globalData
.smallStrings
.undefinedString(&globalData
);
76 JSObject
* object
= asObject(v
);
77 if (object
->methodTable()->getCallData(object
, callData
) != CallTypeNone
)
78 return globalData
.smallStrings
.functionString(&globalData
);
80 return globalData
.smallStrings
.objectString(&globalData
);
83 bool jsIsObjectType(JSValue v
)
88 JSType type
= v
.asCell()->structure()->typeInfo().type();
89 if (type
== NumberType
|| type
== StringType
)
91 if (type
>= ObjectType
) {
92 if (asObject(v
)->structure()->typeInfo().masqueradesAsUndefined())
95 JSObject
* object
= asObject(v
);
96 if (object
->methodTable()->getCallData(object
, callData
) != CallTypeNone
)
102 bool jsIsFunctionType(JSValue v
)
106 JSObject
* object
= asObject(v
);
107 if (object
->methodTable()->getCallData(object
, callData
) != CallTypeNone
)