source: webkit/trunk/JavaScriptCore/runtime/JSImmediate.cpp@ 46598

Last change on this file since 46598 was 46598, checked in by [email protected], 16 years ago

Merged nitro-extreme branch into trunk.

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1/*
2 * Copyright (C) 2003-2006, 2008 Apple Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21#include "config.h"
22#include "JSImmediate.h"
23
24#if !USE(JSVALUE32_64)
25
26#include "BooleanConstructor.h"
27#include "BooleanPrototype.h"
28#include "Error.h"
29#include "ExceptionHelpers.h"
30#include "JSGlobalObject.h"
31#include "JSNotAnObject.h"
32#include "NumberConstructor.h"
33#include "NumberPrototype.h"
34
35namespace JSC {
36
37JSObject* JSImmediate::toThisObject(JSValue v, ExecState* exec)
38{
39 ASSERT(isImmediate(v));
40 if (isNumber(v))
41 return constructNumber(exec, v);
42 if (isBoolean(v))
43 return constructBooleanFromImmediateBoolean(exec, v);
44 ASSERT(v.isUndefinedOrNull());
45 return exec->globalThisValue();
46}
47
48JSObject* JSImmediate::toObject(JSValue v, ExecState* exec)
49{
50 ASSERT(isImmediate(v));
51 if (isNumber(v))
52 return constructNumber(exec, v);
53 if (isBoolean(v))
54 return constructBooleanFromImmediateBoolean(exec, v);
55
56 JSNotAnObjectErrorStub* exception = createNotAnObjectErrorStub(exec, v.isNull());
57 exec->setException(exception);
58 return new (exec) JSNotAnObject(exec, exception);
59}
60
61JSObject* JSImmediate::prototype(JSValue v, ExecState* exec)
62{
63 ASSERT(isImmediate(v));
64 if (isNumber(v))
65 return exec->lexicalGlobalObject()->numberPrototype();
66 if (isBoolean(v))
67 return exec->lexicalGlobalObject()->booleanPrototype();
68
69 JSNotAnObjectErrorStub* exception = createNotAnObjectErrorStub(exec, v.isNull());
70 exec->setException(exception);
71 return new (exec) JSNotAnObject(exec, exception);
72}
73
74} // namespace JSC
75
76#endif // !USE(JSVALUE32_64)
Note: See TracBrowser for help on using the repository browser.