source: webkit/trunk/JavaScriptCore/runtime/JSObject.cpp@ 49734

Last change on this file since 49734 was 49734, checked in by [email protected], 16 years ago

Rolled back in r49717 with the build maybe working now?

  • Property svn:eol-style set to native
File size: 24.3 KB
Line 
1/*
2 * Copyright (C) 1999-2001 Harri Porten ([email protected])
3 * Copyright (C) 2001 Peter Kelly ([email protected])
4 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Apple Inc. All rights reserved.
5 * Copyright (C) 2007 Eric Seidel ([email protected])
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 */
23
24#include "config.h"
25#include "JSObject.h"
26
27#include "DatePrototype.h"
28#include "ErrorConstructor.h"
29#include "GetterSetter.h"
30#include "JSGlobalObject.h"
31#include "NativeErrorConstructor.h"
32#include "ObjectPrototype.h"
33#include "PropertyDescriptor.h"
34#include "PropertyNameArray.h"
35#include "Lookup.h"
36#include "Nodes.h"
37#include "Operations.h"
38#include <math.h>
39#include <wtf/Assertions.h>
40
41namespace JSC {
42
43ASSERT_CLASS_FITS_IN_CELL(JSObject);
44
45static inline void getEnumerablePropertyNames(ExecState* exec, const ClassInfo* classInfo, PropertyNameArray& propertyNames)
46{
47 // Add properties from the static hashtables of properties
48 for (; classInfo; classInfo = classInfo->parentClass) {
49 const HashTable* table = classInfo->propHashTable(exec);
50 if (!table)
51 continue;
52 table->initializeIfNeeded(exec);
53 ASSERT(table->table);
54
55 int hashSizeMask = table->compactSize - 1;
56 const HashEntry* entry = table->table;
57 for (int i = 0; i <= hashSizeMask; ++i, ++entry) {
58 if (entry->key() && !(entry->attributes() & DontEnum))
59 propertyNames.add(entry->key());
60 }
61 }
62}
63
64void JSObject::markChildren(MarkStack& markStack)
65{
66#ifndef NDEBUG
67 bool wasCheckingForDefaultMarkViolation = markStack.m_isCheckingForDefaultMarkViolation;
68 markStack.m_isCheckingForDefaultMarkViolation = false;
69#endif
70
71 markChildrenDirect(markStack);
72
73#ifndef NDEBUG
74 markStack.m_isCheckingForDefaultMarkViolation = wasCheckingForDefaultMarkViolation;
75#endif
76}
77
78UString JSObject::className() const
79{
80 const ClassInfo* info = classInfo();
81 if (info)
82 return info->className;
83 return "Object";
84}
85
86bool JSObject::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
87{
88 return getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);
89}
90
91static void throwSetterError(ExecState* exec)
92{
93 throwError(exec, TypeError, "setting a property that has only a getter");
94}
95
96// ECMA 8.6.2.2
97void JSObject::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
98{
99 ASSERT(value);
100 ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
101
102 if (propertyName == exec->propertyNames().underscoreProto) {
103 // Setting __proto__ to a non-object, non-null value is silently ignored to match Mozilla.
104 if (!value.isObject() && !value.isNull())
105 return;
106
107 JSValue nextPrototypeValue = value;
108 while (nextPrototypeValue && nextPrototypeValue.isObject()) {
109 JSObject* nextPrototype = asObject(nextPrototypeValue)->unwrappedObject();
110 if (nextPrototype == this) {
111 throwError(exec, GeneralError, "cyclic __proto__ value");
112 return;
113 }
114 nextPrototypeValue = nextPrototype->prototype();
115 }
116
117 setPrototype(value);
118 return;
119 }
120
121 // Check if there are any setters or getters in the prototype chain
122 JSValue prototype;
123 for (JSObject* obj = this; !obj->structure()->hasGetterSetterProperties(); obj = asObject(prototype)) {
124 prototype = obj->prototype();
125 if (prototype.isNull()) {
126 putDirectInternal(exec->globalData(), propertyName, value, 0, true, slot);
127 return;
128 }
129 }
130
131 unsigned attributes;
132 JSCell* specificValue;
133 if ((m_structure->get(propertyName, attributes, specificValue) != WTF::notFound) && attributes & ReadOnly)
134 return;
135
136 for (JSObject* obj = this; ; obj = asObject(prototype)) {
137 if (JSValue gs = obj->getDirect(propertyName)) {
138 if (gs.isGetterSetter()) {
139 JSObject* setterFunc = asGetterSetter(gs)->setter();
140 if (!setterFunc) {
141 throwSetterError(exec);
142 return;
143 }
144
145 CallData callData;
146 CallType callType = setterFunc->getCallData(callData);
147 MarkedArgumentBuffer args;
148 args.append(value);
149 call(exec, setterFunc, callType, callData, this, args);
150 return;
151 }
152
153 // If there's an existing property on the object or one of its
154 // prototypes it should be replaced, so break here.
155 break;
156 }
157
158 prototype = obj->prototype();
159 if (prototype.isNull())
160 break;
161 }
162
163 putDirectInternal(exec->globalData(), propertyName, value, 0, true, slot);
164 return;
165}
166
167void JSObject::put(ExecState* exec, unsigned propertyName, JSValue value)
168{
169 PutPropertySlot slot;
170 put(exec, Identifier::from(exec, propertyName), value, slot);
171}
172
173void JSObject::putWithAttributes(ExecState* exec, const Identifier& propertyName, JSValue value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot)
174{
175 putDirectInternal(exec->globalData(), propertyName, value, attributes, checkReadOnly, slot);
176}
177
178void JSObject::putWithAttributes(ExecState* exec, const Identifier& propertyName, JSValue value, unsigned attributes)
179{
180 putDirectInternal(exec->globalData(), propertyName, value, attributes);
181}
182
183void JSObject::putWithAttributes(ExecState* exec, unsigned propertyName, JSValue value, unsigned attributes)
184{
185 putWithAttributes(exec, Identifier::from(exec, propertyName), value, attributes);
186}
187
188bool JSObject::hasProperty(ExecState* exec, const Identifier& propertyName) const
189{
190 PropertySlot slot;
191 return const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot);
192}
193
194bool JSObject::hasProperty(ExecState* exec, unsigned propertyName) const
195{
196 PropertySlot slot;
197 return const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot);
198}
199
200// ECMA 8.6.2.5
201bool JSObject::deleteProperty(ExecState* exec, const Identifier& propertyName)
202{
203 unsigned attributes;
204 JSCell* specificValue;
205 if (m_structure->get(propertyName, attributes, specificValue) != WTF::notFound) {
206 if ((attributes & DontDelete))
207 return false;
208 removeDirect(propertyName);
209 return true;
210 }
211
212 // Look in the static hashtable of properties
213 const HashEntry* entry = findPropertyHashEntry(exec, propertyName);
214 if (entry && entry->attributes() & DontDelete)
215 return false; // this builtin property can't be deleted
216
217 // FIXME: Should the code here actually do some deletion?
218 return true;
219}
220
221bool JSObject::hasOwnProperty(ExecState* exec, const Identifier& propertyName) const
222{
223 PropertySlot slot;
224 return const_cast<JSObject*>(this)->getOwnPropertySlot(exec, propertyName, slot);
225}
226
227bool JSObject::deleteProperty(ExecState* exec, unsigned propertyName)
228{
229 return deleteProperty(exec, Identifier::from(exec, propertyName));
230}
231
232static ALWAYS_INLINE JSValue callDefaultValueFunction(ExecState* exec, const JSObject* object, const Identifier& propertyName)
233{
234 JSValue function = object->get(exec, propertyName);
235 CallData callData;
236 CallType callType = function.getCallData(callData);
237 if (callType == CallTypeNone)
238 return exec->exception();
239
240 // Prevent "toString" and "valueOf" from observing execution if an exception
241 // is pending.
242 if (exec->hadException())
243 return exec->exception();
244
245 JSValue result = call(exec, function, callType, callData, const_cast<JSObject*>(object), exec->emptyList());
246 ASSERT(!result.isGetterSetter());
247 if (exec->hadException())
248 return exec->exception();
249 if (result.isObject())
250 return JSValue();
251 return result;
252}
253
254bool JSObject::getPrimitiveNumber(ExecState* exec, double& number, JSValue& result)
255{
256 result = defaultValue(exec, PreferNumber);
257 number = result.toNumber(exec);
258 return !result.isString();
259}
260
261// ECMA 8.6.2.6
262JSValue JSObject::defaultValue(ExecState* exec, PreferredPrimitiveType hint) const
263{
264 // Must call toString first for Date objects.
265 if ((hint == PreferString) || (hint != PreferNumber && prototype() == exec->lexicalGlobalObject()->datePrototype())) {
266 JSValue value = callDefaultValueFunction(exec, this, exec->propertyNames().toString);
267 if (value)
268 return value;
269 value = callDefaultValueFunction(exec, this, exec->propertyNames().valueOf);
270 if (value)
271 return value;
272 } else {
273 JSValue value = callDefaultValueFunction(exec, this, exec->propertyNames().valueOf);
274 if (value)
275 return value;
276 value = callDefaultValueFunction(exec, this, exec->propertyNames().toString);
277 if (value)
278 return value;
279 }
280
281 ASSERT(!exec->hadException());
282
283 return throwError(exec, TypeError, "No default value");
284}
285
286const HashEntry* JSObject::findPropertyHashEntry(ExecState* exec, const Identifier& propertyName) const
287{
288 for (const ClassInfo* info = classInfo(); info; info = info->parentClass) {
289 if (const HashTable* propHashTable = info->propHashTable(exec)) {
290 if (const HashEntry* entry = propHashTable->entry(exec, propertyName))
291 return entry;
292 }
293 }
294 return 0;
295}
296
297void JSObject::defineGetter(ExecState* exec, const Identifier& propertyName, JSObject* getterFunction, unsigned attributes)
298{
299 JSValue object = getDirect(propertyName);
300 if (object && object.isGetterSetter()) {
301 ASSERT(m_structure->hasGetterSetterProperties());
302 asGetterSetter(object)->setGetter(getterFunction);
303 return;
304 }
305
306 PutPropertySlot slot;
307 GetterSetter* getterSetter = new (exec) GetterSetter(exec);
308 putDirectInternal(exec->globalData(), propertyName, getterSetter, attributes | Getter, true, slot);
309
310 // putDirect will change our Structure if we add a new property. For
311 // getters and setters, though, we also need to change our Structure
312 // if we override an existing non-getter or non-setter.
313 if (slot.type() != PutPropertySlot::NewProperty) {
314 if (!m_structure->isDictionary()) {
315 RefPtr<Structure> structure = Structure::getterSetterTransition(m_structure);
316 setStructure(structure.release());
317 }
318 }
319
320 m_structure->setHasGetterSetterProperties(true);
321 getterSetter->setGetter(getterFunction);
322}
323
324void JSObject::defineSetter(ExecState* exec, const Identifier& propertyName, JSObject* setterFunction, unsigned attributes)
325{
326 JSValue object = getDirect(propertyName);
327 if (object && object.isGetterSetter()) {
328 ASSERT(m_structure->hasGetterSetterProperties());
329 asGetterSetter(object)->setSetter(setterFunction);
330 return;
331 }
332
333 PutPropertySlot slot;
334 GetterSetter* getterSetter = new (exec) GetterSetter(exec);
335 putDirectInternal(exec->globalData(), propertyName, getterSetter, attributes | Setter, true, slot);
336
337 // putDirect will change our Structure if we add a new property. For
338 // getters and setters, though, we also need to change our Structure
339 // if we override an existing non-getter or non-setter.
340 if (slot.type() != PutPropertySlot::NewProperty) {
341 if (!m_structure->isDictionary()) {
342 RefPtr<Structure> structure = Structure::getterSetterTransition(m_structure);
343 setStructure(structure.release());
344 }
345 }
346
347 m_structure->setHasGetterSetterProperties(true);
348 getterSetter->setSetter(setterFunction);
349}
350
351JSValue JSObject::lookupGetter(ExecState*, const Identifier& propertyName)
352{
353 JSObject* object = this;
354 while (true) {
355 if (JSValue value = object->getDirect(propertyName)) {
356 if (!value.isGetterSetter())
357 return jsUndefined();
358 JSObject* functionObject = asGetterSetter(value)->getter();
359 if (!functionObject)
360 return jsUndefined();
361 return functionObject;
362 }
363
364 if (!object->prototype() || !object->prototype().isObject())
365 return jsUndefined();
366 object = asObject(object->prototype());
367 }
368}
369
370JSValue JSObject::lookupSetter(ExecState*, const Identifier& propertyName)
371{
372 JSObject* object = this;
373 while (true) {
374 if (JSValue value = object->getDirect(propertyName)) {
375 if (!value.isGetterSetter())
376 return jsUndefined();
377 JSObject* functionObject = asGetterSetter(value)->setter();
378 if (!functionObject)
379 return jsUndefined();
380 return functionObject;
381 }
382
383 if (!object->prototype() || !object->prototype().isObject())
384 return jsUndefined();
385 object = asObject(object->prototype());
386 }
387}
388
389bool JSObject::hasInstance(ExecState* exec, JSValue value, JSValue proto)
390{
391 if (!value.isObject())
392 return false;
393
394 if (!proto.isObject()) {
395 throwError(exec, TypeError, "instanceof called on an object with an invalid prototype property.");
396 return false;
397 }
398
399 JSObject* object = asObject(value);
400 while ((object = object->prototype().getObject())) {
401 if (proto == object)
402 return true;
403 }
404 return false;
405}
406
407bool JSObject::propertyIsEnumerable(ExecState* exec, const Identifier& propertyName) const
408{
409 unsigned attributes;
410 if (!getPropertyAttributes(exec, propertyName, attributes))
411 return false;
412 return !(attributes & DontEnum);
413}
414
415bool JSObject::getPropertyAttributes(ExecState* exec, const Identifier& propertyName, unsigned& attributes) const
416{
417 JSCell* specificValue;
418 if (m_structure->get(propertyName, attributes, specificValue) != WTF::notFound)
419 return true;
420
421 // Look in the static hashtable of properties
422 const HashEntry* entry = findPropertyHashEntry(exec, propertyName);
423 if (entry) {
424 attributes = entry->attributes();
425 return true;
426 }
427
428 return false;
429}
430
431bool JSObject::getPropertySpecificValue(ExecState*, const Identifier& propertyName, JSCell*& specificValue) const
432{
433 unsigned attributes;
434 if (m_structure->get(propertyName, attributes, specificValue) != WTF::notFound)
435 return true;
436
437 // This could be a function within the static table? - should probably
438 // also look in the hash? This currently should not be a problem, since
439 // we've currently always call 'get' first, which should have populated
440 // the normal storage.
441 return false;
442}
443
444void JSObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
445{
446 getOwnPropertyNames(exec, propertyNames);
447
448 if (prototype().isNull())
449 return;
450
451 JSObject* prototype = asObject(this->prototype());
452 while(1) {
453 if (prototype->structure()->typeInfo().overridesGetPropertyNames()) {
454 prototype->getPropertyNames(exec, propertyNames);
455 break;
456 }
457 prototype->getOwnPropertyNames(exec, propertyNames);
458 JSValue nextProto = prototype->prototype();
459 if (nextProto.isNull())
460 break;
461 prototype = asObject(nextProto);
462 }
463}
464
465void JSObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames)
466{
467 m_structure->getEnumerablePropertyNames(propertyNames);
468 getEnumerablePropertyNames(exec, classInfo(), propertyNames);
469}
470
471bool JSObject::toBoolean(ExecState*) const
472{
473 return true;
474}
475
476double JSObject::toNumber(ExecState* exec) const
477{
478 JSValue primitive = toPrimitive(exec, PreferNumber);
479 if (exec->hadException()) // should be picked up soon in Nodes.cpp
480 return 0.0;
481 return primitive.toNumber(exec);
482}
483
484UString JSObject::toString(ExecState* exec) const
485{
486 JSValue primitive = toPrimitive(exec, PreferString);
487 if (exec->hadException())
488 return "";
489 return primitive.toString(exec);
490}
491
492JSObject* JSObject::toObject(ExecState*) const
493{
494 return const_cast<JSObject*>(this);
495}
496
497JSObject* JSObject::toThisObject(ExecState*) const
498{
499 return const_cast<JSObject*>(this);
500}
501
502JSObject* JSObject::unwrappedObject()
503{
504 return this;
505}
506
507void JSObject::removeDirect(const Identifier& propertyName)
508{
509 size_t offset;
510 if (m_structure->isUncacheableDictionary()) {
511 offset = m_structure->removePropertyWithoutTransition(propertyName);
512 if (offset != WTF::notFound)
513 putDirectOffset(offset, jsUndefined());
514 return;
515 }
516
517 RefPtr<Structure> structure = Structure::removePropertyTransition(m_structure, propertyName, offset);
518 setStructure(structure.release());
519 if (offset != WTF::notFound)
520 putDirectOffset(offset, jsUndefined());
521}
522
523void JSObject::putDirectFunction(ExecState* exec, InternalFunction* function, unsigned attr)
524{
525 putDirectFunction(Identifier(exec, function->name(&exec->globalData())), function, attr);
526}
527
528void JSObject::putDirectFunctionWithoutTransition(ExecState* exec, InternalFunction* function, unsigned attr)
529{
530 putDirectFunctionWithoutTransition(Identifier(exec, function->name(&exec->globalData())), function, attr);
531}
532
533NEVER_INLINE void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue* location)
534{
535 if (JSObject* getterFunction = asGetterSetter(*location)->getter())
536 slot.setGetterSlot(getterFunction);
537 else
538 slot.setUndefined();
539}
540
541Structure* JSObject::createInheritorID()
542{
543 m_inheritorID = JSObject::createStructure(this);
544 return m_inheritorID.get();
545}
546
547void JSObject::allocatePropertyStorage(size_t oldSize, size_t newSize)
548{
549 allocatePropertyStorageInline(oldSize, newSize);
550}
551
552bool JSObject::getOwnPropertyDescriptor(ExecState*, const Identifier& propertyName, PropertyDescriptor& descriptor)
553{
554 unsigned attributes = 0;
555 JSCell* cell = 0;
556 size_t offset = m_structure->get(propertyName, attributes, cell);
557 if (offset == WTF::notFound)
558 return false;
559 descriptor.setDescriptor(getDirectOffset(offset), attributes);
560 return true;
561}
562
563bool JSObject::getPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
564{
565 JSObject* object = this;
566 while (true) {
567 if (object->getOwnPropertyDescriptor(exec, propertyName, descriptor))
568 return true;
569 JSValue prototype = object->prototype();
570 if (!prototype.isObject())
571 return false;
572 object = asObject(prototype);
573 }
574}
575
576static bool putDescriptor(ExecState* exec, JSObject* target, const Identifier& propertyName, PropertyDescriptor& descriptor, unsigned attributes, JSValue oldValue)
577{
578 if (descriptor.isGenericDescriptor() || descriptor.isDataDescriptor()) {
579 target->putWithAttributes(exec, propertyName, descriptor.value() ? descriptor.value() : oldValue, attributes & ~(Getter | Setter));
580 return true;
581 }
582 attributes &= ~ReadOnly;
583 if (descriptor.getter() && descriptor.getter().isObject())
584 target->defineGetter(exec, propertyName, asObject(descriptor.getter()), attributes);
585 if (exec->hadException())
586 return false;
587 if (descriptor.setter() && descriptor.setter().isObject())
588 target->defineSetter(exec, propertyName, asObject(descriptor.setter()), attributes);
589 return !exec->hadException();
590}
591
592bool JSObject::defineOwnProperty(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool throwException)
593{
594 // If we have a new property we can just put it on normally
595 PropertyDescriptor current;
596 if (!getOwnPropertyDescriptor(exec, propertyName, current))
597 return putDescriptor(exec, this, propertyName, descriptor, descriptor.attributes(), jsUndefined());
598
599 if (descriptor.isEmpty())
600 return true;
601
602 if (current.equalTo(descriptor))
603 return true;
604
605 // Filter out invalid changes
606 if (!current.configurable()) {
607 if (descriptor.configurable()) {
608 if (throwException)
609 throwError(exec, TypeError, "Attempting to configurable attribute of unconfigurable property.");
610 return false;
611 }
612 if (descriptor.enumerablePresent() && descriptor.enumerable() != current.enumerable()) {
613 if (throwException)
614 throwError(exec, TypeError, "Attempting to change enumerable attribute of unconfigurable property.");
615 return false;
616 }
617 }
618
619 // A generic descriptor is simply changing the attributes of an existing property
620 if (descriptor.isGenericDescriptor()) {
621 if (!current.attributesEqual(descriptor)) {
622 deleteProperty(exec, propertyName);
623 putDescriptor(exec, this, propertyName, descriptor, current.attributesWithOverride(descriptor), current.value());
624 }
625 return true;
626 }
627
628 // Changing between a normal property or an accessor property
629 if (descriptor.isDataDescriptor() != current.isDataDescriptor()) {
630 if (!current.configurable()) {
631 if (throwException)
632 throwError(exec, TypeError, "Attempting to change access mechanism for an unconfigurable property.");
633 return false;
634 }
635 deleteProperty(exec, propertyName);
636 return putDescriptor(exec, this, propertyName, descriptor, current.attributesWithOverride(descriptor), current.value() ? current.value() : jsUndefined());
637 }
638
639 // Changing the value and attributes of an existing property
640 if (descriptor.isDataDescriptor()) {
641 if (!current.configurable()) {
642 if (!current.writable() && descriptor.writable()) {
643 if (throwException)
644 throwError(exec, TypeError, "Attempting to change writable attribute of unconfigurable property.");
645 return false;
646 }
647 if (!current.writable()) {
648 if (descriptor.value() || !JSValue::strictEqual(current.value(), descriptor.value())) {
649 if (throwException)
650 throwError(exec, TypeError, "Attempting to change value of a readonly property.");
651 return false;
652 }
653 }
654 } else if (current.attributesEqual(descriptor)) {
655 if (!descriptor.value())
656 return true;
657 PutPropertySlot slot;
658 put(exec, propertyName, descriptor.value(), slot);
659 if (exec->hadException())
660 return false;
661 return true;
662 }
663 deleteProperty(exec, propertyName);
664 return putDescriptor(exec, this, propertyName, descriptor, current.attributesWithOverride(descriptor), current.value());
665 }
666
667 // Changing the accessor functions of an existing accessor property
668 ASSERT(descriptor.isAccessorDescriptor());
669 if (!current.configurable()) {
670 if (descriptor.setterPresent() && !(current.setter() && JSValue::strictEqual(current.setter(), descriptor.setter()))) {
671 if (throwException)
672 throwError(exec, TypeError, "Attempting to change the setter of an unconfigurable property.");
673 return false;
674 }
675 if (descriptor.getterPresent() && !(current.getter() && JSValue::strictEqual(current.getter(), descriptor.getter()))) {
676 if (throwException)
677 throwError(exec, TypeError, "Attempting to change the getter of an unconfigurable property.");
678 return false;
679 }
680 }
681 JSValue accessor = getDirect(propertyName);
682 if (!accessor)
683 return false;
684 GetterSetter* getterSetter = asGetterSetter(accessor);
685 if (current.attributesEqual(descriptor)) {
686 if (descriptor.setter())
687 getterSetter->setSetter(asObject(descriptor.setter()));
688 if (descriptor.getter())
689 getterSetter->setGetter(asObject(descriptor.getter()));
690 return true;
691 }
692 deleteProperty(exec, propertyName);
693 unsigned attrs = current.attributesWithOverride(descriptor);
694 if (descriptor.setter())
695 attrs |= Setter;
696 if (descriptor.getter())
697 attrs |= Getter;
698 putDirect(propertyName, getterSetter, attrs);
699 return true;
700}
701
702} // namespace JSC
Note: See TracBrowser for help on using the repository browser.