]>
git.saurik.com Git - apple/javascriptcore.git/blob - runtime/Operations.cpp
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"
26 #include "JSCInlines.h"
29 #include <wtf/MathExtras.h>
33 bool JSValue::equalSlowCase(ExecState
* exec
, JSValue v1
, JSValue v2
)
35 return equalSlowCaseInline(exec
, v1
, v2
);
38 bool JSValue::strictEqualSlowCase(ExecState
* exec
, JSValue v1
, JSValue v2
)
40 return strictEqualSlowCaseInline(exec
, v1
, v2
);
43 NEVER_INLINE JSValue
jsAddSlowCase(CallFrame
* callFrame
, JSValue v1
, JSValue v2
)
45 // exception for the Date exception in defaultValue()
46 JSValue p1
= v1
.toPrimitive(callFrame
);
47 JSValue p2
= v2
.toPrimitive(callFrame
);
50 return jsString(callFrame
, asString(p1
), p2
.toString(callFrame
));
53 return jsString(callFrame
, p1
.toString(callFrame
), asString(p2
));
55 return jsNumber(p1
.toNumber(callFrame
) + p2
.toNumber(callFrame
));
58 JSValue
jsTypeStringForValue(VM
& vm
, JSGlobalObject
* globalObject
, JSValue v
)
61 return vm
.smallStrings
.undefinedString();
63 return vm
.smallStrings
.booleanString();
65 return vm
.smallStrings
.numberString();
67 return vm
.smallStrings
.stringString();
69 // Return "undefined" for objects that should be treated
70 // as null when doing comparisons.
71 if (asObject(v
)->structure(vm
)->masqueradesAsUndefined(globalObject
))
72 return vm
.smallStrings
.undefinedString();
74 JSObject
* object
= asObject(v
);
75 if (object
->methodTable(vm
)->getCallData(object
, callData
) != CallTypeNone
)
76 return vm
.smallStrings
.functionString();
78 return vm
.smallStrings
.objectString();
81 JSValue
jsTypeStringForValue(CallFrame
* callFrame
, JSValue v
)
83 return jsTypeStringForValue(callFrame
->vm(), callFrame
->lexicalGlobalObject(), v
);
86 bool jsIsObjectType(CallFrame
* callFrame
, JSValue v
)
91 JSType type
= v
.asCell()->type();
92 if (type
== StringType
)
94 if (type
>= ObjectType
) {
95 if (asObject(v
)->structure(callFrame
->vm())->masqueradesAsUndefined(callFrame
->lexicalGlobalObject()))
98 JSObject
* object
= asObject(v
);
99 if (object
->methodTable(callFrame
->vm())->getCallData(object
, callData
) != CallTypeNone
)
105 bool jsIsFunctionType(JSValue v
)
109 JSObject
* object
= asObject(v
);
110 if (object
->methodTable()->getCallData(object
, callData
) != CallTypeNone
)