Changeset 10207 in webkit for trunk/JavaScriptCore/kjs/object.h
- Timestamp:
- Aug 15, 2005, 5:47:46 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/object.h
r10180 r10207 91 91 92 92 /** 93 * Creates a new ObjectImp with a prototype of Null()93 * Creates a new ObjectImp with a prototype of jsNull() 94 94 * (that is, the ECMAScript "null" value, not a null object pointer). 95 *96 95 */ 97 96 ObjectImp(); 98 97 99 98 virtual void mark(); 100 101 Type type() const; 99 virtual Type type() const; 102 100 103 101 /** … … 178 176 * @return The object's prototype 179 177 */ 180 /**181 * Implementation of the [[Prototype]] internal property (implemented by182 * all Objects)183 */184 178 ValueImp *prototype() const; 185 179 void setPrototype(ValueImp *proto); … … 215 209 * @return The specified property, or Undefined 216 210 */ 217 /**218 * Implementation of the [[Get]] internal property (implemented by all219 * Objects)220 */221 // [[Get]] - must be implemented by all Objects222 211 ValueImp *get(ExecState *exec, const Identifier &propertyName) const; 223 212 ValueImp *get(ExecState *exec, unsigned propertyName) const; 224 213 225 bool getProperty(ExecState *exec, const Identifier& propertyName, ValueImp*& result) const;226 bool getProperty(ExecState *exec, unsigned propertyName, ValueImp*& result) const;227 228 214 bool getPropertySlot(ExecState *, const Identifier&, PropertySlot&); 229 215 bool getPropertySlot(ExecState *, unsigned, PropertySlot&); … … 241 227 * @param propertyValue The value to set 242 228 */ 243 /** 244 * Implementation of the [[Put]] internal property (implemented by all 245 * Objects) 246 */ 247 virtual void put(ExecState *exec, const Identifier &propertyName, 248 ValueImp *value, int attr = None); 249 virtual void put(ExecState *exec, unsigned propertyName, 250 ValueImp *value, int attr = None); 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); 251 231 252 232 /** … … 276 256 * @return true if the object has the property, otherwise false 277 257 */ 278 /** 279 * Implementation of the [[HasProperty]] internal property (implemented by 280 * all Objects) 281 */ 282 bool hasProperty(ExecState *exec, 283 const Identifier &propertyName) const; 258 bool hasProperty(ExecState *exec, const Identifier &propertyName) const; 284 259 bool hasProperty(ExecState *exec, unsigned propertyName) const; 285 286 /**287 * Checks to see whether the object has a property with the specified name.288 *289 * See ECMA 15.2.4.5290 *291 * @param exec The current execution state292 * @param propertyName The name of the property to check for293 * @return true if the object has the property, otherwise false294 */295 virtual bool hasOwnProperty(ExecState *exec, const Identifier &propertyName) const;296 virtual bool hasOwnProperty(ExecState *exec, unsigned propertyName) const;297 260 298 261 /** … … 307 270 * allowed. 308 271 */ 309 /** 310 * Implementation of the [[Delete]] internal property (implemented by all 311 * Objects) 312 */ 313 virtual bool deleteProperty(ExecState *exec, 314 const Identifier &propertyName); 272 virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName); 315 273 virtual bool deleteProperty(ExecState *exec, unsigned propertyName); 316 317 /**318 * Remove all properties from this object.319 * This doesn't take DontDelete into account, and isn't in the ECMA spec.320 * It's simply a quick way to remove everything before destroying.321 */322 void deleteAllProperties(ExecState *);323 274 324 275 /** … … 408 359 * @return The return value from the function 409 360 */ 410 /**411 * Implementation of the [[Call]] internal property412 */413 361 ValueImp *call(ExecState *exec, ObjectImp *thisObj, const List &args); 414 362 virtual ValueImp *callAsFunction(ExecState *exec, ObjectImp *thisObj, const List &args); … … 432 380 * @return true if value delegates behavior to this object, otherwise 433 381 * false 434 */435 /**436 * Implementation of the [[HasInstance]] internal property437 382 */ 438 383 virtual bool hasInstance(ExecState *exec, ValueImp *value); … … 463 408 * @param exec The current execution state 464 409 * @return The function's scope 465 */466 /**467 * Implementation of the [[Scope]] internal property468 410 */ 469 411 const ScopeChain &scope() const { return _scope; } … … 505 447 * @param v The new internal value 506 448 */ 507 508 449 void setInternalValue(ValueImp *v); 509 450 … … 514 455 ObjectImp *toObject(ExecState *exec) const; 515 456 516 // This get method only looks at the property map. 517 // A bit like hasProperty(recursive=false), this doesn't go to the prototype. 457 // This get function only looks at the property map. 518 458 // This is used e.g. by lookupOrCreateFunction (to cache a function, we don't want 519 459 // to look up in the prototype, it might already exist there) … … 525 465 void putDirect(const Identifier &propertyName, int value, int attr = 0); 526 466 467 /** 468 * Remove all properties from this object. 469 * This doesn't take DontDelete into account, and isn't in the ECMA spec. 470 * It's simply a quick way to remove everything stored in the property map. 471 */ 472 void clearProperties() { _prop.clear(); } 473 527 474 void saveProperties(SavedProperties &p) const { _prop.save(p); } 528 475 void restoreProperties(const SavedProperties &p) { _prop.restore(p); } … … 537 484 ScopeChain _scope; 538 485 }; 539 540 // it may seem crazy to inline a function this large but it makes a big difference541 // since this is function very hot in variable lookup542 inline bool ObjectImp::getPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)543 {544 ObjectImp *imp = this;545 546 while (true) {547 if (imp->getOwnPropertySlot(exec, propertyName, slot))548 return true;549 550 ValueImp *proto = imp->_proto;551 if (!proto->isObject())552 break;553 554 imp = static_cast<ObjectImp *>(proto);555 }556 557 return false;558 }559 560 // it may seem crazy to inline a function this large, especially a virtual function,561 // but it makes a big difference to property lookup if subclasses can inline their562 // superclass call to this563 inline bool ObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)564 {565 ValueImp **impLocation = getDirectLocation(propertyName);566 if (impLocation) {567 slot.setValueSlot(this, impLocation);568 return true;569 }570 571 // non-standard netscape extension572 if (propertyName == exec->dynamicInterpreter()->specialPrototypeIdentifier()) {573 slot.setValueSlot(this, &_proto);574 return true;575 }576 577 return false;578 }579 486 580 487 /** … … 590 497 URIError = 6}; 591 498 592 ObjectImp *error(ExecState *exec, ErrorType type = GeneralError,593 const char *message = 0, int lineno = -1, int sourceId = -1, const UString *sourceURL = 0);594 595 499 /** 596 500 * @short Factory methods for error objects. … … 604 508 * @param errtype Type of error. 605 509 * @param message Optional error message. 606 * @param line noOptional line number.607 * @param linenoOptional source id.608 * /609 static ObjectImp *create(ExecState *exec, ErrorType errtype = GeneralError,610 const char *message = 0, int lineno = -1,611 int sourceId = -1, const UString *sourceURL = 0);510 * @param lineNumber Optional line number. 511 * @param sourceId Optional source id. 512 * @param sourceURL Optional source URL. 513 */ 514 static ObjectImp *create(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString *sourceURL); 515 static ObjectImp *create(ExecState *, ErrorType, const char *message); 612 516 613 517 /** … … 617 521 }; 618 522 523 ObjectImp *throwError(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString *sourceURL); 524 ObjectImp *throwError(ExecState *, ErrorType, const UString &message); 525 ObjectImp *throwError(ExecState *, ErrorType, const char *message); 526 ObjectImp *throwError(ExecState *, ErrorType); 527 619 528 inline bool AllocatedValueImp::isObject(const ClassInfo *info) const 620 529 { … … 662 571 } 663 572 573 // It may seem crazy to inline a function this large but it makes a big difference 574 // since this is function very hot in variable lookup 575 inline bool ObjectImp::getPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) 576 { 577 ObjectImp *object = this; 578 while (true) { 579 if (object->getOwnPropertySlot(exec, propertyName, slot)) 580 return true; 581 582 ValueImp *proto = object->_proto; 583 if (!proto->isObject()) 584 return false; 585 586 object = static_cast<ObjectImp *>(proto); 587 } 588 } 589 590 // It may seem crazy to inline a function this large, especially a virtual function, 591 // but it makes a big difference to property lookup that derived classes can inline their 592 // base class call to this. 593 inline bool ObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) 594 { 595 if (ValueImp **location = getDirectLocation(propertyName)) { 596 slot.setValueSlot(this, location); 597 return true; 598 } 599 600 // non-standard Netscape extension 601 if (propertyName == exec->dynamicInterpreter()->specialPrototypeIdentifier()) { 602 slot.setValueSlot(this, &_proto); 603 return true; 604 } 605 606 return false; 607 } 608 664 609 } // namespace 665 610
Note:
See TracChangeset
for help on using the changeset viewer.