Changeset 37684 in webkit for trunk/JavaScriptCore/kjs/JSObject.h
- Timestamp:
- Oct 18, 2008, 6:52:42 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSObject.h
r37681 r37684 68 68 bool inherits(const ClassInfo* classInfo) const { return JSCell::isObject(classInfo); } 69 69 70 JSValue *prototype() const;71 void setPrototype(JSValue *prototype);70 JSValuePtr prototype() const; 71 void setPrototype(JSValuePtr prototype); 72 72 73 73 void setStructureID(PassRefPtr<StructureID>); … … 78 78 virtual UString className() const; 79 79 80 JSValue *get(ExecState*, const Identifier& propertyName) const;81 JSValue *get(ExecState*, unsigned propertyName) const;80 JSValuePtr get(ExecState*, const Identifier& propertyName) const; 81 JSValuePtr get(ExecState*, unsigned propertyName) const; 82 82 83 83 bool getPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); … … 87 87 virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&); 88 88 89 virtual void put(ExecState*, const Identifier& propertyName, JSValue *value, PutPropertySlot&);90 virtual void put(ExecState*, unsigned propertyName, JSValue *value);91 92 virtual void putWithAttributes(ExecState*, const Identifier& propertyName, JSValue *value, unsigned attributes);93 virtual void putWithAttributes(ExecState*, unsigned propertyName, JSValue *value, unsigned attributes);89 virtual void put(ExecState*, const Identifier& propertyName, JSValuePtr value, PutPropertySlot&); 90 virtual void put(ExecState*, unsigned propertyName, JSValuePtr value); 91 92 virtual void putWithAttributes(ExecState*, const Identifier& propertyName, JSValuePtr value, unsigned attributes); 93 virtual void putWithAttributes(ExecState*, unsigned propertyName, JSValuePtr value, unsigned attributes); 94 94 95 95 bool propertyIsEnumerable(ExecState*, const Identifier& propertyName) const; … … 102 102 virtual bool deleteProperty(ExecState*, unsigned propertyName); 103 103 104 virtual JSValue *defaultValue(ExecState*, PreferredPrimitiveType) const;105 106 virtual bool hasInstance(ExecState*, JSValue *, JSValue*prototypeProperty);104 virtual JSValuePtr defaultValue(ExecState*, PreferredPrimitiveType) const; 105 106 virtual bool hasInstance(ExecState*, JSValuePtr, JSValuePtr prototypeProperty); 107 107 108 108 virtual void getPropertyNames(ExecState*, PropertyNameArray&); 109 109 110 virtual JSValue *toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const;111 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue *& value);110 virtual JSValuePtr toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const; 111 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValuePtr& value); 112 112 virtual bool toBoolean(ExecState*) const; 113 113 virtual double toNumber(ExecState*) const; … … 121 121 122 122 // This get function only looks at the property map. 123 JSValue *getDirect(const Identifier& propertyName) const123 JSValuePtr getDirect(const Identifier& propertyName) const 124 124 { 125 125 size_t offset = m_structureID->propertyMap().get(propertyName); … … 127 127 } 128 128 129 JSValue ** getDirectLocation(const Identifier& propertyName)129 JSValuePtr* getDirectLocation(const Identifier& propertyName) 130 130 { 131 131 size_t offset = m_structureID->propertyMap().get(propertyName); … … 133 133 } 134 134 135 JSValue ** getDirectLocation(const Identifier& propertyName, unsigned& attributes)135 JSValuePtr* getDirectLocation(const Identifier& propertyName, unsigned& attributes) 136 136 { 137 137 size_t offset = m_structureID->propertyMap().get(propertyName, attributes); … … 139 139 } 140 140 141 size_t offsetForLocation(JSValue ** location)141 size_t offsetForLocation(JSValuePtr* location) 142 142 { 143 143 return location - m_propertyStorage; 144 144 } 145 145 146 JSValue ** locationForOffset(size_t offset)146 JSValuePtr* locationForOffset(size_t offset) 147 147 { 148 148 return &m_propertyStorage[offset]; … … 155 155 bool hasGetterSetterProperties() { return m_structureID->hasGetterSetterProperties(); } 156 156 157 void putDirect(const Identifier& propertyName, JSValue *value, unsigned attr = 0);158 void putDirect(const Identifier& propertyName, JSValue *value, unsigned attr, bool checkReadOnly, PutPropertySlot& slot);157 void putDirect(const Identifier& propertyName, JSValuePtr value, unsigned attr = 0); 158 void putDirect(const Identifier& propertyName, JSValuePtr value, unsigned attr, bool checkReadOnly, PutPropertySlot& slot); 159 159 void putDirectFunction(ExecState* exec, InternalFunction* function, unsigned attr = 0); 160 void putDirectWithoutTransition(const Identifier& propertyName, JSValue *value, unsigned attr);160 void putDirectWithoutTransition(const Identifier& propertyName, JSValuePtr value, unsigned attr); 161 161 void putDirectFunctionWithoutTransition(ExecState* exec, InternalFunction* function, unsigned attr); 162 162 163 163 // Fast access to known property offsets. 164 JSValue *getDirectOffset(size_t offset) { return m_propertyStorage[offset]; }165 void putDirectOffset(size_t offset, JSValue *value) { m_propertyStorage[offset] = value; }166 167 void fillGetterPropertySlot(PropertySlot&, JSValue ** location);164 JSValuePtr getDirectOffset(size_t offset) { return m_propertyStorage[offset]; } 165 void putDirectOffset(size_t offset, JSValuePtr value) { m_propertyStorage[offset] = value; } 166 167 void fillGetterPropertySlot(PropertySlot&, JSValuePtr* location); 168 168 169 169 virtual void defineGetter(ExecState*, const Identifier& propertyName, JSObject* getterFunction); 170 170 virtual void defineSetter(ExecState*, const Identifier& propertyName, JSObject* setterFunction); 171 virtual JSValue *lookupGetter(ExecState*, const Identifier& propertyName);172 virtual JSValue *lookupSetter(ExecState*, const Identifier& propertyName);171 virtual JSValuePtr lookupGetter(ExecState*, const Identifier& propertyName); 172 virtual JSValuePtr lookupSetter(ExecState*, const Identifier& propertyName); 173 173 174 174 virtual bool isGlobalObject() const { return false; } … … 184 184 static const size_t nonInlineBaseStorageCapacity = 16; 185 185 186 static PassRefPtr<StructureID> createStructureID(JSValue *proto) { return StructureID::create(proto, TypeInfo(ObjectType)); }186 static PassRefPtr<StructureID> createStructureID(JSValuePtr proto) { return StructureID::create(proto, TypeInfo(ObjectType)); } 187 187 188 188 protected: … … 196 196 197 197 PropertyStorage m_propertyStorage; 198 JSValue *m_inlineStorage[inlineStorageCapacity];198 JSValuePtr m_inlineStorage[inlineStorageCapacity]; 199 199 }; 200 200 201 JSObject* asObject(JSValue *);201 JSObject* asObject(JSValuePtr); 202 202 203 203 JSObject* constructEmptyObject(ExecState*); 204 204 205 inline JSObject* asObject(JSValue *value)205 inline JSObject* asObject(JSValuePtr value) 206 206 { 207 207 ASSERT(asCell(value)->isObject()); … … 227 227 } 228 228 229 inline JSValue *JSObject::prototype() const229 inline JSValuePtr JSObject::prototype() const 230 230 { 231 231 return m_structureID->storedPrototype(); 232 232 } 233 233 234 inline void JSObject::setPrototype(JSValue *prototype)234 inline void JSObject::setPrototype(JSValuePtr prototype) 235 235 { 236 236 ASSERT(prototype); … … 267 267 } 268 268 269 inline JSValue *JSObject::get(ExecState* exec, const Identifier& propertyName) const269 inline JSValuePtr JSObject::get(ExecState* exec, const Identifier& propertyName) const 270 270 { 271 271 PropertySlot slot(this); … … 276 276 } 277 277 278 inline JSValue *JSObject::get(ExecState* exec, unsigned propertyName) const278 inline JSValuePtr JSObject::get(ExecState* exec, unsigned propertyName) const 279 279 { 280 280 PropertySlot slot(this); … … 294 294 return true; 295 295 296 JSValue *prototype = object->prototype();296 JSValuePtr prototype = object->prototype(); 297 297 if (!prototype->isObject()) 298 298 return false; … … 310 310 return true; 311 311 312 JSValue *prototype = object->prototype();312 JSValuePtr prototype = object->prototype(); 313 313 if (!prototype->isObject()) 314 314 break; … … 326 326 { 327 327 unsigned attributes; 328 if (JSValue ** location = getDirectLocation(propertyName, attributes)) {328 if (JSValuePtr* location = getDirectLocation(propertyName, attributes)) { 329 329 if (m_structureID->hasGetterSetterProperties() && location[0]->isGetterSetter()) { 330 330 slotIsWriteable = false; … … 352 352 ALWAYS_INLINE bool JSObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 353 353 { 354 if (JSValue ** location = getDirectLocation(propertyName)) {354 if (JSValuePtr* location = getDirectLocation(propertyName)) { 355 355 if (m_structureID->hasGetterSetterProperties() && location[0]->isGetterSetter()) 356 356 fillGetterPropertySlot(slot, location); … … 369 369 } 370 370 371 inline void JSObject::putDirect(const Identifier& propertyName, JSValue *value, unsigned attr)371 inline void JSObject::putDirect(const Identifier& propertyName, JSValuePtr value, unsigned attr) 372 372 { 373 373 PutPropertySlot slot; … … 375 375 } 376 376 377 inline void JSObject::putDirect(const Identifier& propertyName, JSValue *value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot)377 inline void JSObject::putDirect(const Identifier& propertyName, JSValuePtr value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot) 378 378 { 379 379 ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); … … 425 425 } 426 426 427 inline void JSObject::putDirectWithoutTransition(const Identifier& propertyName, JSValue *value, unsigned attributes)427 inline void JSObject::putDirectWithoutTransition(const Identifier& propertyName, JSValuePtr value, unsigned attributes) 428 428 { 429 429 size_t currentCapacity = m_structureID->propertyStorageCapacity(); … … 441 441 } 442 442 443 inline JSValue *JSObject::toPrimitive(ExecState* exec, PreferredPrimitiveType preferredType) const443 inline JSValuePtr JSObject::toPrimitive(ExecState* exec, PreferredPrimitiveType preferredType) const 444 444 { 445 445 return defaultValue(exec, preferredType); 446 446 } 447 447 448 inline JSValue *JSValue::get(ExecState* exec, const Identifier& propertyName) const448 inline JSValuePtr JSValue::get(ExecState* exec, const Identifier& propertyName) const 449 449 { 450 450 PropertySlot slot(this); … … 452 452 } 453 453 454 inline JSValue *JSValue::get(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) const454 inline JSValuePtr JSValue::get(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) const 455 455 { 456 456 if (UNLIKELY(JSImmediate::isImmediate(asValue()))) { … … 465 465 return slot.getValue(exec, propertyName); 466 466 ASSERT(cell->isObject()); 467 JSValue *prototype = static_cast<JSObject*>(cell)->prototype();467 JSValuePtr prototype = static_cast<JSObject*>(cell)->prototype(); 468 468 if (!prototype->isObject()) 469 469 return jsUndefined(); … … 472 472 } 473 473 474 inline JSValue *JSValue::get(ExecState* exec, unsigned propertyName) const474 inline JSValuePtr JSValue::get(ExecState* exec, unsigned propertyName) const 475 475 { 476 476 PropertySlot slot(this); … … 478 478 } 479 479 480 inline JSValue *JSValue::get(ExecState* exec, unsigned propertyName, PropertySlot& slot) const480 inline JSValuePtr JSValue::get(ExecState* exec, unsigned propertyName, PropertySlot& slot) const 481 481 { 482 482 if (UNLIKELY(JSImmediate::isImmediate(asValue()))) { … … 491 491 return slot.getValue(exec, propertyName); 492 492 ASSERT(cell->isObject()); 493 JSValue *prototype = static_cast<JSObject*>(cell)->prototype();493 JSValuePtr prototype = static_cast<JSObject*>(cell)->prototype(); 494 494 if (!prototype->isObject()) 495 495 return jsUndefined(); … … 498 498 } 499 499 500 inline void JSValue::put(ExecState* exec, const Identifier& propertyName, JSValue *value, PutPropertySlot& slot)500 inline void JSValue::put(ExecState* exec, const Identifier& propertyName, JSValuePtr value, PutPropertySlot& slot) 501 501 { 502 502 if (UNLIKELY(JSImmediate::isImmediate(asValue()))) { … … 507 507 } 508 508 509 inline void JSValue::put(ExecState* exec, unsigned propertyName, JSValue *value)509 inline void JSValue::put(ExecState* exec, unsigned propertyName, JSValuePtr value) 510 510 { 511 511 if (UNLIKELY(JSImmediate::isImmediate(asValue()))) { … … 520 520 ASSERT(newSize > oldSize); 521 521 522 JSValue ** oldPropertyStorage = m_propertyStorage;523 m_propertyStorage = new JSValue *[newSize];522 JSValuePtr* oldPropertyStorage = m_propertyStorage; 523 m_propertyStorage = new JSValuePtr[newSize]; 524 524 525 525 for (unsigned i = 0; i < oldSize; ++i)
Note:
See TracChangeset
for help on using the changeset viewer.