Debian Codegraph @

src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSValue.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 1999-2001 Harri Porten ([email protected])
3 * Copyright (C) 2001 Peter Kelly ([email protected])
4 * Copyright (C) 2003, 2007, 2008 Apple Inc. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #include "config.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/config.h`/
24 #include "JSValue.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSValue.h`/
25
26 #include "BooleanConstructor.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/BooleanConstructor.h`/
27 #include "BooleanPrototype.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/BooleanPrototype.h`/
28 #include "ExceptionHelpers.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ExceptionHelpers.h`/
29 #include "JSGlobalObject.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalObject.h`/
30 #include "JSFunction.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSFunction.h`/
31 #include "JSNotAnObject.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSNotAnObject.h`/
32 #include "NumberObject.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/NumberObject.h`/
33 #include <wtf/MathExtras.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h`/
34 #include <wtf/StringExtras.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/StringExtras.h`/
35
36 namespace JSCcxx . . $ `<built-in>:463:9`! {
37
38 static const double D32cxx . . $ QTJSC/D32. = 4294967296.0;
39
40 // ECMA 9.4
41 double JSValuecxx . . $ QTJSC/JSValue#::toIntegercxx . . $ QTJSC/JSValue#toInteger(1fd034e372fd1279).(ExecStatecxx . . $ QTJSC/ExecState#* exec) const
42 {
43 if (isInt32cxx . . $ QTJSC/JSValue#isInt32(50ce9a9e25b4a850).())
44 return asInt32cxx . . $ QTJSC/JSValue#asInt32(455f465bc33b4cdf).();
45 double d = toNumbercxx . . $ QTJSC/JSValue#toNumber(1fd034e372fd1279).(exec);
46 return stdcxx . . $ std/::isnan(d) ? 0.0 : trunccxx . . $ trunc(447c67c6676f75c3).(d);
47 }
48
49 double JSValuecxx . . $ QTJSC/JSValue#::toIntegerPreserveNaNcxx . . $ QTJSC/JSValue#toIntegerPreserveNaN(1fd034e372fd1279).(ExecStatecxx . . $ QTJSC/ExecState#* exec) const
50 {
51 if (isInt32cxx . . $ QTJSC/JSValue#isInt32(50ce9a9e25b4a850).())
52 return asInt32cxx . . $ QTJSC/JSValue#asInt32(455f465bc33b4cdf).();
53 return trunccxx . . $ trunc(447c67c6676f75c3).(toNumbercxx . . $ QTJSC/JSValue#toNumber(1fd034e372fd1279).(exec));
54 }
55
56 JSObjectcxx . . $ QTJSC/JSObject#* JSValuecxx . . $ QTJSC/JSValue#::toObjectSlowCasecxx . . $ QTJSC/JSValue#toObjectSlowCase(8709ed4849a165ab).(ExecStatecxx . . $ QTJSC/ExecState#* exec) const
57 {
58 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!isCell());
59
60 if (isInt32cxx . . $ QTJSC/JSValue#isInt32(50ce9a9e25b4a850).() || isDoublecxx . . $ QTJSC/JSValue#isDouble(50ce9a9e25b4a850).())
61 return constructNumbercxx . . $ QTJSC/constructNumber(106f9f7992b96829).(exec, asValuecxx . . $ QTJSC/JSValue#asValue(2b3a0f51c71d9b1b).());
62 if (isTruecxx . . $ QTJSC/JSValue#isTrue(50ce9a9e25b4a850).() || isFalsecxx . . $ QTJSC/JSValue#isFalse(50ce9a9e25b4a850).())
63 return constructBooleanFromImmediateBooleancxx . . $ QTJSC/constructBooleanFromImmediateBoolean(b9a2be0440c5b051).(exec, asValuecxx . . $ QTJSC/JSValue#asValue(2b3a0f51c71d9b1b).());
64 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(isUndefinedOrNull());
65 JSNotAnObjectErrorStubcxx . . $ QTJSC/JSNotAnObjectErrorStub#* exception = createNotAnObjectErrorStubcxx . . $ QTJSC/createNotAnObjectErrorStub(c79170a29de2b061).(exec, isNullcxx . . $ QTJSC/JSValue#isNull(50ce9a9e25b4a850).());
66 exec->setExceptioncxx . . $ QTJSC/ExecState#setException(5c2ac18db087b3e6).(exception);
67 return new (exec) JSNotAnObjectcxx . . $ QTJSC/JSNotAnObject#(exec, exception);
68 }
69
70 JSObjectcxx . . $ QTJSC/JSObject#* JSValuecxx . . $ QTJSC/JSValue#::toThisObjectSlowCasecxx . . $ QTJSC/JSValue#toThisObjectSlowCase(8709ed4849a165ab).(ExecStatecxx . . $ QTJSC/ExecState#* exec) const
71 {
72 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!isCell());
73
74 if (isInt32cxx . . $ QTJSC/JSValue#isInt32(50ce9a9e25b4a850).() || isDoublecxx . . $ QTJSC/JSValue#isDouble(50ce9a9e25b4a850).())
75 return constructNumbercxx . . $ QTJSC/constructNumber(106f9f7992b96829).(exec, asValuecxx . . $ QTJSC/JSValue#asValue(2b3a0f51c71d9b1b).());
76 if (isTruecxx . . $ QTJSC/JSValue#isTrue(50ce9a9e25b4a850).() || isFalsecxx . . $ QTJSC/JSValue#isFalse(50ce9a9e25b4a850).())
77 return constructBooleanFromImmediateBooleancxx . . $ QTJSC/constructBooleanFromImmediateBoolean(b9a2be0440c5b051).(exec, asValuecxx . . $ QTJSC/JSValue#asValue(2b3a0f51c71d9b1b).());
78 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(isUndefinedOrNull());
79 return exec->globalThisValuecxx . . $ QTJSC/ExecState#globalThisValue(8ac23ea934d7a115).();
80 }
81
82 JSObjectcxx . . $ QTJSC/JSObject#* JSValuecxx . . $ QTJSC/JSValue#::synthesizeObjectcxx . . $ QTJSC/JSValue#synthesizeObject(8709ed4849a165ab).(ExecStatecxx . . $ QTJSC/ExecState#* exec) const
83 {
84 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!isCell());
85 if (isNumbercxx . . $ QTJSC/JSValue#isNumber(50ce9a9e25b4a850).())
86 return constructNumbercxx . . $ QTJSC/constructNumber(106f9f7992b96829).(exec, asValuecxx . . $ QTJSC/JSValue#asValue(2b3a0f51c71d9b1b).());
87 if (isBooleancxx . . $ QTJSC/JSValue#isBoolean(50ce9a9e25b4a850).())
88 return constructBooleanFromImmediateBooleancxx . . $ QTJSC/constructBooleanFromImmediateBoolean(b9a2be0440c5b051).(exec, asValuecxx . . $ QTJSC/JSValue#asValue(2b3a0f51c71d9b1b).());
89
90 JSNotAnObjectErrorStubcxx . . $ QTJSC/JSNotAnObjectErrorStub#* exception = createNotAnObjectErrorStubcxx . . $ QTJSC/createNotAnObjectErrorStub(c79170a29de2b061).(exec, isNullcxx . . $ QTJSC/JSValue#isNull(50ce9a9e25b4a850).());
91 exec->setExceptioncxx . . $ QTJSC/ExecState#setException(5c2ac18db087b3e6).(exception);
92 return new (exec) JSNotAnObjectcxx . . $ QTJSC/JSNotAnObject#(exec, exception);
93 }
94
95 JSObjectcxx . . $ QTJSC/JSObject#* JSValuecxx . . $ QTJSC/JSValue#::synthesizePrototypecxx . . $ QTJSC/JSValue#synthesizePrototype(8709ed4849a165ab).(ExecStatecxx . . $ QTJSC/ExecState#* exec) const
96 {
97 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!isCell());
98 if (isNumbercxx . . $ QTJSC/JSValue#isNumber(50ce9a9e25b4a850).())
99 return exec->lexicalGlobalObjectcxx . . $ QTJSC/ExecState#lexicalGlobalObject(3d50c730b5e26899).()->numberPrototypecxx . . $ QTJSC/JSGlobalObject#numberPrototype(4c03e88d2d97b2f).();
100 if (isBooleancxx . . $ QTJSC/JSValue#isBoolean(50ce9a9e25b4a850).())
101 return exec->lexicalGlobalObjectcxx . . $ QTJSC/ExecState#lexicalGlobalObject(3d50c730b5e26899).()->booleanPrototypecxx . . $ QTJSC/JSGlobalObject#booleanPrototype(f1f627b0957482eb).();
102
103 JSNotAnObjectErrorStubcxx . . $ QTJSC/JSNotAnObjectErrorStub#* exception = createNotAnObjectErrorStubcxx . . $ QTJSC/createNotAnObjectErrorStub(c79170a29de2b061).(exec, isNullcxx . . $ QTJSC/JSValue#isNull(50ce9a9e25b4a850).());
104 exec->setExceptioncxx . . $ QTJSC/ExecState#setException(5c2ac18db087b3e6).(exception);
105 return new (exec) JSNotAnObjectcxx . . $ QTJSC/JSNotAnObject#(exec, exception);
106 }
107
108 #ifndef NDEBUGcxx . . $ `<built-in>:472:9`!
109 char* JSValue::description()
110 {
111 static const size_t size = 32;
112 static char description[size];
113
114 if (!*this)
115 snprintf(description, size, "<JSValue()>");
116 else if (isInt32())
117 snprintf(description, size, "Int32: %d", asInt32());
118 else if (isDouble())
119 snprintf(description, size, "Double: %lf", asDouble());
120 else if (isCell())
121 snprintf(description, size, "Cell: %p", asCell());
122 else if (isTrue())
123 snprintf(description, size, "True");
124 else if (isFalse())
125 snprintf(description, size, "False");
126 else if (isNull())
127 snprintf(description, size, "Null");
128 else {
129 ASSERT(isUndefined());
130 snprintf(description, size, "Undefined");
131 }
132
133 return description;
134 }
135 #endif
136
137 int32_tcxx . . $ int32_t# toInt32SlowCasecxx . . $ QTJSC/toInt32SlowCase(b3bf83f442ac9fa7).(double d, bool& ok)
138 {
139 ok = true;
140
141 if (d >= -D32cxx . . $ QTJSC/D32. / 2 && d < D32cxx . . $ QTJSC/D32. / 2)
142 return static_cast<int32_tcxx . . $ int32_t#>(d);
143
144 if (stdcxx . . $ std/::isnan(d) || stdcxx . . $ std/::isinf(d)) {
145 ok = false;
146 return 0;
147 }
148
149 double d32 = fmodcxx . . $ fmod(d8e7e0733fa41c87).(trunccxx . . $ trunc(447c67c6676f75c3).(d), D32cxx . . $ QTJSC/D32.);
150 if (d32 >= D32cxx . . $ QTJSC/D32. / 2)
151 d32 -= D32cxx . . $ QTJSC/D32.;
152 else if (d32 < -D32cxx . . $ QTJSC/D32. / 2)
153 d32 += D32cxx . . $ QTJSC/D32.;
154 return static_cast<int32_tcxx . . $ int32_t#>(d32);
155 }
156
157 uint32_tcxx . . $ uint32_t# toUInt32SlowCasecxx . . $ QTJSC/toUInt32SlowCase(38c7aa8fca72fcd5).(double d, bool& ok)
158 {
159 ok = true;
160
161 if (d >= 0.0 && d < D32cxx . . $ QTJSC/D32.)
162 return static_cast<uint32_tcxx . . $ uint32_t#>(d);
163
164 if (stdcxx . . $ std/::isnan(d) || stdcxx . . $ std/::isinf(d)) {
165 ok = false;
166 return 0;
167 }
168
169 double d32 = fmodcxx . . $ fmod(d8e7e0733fa41c87).(trunccxx . . $ trunc(447c67c6676f75c3).(d), D32cxx . . $ QTJSC/D32.);
170 if (d32 < 0)
171 d32 += D32cxx . . $ QTJSC/D32.;
172 return static_cast<uint32_tcxx . . $ uint32_t#>(d32);
173 }
174
175 NEVER_INLINEcxx . . $ `../3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:35:9`! double nonInlineNaNcxx . . $ QTJSC/nonInlineNaN(31fa7155c10fdd13).()
176 {
177 #if OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(SYMBIAN)
178 return nanval();
179 #else
180 return stdcxx . . $ std/::numeric_limitscxx . . $ std/numeric_limits#<double>::quiet_NaNcxx . . $ std/numeric_limits#quiet_NaN(31fa7155c10fdd13).();
181 #endif
182 }
183
184 } // namespace JSC