1 | /*
|
---|
2 | * Copyright (C) 2007 Apple Inc. All rights reserved.
|
---|
3 | *
|
---|
4 | * Redistribution and use in source and binary forms, with or without
|
---|
5 | * modification, are permitted provided that the following conditions
|
---|
6 | * are met:
|
---|
7 | *
|
---|
8 | * 1. Redistributions of source code must retain the above copyright
|
---|
9 | * notice, this list of conditions and the following disclaimer.
|
---|
10 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
11 | * notice, this list of conditions and the following disclaimer in the
|
---|
12 | * documentation and/or other materials provided with the distribution.
|
---|
13 | * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
---|
14 | * its contributors may be used to endorse or promote products derived
|
---|
15 | * from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
|
---|
18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
---|
19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
20 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
|
---|
21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
---|
22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
---|
23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | #include "config.h"
|
---|
30 | #include "JSGlobalObject.h"
|
---|
31 |
|
---|
32 | #include "SavedBuiltins.h"
|
---|
33 | #include "array_object.h"
|
---|
34 | #include "bool_object.h"
|
---|
35 | #include "date_object.h"
|
---|
36 | #include "debugger.h"
|
---|
37 | #include "error_object.h"
|
---|
38 | #include "function_object.h"
|
---|
39 | #include "math_object.h"
|
---|
40 | #include "number_object.h"
|
---|
41 | #include "object_object.h"
|
---|
42 | #include "regexp_object.h"
|
---|
43 | #include "string_object.h"
|
---|
44 |
|
---|
45 | #if HAVE(SYS_TIME_H)
|
---|
46 | #include <sys/time.h>
|
---|
47 | #endif
|
---|
48 |
|
---|
49 | #if PLATFORM(WIN_OS)
|
---|
50 | #include <windows.h>
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | #if PLATFORM(QT)
|
---|
54 | #include <QDateTime>
|
---|
55 | #endif
|
---|
56 |
|
---|
57 | namespace KJS {
|
---|
58 |
|
---|
59 | // Default number of ticks before a timeout check should be done.
|
---|
60 | static const int initialTickCountThreshold = 255;
|
---|
61 |
|
---|
62 | // Preferred number of milliseconds between each timeout check
|
---|
63 | static const int preferredScriptCheckTimeInterval = 1000;
|
---|
64 |
|
---|
65 | static inline void markIfNeeded(JSValue* v)
|
---|
66 | {
|
---|
67 | if (v && !v->marked())
|
---|
68 | v->mark();
|
---|
69 | }
|
---|
70 |
|
---|
71 | // Returns the current time in milliseconds
|
---|
72 | // It doesn't matter what "current time" is here, just as long as
|
---|
73 | // it's possible to measure the time difference correctly.
|
---|
74 | static inline unsigned getCurrentTime() {
|
---|
75 | #if HAVE(SYS_TIME_H)
|
---|
76 | struct timeval tv;
|
---|
77 | gettimeofday(&tv, 0);
|
---|
78 | return tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
---|
79 | #elif PLATFORM(QT)
|
---|
80 | QDateTime t = QDateTime::currentDateTime();
|
---|
81 | return t.toTime_t() * 1000 + t.time().msec();
|
---|
82 | #elif PLATFORM(WIN_OS)
|
---|
83 | return timeGetTime();
|
---|
84 | #else
|
---|
85 | #error Platform does not have getCurrentTime function
|
---|
86 | #endif
|
---|
87 | }
|
---|
88 |
|
---|
89 | JSGlobalObject* JSGlobalObject::s_head = 0;
|
---|
90 |
|
---|
91 | JSGlobalObject::~JSGlobalObject()
|
---|
92 | {
|
---|
93 | ASSERT(JSLock::currentThreadIsHoldingLock());
|
---|
94 |
|
---|
95 | if (d()->debugger)
|
---|
96 | d()->debugger->detach(this);
|
---|
97 |
|
---|
98 | d()->next->d()->prev = d()->prev;
|
---|
99 | d()->prev->d()->next = d()->next;
|
---|
100 | s_head = d()->next;
|
---|
101 | if (s_head == this)
|
---|
102 | s_head = 0;
|
---|
103 |
|
---|
104 | delete d();
|
---|
105 | }
|
---|
106 |
|
---|
107 | void JSGlobalObject::init()
|
---|
108 | {
|
---|
109 | ASSERT(JSLock::currentThreadIsHoldingLock());
|
---|
110 |
|
---|
111 | if (s_head) {
|
---|
112 | d()->prev = s_head;
|
---|
113 | d()->next = s_head->d()->next;
|
---|
114 | s_head->d()->next->d()->prev = this;
|
---|
115 | s_head->d()->next = this;
|
---|
116 | } else
|
---|
117 | s_head = d()->next = d()->prev = this;
|
---|
118 |
|
---|
119 | d()->compatMode = NativeMode;
|
---|
120 |
|
---|
121 | resetTimeoutCheck();
|
---|
122 | d()->timeoutTime = 0;
|
---|
123 | d()->timeoutCheckCount = 0;
|
---|
124 |
|
---|
125 | d()->currentExec = 0;
|
---|
126 | d()->recursion = 0;
|
---|
127 | d()->debugger = 0;
|
---|
128 |
|
---|
129 | reset(prototype());
|
---|
130 | }
|
---|
131 |
|
---|
132 | static inline JSObject* lastInPrototypeChain(JSObject* object)
|
---|
133 | {
|
---|
134 | JSObject* o = object;
|
---|
135 | while (o->prototype()->isObject())
|
---|
136 | o = static_cast<JSObject*>(o->prototype());
|
---|
137 | return o;
|
---|
138 | }
|
---|
139 |
|
---|
140 | void JSGlobalObject::reset(JSValue* prototype)
|
---|
141 | {
|
---|
142 | // Clear before inititalizing, to avoid marking uninitialized (dangerous) or
|
---|
143 | // stale (wasteful) pointers during possible garbage collection while creating
|
---|
144 | // new objects below.
|
---|
145 |
|
---|
146 | ExecState* exec = &d()->globalExec;
|
---|
147 |
|
---|
148 | // Prototypes
|
---|
149 | d()->functionPrototype = 0;
|
---|
150 | d()->objectPrototype = 0;
|
---|
151 |
|
---|
152 | d()->arrayPrototype = 0;
|
---|
153 | d()->stringPrototype = 0;
|
---|
154 | d()->booleanPrototype = 0;
|
---|
155 | d()->numberPrototype = 0;
|
---|
156 | d()->datePrototype = 0;
|
---|
157 | d()->regExpPrototype = 0;
|
---|
158 | d()->errorPrototype = 0;
|
---|
159 |
|
---|
160 | d()->evalErrorPrototype = 0;
|
---|
161 | d()->rangeErrorPrototype = 0;
|
---|
162 | d()->referenceErrorPrototype = 0;
|
---|
163 | d()->syntaxErrorPrototype = 0;
|
---|
164 | d()->typeErrorPrototype = 0;
|
---|
165 | d()->URIErrorPrototype = 0;
|
---|
166 |
|
---|
167 | // Constructors
|
---|
168 | d()->objectConstructor = 0;
|
---|
169 | d()->functionConstructor = 0;
|
---|
170 | d()->arrayConstructor = 0;
|
---|
171 | d()->stringConstructor = 0;
|
---|
172 | d()->booleanConstructor = 0;
|
---|
173 | d()->numberConstructor = 0;
|
---|
174 | d()->dateConstructor = 0;
|
---|
175 | d()->regExpConstructor = 0;
|
---|
176 | d()->errorConstructor = 0;
|
---|
177 |
|
---|
178 | d()->evalErrorConstructor = 0;
|
---|
179 | d()->rangeErrorConstructor = 0;
|
---|
180 | d()->referenceErrorConstructor = 0;
|
---|
181 | d()->syntaxErrorConstructor = 0;
|
---|
182 | d()->typeErrorConstructor = 0;
|
---|
183 | d()->URIErrorConstructor = 0;
|
---|
184 |
|
---|
185 | // Prototypes
|
---|
186 | d()->functionPrototype = new FunctionPrototype(exec);
|
---|
187 | d()->objectPrototype = new ObjectPrototype(exec, d()->functionPrototype);
|
---|
188 | d()->functionPrototype->setPrototype(d()->objectPrototype);
|
---|
189 |
|
---|
190 | d()->arrayPrototype = new ArrayPrototype(exec, d()->objectPrototype);
|
---|
191 | d()->stringPrototype = new StringPrototype(exec, d()->objectPrototype);
|
---|
192 | d()->booleanPrototype = new BooleanPrototype(exec, d()->objectPrototype, d()->functionPrototype);
|
---|
193 | d()->numberPrototype = new NumberPrototype(exec, d()->objectPrototype, d()->functionPrototype);
|
---|
194 | d()->datePrototype = new DatePrototype(exec, d()->objectPrototype);
|
---|
195 | d()->regExpPrototype = new RegExpPrototype(exec, d()->objectPrototype, d()->functionPrototype);;
|
---|
196 | d()->errorPrototype = new ErrorPrototype(exec, d()->objectPrototype, d()->functionPrototype);
|
---|
197 |
|
---|
198 | d()->evalErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, EvalError, "EvalError", "EvalError");
|
---|
199 | d()->rangeErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, RangeError, "RangeError", "RangeError");
|
---|
200 | d()->referenceErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, ReferenceError, "ReferenceError", "ReferenceError");
|
---|
201 | d()->syntaxErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, SyntaxError, "SyntaxError", "SyntaxError");
|
---|
202 | d()->typeErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, TypeError, "TypeError", "TypeError");
|
---|
203 | d()->URIErrorPrototype = new NativeErrorPrototype(exec, d()->errorPrototype, URIError, "URIError", "URIError");
|
---|
204 |
|
---|
205 | // Constructors
|
---|
206 | d()->objectConstructor = new ObjectObjectImp(exec, d()->objectPrototype, d()->functionPrototype);
|
---|
207 | d()->functionConstructor = new FunctionObjectImp(exec, d()->functionPrototype);
|
---|
208 | d()->arrayConstructor = new ArrayObjectImp(exec, d()->functionPrototype, d()->arrayPrototype);
|
---|
209 | d()->stringConstructor = new StringObjectImp(exec, d()->functionPrototype, d()->stringPrototype);
|
---|
210 | d()->booleanConstructor = new BooleanObjectImp(exec, d()->functionPrototype, d()->booleanPrototype);
|
---|
211 | d()->numberConstructor = new NumberObjectImp(exec, d()->functionPrototype, d()->numberPrototype);
|
---|
212 | d()->dateConstructor = new DateObjectImp(exec, d()->functionPrototype, d()->datePrototype);
|
---|
213 | d()->regExpConstructor = new RegExpObjectImp(exec, d()->functionPrototype, d()->regExpPrototype);
|
---|
214 | d()->errorConstructor = new ErrorObjectImp(exec, d()->functionPrototype, d()->errorPrototype);
|
---|
215 |
|
---|
216 | d()->evalErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->evalErrorPrototype);
|
---|
217 | d()->rangeErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->rangeErrorPrototype);
|
---|
218 | d()->referenceErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->referenceErrorPrototype);
|
---|
219 | d()->syntaxErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->syntaxErrorPrototype);
|
---|
220 | d()->typeErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->typeErrorPrototype);
|
---|
221 | d()->URIErrorConstructor = new NativeErrorImp(exec, d()->functionPrototype, d()->URIErrorPrototype);
|
---|
222 |
|
---|
223 | d()->functionPrototype->put(exec, exec->propertyNames().constructor, d()->functionConstructor, DontEnum);
|
---|
224 |
|
---|
225 | d()->objectPrototype->put(exec, exec->propertyNames().constructor, d()->objectConstructor, DontEnum | DontDelete | ReadOnly);
|
---|
226 | d()->functionPrototype->put(exec, exec->propertyNames().constructor, d()->functionConstructor, DontEnum | DontDelete | ReadOnly);
|
---|
227 | d()->arrayPrototype->put(exec, exec->propertyNames().constructor, d()->arrayConstructor, DontEnum | DontDelete | ReadOnly);
|
---|
228 | d()->booleanPrototype->put(exec, exec->propertyNames().constructor, d()->booleanConstructor, DontEnum | DontDelete | ReadOnly);
|
---|
229 | d()->stringPrototype->put(exec, exec->propertyNames().constructor, d()->stringConstructor, DontEnum | DontDelete | ReadOnly);
|
---|
230 | d()->numberPrototype->put(exec, exec->propertyNames().constructor, d()->numberConstructor, DontEnum | DontDelete | ReadOnly);
|
---|
231 | d()->datePrototype->put(exec, exec->propertyNames().constructor, d()->dateConstructor, DontEnum | DontDelete | ReadOnly);
|
---|
232 | d()->regExpPrototype->put(exec, exec->propertyNames().constructor, d()->regExpConstructor, DontEnum | DontDelete | ReadOnly);
|
---|
233 | d()->errorPrototype->put(exec, exec->propertyNames().constructor, d()->errorConstructor, DontEnum | DontDelete | ReadOnly);
|
---|
234 | d()->evalErrorPrototype->put(exec, exec->propertyNames().constructor, d()->evalErrorConstructor, DontEnum | DontDelete | ReadOnly);
|
---|
235 | d()->rangeErrorPrototype->put(exec, exec->propertyNames().constructor, d()->rangeErrorConstructor, DontEnum | DontDelete | ReadOnly);
|
---|
236 | d()->referenceErrorPrototype->put(exec, exec->propertyNames().constructor, d()->referenceErrorConstructor, DontEnum | DontDelete | ReadOnly);
|
---|
237 | d()->syntaxErrorPrototype->put(exec, exec->propertyNames().constructor, d()->syntaxErrorConstructor, DontEnum | DontDelete | ReadOnly);
|
---|
238 | d()->typeErrorPrototype->put(exec, exec->propertyNames().constructor, d()->typeErrorConstructor, DontEnum | DontDelete | ReadOnly);
|
---|
239 | d()->URIErrorPrototype->put(exec, exec->propertyNames().constructor, d()->URIErrorConstructor, DontEnum | DontDelete | ReadOnly);
|
---|
240 |
|
---|
241 | // Set global constructors
|
---|
242 |
|
---|
243 | // FIXME: kjs_window.cpp checks Internal/DontEnum as a performance hack, to
|
---|
244 | // see that these values can be put directly without a check for override
|
---|
245 | // properties.
|
---|
246 |
|
---|
247 | // FIXME: These properties should be handled by a static hash table.
|
---|
248 |
|
---|
249 | putDirect("Object", d()->objectConstructor, DontEnum);
|
---|
250 | putDirect("Function", d()->functionConstructor, DontEnum);
|
---|
251 | putDirect("Array", d()->arrayConstructor, DontEnum);
|
---|
252 | putDirect("Boolean", d()->booleanConstructor, DontEnum);
|
---|
253 | putDirect("String", d()->stringConstructor, DontEnum);
|
---|
254 | putDirect("Number", d()->numberConstructor, DontEnum);
|
---|
255 | putDirect("Date", d()->dateConstructor, DontEnum);
|
---|
256 | putDirect("RegExp", d()->regExpConstructor, DontEnum);
|
---|
257 | putDirect("Error", d()->errorConstructor, DontEnum);
|
---|
258 | putDirect("EvalError", d()->evalErrorConstructor, Internal);
|
---|
259 | putDirect("RangeError", d()->rangeErrorConstructor, Internal);
|
---|
260 | putDirect("ReferenceError", d()->referenceErrorConstructor, Internal);
|
---|
261 | putDirect("SyntaxError", d()->syntaxErrorConstructor, Internal);
|
---|
262 | putDirect("TypeError", d()->typeErrorConstructor, Internal);
|
---|
263 | putDirect("URIError", d()->URIErrorConstructor, Internal);
|
---|
264 |
|
---|
265 | // Set global values.
|
---|
266 |
|
---|
267 | putDirect("Math", new MathObjectImp(exec, d()->objectPrototype), DontEnum);
|
---|
268 |
|
---|
269 | putDirect("NaN", jsNaN(), DontEnum | DontDelete);
|
---|
270 | putDirect("Infinity", jsNumber(Inf), DontEnum | DontDelete);
|
---|
271 | putDirect("undefined", jsUndefined(), DontEnum | DontDelete);
|
---|
272 |
|
---|
273 | // Set global functions.
|
---|
274 |
|
---|
275 | putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::Eval, 1, "eval"), DontEnum);
|
---|
276 | putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::ParseInt, 2, "parseInt"), DontEnum);
|
---|
277 | putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::ParseFloat, 1, "parseFloat"), DontEnum);
|
---|
278 | putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::IsNaN, 1, "isNaN"), DontEnum);
|
---|
279 | putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::IsFinite, 1, "isFinite"), DontEnum);
|
---|
280 | putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::Escape, 1, "escape"), DontEnum);
|
---|
281 | putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::UnEscape, 1, "unescape"), DontEnum);
|
---|
282 | putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::DecodeURI, 1, "decodeURI"), DontEnum);
|
---|
283 | putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::DecodeURIComponent, 1, "decodeURIComponent"), DontEnum);
|
---|
284 | putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::EncodeURI, 1, "encodeURI"), DontEnum);
|
---|
285 | putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::EncodeURIComponent, 1, "encodeURIComponent"), DontEnum);
|
---|
286 | #ifndef NDEBUG
|
---|
287 | putDirectFunction(new GlobalFuncImp(exec, d()->functionPrototype, GlobalFuncImp::KJSPrint, 1, "kjsprint"), DontEnum);
|
---|
288 | #endif
|
---|
289 |
|
---|
290 | // Set prototype, and also insert the object prototype at the end of the chain.
|
---|
291 |
|
---|
292 | setPrototype(prototype);
|
---|
293 | lastInPrototypeChain(this)->setPrototype(d()->objectPrototype);
|
---|
294 | }
|
---|
295 |
|
---|
296 | void JSGlobalObject::startTimeoutCheck()
|
---|
297 | {
|
---|
298 | if (!d()->timeoutCheckCount)
|
---|
299 | resetTimeoutCheck();
|
---|
300 |
|
---|
301 | ++d()->timeoutCheckCount;
|
---|
302 | }
|
---|
303 |
|
---|
304 | void JSGlobalObject::stopTimeoutCheck()
|
---|
305 | {
|
---|
306 | --d()->timeoutCheckCount;
|
---|
307 | }
|
---|
308 |
|
---|
309 | void JSGlobalObject::resetTimeoutCheck()
|
---|
310 | {
|
---|
311 | d()->tickCount = 0;
|
---|
312 | d()->ticksUntilNextTimeoutCheck = initialTickCountThreshold;
|
---|
313 | d()->timeAtLastCheckTimeout = 0;
|
---|
314 | d()->timeExecuting = 0;
|
---|
315 | }
|
---|
316 |
|
---|
317 | bool JSGlobalObject::checkTimeout()
|
---|
318 | {
|
---|
319 | d()->tickCount = 0;
|
---|
320 |
|
---|
321 | unsigned currentTime = getCurrentTime();
|
---|
322 |
|
---|
323 | if (!d()->timeAtLastCheckTimeout) {
|
---|
324 | // Suspicious amount of looping in a script -- start timing it
|
---|
325 | d()->timeAtLastCheckTimeout = currentTime;
|
---|
326 | return false;
|
---|
327 | }
|
---|
328 |
|
---|
329 | unsigned timeDiff = currentTime - d()->timeAtLastCheckTimeout;
|
---|
330 |
|
---|
331 | if (timeDiff == 0)
|
---|
332 | timeDiff = 1;
|
---|
333 |
|
---|
334 | d()->timeExecuting += timeDiff;
|
---|
335 | d()->timeAtLastCheckTimeout = currentTime;
|
---|
336 |
|
---|
337 | // Adjust the tick threshold so we get the next checkTimeout call in the interval specified in
|
---|
338 | // preferredScriptCheckTimeInterval
|
---|
339 | d()->ticksUntilNextTimeoutCheck = (unsigned)((float)preferredScriptCheckTimeInterval / timeDiff) * d()->ticksUntilNextTimeoutCheck;
|
---|
340 |
|
---|
341 | // If the new threshold is 0 reset it to the default threshold. This can happen if the timeDiff is higher than the
|
---|
342 | // preferred script check time interval.
|
---|
343 | if (d()->ticksUntilNextTimeoutCheck == 0)
|
---|
344 | d()->ticksUntilNextTimeoutCheck = initialTickCountThreshold;
|
---|
345 |
|
---|
346 | if (d()->timeoutTime && d()->timeExecuting > d()->timeoutTime) {
|
---|
347 | if (shouldInterruptScript())
|
---|
348 | return true;
|
---|
349 |
|
---|
350 | resetTimeoutCheck();
|
---|
351 | }
|
---|
352 |
|
---|
353 | return false;
|
---|
354 | }
|
---|
355 |
|
---|
356 | void JSGlobalObject::saveBuiltins(SavedBuiltins& builtins) const
|
---|
357 | {
|
---|
358 | if (!builtins._internal)
|
---|
359 | builtins._internal = new SavedBuiltinsInternal;
|
---|
360 |
|
---|
361 | builtins._internal->objectConstructor = d()->objectConstructor;
|
---|
362 | builtins._internal->functionConstructor = d()->functionConstructor;
|
---|
363 | builtins._internal->arrayConstructor = d()->arrayConstructor;
|
---|
364 | builtins._internal->booleanConstructor = d()->booleanConstructor;
|
---|
365 | builtins._internal->stringConstructor = d()->stringConstructor;
|
---|
366 | builtins._internal->numberConstructor = d()->numberConstructor;
|
---|
367 | builtins._internal->dateConstructor = d()->dateConstructor;
|
---|
368 | builtins._internal->regExpConstructor = d()->regExpConstructor;
|
---|
369 | builtins._internal->errorConstructor = d()->errorConstructor;
|
---|
370 | builtins._internal->evalErrorConstructor = d()->evalErrorConstructor;
|
---|
371 | builtins._internal->rangeErrorConstructor = d()->rangeErrorConstructor;
|
---|
372 | builtins._internal->referenceErrorConstructor = d()->referenceErrorConstructor;
|
---|
373 | builtins._internal->syntaxErrorConstructor = d()->syntaxErrorConstructor;
|
---|
374 | builtins._internal->typeErrorConstructor = d()->typeErrorConstructor;
|
---|
375 | builtins._internal->URIErrorConstructor = d()->URIErrorConstructor;
|
---|
376 |
|
---|
377 | builtins._internal->objectPrototype = d()->objectPrototype;
|
---|
378 | builtins._internal->functionPrototype = d()->functionPrototype;
|
---|
379 | builtins._internal->arrayPrototype = d()->arrayPrototype;
|
---|
380 | builtins._internal->booleanPrototype = d()->booleanPrototype;
|
---|
381 | builtins._internal->stringPrototype = d()->stringPrototype;
|
---|
382 | builtins._internal->numberPrototype = d()->numberPrototype;
|
---|
383 | builtins._internal->datePrototype = d()->datePrototype;
|
---|
384 | builtins._internal->regExpPrototype = d()->regExpPrototype;
|
---|
385 | builtins._internal->errorPrototype = d()->errorPrototype;
|
---|
386 | builtins._internal->evalErrorPrototype = d()->evalErrorPrototype;
|
---|
387 | builtins._internal->rangeErrorPrototype = d()->rangeErrorPrototype;
|
---|
388 | builtins._internal->referenceErrorPrototype = d()->referenceErrorPrototype;
|
---|
389 | builtins._internal->syntaxErrorPrototype = d()->syntaxErrorPrototype;
|
---|
390 | builtins._internal->typeErrorPrototype = d()->typeErrorPrototype;
|
---|
391 | builtins._internal->URIErrorPrototype = d()->URIErrorPrototype;
|
---|
392 | }
|
---|
393 |
|
---|
394 | void JSGlobalObject::restoreBuiltins(const SavedBuiltins& builtins)
|
---|
395 | {
|
---|
396 | if (!builtins._internal)
|
---|
397 | return;
|
---|
398 |
|
---|
399 | d()->objectConstructor = builtins._internal->objectConstructor;
|
---|
400 | d()->functionConstructor = builtins._internal->functionConstructor;
|
---|
401 | d()->arrayConstructor = builtins._internal->arrayConstructor;
|
---|
402 | d()->booleanConstructor = builtins._internal->booleanConstructor;
|
---|
403 | d()->stringConstructor = builtins._internal->stringConstructor;
|
---|
404 | d()->numberConstructor = builtins._internal->numberConstructor;
|
---|
405 | d()->dateConstructor = builtins._internal->dateConstructor;
|
---|
406 | d()->regExpConstructor = builtins._internal->regExpConstructor;
|
---|
407 | d()->errorConstructor = builtins._internal->errorConstructor;
|
---|
408 | d()->evalErrorConstructor = builtins._internal->evalErrorConstructor;
|
---|
409 | d()->rangeErrorConstructor = builtins._internal->rangeErrorConstructor;
|
---|
410 | d()->referenceErrorConstructor = builtins._internal->referenceErrorConstructor;
|
---|
411 | d()->syntaxErrorConstructor = builtins._internal->syntaxErrorConstructor;
|
---|
412 | d()->typeErrorConstructor = builtins._internal->typeErrorConstructor;
|
---|
413 | d()->URIErrorConstructor = builtins._internal->URIErrorConstructor;
|
---|
414 |
|
---|
415 | d()->objectPrototype = builtins._internal->objectPrototype;
|
---|
416 | d()->functionPrototype = builtins._internal->functionPrototype;
|
---|
417 | d()->arrayPrototype = builtins._internal->arrayPrototype;
|
---|
418 | d()->booleanPrototype = builtins._internal->booleanPrototype;
|
---|
419 | d()->stringPrototype = builtins._internal->stringPrototype;
|
---|
420 | d()->numberPrototype = builtins._internal->numberPrototype;
|
---|
421 | d()->datePrototype = builtins._internal->datePrototype;
|
---|
422 | d()->regExpPrototype = builtins._internal->regExpPrototype;
|
---|
423 | d()->errorPrototype = builtins._internal->errorPrototype;
|
---|
424 | d()->evalErrorPrototype = builtins._internal->evalErrorPrototype;
|
---|
425 | d()->rangeErrorPrototype = builtins._internal->rangeErrorPrototype;
|
---|
426 | d()->referenceErrorPrototype = builtins._internal->referenceErrorPrototype;
|
---|
427 | d()->syntaxErrorPrototype = builtins._internal->syntaxErrorPrototype;
|
---|
428 | d()->typeErrorPrototype = builtins._internal->typeErrorPrototype;
|
---|
429 | d()->URIErrorPrototype = builtins._internal->URIErrorPrototype;
|
---|
430 | }
|
---|
431 |
|
---|
432 | void JSGlobalObject::mark()
|
---|
433 | {
|
---|
434 | JSVariableObject::mark();
|
---|
435 |
|
---|
436 | if (d()->currentExec)
|
---|
437 | d()->currentExec->mark();
|
---|
438 |
|
---|
439 | markIfNeeded(d()->globalExec.exception());
|
---|
440 |
|
---|
441 | markIfNeeded(d()->objectConstructor);
|
---|
442 | markIfNeeded(d()->functionConstructor);
|
---|
443 | markIfNeeded(d()->arrayConstructor);
|
---|
444 | markIfNeeded(d()->booleanConstructor);
|
---|
445 | markIfNeeded(d()->stringConstructor);
|
---|
446 | markIfNeeded(d()->numberConstructor);
|
---|
447 | markIfNeeded(d()->dateConstructor);
|
---|
448 | markIfNeeded(d()->regExpConstructor);
|
---|
449 | markIfNeeded(d()->errorConstructor);
|
---|
450 | markIfNeeded(d()->evalErrorConstructor);
|
---|
451 | markIfNeeded(d()->rangeErrorConstructor);
|
---|
452 | markIfNeeded(d()->referenceErrorConstructor);
|
---|
453 | markIfNeeded(d()->syntaxErrorConstructor);
|
---|
454 | markIfNeeded(d()->typeErrorConstructor);
|
---|
455 | markIfNeeded(d()->URIErrorConstructor);
|
---|
456 |
|
---|
457 | markIfNeeded(d()->objectPrototype);
|
---|
458 | markIfNeeded(d()->functionPrototype);
|
---|
459 | markIfNeeded(d()->arrayPrototype);
|
---|
460 | markIfNeeded(d()->booleanPrototype);
|
---|
461 | markIfNeeded(d()->stringPrototype);
|
---|
462 | markIfNeeded(d()->numberPrototype);
|
---|
463 | markIfNeeded(d()->datePrototype);
|
---|
464 | markIfNeeded(d()->regExpPrototype);
|
---|
465 | markIfNeeded(d()->errorPrototype);
|
---|
466 | markIfNeeded(d()->evalErrorPrototype);
|
---|
467 | markIfNeeded(d()->rangeErrorPrototype);
|
---|
468 | markIfNeeded(d()->referenceErrorPrototype);
|
---|
469 | markIfNeeded(d()->syntaxErrorPrototype);
|
---|
470 | markIfNeeded(d()->typeErrorPrototype);
|
---|
471 | markIfNeeded(d()->URIErrorPrototype);
|
---|
472 | }
|
---|
473 |
|
---|
474 | ExecState* JSGlobalObject::globalExec()
|
---|
475 | {
|
---|
476 | return &d()->globalExec;
|
---|
477 | }
|
---|
478 |
|
---|
479 | } // namespace KJS
|
---|