1 | // -*- c-basic-offset: 2 -*-
|
---|
2 | /*
|
---|
3 | * This file is part of the KDE libraries
|
---|
4 | * Copyright (C) 1999-2001 Harri Porten ([email protected])
|
---|
5 | * Copyright (C) 2001 Peter Kelly ([email protected])
|
---|
6 | * Copyright (C) 2003 Apple Computer, Inc.
|
---|
7 | *
|
---|
8 | * This library is free software; you can redistribute it and/or
|
---|
9 | * modify it under the terms of the GNU Library General Public
|
---|
10 | * License as published by the Free Software Foundation; either
|
---|
11 | * version 2 of the License, or (at your option) any later version.
|
---|
12 | *
|
---|
13 | * This library is distributed in the hope that it will be useful,
|
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
16 | * Library General Public License for more details.
|
---|
17 | *
|
---|
18 | * You should have received a copy of the GNU Library General Public License
|
---|
19 | * along with this library; see the file COPYING.LIB. If not, write to
|
---|
20 | * the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
---|
21 | * Boston, MA 02110-1301, USA.
|
---|
22 | *
|
---|
23 | */
|
---|
24 |
|
---|
25 | #include "value.h"
|
---|
26 | #include "object.h"
|
---|
27 | #include "types.h"
|
---|
28 | #include "interpreter.h"
|
---|
29 | #include "lookup.h"
|
---|
30 | #include "reference_list.h"
|
---|
31 |
|
---|
32 | #include <assert.h>
|
---|
33 | #include <math.h>
|
---|
34 | #include <stdio.h>
|
---|
35 |
|
---|
36 | #include "internal.h"
|
---|
37 | #include "collector.h"
|
---|
38 | #include "operations.h"
|
---|
39 | #include "error_object.h"
|
---|
40 | #include "nodes.h"
|
---|
41 |
|
---|
42 | #ifndef NDEBUG
|
---|
43 | //#define JAVASCRIPT_CALL_TRACING 1
|
---|
44 | #endif
|
---|
45 |
|
---|
46 | #if JAVASCRIPT_CALL_TRACING
|
---|
47 | static bool _traceJavaScript = false;
|
---|
48 |
|
---|
49 | extern "C" {
|
---|
50 | void setTraceJavaScript(bool f)
|
---|
51 | {
|
---|
52 | _traceJavaScript = f;
|
---|
53 | }
|
---|
54 |
|
---|
55 | static bool traceJavaScript()
|
---|
56 | {
|
---|
57 | return _traceJavaScript;
|
---|
58 | }
|
---|
59 | }
|
---|
60 | #endif
|
---|
61 |
|
---|
62 | namespace KJS {
|
---|
63 |
|
---|
64 | // ------------------------------ Object ---------------------------------------
|
---|
65 |
|
---|
66 | ValueImp *ObjectImp::call(ExecState *exec, ObjectImp *thisObj, const List &args)
|
---|
67 | {
|
---|
68 | assert(implementsCall());
|
---|
69 |
|
---|
70 | #if KJS_MAX_STACK > 0
|
---|
71 | static int depth = 0; // sum of all concurrent interpreters
|
---|
72 |
|
---|
73 | #if JAVASCRIPT_CALL_TRACING
|
---|
74 | static bool tracing = false;
|
---|
75 | if (traceJavaScript() && !tracing) {
|
---|
76 | tracing = true;
|
---|
77 | for (int i = 0; i < depth; i++)
|
---|
78 | putchar (' ');
|
---|
79 | printf ("*** calling: %s\n", toString(exec).ascii());
|
---|
80 | for (int j = 0; j < args.size(); j++) {
|
---|
81 | for (int i = 0; i < depth; i++)
|
---|
82 | putchar (' ');
|
---|
83 | printf ("*** arg[%d] = %s\n", j, args[j]->toString(exec).ascii());
|
---|
84 | }
|
---|
85 | tracing = false;
|
---|
86 | }
|
---|
87 | #endif
|
---|
88 |
|
---|
89 | if (++depth > KJS_MAX_STACK) {
|
---|
90 | --depth;
|
---|
91 | return throwError(exec, RangeError, "Maximum call stack size exceeded.");
|
---|
92 | }
|
---|
93 | #endif
|
---|
94 |
|
---|
95 | ValueImp *ret = callAsFunction(exec,thisObj,args);
|
---|
96 |
|
---|
97 | #if KJS_MAX_STACK > 0
|
---|
98 | --depth;
|
---|
99 | #endif
|
---|
100 |
|
---|
101 | #if JAVASCRIPT_CALL_TRACING
|
---|
102 | if (traceJavaScript() && !tracing) {
|
---|
103 | tracing = true;
|
---|
104 | for (int i = 0; i < depth; i++)
|
---|
105 | putchar (' ');
|
---|
106 | printf ("*** returning: %s\n", ret->toString(exec).ascii());
|
---|
107 | tracing = false;
|
---|
108 | }
|
---|
109 | #endif
|
---|
110 |
|
---|
111 | return ret;
|
---|
112 | }
|
---|
113 |
|
---|
114 | // ------------------------------ ObjectImp ------------------------------------
|
---|
115 |
|
---|
116 | void ObjectImp::mark()
|
---|
117 | {
|
---|
118 | AllocatedValueImp::mark();
|
---|
119 |
|
---|
120 | ValueImp *proto = _proto;
|
---|
121 | if (!proto->marked())
|
---|
122 | proto->mark();
|
---|
123 |
|
---|
124 | _prop.mark();
|
---|
125 |
|
---|
126 | if (_internalValue && !_internalValue->marked())
|
---|
127 | _internalValue->mark();
|
---|
128 |
|
---|
129 | _scope.mark();
|
---|
130 | }
|
---|
131 |
|
---|
132 | Type ObjectImp::type() const
|
---|
133 | {
|
---|
134 | return ObjectType;
|
---|
135 | }
|
---|
136 |
|
---|
137 | const ClassInfo *ObjectImp::classInfo() const
|
---|
138 | {
|
---|
139 | return 0;
|
---|
140 | }
|
---|
141 |
|
---|
142 | UString ObjectImp::className() const
|
---|
143 | {
|
---|
144 | const ClassInfo *ci = classInfo();
|
---|
145 | if ( ci )
|
---|
146 | return ci->className;
|
---|
147 | return "Object";
|
---|
148 | }
|
---|
149 |
|
---|
150 | ValueImp *ObjectImp::get(ExecState *exec, const Identifier &propertyName) const
|
---|
151 | {
|
---|
152 | PropertySlot slot;
|
---|
153 |
|
---|
154 | if (const_cast<ObjectImp *>(this)->getPropertySlot(exec, propertyName, slot))
|
---|
155 | return slot.getValue(exec, propertyName);
|
---|
156 |
|
---|
157 | return Undefined();
|
---|
158 | }
|
---|
159 |
|
---|
160 | ValueImp *ObjectImp::get(ExecState *exec, unsigned propertyName) const
|
---|
161 | {
|
---|
162 | PropertySlot slot;
|
---|
163 | if (const_cast<ObjectImp *>(this)->getPropertySlot(exec, propertyName, slot))
|
---|
164 | return slot.getValue(exec, propertyName);
|
---|
165 |
|
---|
166 | return Undefined();
|
---|
167 | }
|
---|
168 |
|
---|
169 | bool ObjectImp::getPropertySlot(ExecState *exec, unsigned propertyName, PropertySlot& slot)
|
---|
170 | {
|
---|
171 | ObjectImp *imp = this;
|
---|
172 |
|
---|
173 | while (true) {
|
---|
174 | if (imp->getOwnPropertySlot(exec, propertyName, slot))
|
---|
175 | return true;
|
---|
176 |
|
---|
177 | ValueImp *proto = imp->_proto;
|
---|
178 | if (!proto->isObject())
|
---|
179 | break;
|
---|
180 |
|
---|
181 | imp = static_cast<ObjectImp *>(proto);
|
---|
182 | }
|
---|
183 |
|
---|
184 | return false;
|
---|
185 | }
|
---|
186 |
|
---|
187 | bool ObjectImp::getOwnPropertySlot(ExecState *exec, unsigned propertyName, PropertySlot& slot)
|
---|
188 | {
|
---|
189 | return getOwnPropertySlot(exec, Identifier::from(propertyName), slot);
|
---|
190 | }
|
---|
191 |
|
---|
192 | // ECMA 8.6.2.2
|
---|
193 | void ObjectImp::put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr)
|
---|
194 | {
|
---|
195 | assert(value);
|
---|
196 |
|
---|
197 | // non-standard netscape extension
|
---|
198 | if (propertyName == exec->dynamicInterpreter()->specialPrototypeIdentifier()) {
|
---|
199 | setPrototype(value);
|
---|
200 | return;
|
---|
201 | }
|
---|
202 |
|
---|
203 | /* TODO: check for write permissions directly w/o this call */
|
---|
204 | /* Doesn't look very easy with the PropertyMap API - David */
|
---|
205 | // putValue() is used for JS assignemnts. It passes no attribute.
|
---|
206 | // Assume that a C++ implementation knows what it is doing
|
---|
207 | // and let it override the canPut() check.
|
---|
208 | if ((attr == None || attr == DontDelete) && !canPut(exec,propertyName)) {
|
---|
209 | #ifdef KJS_VERBOSE
|
---|
210 | fprintf( stderr, "WARNING: canPut %s said NO\n", propertyName.ascii() );
|
---|
211 | #endif
|
---|
212 | return;
|
---|
213 | }
|
---|
214 |
|
---|
215 | _prop.put(propertyName,value,attr);
|
---|
216 | }
|
---|
217 |
|
---|
218 | void ObjectImp::put(ExecState *exec, unsigned propertyName,
|
---|
219 | ValueImp *value, int attr)
|
---|
220 | {
|
---|
221 | put(exec, Identifier::from(propertyName), value, attr);
|
---|
222 | }
|
---|
223 |
|
---|
224 | // ECMA 8.6.2.3
|
---|
225 | bool ObjectImp::canPut(ExecState *, const Identifier &propertyName) const
|
---|
226 | {
|
---|
227 | int attributes;
|
---|
228 | ValueImp *v = _prop.get(propertyName, attributes);
|
---|
229 | if (v)
|
---|
230 | return!(attributes & ReadOnly);
|
---|
231 |
|
---|
232 | // Look in the static hashtable of properties
|
---|
233 | const HashEntry* e = findPropertyHashEntry(propertyName);
|
---|
234 | if (e)
|
---|
235 | return !(e->attr & ReadOnly);
|
---|
236 |
|
---|
237 | // Don't look in the prototype here. We can always put an override
|
---|
238 | // in the object, even if the prototype has a ReadOnly property.
|
---|
239 | return true;
|
---|
240 | }
|
---|
241 |
|
---|
242 | // ECMA 8.6.2.4
|
---|
243 | bool ObjectImp::hasProperty(ExecState *exec, const Identifier &propertyName) const
|
---|
244 | {
|
---|
245 | PropertySlot slot;
|
---|
246 | return const_cast<ObjectImp *>(this)->getPropertySlot(exec, propertyName, slot);
|
---|
247 | }
|
---|
248 |
|
---|
249 | bool ObjectImp::hasProperty(ExecState *exec, unsigned propertyName) const
|
---|
250 | {
|
---|
251 | PropertySlot slot;
|
---|
252 | return const_cast<ObjectImp *>(this)->getPropertySlot(exec, propertyName, slot);
|
---|
253 | }
|
---|
254 |
|
---|
255 | // ECMA 8.6.2.5
|
---|
256 | bool ObjectImp::deleteProperty(ExecState */*exec*/, const Identifier &propertyName)
|
---|
257 | {
|
---|
258 | int attributes;
|
---|
259 | ValueImp *v = _prop.get(propertyName, attributes);
|
---|
260 | if (v) {
|
---|
261 | if ((attributes & DontDelete))
|
---|
262 | return false;
|
---|
263 | _prop.remove(propertyName);
|
---|
264 | return true;
|
---|
265 | }
|
---|
266 |
|
---|
267 | // Look in the static hashtable of properties
|
---|
268 | const HashEntry* entry = findPropertyHashEntry(propertyName);
|
---|
269 | if (entry && entry->attr & DontDelete)
|
---|
270 | return false; // this builtin property can't be deleted
|
---|
271 | return true;
|
---|
272 | }
|
---|
273 |
|
---|
274 | bool ObjectImp::deleteProperty(ExecState *exec, unsigned propertyName)
|
---|
275 | {
|
---|
276 | return deleteProperty(exec, Identifier::from(propertyName));
|
---|
277 | }
|
---|
278 |
|
---|
279 | // ECMA 8.6.2.6
|
---|
280 | ValueImp *ObjectImp::defaultValue(ExecState *exec, Type hint) const
|
---|
281 | {
|
---|
282 | if (hint != StringType && hint != NumberType) {
|
---|
283 | /* Prefer String for Date objects */
|
---|
284 | if (_proto == exec->lexicalInterpreter()->builtinDatePrototype())
|
---|
285 | hint = StringType;
|
---|
286 | else
|
---|
287 | hint = NumberType;
|
---|
288 | }
|
---|
289 |
|
---|
290 | ValueImp *v;
|
---|
291 | if (hint == StringType)
|
---|
292 | v = get(exec,toStringPropertyName);
|
---|
293 | else
|
---|
294 | v = get(exec,valueOfPropertyName);
|
---|
295 |
|
---|
296 | if (v->isObject()) {
|
---|
297 | ObjectImp *o = static_cast<ObjectImp*>(v);
|
---|
298 | if (o->implementsCall()) { // spec says "not primitive type" but ...
|
---|
299 | ObjectImp *thisObj = const_cast<ObjectImp*>(this);
|
---|
300 | ValueImp *def = o->call(exec,thisObj,List::empty());
|
---|
301 | Type defType = def->type();
|
---|
302 | if (defType == UnspecifiedType || defType == UndefinedType ||
|
---|
303 | defType == NullType || defType == BooleanType ||
|
---|
304 | defType == StringType || defType == NumberType) {
|
---|
305 | return def;
|
---|
306 | }
|
---|
307 | }
|
---|
308 | }
|
---|
309 |
|
---|
310 | if (hint == StringType)
|
---|
311 | v = get(exec,valueOfPropertyName);
|
---|
312 | else
|
---|
313 | v = get(exec,toStringPropertyName);
|
---|
314 |
|
---|
315 | if (v->isObject()) {
|
---|
316 | ObjectImp *o = static_cast<ObjectImp*>(v);
|
---|
317 | if (o->implementsCall()) { // spec says "not primitive type" but ...
|
---|
318 | ObjectImp *thisObj = const_cast<ObjectImp*>(this);
|
---|
319 | ValueImp *def = o->call(exec,thisObj,List::empty());
|
---|
320 | Type defType = def->type();
|
---|
321 | if (defType == UnspecifiedType || defType == UndefinedType ||
|
---|
322 | defType == NullType || defType == BooleanType ||
|
---|
323 | defType == StringType || defType == NumberType) {
|
---|
324 | return def;
|
---|
325 | }
|
---|
326 | }
|
---|
327 | }
|
---|
328 |
|
---|
329 | if (exec->hadException())
|
---|
330 | return exec->exception();
|
---|
331 |
|
---|
332 | return throwError(exec, TypeError, "No default value");
|
---|
333 | }
|
---|
334 |
|
---|
335 | const HashEntry* ObjectImp::findPropertyHashEntry(const Identifier& propertyName) const
|
---|
336 | {
|
---|
337 | for (const ClassInfo *info = classInfo(); info; info = info->parentClass) {
|
---|
338 | if (const HashTable *propHashTable = info->propHashTable) {
|
---|
339 | if (const HashEntry *e = Lookup::findEntry(propHashTable, propertyName))
|
---|
340 | return e;
|
---|
341 | }
|
---|
342 | }
|
---|
343 | return 0;
|
---|
344 | }
|
---|
345 |
|
---|
346 | bool ObjectImp::implementsConstruct() const
|
---|
347 | {
|
---|
348 | return false;
|
---|
349 | }
|
---|
350 |
|
---|
351 | ObjectImp *ObjectImp::construct(ExecState */*exec*/, const List &/*args*/)
|
---|
352 | {
|
---|
353 | assert(false);
|
---|
354 | return NULL;
|
---|
355 | }
|
---|
356 |
|
---|
357 | ObjectImp *ObjectImp::construct(ExecState *exec, const List &args, const UString &/*sourceURL*/, int /*lineNumber*/)
|
---|
358 | {
|
---|
359 | return construct(exec, args);
|
---|
360 | }
|
---|
361 |
|
---|
362 | bool ObjectImp::implementsCall() const
|
---|
363 | {
|
---|
364 | return false;
|
---|
365 | }
|
---|
366 |
|
---|
367 | ValueImp *ObjectImp::callAsFunction(ExecState */*exec*/, ObjectImp */*thisObj*/, const List &/*args*/)
|
---|
368 | {
|
---|
369 | assert(false);
|
---|
370 | return NULL;
|
---|
371 | }
|
---|
372 |
|
---|
373 | bool ObjectImp::implementsHasInstance() const
|
---|
374 | {
|
---|
375 | return false;
|
---|
376 | }
|
---|
377 |
|
---|
378 | bool ObjectImp::hasInstance(ExecState */*exec*/, ValueImp */*value*/)
|
---|
379 | {
|
---|
380 | assert(false);
|
---|
381 | return false;
|
---|
382 | }
|
---|
383 |
|
---|
384 | ReferenceList ObjectImp::propList(ExecState *exec, bool recursive)
|
---|
385 | {
|
---|
386 | ReferenceList list;
|
---|
387 | if (_proto->isObject() && recursive)
|
---|
388 | list = static_cast<ObjectImp*>(_proto)->propList(exec,recursive);
|
---|
389 |
|
---|
390 | _prop.addEnumerablesToReferenceList(list, this);
|
---|
391 |
|
---|
392 | // Add properties from the static hashtable of properties
|
---|
393 | const ClassInfo *info = classInfo();
|
---|
394 | while (info) {
|
---|
395 | if (info->propHashTable) {
|
---|
396 | int size = info->propHashTable->size;
|
---|
397 | const HashEntry *e = info->propHashTable->entries;
|
---|
398 | for (int i = 0; i < size; ++i, ++e) {
|
---|
399 | if ( e->s && !(e->attr & DontEnum) )
|
---|
400 | list.append(Reference(this, e->s)); /// ######### check for duplicates with the propertymap
|
---|
401 | }
|
---|
402 | }
|
---|
403 | info = info->parentClass;
|
---|
404 | }
|
---|
405 |
|
---|
406 | return list;
|
---|
407 | }
|
---|
408 |
|
---|
409 | ValueImp *ObjectImp::toPrimitive(ExecState *exec, Type preferredType) const
|
---|
410 | {
|
---|
411 | return defaultValue(exec,preferredType);
|
---|
412 | }
|
---|
413 |
|
---|
414 | bool ObjectImp::toBoolean(ExecState */*exec*/) const
|
---|
415 | {
|
---|
416 | return true;
|
---|
417 | }
|
---|
418 |
|
---|
419 | double ObjectImp::toNumber(ExecState *exec) const
|
---|
420 | {
|
---|
421 | ValueImp *prim = toPrimitive(exec,NumberType);
|
---|
422 | if (exec->hadException()) // should be picked up soon in nodes.cpp
|
---|
423 | return 0.0;
|
---|
424 | return prim->toNumber(exec);
|
---|
425 | }
|
---|
426 |
|
---|
427 | UString ObjectImp::toString(ExecState *exec) const
|
---|
428 | {
|
---|
429 | ValueImp *prim = toPrimitive(exec,StringType);
|
---|
430 | if (exec->hadException()) // should be picked up soon in nodes.cpp
|
---|
431 | return "";
|
---|
432 | return prim->toString(exec);
|
---|
433 | }
|
---|
434 |
|
---|
435 | ObjectImp *ObjectImp::toObject(ExecState */*exec*/) const
|
---|
436 | {
|
---|
437 | return const_cast<ObjectImp*>(this);
|
---|
438 | }
|
---|
439 |
|
---|
440 | void ObjectImp::putDirect(const Identifier &propertyName, ValueImp *value, int attr)
|
---|
441 | {
|
---|
442 | _prop.put(propertyName, value, attr);
|
---|
443 | }
|
---|
444 |
|
---|
445 | void ObjectImp::putDirect(const Identifier &propertyName, int value, int attr)
|
---|
446 | {
|
---|
447 | _prop.put(propertyName, jsNumber(value), attr);
|
---|
448 | }
|
---|
449 |
|
---|
450 | // ------------------------------ Error ----------------------------------------
|
---|
451 |
|
---|
452 | const char * const errorNamesArr[] = {
|
---|
453 | I18N_NOOP("Error"), // GeneralError
|
---|
454 | I18N_NOOP("Evaluation error"), // EvalError
|
---|
455 | I18N_NOOP("Range error"), // RangeError
|
---|
456 | I18N_NOOP("Reference error"), // ReferenceError
|
---|
457 | I18N_NOOP("Syntax error"), // SyntaxError
|
---|
458 | I18N_NOOP("Type error"), // TypeError
|
---|
459 | I18N_NOOP("URI error"), // URIError
|
---|
460 | };
|
---|
461 |
|
---|
462 | const char * const * const Error::errorNames = errorNamesArr;
|
---|
463 |
|
---|
464 | ObjectImp *Error::create(ExecState *exec, ErrorType errtype, const UString &message,
|
---|
465 | int lineno, int sourceId, const UString *sourceURL)
|
---|
466 | {
|
---|
467 | ObjectImp *cons;
|
---|
468 | switch (errtype) {
|
---|
469 | case EvalError:
|
---|
470 | cons = exec->lexicalInterpreter()->builtinEvalError();
|
---|
471 | break;
|
---|
472 | case RangeError:
|
---|
473 | cons = exec->lexicalInterpreter()->builtinRangeError();
|
---|
474 | break;
|
---|
475 | case ReferenceError:
|
---|
476 | cons = exec->lexicalInterpreter()->builtinReferenceError();
|
---|
477 | break;
|
---|
478 | case SyntaxError:
|
---|
479 | cons = exec->lexicalInterpreter()->builtinSyntaxError();
|
---|
480 | break;
|
---|
481 | case TypeError:
|
---|
482 | cons = exec->lexicalInterpreter()->builtinTypeError();
|
---|
483 | break;
|
---|
484 | case URIError:
|
---|
485 | cons = exec->lexicalInterpreter()->builtinURIError();
|
---|
486 | break;
|
---|
487 | default:
|
---|
488 | cons = exec->lexicalInterpreter()->builtinError();
|
---|
489 | break;
|
---|
490 | }
|
---|
491 |
|
---|
492 | List args;
|
---|
493 | if (message.isEmpty())
|
---|
494 | args.append(jsString(errorNames[errtype]));
|
---|
495 | else
|
---|
496 | args.append(jsString(message));
|
---|
497 | ObjectImp *err = static_cast<ObjectImp *>(cons->construct(exec,args));
|
---|
498 |
|
---|
499 | if (lineno != -1)
|
---|
500 | err->put(exec, "line", Number(lineno));
|
---|
501 | if (sourceId != -1)
|
---|
502 | err->put(exec, "sourceId", Number(sourceId));
|
---|
503 |
|
---|
504 | if(sourceURL)
|
---|
505 | err->put(exec,"sourceURL", String(*sourceURL));
|
---|
506 |
|
---|
507 | return err;
|
---|
508 |
|
---|
509 | /*
|
---|
510 | #ifndef NDEBUG
|
---|
511 | const char *msg = err->get("message")->toString().value().ascii();
|
---|
512 | if (l >= 0)
|
---|
513 | fprintf(stderr, "KJS: %s at line %d. %s\n", estr, l, msg);
|
---|
514 | else
|
---|
515 | fprintf(stderr, "KJS: %s. %s\n", estr, msg);
|
---|
516 | #endif
|
---|
517 |
|
---|
518 | return err;
|
---|
519 | */
|
---|
520 | }
|
---|
521 |
|
---|
522 | ObjectImp *Error::create(ExecState *exec, ErrorType type, const char *message)
|
---|
523 | {
|
---|
524 | return create(exec, type, message, -1, -1, NULL);
|
---|
525 | }
|
---|
526 |
|
---|
527 | ObjectImp *throwError(ExecState *exec, ErrorType type)
|
---|
528 | {
|
---|
529 | ObjectImp *error = Error::create(exec, type, UString(), -1, -1, NULL);
|
---|
530 | exec->setException(error);
|
---|
531 | return error;
|
---|
532 | }
|
---|
533 |
|
---|
534 | ObjectImp *throwError(ExecState *exec, ErrorType type, const UString &message)
|
---|
535 | {
|
---|
536 | ObjectImp *error = Error::create(exec, type, message, -1, -1, NULL);
|
---|
537 | exec->setException(error);
|
---|
538 | return error;
|
---|
539 | }
|
---|
540 |
|
---|
541 | ObjectImp *throwError(ExecState *exec, ErrorType type, const char *message)
|
---|
542 | {
|
---|
543 | ObjectImp *error = Error::create(exec, type, message, -1, -1, NULL);
|
---|
544 | exec->setException(error);
|
---|
545 | return error;
|
---|
546 | }
|
---|
547 |
|
---|
548 | ObjectImp *throwError(ExecState *exec, ErrorType type, const UString &message, int line, int sourceId, const UString *sourceURL)
|
---|
549 | {
|
---|
550 | ObjectImp *error = Error::create(exec, type, message, line, sourceId, sourceURL);
|
---|
551 | exec->setException(error);
|
---|
552 | return error;
|
---|
553 | }
|
---|
554 |
|
---|
555 | } // namespace KJS
|
---|