source: webkit/trunk/JavaScriptCore/kjs/object.cpp@ 18837

Last change on this file since 18837 was 17372, checked in by darin, 19 years ago

Reviewed by Geoff.

  • made changes so the code compiles with the highest warning level under MSVC (disabling some warnings, making some code fixes)
  • API/JSCallbackConstructor.cpp: (KJS::JSCallbackConstructor::construct):
  • API/JSCallbackFunction.cpp: (KJS::JSCallbackFunction::callAsFunction):
  • API/JSCallbackObject.cpp: (KJS::JSCallbackObject::init): (KJS::JSCallbackObject::construct): (KJS::JSCallbackObject::callAsFunction):
  • API/JSObjectRef.cpp: (JSPropertyNameArrayGetNameAtIndex):
  • API/JSStringRef.cpp: (JSStringCreateWithCharacters):
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • bindings/c/c_utility.cpp: (KJS::Bindings::convertUTF8ToUTF16): (KJS::Bindings::coerceValueToNPVariantStringType): (KJS::Bindings::convertValueToNPVariant):
  • kjs/DateMath.h: (KJS::GregorianDateTime::GregorianDateTime):
  • kjs/ExecState.h: (KJS::ExecState::hadException):
  • kjs/JSImmediate.h: (KJS::JSImmediate::fromDouble): (KJS::JSImmediate::toDouble): (KJS::JSImmediate::NanAsBits): (KJS::JSImmediate::oneAsBits):
  • kjs/Parser.h:
  • kjs/PropertyNameArray.h: (KJS::PropertyNameArray::size):
  • kjs/array_object.cpp: (ArrayObjectImp::callAsFunction):
  • kjs/bool_object.cpp: (BooleanObjectImp::callAsFunction):
  • kjs/collector.cpp: (KJS::Collector::allocate): (KJS::Collector::markCurrentThreadConservatively): (KJS::Collector::collect):
  • kjs/completion.h: (KJS::Completion::isValueCompletion):
  • kjs/date_object.cpp: (KJS::findMonth):
  • kjs/debugger.cpp: (Debugger::sourceParsed): (Debugger::sourceUnused): (Debugger::exception): (Debugger::atStatement): (Debugger::callEvent): (Debugger::returnEvent):
  • kjs/dtoa.cpp:
  • kjs/error_object.cpp: (ErrorObjectImp::callAsFunction): (NativeErrorImp::callAsFunction):
  • kjs/function.cpp: (KJS::FunctionImp::processVarDecls): (KJS::GlobalFuncImp::callAsFunction):
  • kjs/function_object.cpp: (FunctionPrototype::callAsFunction):
  • kjs/grammar.y:
  • kjs/identifier.cpp: (KJS::CStringTranslator::translate): (KJS::Identifier::add):
  • kjs/internal.h:
  • kjs/lexer.cpp: (Lexer::lex): (Lexer::isIdentStart): (Lexer::isIdentPart): (isDecimalDigit): (Lexer::isHexDigit): (Lexer::isOctalDigit): (Lexer::matchPunctuator): (Lexer::singleEscape): (Lexer::convertOctal): (Lexer::convertHex): (Lexer::convertUnicode): (Lexer::record8):
  • kjs/lexer.h:
  • kjs/math_object.cpp: (MathFuncImp::callAsFunction):
  • kjs/number_object.cpp: (integer_part_noexp): (intPow10): (NumberProtoFunc::callAsFunction): (NumberObjectImp::callAsFunction):
  • kjs/object.cpp: (KJS::JSObject::deleteProperty): (KJS::JSObject::callAsFunction): (KJS::JSObject::toBoolean): (KJS::JSObject::toObject):
  • kjs/object.h: (KJS::JSObject::getPropertySlot):
  • kjs/property_map.cpp: (KJS::isValid): (KJS::PropertyMap::put): (KJS::PropertyMap::insert): (KJS::PropertyMap::containsGettersOrSetters):
  • kjs/property_map.h: (KJS::PropertyMap::hasGetterSetterProperties):
  • kjs/property_slot.h:
  • kjs/string_object.cpp: (StringInstance::getPropertyNames): (StringObjectImp::callAsFunction): (StringObjectFuncImp::callAsFunction):
  • kjs/ustring.cpp: (KJS::UString::Rep::computeHash): (KJS::UString::UString): (KJS::UString::from): (KJS::UString::append): (KJS::UString::ascii): (KJS::UString::operator=): (KJS::UString::find): (KJS::UString::rfind):
  • kjs/ustring.h: (KJS::UChar::high): (KJS::UChar::low): (KJS::UCharReference::low): (KJS::UCharReference::high):
  • kjs/value.cpp: (KJS::JSValue::toUInt16):
  • kjs/value.h:
  • pcre/pcre_compile.c: (get_othercase_range):
  • pcre/pcre_exec.c: (match):
  • pcre/pcre_internal.h:
  • wtf/HashFunctions.h: (WTF::intHash): (WTF::PtrHash::hash):
  • wtf/MathExtras.h: (isnan): (lround): (lroundf):
  • wtf/StringExtras.h: (strncasecmp):
  • wtf/unicode/icu/UnicodeIcu.h: (WTF::Unicode::isPrintableChar):
  • Property svn:eol-style set to native
File size: 17.6 KB
Line 
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, 2004, 2005, 2006 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 Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 *
23 */
24
25#include "config.h"
26#include "object.h"
27
28#include "error_object.h"
29#include "lookup.h"
30#include "nodes.h"
31#include "operations.h"
32#include "PropertyNameArray.h"
33#include <math.h>
34
35// maximum global call stack size. Protects against accidental or
36// malicious infinite recursions. Define to -1 if you want no limit.
37#if PLATFORM(DARWIN) || PLATFORM(WIN_OS)
38// Given OS X stack sizes we run out of stack at about 350 levels.
39// If we improve our stack usage, we can bump this number.
40#define KJS_MAX_STACK 100
41#else
42#define KJS_MAX_STACK 1000
43#endif
44
45#define JAVASCRIPT_CALL_TRACING 0
46
47#if JAVASCRIPT_CALL_TRACING
48static bool _traceJavaScript = false;
49
50extern "C" {
51 void setTraceJavaScript(bool f)
52 {
53 _traceJavaScript = f;
54 }
55
56 static bool traceJavaScript()
57 {
58 return _traceJavaScript;
59 }
60}
61#endif
62
63namespace KJS {
64
65// ------------------------------ Object ---------------------------------------
66
67JSValue *JSObject::call(ExecState *exec, JSObject *thisObj, const List &args)
68{
69 assert(implementsCall());
70
71#if KJS_MAX_STACK > 0
72 static int depth = 0; // sum of all concurrent interpreters
73
74#if JAVASCRIPT_CALL_TRACING
75 static bool tracing = false;
76 if (traceJavaScript() && !tracing) {
77 tracing = true;
78 for (int i = 0; i < depth; i++)
79 putchar (' ');
80 printf ("*** calling: %s\n", toString(exec).ascii());
81 for (int j = 0; j < args.size(); j++) {
82 for (int i = 0; i < depth; i++)
83 putchar (' ');
84 printf ("*** arg[%d] = %s\n", j, args[j]->toString(exec).ascii());
85 }
86 tracing = false;
87 }
88#endif
89
90 if (++depth > KJS_MAX_STACK) {
91 --depth;
92 return throwError(exec, RangeError, "Maximum call stack size exceeded.");
93 }
94#endif
95
96 JSValue *ret = callAsFunction(exec,thisObj,args);
97
98#if KJS_MAX_STACK > 0
99 --depth;
100#endif
101
102#if JAVASCRIPT_CALL_TRACING
103 if (traceJavaScript() && !tracing) {
104 tracing = true;
105 for (int i = 0; i < depth; i++)
106 putchar (' ');
107 printf ("*** returning: %s\n", ret->toString(exec).ascii());
108 tracing = false;
109 }
110#endif
111
112 return ret;
113}
114
115// ------------------------------ JSObject ------------------------------------
116
117void JSObject::mark()
118{
119 JSCell::mark();
120
121 JSValue *proto = _proto;
122 if (!proto->marked())
123 proto->mark();
124
125 _prop.mark();
126}
127
128JSType JSObject::type() const
129{
130 return ObjectType;
131}
132
133const ClassInfo *JSObject::classInfo() const
134{
135 return 0;
136}
137
138UString JSObject::className() const
139{
140 const ClassInfo *ci = classInfo();
141 if ( ci )
142 return ci->className;
143 return "Object";
144}
145
146JSValue *JSObject::get(ExecState *exec, const Identifier &propertyName) const
147{
148 PropertySlot slot;
149
150 if (const_cast<JSObject *>(this)->getPropertySlot(exec, propertyName, slot))
151 return slot.getValue(exec, const_cast<JSObject *>(this), propertyName);
152
153 return jsUndefined();
154}
155
156JSValue *JSObject::get(ExecState *exec, unsigned propertyName) const
157{
158 PropertySlot slot;
159 if (const_cast<JSObject *>(this)->getPropertySlot(exec, propertyName, slot))
160 return slot.getValue(exec, const_cast<JSObject *>(this), propertyName);
161
162 return jsUndefined();
163}
164
165bool JSObject::getPropertySlot(ExecState *exec, unsigned propertyName, PropertySlot& slot)
166{
167 JSObject *imp = this;
168
169 while (true) {
170 if (imp->getOwnPropertySlot(exec, propertyName, slot))
171 return true;
172
173 JSValue *proto = imp->_proto;
174 if (!proto->isObject())
175 break;
176
177 imp = static_cast<JSObject *>(proto);
178 }
179
180 return false;
181}
182
183bool JSObject::getOwnPropertySlot(ExecState *exec, unsigned propertyName, PropertySlot& slot)
184{
185 return getOwnPropertySlot(exec, Identifier::from(propertyName), slot);
186}
187
188static void throwSetterError(ExecState *exec)
189{
190 throwError(exec, TypeError, "setting a property that has only a getter");
191}
192
193// ECMA 8.6.2.2
194void JSObject::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
195{
196 assert(value);
197
198 // non-standard netscape extension
199 if (propertyName == exec->dynamicInterpreter()->specialPrototypeIdentifier()) {
200 setPrototype(value);
201 return;
202 }
203
204 /* TODO: check for write permissions directly w/o this call */
205 /* Doesn't look very easy with the PropertyMap API - David */
206 // putValue() is used for JS assignemnts. It passes no attribute.
207 // Assume that a C++ implementation knows what it is doing
208 // and let it override the canPut() check.
209 if ((attr == None || attr == DontDelete) && !canPut(exec,propertyName)) {
210#ifdef KJS_VERBOSE
211 fprintf( stderr, "WARNING: canPut %s said NO\n", propertyName.ascii() );
212#endif
213 return;
214 }
215
216 // Check if there are any setters or getters in the prototype chain
217 JSObject *obj = this;
218 bool hasGettersOrSetters = false;
219 while (true) {
220 if (obj->_prop.hasGetterSetterProperties()) {
221 hasGettersOrSetters = true;
222 break;
223 }
224
225 if (!obj->_proto->isObject())
226 break;
227
228 obj = static_cast<JSObject *>(obj->_proto);
229 }
230
231 if (hasGettersOrSetters) {
232 obj = this;
233 while (true) {
234 unsigned attributes;
235 if (JSValue *gs = obj->_prop.get(propertyName, attributes)) {
236 if (attributes & GetterSetter) {
237 JSObject *setterFunc = static_cast<GetterSetterImp *>(gs)->getSetter();
238
239 if (!setterFunc) {
240 throwSetterError(exec);
241 return;
242 }
243
244 List args;
245 args.append(value);
246
247 setterFunc->call(exec, this, args);
248 return;
249 } else {
250 // If there's an existing property on the object or one of its
251 // prototype it should be replaced, so we just break here.
252 break;
253 }
254 }
255
256 if (!obj->_proto->isObject())
257 break;
258
259 obj = static_cast<JSObject *>(obj->_proto);
260 }
261 }
262
263 _prop.put(propertyName,value,attr);
264}
265
266void JSObject::put(ExecState *exec, unsigned propertyName,
267 JSValue *value, int attr)
268{
269 put(exec, Identifier::from(propertyName), value, attr);
270}
271
272// ECMA 8.6.2.3
273bool JSObject::canPut(ExecState *, const Identifier &propertyName) const
274{
275 unsigned attributes;
276
277 // Don't look in the prototype here. We can always put an override
278 // in the object, even if the prototype has a ReadOnly property.
279
280 if (!getPropertyAttributes(propertyName, attributes))
281 return true;
282 else
283 return !(attributes & ReadOnly);
284}
285
286// ECMA 8.6.2.4
287bool JSObject::hasProperty(ExecState *exec, const Identifier &propertyName) const
288{
289 PropertySlot slot;
290 return const_cast<JSObject *>(this)->getPropertySlot(exec, propertyName, slot);
291}
292
293bool JSObject::hasProperty(ExecState *exec, unsigned propertyName) const
294{
295 PropertySlot slot;
296 return const_cast<JSObject *>(this)->getPropertySlot(exec, propertyName, slot);
297}
298
299// ECMA 8.6.2.5
300bool JSObject::deleteProperty(ExecState* /*exec*/, const Identifier &propertyName)
301{
302 unsigned attributes;
303 JSValue *v = _prop.get(propertyName, attributes);
304 if (v) {
305 if ((attributes & DontDelete))
306 return false;
307 _prop.remove(propertyName);
308 if (attributes & GetterSetter)
309 _prop.setHasGetterSetterProperties(_prop.containsGettersOrSetters());
310 return true;
311 }
312
313 // Look in the static hashtable of properties
314 const HashEntry* entry = findPropertyHashEntry(propertyName);
315 if (entry && entry->attr & DontDelete)
316 return false; // this builtin property can't be deleted
317 return true;
318}
319
320bool JSObject::deleteProperty(ExecState *exec, unsigned propertyName)
321{
322 return deleteProperty(exec, Identifier::from(propertyName));
323}
324
325static ALWAYS_INLINE JSValue *tryGetAndCallProperty(ExecState *exec, const JSObject *object, const Identifier &propertyName) {
326 JSValue *v = object->get(exec, propertyName);
327 if (v->isObject()) {
328 JSObject *o = static_cast<JSObject*>(v);
329 if (o->implementsCall()) { // spec says "not primitive type" but ...
330 JSObject *thisObj = const_cast<JSObject*>(object);
331 JSValue *def = o->call(exec, thisObj, List::empty());
332 JSType defType = def->type();
333 ASSERT(defType != GetterSetterType);
334 if (defType != ObjectType)
335 return def;
336 }
337 }
338 return NULL;
339}
340
341// ECMA 8.6.2.6
342JSValue *JSObject::defaultValue(ExecState *exec, JSType hint) const
343{
344 Identifier firstPropertyName;
345 Identifier secondPropertyName;
346 /* Prefer String for Date objects */
347 if ((hint == StringType) || (hint != StringType) && (hint != NumberType) && (_proto == exec->lexicalInterpreter()->builtinDatePrototype())) {
348 firstPropertyName = toStringPropertyName;
349 secondPropertyName = valueOfPropertyName;
350 } else {
351 firstPropertyName = valueOfPropertyName;
352 secondPropertyName = toStringPropertyName;
353 }
354
355 JSValue *v;
356 if ((v = tryGetAndCallProperty(exec, this, firstPropertyName)))
357 return v;
358 if ((v = tryGetAndCallProperty(exec, this, secondPropertyName)))
359 return v;
360
361 if (exec->hadException())
362 return exec->exception();
363
364 return throwError(exec, TypeError, "No default value");
365}
366
367const HashEntry* JSObject::findPropertyHashEntry(const Identifier& propertyName) const
368{
369 for (const ClassInfo *info = classInfo(); info; info = info->parentClass) {
370 if (const HashTable *propHashTable = info->propHashTable) {
371 if (const HashEntry *e = Lookup::findEntry(propHashTable, propertyName))
372 return e;
373 }
374 }
375 return 0;
376}
377
378void JSObject::defineGetter(ExecState*, const Identifier& propertyName, JSObject* getterFunc)
379{
380 JSValue *o = getDirect(propertyName);
381 GetterSetterImp *gs;
382
383 if (o && o->type() == GetterSetterType) {
384 gs = static_cast<GetterSetterImp *>(o);
385 } else {
386 gs = new GetterSetterImp;
387 putDirect(propertyName, gs, GetterSetter);
388 }
389
390 _prop.setHasGetterSetterProperties(true);
391 gs->setGetter(getterFunc);
392}
393
394void JSObject::defineSetter(ExecState*, const Identifier& propertyName, JSObject* setterFunc)
395{
396 JSValue *o = getDirect(propertyName);
397 GetterSetterImp *gs;
398
399 if (o && o->type() == GetterSetterType) {
400 gs = static_cast<GetterSetterImp *>(o);
401 } else {
402 gs = new GetterSetterImp;
403 putDirect(propertyName, gs, GetterSetter);
404 }
405
406 _prop.setHasGetterSetterProperties(true);
407 gs->setSetter(setterFunc);
408}
409
410bool JSObject::implementsConstruct() const
411{
412 return false;
413}
414
415JSObject* JSObject::construct(ExecState*, const List& /*args*/)
416{
417 assert(false);
418 return NULL;
419}
420
421JSObject* JSObject::construct(ExecState* exec, const List& args, const Identifier& /*functionName*/, const UString& /*sourceURL*/, int /*lineNumber*/)
422{
423 return construct(exec, args);
424}
425
426bool JSObject::implementsCall() const
427{
428 return false;
429}
430
431JSValue *JSObject::callAsFunction(ExecState* /*exec*/, JSObject* /*thisObj*/, const List &/*args*/)
432{
433 assert(false);
434 return NULL;
435}
436
437bool JSObject::implementsHasInstance() const
438{
439 return false;
440}
441
442bool JSObject::hasInstance(ExecState* exec, JSValue* value)
443{
444 JSValue* proto = get(exec, prototypePropertyName);
445 if (!proto->isObject()) {
446 throwError(exec, TypeError, "intanceof called on an object with an invalid prototype property.");
447 return false;
448 }
449
450 if (!value->isObject())
451 return false;
452
453 JSObject* o = static_cast<JSObject*>(value);
454 while ((o = o->prototype()->getObject())) {
455 if (o == proto)
456 return true;
457 }
458 return false;
459}
460
461bool JSObject::propertyIsEnumerable(ExecState*, const Identifier& propertyName) const
462{
463 unsigned attributes;
464
465 if (!getPropertyAttributes(propertyName, attributes))
466 return false;
467 else
468 return !(attributes & DontEnum);
469}
470
471bool JSObject::getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const
472{
473 if (_prop.get(propertyName, attributes))
474 return true;
475
476 // Look in the static hashtable of properties
477 const HashEntry* e = findPropertyHashEntry(propertyName);
478 if (e) {
479 attributes = e->attr;
480 return true;
481 }
482
483 return false;
484}
485
486void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
487{
488 _prop.getEnumerablePropertyNames(propertyNames);
489
490 // Add properties from the static hashtable of properties
491 const ClassInfo *info = classInfo();
492 while (info) {
493 if (info->propHashTable) {
494 int size = info->propHashTable->size;
495 const HashEntry *e = info->propHashTable->entries;
496 for (int i = 0; i < size; ++i, ++e) {
497 if (e->s && !(e->attr & DontEnum))
498 propertyNames.add(e->s);
499 }
500 }
501 info = info->parentClass;
502 }
503 if (_proto->isObject())
504 static_cast<JSObject*>(_proto)->getPropertyNames(exec, propertyNames);
505}
506
507bool JSObject::toBoolean(ExecState*) const
508{
509 return true;
510}
511
512double JSObject::toNumber(ExecState *exec) const
513{
514 JSValue *prim = toPrimitive(exec,NumberType);
515 if (exec->hadException()) // should be picked up soon in nodes.cpp
516 return 0.0;
517 return prim->toNumber(exec);
518}
519
520UString JSObject::toString(ExecState *exec) const
521{
522 JSValue *prim = toPrimitive(exec,StringType);
523 if (exec->hadException()) // should be picked up soon in nodes.cpp
524 return "";
525 return prim->toString(exec);
526}
527
528JSObject *JSObject::toObject(ExecState*) const
529{
530 return const_cast<JSObject*>(this);
531}
532
533void JSObject::putDirect(const Identifier &propertyName, JSValue *value, int attr)
534{
535 _prop.put(propertyName, value, attr);
536}
537
538void JSObject::putDirect(const Identifier &propertyName, int value, int attr)
539{
540 _prop.put(propertyName, jsNumber(value), attr);
541}
542
543void JSObject::putDirectFunction(InternalFunctionImp* func, int attr)
544{
545 putDirect(func->functionName(), func, attr);
546}
547
548void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue **location)
549{
550 GetterSetterImp *gs = static_cast<GetterSetterImp *>(*location);
551 JSObject *getterFunc = gs->getGetter();
552 if (getterFunc)
553 slot.setGetterSlot(this, getterFunc);
554 else
555 slot.setUndefined(this);
556}
557
558// ------------------------------ Error ----------------------------------------
559
560const char * const errorNamesArr[] = {
561 I18N_NOOP("Error"), // GeneralError
562 I18N_NOOP("Evaluation error"), // EvalError
563 I18N_NOOP("Range error"), // RangeError
564 I18N_NOOP("Reference error"), // ReferenceError
565 I18N_NOOP("Syntax error"), // SyntaxError
566 I18N_NOOP("Type error"), // TypeError
567 I18N_NOOP("URI error"), // URIError
568};
569
570const char * const * const Error::errorNames = errorNamesArr;
571
572JSObject *Error::create(ExecState *exec, ErrorType errtype, const UString &message,
573 int lineno, int sourceId, const UString &sourceURL)
574{
575 JSObject *cons;
576 switch (errtype) {
577 case EvalError:
578 cons = exec->lexicalInterpreter()->builtinEvalError();
579 break;
580 case RangeError:
581 cons = exec->lexicalInterpreter()->builtinRangeError();
582 break;
583 case ReferenceError:
584 cons = exec->lexicalInterpreter()->builtinReferenceError();
585 break;
586 case SyntaxError:
587 cons = exec->lexicalInterpreter()->builtinSyntaxError();
588 break;
589 case TypeError:
590 cons = exec->lexicalInterpreter()->builtinTypeError();
591 break;
592 case URIError:
593 cons = exec->lexicalInterpreter()->builtinURIError();
594 break;
595 default:
596 cons = exec->lexicalInterpreter()->builtinError();
597 break;
598 }
599
600 List args;
601 if (message.isEmpty())
602 args.append(jsString(errorNames[errtype]));
603 else
604 args.append(jsString(message));
605 JSObject *err = static_cast<JSObject *>(cons->construct(exec,args));
606
607 if (lineno != -1)
608 err->put(exec, "line", jsNumber(lineno));
609 if (sourceId != -1)
610 err->put(exec, "sourceId", jsNumber(sourceId));
611
612 if(!sourceURL.isNull())
613 err->put(exec, "sourceURL", jsString(sourceURL));
614
615 return err;
616
617/*
618#ifndef NDEBUG
619 const char *msg = err->get(messagePropertyName)->toString().value().ascii();
620 if (l >= 0)
621 fprintf(stderr, "KJS: %s at line %d. %s\n", estr, l, msg);
622 else
623 fprintf(stderr, "KJS: %s. %s\n", estr, msg);
624#endif
625
626 return err;
627*/
628}
629
630JSObject *Error::create(ExecState *exec, ErrorType type, const char *message)
631{
632 return create(exec, type, message, -1, -1, NULL);
633}
634
635JSObject *throwError(ExecState *exec, ErrorType type)
636{
637 JSObject *error = Error::create(exec, type, UString(), -1, -1, NULL);
638 exec->setException(error);
639 return error;
640}
641
642JSObject *throwError(ExecState *exec, ErrorType type, const UString &message)
643{
644 JSObject *error = Error::create(exec, type, message, -1, -1, NULL);
645 exec->setException(error);
646 return error;
647}
648
649JSObject *throwError(ExecState *exec, ErrorType type, const char *message)
650{
651 JSObject *error = Error::create(exec, type, message, -1, -1, NULL);
652 exec->setException(error);
653 return error;
654}
655
656JSObject *throwError(ExecState *exec, ErrorType type, const UString &message, int line, int sourceId, const UString &sourceURL)
657{
658 JSObject *error = Error::create(exec, type, message, line, sourceId, sourceURL);
659 exec->setException(error);
660 return error;
661}
662
663} // namespace KJS
Note: See TracBrowser for help on using the repository browser.