source:
webkit/trunk/JavaScriptCore/kjs/JSImmediate.cpp@
34757
Last change on this file since 34757 was 34754, checked in by Darin Adler, 17 years ago | |
---|---|
2008-06-23 Darin Adler <Darin Adler>
JavaScriptGlue:
2008-06-23 Darin Adler <Darin Adler>
WebCore:
2008-06-23 Darin Adler <Darin Adler>
|
|
|
|
File size: 1.9 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 | #include "JSGlobalObject.h" |
25 | #include "BooleanObject.h" |
26 | #include "JSNotAnObject.h" |
27 | #include "NumberObject.h" |
28 | #include "JSObject.h" |
29 | |
30 | namespace KJS { |
31 | |
32 | JSObject* JSImmediate::toObject(const JSValue *v, ExecState *exec) |
33 | { |
34 | ASSERT(isImmediate(v)); |
35 | if (v == jsNull()) |
36 | return new (exec) JSNotAnObject(throwError(exec, TypeError, "Null value")); |
37 | if (v == jsUndefined()) |
38 | return new (exec) JSNotAnObject(throwError(exec, TypeError, "Undefined value")); |
39 | if (isBoolean(v)) |
40 | return constructBooleanFromImmediateBoolean(exec, const_cast<JSValue*>(v)); |
41 | ASSERT(isNumber(v)); |
42 | return constructNumberFromImmediateNumber(exec, const_cast<JSValue*>(v)); |
43 | } |
44 | |
45 | UString JSImmediate::toString(const JSValue* v) |
46 | { |
47 | ASSERT(isImmediate(v)); |
48 | if (v == jsNull()) |
49 | return "null"; |
50 | if (v == jsUndefined()) |
51 | return "undefined"; |
52 | if (v == jsBoolean(true)) |
53 | return "true"; |
54 | if (v == jsBoolean(false)) |
55 | return "false"; |
56 | ASSERT(isNumber(v)); |
57 | return UString::from(getTruncatedInt32(v)); |
58 | } |
59 | |
60 | } // namespace KJS |
Note:
See TracBrowser
for help on using the repository browser.