Changeset 11527 in webkit for trunk/JavaScriptCore/kjs/object.h
- Timestamp:
- Dec 10, 2005, 6:06:17 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/object.h
r11447 r11527 81 81 }; 82 82 83 class ObjectImp : public AllocatedValueImp{83 class JSObject : public JSCell { 84 84 public: 85 85 /** 86 * Creates a new ObjectImpwith the specified prototype86 * Creates a new JSObject with the specified prototype 87 87 * 88 88 * @param proto The prototype 89 89 */ 90 ObjectImp(ObjectImp*proto);91 92 /** 93 * Creates a new ObjectImpwith a prototype of jsNull()90 JSObject(JSObject *proto); 91 92 /** 93 * Creates a new JSObject with a prototype of jsNull() 94 94 * (that is, the ECMAScript "null" value, not a null object pointer). 95 95 */ 96 ObjectImp();96 JSObject(); 97 97 98 98 virtual void mark(); … … 114 114 * 115 115 * \code 116 * class BarImp : public ObjectImp{116 * class BarImp : public JSObject { 117 117 * virtual const ClassInfo *classInfo() const { return &info; } 118 118 * static const ClassInfo info; … … 120 120 * }; 121 121 * 122 * class FooImp : public ObjectImp{122 * class FooImp : public JSObject { 123 123 * virtual const ClassInfo *classInfo() const { return &info; } 124 124 * static const ClassInfo info; … … 144 144 * it will return false). 145 145 * 146 * For example, for two ObjectImppointers obj1 and obj2, you can check146 * For example, for two JSObject pointers obj1 and obj2, you can check 147 147 * if obj1's class inherits from obj2's class using the following: 148 148 * … … 176 176 * @return The object's prototype 177 177 */ 178 ValueImp*prototype() const;179 void setPrototype( ValueImp*proto);178 JSValue *prototype() const; 179 void setPrototype(JSValue *proto); 180 180 181 181 /** … … 209 209 * @return The specified property, or Undefined 210 210 */ 211 ValueImp*get(ExecState *exec, const Identifier &propertyName) const;212 ValueImp*get(ExecState *exec, unsigned propertyName) const;211 JSValue *get(ExecState *exec, const Identifier &propertyName) const; 212 JSValue *get(ExecState *exec, unsigned propertyName) const; 213 213 214 214 bool getPropertySlot(ExecState *, const Identifier&, PropertySlot&); … … 227 227 * @param propertyValue The value to set 228 228 */ 229 virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp*value, int attr = None);230 virtual void put(ExecState *exec, unsigned propertyName, ValueImp*value, int attr = None);229 virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None); 230 virtual void put(ExecState *exec, unsigned propertyName, JSValue *value, int attr = None); 231 231 232 232 /** … … 300 300 * all Objects) 301 301 */ 302 virtual ValueImp*defaultValue(ExecState *exec, Type hint) const;302 virtual JSValue *defaultValue(ExecState *exec, Type hint) const; 303 303 304 304 /** … … 340 340 * Implementation of the [[Construct]] internal property 341 341 */ 342 virtual ObjectImp*construct(ExecState *exec, const List &args);343 virtual ObjectImp*construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber);342 virtual JSObject *construct(ExecState *exec, const List &args); 343 virtual JSObject *construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber); 344 344 345 345 /** … … 370 370 * @return The return value from the function 371 371 */ 372 ValueImp *call(ExecState *exec, ObjectImp*thisObj, const List &args);373 virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp*thisObj, const List &args);372 JSValue *call(ExecState *exec, JSObject *thisObj, const List &args); 373 virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); 374 374 375 375 /** … … 392 392 * false 393 393 */ 394 virtual bool hasInstance(ExecState *exec, ValueImp*value);394 virtual bool hasInstance(ExecState *exec, JSValue *value); 395 395 396 396 /** … … 449 449 * @return The internal value of the object 450 450 */ 451 ValueImp*internalValue() const;451 JSValue *internalValue() const; 452 452 453 453 /** … … 458 458 * @param v The new internal value 459 459 */ 460 void setInternalValue( ValueImp*v);461 462 ValueImp*toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const;460 void setInternalValue(JSValue *v); 461 462 JSValue *toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const; 463 463 bool toBoolean(ExecState *exec) const; 464 464 double toNumber(ExecState *exec) const; 465 465 UString toString(ExecState *exec) const; 466 ObjectImp*toObject(ExecState *exec) const;466 JSObject *toObject(ExecState *exec) const; 467 467 468 468 bool getPropertyAttributes(const Identifier& propertyName, int& attributes) const; … … 471 471 // This is used e.g. by lookupOrCreateFunction (to cache a function, we don't want 472 472 // to look up in the prototype, it might already exist there) 473 ValueImp*getDirect(const Identifier& propertyName) const473 JSValue *getDirect(const Identifier& propertyName) const 474 474 { return _prop.get(propertyName); } 475 ValueImp**getDirectLocation(const Identifier& propertyName)475 JSValue **getDirectLocation(const Identifier& propertyName) 476 476 { return _prop.getLocation(propertyName); } 477 void putDirect(const Identifier &propertyName, ValueImp*value, int attr = 0);477 void putDirect(const Identifier &propertyName, JSValue *value, int attr = 0); 478 478 void putDirect(const Identifier &propertyName, int value, int attr = 0); 479 479 … … 493 493 private: 494 494 const HashEntry* findPropertyHashEntry( const Identifier& propertyName ) const; 495 ValueImp*_proto;496 ValueImp*_internalValue;495 JSValue *_proto; 496 JSValue *_internalValue; 497 497 ScopeChain _scope; 498 498 }; … … 525 525 * @param sourceURL Optional source URL. 526 526 */ 527 static ObjectImp*create(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString *sourceURL);528 static ObjectImp*create(ExecState *, ErrorType, const char *message);527 static JSObject *create(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString *sourceURL); 528 static JSObject *create(ExecState *, ErrorType, const char *message); 529 529 530 530 /** … … 534 534 }; 535 535 536 ObjectImp*throwError(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString *sourceURL);537 ObjectImp*throwError(ExecState *, ErrorType, const UString &message);538 ObjectImp*throwError(ExecState *, ErrorType, const char *message);539 ObjectImp*throwError(ExecState *, ErrorType);536 JSObject *throwError(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString *sourceURL); 537 JSObject *throwError(ExecState *, ErrorType, const UString &message); 538 JSObject *throwError(ExecState *, ErrorType, const char *message); 539 JSObject *throwError(ExecState *, ErrorType); 540 540 541 inline bool AllocatedValueImp::isObject(const ClassInfo *info) const542 { 543 return isObject() && static_cast<const ObjectImp*>(this)->inherits(info);544 } 545 546 inline ObjectImp::ObjectImp(ObjectImp*proto)541 inline bool JSCell::isObject(const ClassInfo *info) const 542 { 543 return isObject() && static_cast<const JSObject *>(this)->inherits(info); 544 } 545 546 inline JSObject::JSObject(JSObject *proto) 547 547 : _proto(proto), _internalValue(0) 548 548 { … … 550 550 } 551 551 552 inline ObjectImp::ObjectImp()552 inline JSObject::JSObject() 553 553 : _proto(jsNull()), _internalValue(0) 554 554 { 555 555 } 556 556 557 inline ValueImp *ObjectImp::internalValue() const557 inline JSValue *JSObject::internalValue() const 558 558 { 559 559 return _internalValue; 560 560 } 561 561 562 inline void ObjectImp::setInternalValue(ValueImp*v)562 inline void JSObject::setInternalValue(JSValue *v) 563 563 { 564 564 _internalValue = v; 565 565 } 566 566 567 inline ValueImp *ObjectImp::prototype() const567 inline JSValue *JSObject::prototype() const 568 568 { 569 569 return _proto; 570 570 } 571 571 572 inline void ObjectImp::setPrototype(ValueImp*proto)572 inline void JSObject::setPrototype(JSValue *proto) 573 573 { 574 574 assert(proto); … … 576 576 } 577 577 578 inline bool ObjectImp::inherits(const ClassInfo *info) const578 inline bool JSObject::inherits(const ClassInfo *info) const 579 579 { 580 580 for (const ClassInfo *ci = classInfo(); ci; ci = ci->parentClass) … … 586 586 // It may seem crazy to inline a function this large but it makes a big difference 587 587 // since this is function very hot in variable lookup 588 inline bool ObjectImp::getPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)589 { 590 ObjectImp*object = this;588 inline bool JSObject::getPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) 589 { 590 JSObject *object = this; 591 591 while (true) { 592 592 if (object->getOwnPropertySlot(exec, propertyName, slot)) 593 593 return true; 594 594 595 ValueImp*proto = object->_proto;595 JSValue *proto = object->_proto; 596 596 if (!proto->isObject()) 597 597 return false; 598 598 599 object = static_cast< ObjectImp*>(proto);599 object = static_cast<JSObject *>(proto); 600 600 } 601 601 } … … 604 604 // but it makes a big difference to property lookup that derived classes can inline their 605 605 // base class call to this. 606 inline bool ObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)607 { 608 if ( ValueImp**location = getDirectLocation(propertyName)) {606 inline bool JSObject::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) 607 { 608 if (JSValue **location = getDirectLocation(propertyName)) { 609 609 slot.setValueSlot(this, location); 610 610 return true; … … 620 620 } 621 621 622 // FIXME: Put this function in a separate file named something like scope_chain_mark.h -- can't put it in scope_chain.h since it depends on ObjectImp.622 // FIXME: Put this function in a separate file named something like scope_chain_mark.h -- can't put it in scope_chain.h since it depends on JSObject. 623 623 624 624 inline void ScopeChain::mark() 625 625 { 626 626 for (ScopeChainNode *n = _node; n; n = n->next) { 627 ObjectImp*o = n->object;627 JSObject *o = n->object; 628 628 if (!o->marked()) 629 629 o->mark();
Note:
See TracChangeset
for help on using the changeset viewer.