1 /*
2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 #include "APICast.h"
28 #include "Error.h"
29 #include "JSCallbackFunction.h"
30 #include "JSClassRef.h"
31 #include "JSGlobalObject.h"
32 #include "JSLock.h"
33 #include "JSObjectRef.h"
34 #include "JSString.h"
35 #include "JSStringRef.h"
36 #include "OpaqueJSString.h"
37 #include "PropertyNameArray.h"
38 #include <wtf/Vector.h>
39
40 namespace JSC {
41
42 template <class Base>
asCallbackObject(JSValue value)43 inline JSCallbackObject<Base>* JSCallbackObject<Base>::asCallbackObject(JSValue value)
44 {
45 ASSERT(asObject(value)->inherits(&info));
46 return static_cast<JSCallbackObject*>(asObject(value));
47 }
48
49 template <class Base>
JSCallbackObject(ExecState * exec,PassRefPtr<Structure> structure,JSClassRef jsClass,void * data)50 JSCallbackObject<Base>::JSCallbackObject(ExecState* exec, PassRefPtr<Structure> structure, JSClassRef jsClass, void* data)
51 : Base(structure)
52 , m_callbackObjectData(new JSCallbackObjectData(data, jsClass))
53 {
54 init(exec);
55 }
56
57 // Global object constructor.
58 // FIXME: Move this into a separate JSGlobalCallbackObject class derived from this one.
59 template <class Base>
JSCallbackObject(JSClassRef jsClass)60 JSCallbackObject<Base>::JSCallbackObject(JSClassRef jsClass)
61 : Base()
62 , m_callbackObjectData(new JSCallbackObjectData(0, jsClass))
63 {
64 ASSERT(Base::isGlobalObject());
65 init(static_cast<JSGlobalObject*>(this)->globalExec());
66 }
67
68 template <class Base>
init(ExecState * exec)69 void JSCallbackObject<Base>::init(ExecState* exec)
70 {
71 ASSERT(exec);
72
73 Vector<JSObjectInitializeCallback, 16> initRoutines;
74 JSClassRef jsClass = classRef();
75 do {
76 if (JSObjectInitializeCallback initialize = jsClass->initialize)
77 initRoutines.append(initialize);
78 } while ((jsClass = jsClass->parentClass));
79
80 // initialize from base to derived
81 for (int i = static_cast<int>(initRoutines.size()) - 1; i >= 0; i--) {
82 JSLock::DropAllLocks dropAllLocks(exec);
83 JSObjectInitializeCallback initialize = initRoutines[i];
84 initialize(toRef(exec), toRef(this));
85 }
86 }
87
88 template <class Base>
~JSCallbackObject()89 JSCallbackObject<Base>::~JSCallbackObject()
90 {
91 JSObjectRef thisRef = toRef(this);
92
93 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
94 if (JSObjectFinalizeCallback finalize = jsClass->finalize)
95 finalize(thisRef);
96 }
97
98 template <class Base>
className()99 UString JSCallbackObject<Base>::className() const
100 {
101 UString thisClassName = classRef()->className();
102 if (!thisClassName.isEmpty())
103 return thisClassName;
104
105 return Base::className();
106 }
107
108 template <class Base>
getOwnPropertySlot(ExecState * exec,const Identifier & propertyName,PropertySlot & slot)109 bool JSCallbackObject<Base>::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
110 {
111 JSContextRef ctx = toRef(exec);
112 JSObjectRef thisRef = toRef(this);
113 RefPtr<OpaqueJSString> propertyNameRef;
114
115 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
116 // optional optimization to bypass getProperty in cases when we only need to know if the property exists
117 if (JSObjectHasPropertyCallback hasProperty = jsClass->hasProperty) {
118 if (!propertyNameRef)
119 propertyNameRef = OpaqueJSString::create(propertyName.ustring());
120 JSLock::DropAllLocks dropAllLocks(exec);
121 if (hasProperty(ctx, thisRef, propertyNameRef.get())) {
122 slot.setCustom(this, callbackGetter);
123 return true;
124 }
125 } else if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) {
126 if (!propertyNameRef)
127 propertyNameRef = OpaqueJSString::create(propertyName.ustring());
128 JSValueRef exception = 0;
129 JSValueRef value;
130 {
131 JSLock::DropAllLocks dropAllLocks(exec);
132 value = getProperty(ctx, thisRef, propertyNameRef.get(), &exception);
133 }
134 exec->setException(toJS(exec, exception));
135 if (value) {
136 slot.setValue(toJS(exec, value));
137 return true;
138 }
139 if (exception) {
140 slot.setValue(jsUndefined());
141 return true;
142 }
143 }
144
145 if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
146 if (staticValues->contains(propertyName.ustring().rep())) {
147 slot.setCustom(this, staticValueGetter);
148 return true;
149 }
150 }
151
152 if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
153 if (staticFunctions->contains(propertyName.ustring().rep())) {
154 slot.setCustom(this, staticFunctionGetter);
155 return true;
156 }
157 }
158 }
159
160 return Base::getOwnPropertySlot(exec, propertyName, slot);
161 }
162
163 template <class Base>
getOwnPropertySlot(ExecState * exec,unsigned propertyName,PropertySlot & slot)164 bool JSCallbackObject<Base>::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
165 {
166 return getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);
167 }
168
169 template <class Base>
put(ExecState * exec,const Identifier & propertyName,JSValue value,PutPropertySlot & slot)170 void JSCallbackObject<Base>::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
171 {
172 JSContextRef ctx = toRef(exec);
173 JSObjectRef thisRef = toRef(this);
174 RefPtr<OpaqueJSString> propertyNameRef;
175 JSValueRef valueRef = toRef(exec, value);
176
177 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
178 if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) {
179 if (!propertyNameRef)
180 propertyNameRef = OpaqueJSString::create(propertyName.ustring());
181 JSValueRef exception = 0;
182 bool result;
183 {
184 JSLock::DropAllLocks dropAllLocks(exec);
185 result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
186 }
187 exec->setException(toJS(exec, exception));
188 if (result || exception)
189 return;
190 }
191
192 if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
193 if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) {
194 if (entry->attributes & kJSPropertyAttributeReadOnly)
195 return;
196 if (JSObjectSetPropertyCallback setProperty = entry->setProperty) {
197 if (!propertyNameRef)
198 propertyNameRef = OpaqueJSString::create(propertyName.ustring());
199 JSValueRef exception = 0;
200 bool result;
201 {
202 JSLock::DropAllLocks dropAllLocks(exec);
203 result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
204 }
205 exec->setException(toJS(exec, exception));
206 if (result || exception)
207 return;
208 } else
209 throwError(exec, ReferenceError, "Attempt to set a property that is not settable.");
210 }
211 }
212
213 if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
214 if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
215 if (entry->attributes & kJSPropertyAttributeReadOnly)
216 return;
217 JSCallbackObject<Base>::putDirect(propertyName, value); // put as override property
218 return;
219 }
220 }
221 }
222
223 return Base::put(exec, propertyName, value, slot);
224 }
225
226 template <class Base>
deleteProperty(ExecState * exec,const Identifier & propertyName)227 bool JSCallbackObject<Base>::deleteProperty(ExecState* exec, const Identifier& propertyName)
228 {
229 JSContextRef ctx = toRef(exec);
230 JSObjectRef thisRef = toRef(this);
231 RefPtr<OpaqueJSString> propertyNameRef;
232
233 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
234 if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) {
235 if (!propertyNameRef)
236 propertyNameRef = OpaqueJSString::create(propertyName.ustring());
237 JSValueRef exception = 0;
238 bool result;
239 {
240 JSLock::DropAllLocks dropAllLocks(exec);
241 result = deleteProperty(ctx, thisRef, propertyNameRef.get(), &exception);
242 }
243 exec->setException(toJS(exec, exception));
244 if (result || exception)
245 return true;
246 }
247
248 if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
249 if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) {
250 if (entry->attributes & kJSPropertyAttributeDontDelete)
251 return false;
252 return true;
253 }
254 }
255
256 if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
257 if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
258 if (entry->attributes & kJSPropertyAttributeDontDelete)
259 return false;
260 return true;
261 }
262 }
263 }
264
265 return Base::deleteProperty(exec, propertyName);
266 }
267
268 template <class Base>
deleteProperty(ExecState * exec,unsigned propertyName)269 bool JSCallbackObject<Base>::deleteProperty(ExecState* exec, unsigned propertyName)
270 {
271 return deleteProperty(exec, Identifier::from(exec, propertyName));
272 }
273
274 template <class Base>
getConstructData(ConstructData & constructData)275 ConstructType JSCallbackObject<Base>::getConstructData(ConstructData& constructData)
276 {
277 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
278 if (jsClass->callAsConstructor) {
279 constructData.native.function = construct;
280 return ConstructTypeHost;
281 }
282 }
283 return ConstructTypeNone;
284 }
285
286 template <class Base>
construct(ExecState * exec,JSObject * constructor,const ArgList & args)287 JSObject* JSCallbackObject<Base>::construct(ExecState* exec, JSObject* constructor, const ArgList& args)
288 {
289 JSContextRef execRef = toRef(exec);
290 JSObjectRef constructorRef = toRef(constructor);
291
292 for (JSClassRef jsClass = static_cast<JSCallbackObject<Base>*>(constructor)->classRef(); jsClass; jsClass = jsClass->parentClass) {
293 if (JSObjectCallAsConstructorCallback callAsConstructor = jsClass->callAsConstructor) {
294 int argumentCount = static_cast<int>(args.size());
295 Vector<JSValueRef, 16> arguments(argumentCount);
296 for (int i = 0; i < argumentCount; i++)
297 arguments[i] = toRef(exec, args.at(i));
298 JSValueRef exception = 0;
299 JSObject* result;
300 {
301 JSLock::DropAllLocks dropAllLocks(exec);
302 result = toJS(callAsConstructor(execRef, constructorRef, argumentCount, arguments.data(), &exception));
303 }
304 exec->setException(toJS(exec, exception));
305 return result;
306 }
307 }
308
309 ASSERT_NOT_REACHED(); // getConstructData should prevent us from reaching here
310 return 0;
311 }
312
313 template <class Base>
hasInstance(ExecState * exec,JSValue value,JSValue)314 bool JSCallbackObject<Base>::hasInstance(ExecState* exec, JSValue value, JSValue)
315 {
316 JSContextRef execRef = toRef(exec);
317 JSObjectRef thisRef = toRef(this);
318
319 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
320 if (JSObjectHasInstanceCallback hasInstance = jsClass->hasInstance) {
321 JSValueRef valueRef = toRef(exec, value);
322 JSValueRef exception = 0;
323 bool result;
324 {
325 JSLock::DropAllLocks dropAllLocks(exec);
326 result = hasInstance(execRef, thisRef, valueRef, &exception);
327 }
328 exec->setException(toJS(exec, exception));
329 return result;
330 }
331 }
332 return false;
333 }
334
335 template <class Base>
getCallData(CallData & callData)336 CallType JSCallbackObject<Base>::getCallData(CallData& callData)
337 {
338 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
339 if (jsClass->callAsFunction) {
340 callData.native.function = call;
341 return CallTypeHost;
342 }
343 }
344 return CallTypeNone;
345 }
346
347 template <class Base>
call(ExecState * exec,JSObject * functionObject,JSValue thisValue,const ArgList & args)348 JSValue JSCallbackObject<Base>::call(ExecState* exec, JSObject* functionObject, JSValue thisValue, const ArgList& args)
349 {
350 JSContextRef execRef = toRef(exec);
351 JSObjectRef functionRef = toRef(functionObject);
352 JSObjectRef thisObjRef = toRef(thisValue.toThisObject(exec));
353
354 for (JSClassRef jsClass = static_cast<JSCallbackObject<Base>*>(functionObject)->classRef(); jsClass; jsClass = jsClass->parentClass) {
355 if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) {
356 int argumentCount = static_cast<int>(args.size());
357 Vector<JSValueRef, 16> arguments(argumentCount);
358 for (int i = 0; i < argumentCount; i++)
359 arguments[i] = toRef(exec, args.at(i));
360 JSValueRef exception = 0;
361 JSValue result;
362 {
363 JSLock::DropAllLocks dropAllLocks(exec);
364 result = toJS(exec, callAsFunction(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception));
365 }
366 exec->setException(toJS(exec, exception));
367 return result;
368 }
369 }
370
371 ASSERT_NOT_REACHED(); // getCallData should prevent us from reaching here
372 return JSValue();
373 }
374
375 template <class Base>
getPropertyNames(ExecState * exec,PropertyNameArray & propertyNames)376 void JSCallbackObject<Base>::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
377 {
378 JSContextRef execRef = toRef(exec);
379 JSObjectRef thisRef = toRef(this);
380
381 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
382 if (JSObjectGetPropertyNamesCallback getPropertyNames = jsClass->getPropertyNames) {
383 JSLock::DropAllLocks dropAllLocks(exec);
384 getPropertyNames(execRef, thisRef, toRef(&propertyNames));
385 }
386
387 if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
388 typedef OpaqueJSClassStaticValuesTable::const_iterator iterator;
389 iterator end = staticValues->end();
390 for (iterator it = staticValues->begin(); it != end; ++it) {
391 UString::Rep* name = it->first.get();
392 StaticValueEntry* entry = it->second;
393 if (entry->getProperty && !(entry->attributes & kJSPropertyAttributeDontEnum))
394 propertyNames.add(Identifier(exec, name));
395 }
396 }
397
398 if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
399 typedef OpaqueJSClassStaticFunctionsTable::const_iterator iterator;
400 iterator end = staticFunctions->end();
401 for (iterator it = staticFunctions->begin(); it != end; ++it) {
402 UString::Rep* name = it->first.get();
403 StaticFunctionEntry* entry = it->second;
404 if (!(entry->attributes & kJSPropertyAttributeDontEnum))
405 propertyNames.add(Identifier(exec, name));
406 }
407 }
408 }
409
410 Base::getPropertyNames(exec, propertyNames);
411 }
412
413 template <class Base>
toNumber(ExecState * exec)414 double JSCallbackObject<Base>::toNumber(ExecState* exec) const
415 {
416 // We need this check to guard against the case where this object is rhs of
417 // a binary expression where lhs threw an exception in its conversion to
418 // primitive
419 if (exec->hadException())
420 return NaN;
421 JSContextRef ctx = toRef(exec);
422 JSObjectRef thisRef = toRef(this);
423
424 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
425 if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) {
426 JSValueRef exception = 0;
427 JSValueRef value;
428 {
429 JSLock::DropAllLocks dropAllLocks(exec);
430 value = convertToType(ctx, thisRef, kJSTypeNumber, &exception);
431 }
432 if (exception) {
433 exec->setException(toJS(exec, exception));
434 return 0;
435 }
436
437 double dValue;
438 return toJS(exec, value).getNumber(dValue) ? dValue : NaN;
439 }
440
441 return Base::toNumber(exec);
442 }
443
444 template <class Base>
toString(ExecState * exec)445 UString JSCallbackObject<Base>::toString(ExecState* exec) const
446 {
447 JSContextRef ctx = toRef(exec);
448 JSObjectRef thisRef = toRef(this);
449
450 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
451 if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) {
452 JSValueRef exception = 0;
453 JSValueRef value;
454 {
455 JSLock::DropAllLocks dropAllLocks(exec);
456 value = convertToType(ctx, thisRef, kJSTypeString, &exception);
457 }
458 if (exception) {
459 exec->setException(toJS(exec, exception));
460 return "";
461 }
462 return toJS(exec, value).getString();
463 }
464
465 return Base::toString(exec);
466 }
467
468 template <class Base>
setPrivate(void * data)469 void JSCallbackObject<Base>::setPrivate(void* data)
470 {
471 m_callbackObjectData->privateData = data;
472 }
473
474 template <class Base>
getPrivate()475 void* JSCallbackObject<Base>::getPrivate()
476 {
477 return m_callbackObjectData->privateData;
478 }
479
480 template <class Base>
inherits(JSClassRef c)481 bool JSCallbackObject<Base>::inherits(JSClassRef c) const
482 {
483 for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
484 if (jsClass == c)
485 return true;
486
487 return false;
488 }
489
490 template <class Base>
staticValueGetter(ExecState * exec,const Identifier & propertyName,const PropertySlot & slot)491 JSValue JSCallbackObject<Base>::staticValueGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
492 {
493 JSCallbackObject* thisObj = asCallbackObject(slot.slotBase());
494
495 JSObjectRef thisRef = toRef(thisObj);
496 RefPtr<OpaqueJSString> propertyNameRef;
497
498 for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass)
499 if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec))
500 if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep()))
501 if (JSObjectGetPropertyCallback getProperty = entry->getProperty) {
502 if (!propertyNameRef)
503 propertyNameRef = OpaqueJSString::create(propertyName.ustring());
504 JSValueRef exception = 0;
505 JSValueRef value;
506 {
507 JSLock::DropAllLocks dropAllLocks(exec);
508 value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
509 }
510 exec->setException(toJS(exec, exception));
511 if (value)
512 return toJS(exec, value);
513 if (exception)
514 return jsUndefined();
515 }
516
517 return throwError(exec, ReferenceError, "Static value property defined with NULL getProperty callback.");
518 }
519
520 template <class Base>
staticFunctionGetter(ExecState * exec,const Identifier & propertyName,const PropertySlot & slot)521 JSValue JSCallbackObject<Base>::staticFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
522 {
523 JSCallbackObject* thisObj = asCallbackObject(slot.slotBase());
524
525 // Check for cached or override property.
526 PropertySlot slot2(thisObj);
527 if (thisObj->Base::getOwnPropertySlot(exec, propertyName, slot2))
528 return slot2.getValue(exec, propertyName);
529
530 for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) {
531 if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
532 if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
533 if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) {
534 JSObject* o = new (exec) JSCallbackFunction(exec, callAsFunction, propertyName);
535 thisObj->putDirect(propertyName, o, entry->attributes);
536 return o;
537 }
538 }
539 }
540 }
541
542 return throwError(exec, ReferenceError, "Static function property defined with NULL callAsFunction callback.");
543 }
544
545 template <class Base>
callbackGetter(ExecState * exec,const Identifier & propertyName,const PropertySlot & slot)546 JSValue JSCallbackObject<Base>::callbackGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
547 {
548 JSCallbackObject* thisObj = asCallbackObject(slot.slotBase());
549
550 JSObjectRef thisRef = toRef(thisObj);
551 RefPtr<OpaqueJSString> propertyNameRef;
552
553 for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass)
554 if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) {
555 if (!propertyNameRef)
556 propertyNameRef = OpaqueJSString::create(propertyName.ustring());
557 JSValueRef exception = 0;
558 JSValueRef value;
559 {
560 JSLock::DropAllLocks dropAllLocks(exec);
561 value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
562 }
563 exec->setException(toJS(exec, exception));
564 if (value)
565 return toJS(exec, value);
566 if (exception)
567 return jsUndefined();
568 }
569
570 return throwError(exec, ReferenceError, "hasProperty callback returned true for a property that doesn't exist.");
571 }
572
573 } // namespace JSC
574