Changeset 10076 in webkit for trunk/JavaScriptCore/kjs/object.h


Ignore:
Timestamp:
Aug 6, 2005, 11:17:49 PM (20 years ago)
Author:
mjs
Message:

JavaScriptCore:

Reviewed by Darin.

Change over to the new PropertySlot mechanism for property
lookup. This allows the elimination of hasOwnProperty
methods. Also did some of the performance tuning enabled by this
(but not yet all the possible improvements for function calls,
assignment, ++, and so forth). And also much code cleanup.

Net result is about a 2% speedup on the JS iBench.

Also redid Geoff's fix for the chrashing applet by avoiding a NULL
prototype in the bindings code and using the default of Null()
instead.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • bindings/objc/objc_runtime.h:
  • bindings/objc/objc_runtime.mm: (ObjcFallbackObjectImp::ObjcFallbackObjectImp): (ObjcFallbackObjectImp::getOwnPropertySlot):
  • bindings/runtime_array.cpp: (RuntimeArrayImp::lengthGetter): (RuntimeArrayImp::indexGetter): (RuntimeArrayImp::getOwnPropertySlot):
  • bindings/runtime_array.h:
  • bindings/runtime_method.cpp: (RuntimeMethodImp::lengthGetter): (RuntimeMethodImp::getOwnPropertySlot):
  • bindings/runtime_method.h:
  • bindings/runtime_object.cpp: (RuntimeObjectImp::RuntimeObjectImp): (RuntimeObjectImp::fallbackObjectGetter): (RuntimeObjectImp::fieldGetter): (RuntimeObjectImp::methodGetter): (RuntimeObjectImp::getOwnPropertySlot):
  • bindings/runtime_object.h:
  • bindings/runtime_root.h:
  • kjs/array_instance.h:
  • kjs/array_object.cpp: (ArrayInstanceImp::lengthGetter): (ArrayInstanceImp::getOwnPropertySlot): (ArrayPrototypeImp::getOwnPropertySlot):
  • kjs/array_object.h:
  • kjs/date_object.cpp: (DatePrototypeImp::getOwnPropertySlot):
  • kjs/date_object.h:
  • kjs/function.cpp: (KJS::FunctionImp::argumentsGetter): (KJS::FunctionImp::lengthGetter): (KJS::FunctionImp::getOwnPropertySlot): (KJS::FunctionImp::put): (KJS::FunctionImp::deleteProperty): (KJS::ArgumentsImp::mappedIndexGetter): (KJS::ArgumentsImp::getOwnPropertySlot): (KJS::ActivationImp::argumentsGetter): (KJS::ActivationImp::getArgumentsGetter): (KJS::ActivationImp::getOwnPropertySlot): (KJS::ActivationImp::deleteProperty):
  • kjs/function.h:
  • kjs/internal.cpp: (InterpreterImp::InterpreterImp): (InterpreterImp::initGlobalObject): (InterpreterImp::~InterpreterImp): (InterpreterImp::evaluate):
  • kjs/internal.h: (KJS::InterpreterImp::globalExec):
  • kjs/interpreter.cpp: (Interpreter::Interpreter): (Interpreter::createLanguageInstanceForValue):
  • kjs/interpreter.h: (KJS::Interpreter::argumentsIdentifier): (KJS::Interpreter::specialPrototypeIdentifier):
  • kjs/lookup.h: (KJS::staticFunctionGetter): (KJS::staticValueGetter): (KJS::getStaticPropertySlot): (KJS::getStaticFunctionSlot): (KJS::getStaticValueSlot):
  • kjs/math_object.cpp: (MathObjectImp::getOwnPropertySlot):
  • kjs/math_object.h:
  • kjs/nodes.cpp: (ResolveNode::evaluate): (ResolveNode::evaluateReference): (AccessorNode1::evaluate): (AccessorNode2::evaluate):
  • kjs/number_object.cpp: (NumberObjectImp::getOwnPropertySlot):
  • kjs/number_object.h:
  • kjs/object.cpp: (KJS::ObjectImp::get): (KJS::ObjectImp::getProperty): (KJS::ObjectImp::getPropertySlot): (KJS::ObjectImp::getOwnPropertySlot): (KJS::ObjectImp::put): (KJS::ObjectImp::hasProperty): (KJS::ObjectImp::hasOwnProperty):
  • kjs/object.h: (KJS::ObjectImp::getDirectLocation): (KJS::ObjectImp::getPropertySlot): (KJS::ObjectImp::getOwnPropertySlot):
  • kjs/object_wrapper.h: Added. (KJS::): (KJS::Object::Object): (KJS::Object::operator ObjectImp *):
  • kjs/property_map.cpp: (KJS::PropertyMap::getLocation):
  • kjs/property_map.h:
  • kjs/property_slot.cpp: Added. (KJS::PropertySlot::undefinedGetter):
  • kjs/property_slot.h: Added. (KJS::PropertySlot::isSet): (KJS::PropertySlot::getValue): (KJS::PropertySlot::setValueSlot): (KJS::PropertySlot::setStaticEntry): (KJS::PropertySlot::setCustom): (KJS::PropertySlot::setCustomIndex): (KJS::PropertySlot::setUndefined): (KJS::PropertySlot::slotBase): (KJS::PropertySlot::staticEntry): (KJS::PropertySlot::index): (KJS::PropertySlot::):
  • kjs/protect.h:
  • kjs/protected_object.h: Added. (KJS::ProtectedObject::ProtectedObject): (KJS::ProtectedObject::~ProtectedObject): (KJS::ProtectedObject::operator=): (KJS::ProtectedReference::ProtectedReference): (KJS::ProtectedReference::~ProtectedReference): (KJS::ProtectedReference::operator=):
  • kjs/reference.h:
  • kjs/reference_list.cpp:
  • kjs/regexp_object.cpp: (RegExpObjectImp::backrefGetter): (RegExpObjectImp::getOwnPropertySlot):
  • kjs/regexp_object.h:
  • kjs/string_object.cpp: (StringInstanceImp::lengthGetter): (StringInstanceImp::indexGetter): (StringInstanceImp::getOwnPropertySlot): (StringPrototypeImp::getOwnPropertySlot):
  • kjs/string_object.h:

WebCore:

Reviewed by Darin.

Change over to the new PropertySlot mechanism for property
lookup. This allows the elimination of hasOwnProperty methods. I
also did a bunch of code cleanup and regularization of the various
property lookup methods.

Test cases added: Added a test case for a bug I found along the way.

  • layout-tests/fast/js/string-index-overflow.html:
  • layout-tests/fast/js/string-index-overflow-expected.txt:
  • khtml/ecma/kjs_binding.cpp: (KJS::ScriptInterpreter::createLanguageInstanceForValue):
  • khtml/ecma/kjs_binding.h:
  • khtml/ecma/kjs_css.cpp: (KJS::DOMCSSStyleDeclaration::indexGetter): (KJS::DOMCSSStyleDeclaration::cssPropertyGetter): (KJS::DOMCSSStyleDeclaration::getOwnPropertySlot): (KJS::DOMCSSStyleDeclaration::getValueProperty): (KJS::DOMStyleSheet::getOwnPropertySlot): (KJS::DOMStyleSheetList::getValueProperty): (KJS::DOMStyleSheetList::indexGetter): (KJS::DOMStyleSheetList::nameGetter): (KJS::DOMStyleSheetList::getOwnPropertySlot): (KJS::DOMMediaList::getValueProperty): (KJS::DOMMediaList::indexGetter): (KJS::DOMMediaList::getOwnPropertySlot): (KJS::DOMCSSStyleSheet::getValueProperty): (KJS::DOMCSSStyleSheet::getOwnPropertySlot): (KJS::DOMCSSRuleList::getValueProperty): (KJS::DOMCSSRuleList::indexGetter): (KJS::DOMCSSRuleList::getOwnPropertySlot): (KJS::DOMCSSRule::getOwnPropertySlot): (KJS::CSSRuleConstructor::getOwnPropertySlot): (KJS::DOMCSSValue::getValueProperty): (KJS::DOMCSSValue::getOwnPropertySlot): (KJS::CSSValueConstructor::getOwnPropertySlot): (KJS::DOMCSSPrimitiveValue::getValueProperty): (KJS::DOMCSSPrimitiveValue::getOwnPropertySlot): (KJS::CSSPrimitiveValueConstructor::getOwnPropertySlot): (KJS::DOMCSSValueList::getValueProperty): (KJS::DOMCSSValueList::indexGetter): (KJS::DOMCSSValueList::getOwnPropertySlot): (KJS::DOMRGBColor::getOwnPropertySlot): (KJS::DOMRect::getOwnPropertySlot): (KJS::DOMCounter::getOwnPropertySlot):
  • khtml/ecma/kjs_css.h: (KJS::DOMCSSStyleDeclaration::): (KJS::DOMCSSStyleSheet::): (KJS::DOMCSSRule::): (KJS::DOMCSSValueList::):
  • khtml/ecma/kjs_dom.cpp: (KJS::DOMNode::getOwnPropertySlot): (KJS::): (KJS::DOMNodeList::getValueProperty): (KJS::DOMNodeList::indexGetter): (KJS::DOMNodeList::nameGetter): (KJS::DOMNodeList::getOwnPropertySlot): (KJS::DOMNodeList::call): (KJS::DOMAttr::getOwnPropertySlot): (KJS::DOMDocument::getOwnPropertySlot): (KJS::DOMElement::getValueProperty): (KJS::DOMElement::attributeGetter): (KJS::DOMElement::getOwnPropertySlot): (KJS::DOMDocumentType::getOwnPropertySlot): (KJS::DOMNamedNodeMap::lengthGetter): (KJS::DOMNamedNodeMap::indexGetter): (KJS::DOMNamedNodeMap::getOwnPropertySlot): (KJS::DOMProcessingInstruction::getOwnPropertySlot): (KJS::DOMNotation::getOwnPropertySlot): (KJS::DOMEntity::getOwnPropertySlot): (KJS::NodeConstructor::getOwnPropertySlot): (KJS::DOMExceptionConstructor::getOwnPropertySlot): (KJS::DOMNamedNodesCollection::lengthGetter): (KJS::DOMNamedNodesCollection::indexGetter): (KJS::DOMNamedNodesCollection::getOwnPropertySlot): (KJS::DOMCharacterData::getOwnPropertySlot):
  • khtml/ecma/kjs_dom.h:
  • khtml/ecma/kjs_events.cpp: (KJS::EventConstructor::getOwnPropertySlot): (KJS::DOMEvent::getOwnPropertySlot): (KJS::EventExceptionConstructor::getOwnPropertySlot): (KJS::DOMUIEvent::getOwnPropertySlot): (KJS::DOMMouseEvent::getOwnPropertySlot): (KJS::DOMKeyboardEvent::getOwnPropertySlot): (KJS::MutationEventConstructor::getOwnPropertySlot): (KJS::DOMMutationEvent::getOwnPropertySlot): (KJS::DOMWheelEvent::getOwnPropertySlot): (KJS::Clipboard::getOwnPropertySlot):
  • khtml/ecma/kjs_events.h:
  • khtml/ecma/kjs_html.cpp: (KJS::HTMLDocument::namedItemGetter): (KJS::HTMLDocument::getValueProperty): (KJS::HTMLDocument::getOwnPropertySlot): (KJS::HTMLElement::formIndexGetter): (KJS::HTMLElement::formNameGetter): (KJS::HTMLElement::selectIndexGetter): (KJS::HTMLElement::framesetNameGetter): (KJS::HTMLElement::frameWindowPropertyGetter): (KJS::HTMLElement::runtimeObjectGetter): (KJS::HTMLElement::runtimeObjectPropertyGetter): (KJS::HTMLElement::getOwnPropertySlot): (KJS::HTMLCollection::lengthGetter): (KJS::HTMLCollection::indexGetter): (KJS::HTMLCollection::nameGetter): (KJS::HTMLCollection::getOwnPropertySlot): (KJS::HTMLSelectCollection::selectedIndexGetter): (KJS::HTMLSelectCollection::getOwnPropertySlot): (KJS::Image::getOwnPropertySlot): (KJS::Context2D::getOwnPropertySlot): (KJS::Gradient::getOwnPropertySlot): (KJS::ImagePattern::getOwnPropertySlot):
  • khtml/ecma/kjs_html.h: (KJS::HTMLCollection::toBoolean):
  • khtml/ecma/kjs_navigator.cpp: (KJS::Plugins::): (KJS::MimeTypes::): (KJS::Plugin::): (KJS::MimeType::): (KJS::): (KJS::Navigator::getOwnPropertySlot): (KJS::Plugins::getValueProperty): (KJS::Plugins::indexGetter): (KJS::Plugins::nameGetter): (KJS::Plugins::getOwnPropertySlot): (KJS::MimeTypes::getValueProperty): (KJS::MimeTypes::indexGetter): (KJS::MimeTypes::nameGetter): (KJS::MimeTypes::getOwnPropertySlot): (KJS::Plugin::getValueProperty): (KJS::Plugin::indexGetter): (KJS::Plugin::nameGetter): (KJS::Plugin::getOwnPropertySlot): (KJS::MimeType::getValueProperty): (KJS::MimeType::getOwnPropertySlot):
  • khtml/ecma/kjs_navigator.h:
  • khtml/ecma/kjs_range.cpp: (KJS::DOMRange::getOwnPropertySlot): (KJS::RangeConstructor::getOwnPropertySlot):
  • khtml/ecma/kjs_range.h:
  • khtml/ecma/kjs_traversal.cpp: (KJS::DOMNodeIterator::getOwnPropertySlot): (KJS::NodeFilterConstructor::getOwnPropertySlot): (KJS::DOMTreeWalker::getOwnPropertySlot):
  • khtml/ecma/kjs_traversal.h:
  • khtml/ecma/kjs_views.cpp: (KJS::DOMAbstractView::~DOMAbstractView): (KJS::DOMAbstractView::getValueProperty): (KJS::DOMAbstractView::getOwnPropertySlot):
  • khtml/ecma/kjs_views.h:
  • khtml/ecma/kjs_window.cpp: (KJS::FrameArray::): (KJS::FrameArray::classInfo): (KJS::Screen::getOwnPropertySlot): (KJS::Window::getValueProperty): (KJS::Window::childFrameGetter): (KJS::Window::namedFrameGetter): (KJS::Window::indexGetter): (KJS::Window::namedItemGetter): (KJS::Window::getOwnPropertySlot): (KJS::): (KJS::FrameArray::getValueProperty): (KJS::FrameArray::indexGetter): (KJS::FrameArray::nameGetter): (KJS::FrameArray::getOwnPropertySlot): (KJS::Location::getValueProperty): (KJS::Location::getOwnPropertySlot): (KJS::Selection::getValueProperty): (KJS::Selection::getOwnPropertySlot): (KJS::BarInfo::getValueProperty): (KJS::BarInfo::getOwnPropertySlot): (KJS::History::getOwnPropertySlot):
  • khtml/ecma/kjs_window.h:
  • khtml/ecma/xmlhttprequest.cpp: (KJS::XMLHttpRequest::getOwnPropertySlot):
  • khtml/ecma/xmlhttprequest.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/object.h

    r9889 r10076  
    3939#endif
    4040
    41 #include "value.h"
    4241#include "types.h"
     42#include "interpreter.h"
    4343#include "reference_list.h"
    4444#include "property_map.h"
     45#include "property_slot.h"
    4546#include "scope_chain.h"
    4647
     
    5051  class HashEntry;
    5152  class ListImp;
    52   class ReferenceList;
    53 
    54   // ECMA 262-3 8.6.1
    55   // Attributes (only applicable to the Object type)
    56   enum Attribute { None       = 0,
    57                    ReadOnly   = 1 << 1, // property can be only read, not written
    58                    DontEnum   = 1 << 2, // property doesn't appear in (for .. in ..)
    59                    DontDelete = 1 << 3, // property can't be deleted
    60                    Internal   = 1 << 4, // an internal property, set to by pass checks
    61                    Function   = 1 << 5 }; // property is a function - only used by static hashtables
    6253
    6354  /**
     
    8475  };
    8576 
    86   /**
    87    * Represents an Object. This is a wrapper for ObjectImp
    88    */
    89   class Object : public Value {
    90   public:
    91     Object() { }
    92     Object(ObjectImp *);
    93     operator ObjectImp *() const { return imp(); }
    94    
    95     ObjectImp *imp() const;
    96 
    97     const ClassInfo *classInfo() const;
    98     bool inherits(const ClassInfo *cinfo) const;
    99 
    100     /**
    101      * Converts a Value into an Object. If the value's type is not ObjectType,
    102      * a null object will be returned (i.e. one with it's internal pointer set
    103      * to 0). If you do not know for sure whether the value is of type
    104      * ObjectType, you should check the isValid() methods afterwards before
    105      * calling any methods on the Object.
    106      *
    107      * @return The value converted to an object
    108      */
    109     static Object dynamicCast(const Value &v);
    110 
    111     /**
    112      * Returns the prototype of this object. Note that this is not the same as
    113      * the "prototype" property.
    114      *
    115      * See ECMA 8.6.2
    116      *
    117      * @return The object's prototype
    118      */
    119     Value prototype() const;
    120 
    121     /**
    122      * Returns the class name of the object
    123      *
    124      * See ECMA 8.6.2
    125      *
    126      * @return The object's class name
    127      */
    128     UString className() const;
    129 
    130     /**
    131      * Retrieves the specified property from the object. If neither the object
    132      * or any other object in it's prototype chain have the property, this
    133      * function will return Undefined.
    134      *
    135      * See ECMA 8.6.2.1
    136      *
    137      * @param exec The current execution state
    138      * @param propertyName The name of the property to retrieve
    139      *
    140      * @return The specified property, or Undefined
    141      */
    142     Value get(ExecState *exec, const Identifier &propertyName) const;
    143     Value get(ExecState *exec, unsigned propertyName) const;
    144 
    145     /**
    146      * Sets the specified property.
    147      *
    148      * See ECMA 8.6.2.2
    149      *
    150      * @param exec The current execution state
    151      * @param propertyName The name of the property to set
    152      * @param propertyValue The value to set
    153      */
    154     void put(ExecState *exec, const Identifier &propertyName,
    155              const Value &value, int attr = None);
    156     void put(ExecState *exec, unsigned propertyName,
    157              const Value &value, int attr = None);
    158 
    159     /**
    160      * Used to check whether or not a particular property is allowed to be set
    161      * on an object
    162      *
    163      * See ECMA 8.6.2.3
    164      *
    165      * @param exec The current execution state
    166      * @param propertyName The name of the property
    167      * @return true if the property can be set, otherwise false
    168      */
    169     bool canPut(ExecState *exec, const Identifier &propertyName) const;
    170 
    171     /**
    172      * Checks to see whether the object (or any object in it's prototype chain)
    173      * has a property with the specified name.
    174      *
    175      * See ECMA 8.6.2.4
    176      *
    177      * @param exec The current execution state
    178      * @param propertyName The name of the property to check for
    179      * @return true if the object has the property, otherwise false
    180      */
    181     bool hasProperty(ExecState *exec, const Identifier &propertyName) const;
    182     bool hasProperty(ExecState *exec, unsigned propertyName) const;
    183 
    184     /**
    185      * Checks to see whether the object has a property with the specified name.
    186      *
    187      * See ECMA 15.2.4.5
    188      *
    189      * @param exec The current execution state
    190      * @param propertyName The name of the property to check for
    191      * @return true if the object has the property, otherwise false
    192      */
    193     bool hasOwnProperty(ExecState *exec, const Identifier &propertyName) const;
    194     bool hasOwnProperty(ExecState *exec, unsigned propertyName) const;
    195 
    196     /**
    197      * Removes the specified property from the object.
    198      *
    199      * See ECMA 8.6.2.5
    200      *
    201      * @param exec The current execution state
    202      * @param propertyName The name of the property to delete
    203      * @return true if the property was successfully deleted or did not
    204      * exist on the object. false if deleting the specified property is not
    205      * allowed.
    206      */
    207     bool deleteProperty(ExecState *exec, const Identifier &propertyName);
    208     bool deleteProperty(ExecState *exec, unsigned propertyName);
    209 
    210     /**
    211      * Converts the object into a primitive value. The value return may differ
    212      * depending on the supplied hint
    213      *
    214      * See ECMA 8.6.2.6
    215      *
    216      * @param exec The current execution state
    217      * @param hint The desired primitive type to convert to
    218      * @return A primitive value converted from the objetc. Note that the
    219      * type of primitive value returned may not be the same as the requested
    220      * hint.
    221      */
    222     Value defaultValue(ExecState *exec, Type hint) const;
    223 
    224     /**
    225      * Whether or not the object implements the construct() method. If this
    226      * returns false you should not call the construct() method on this
    227      * object (typically, an assertion will fail to indicate this).
    228      *
    229      * @return true if this object implements the construct() method, otherwise
    230      * false
    231      */
    232     bool implementsConstruct() const;
    233 
    234     /**
    235      * Creates a new object based on this object. Typically this means the
    236      * following:
    237      * 1. A new object is created
    238      * 2. The prototype of the new object is set to the value of this object's
    239      *    "prototype" property
    240      * 3. The call() method of this object is called, with the new object
    241      *    passed as the this value
    242      * 4. The new object is returned
    243      *
    244      * In some cases, Host objects may differ from these semantics, although
    245      * this is discouraged.
    246      *
    247      * If an error occurs during construction, the execution state's exception
    248      * will be set. This can be tested for with ExecState::hadException().
    249      * Under some circumstances, the exception object may also be returned.
    250      *
    251      * Note: This function should not be called if implementsConstruct() returns
    252      * false, in which case it will result in an assertion failure.
    253      *
    254      * @param exec The current execution state
    255      * @param args The arguments to be passed to call() once the new object has
    256      * been created
    257      * @return The newly created &amp; initialized object
    258      */
    259     Object construct(ExecState *exec, const List &args);
    260     Object construct(ExecState *exec, const List &args, const UString &sourceURL, int lineNumber);
    261 
    262     /**
    263      * Whether or not the object implements the call() method. If this returns
    264      * false you should not call the call() method on this object (typically,
    265      * an assertion will fail to indicate this).
    266      *
    267      * @return true if this object implements the call() method, otherwise
    268      * false
    269      */
    270     bool implementsCall() const;
    271 
    272 
    273     /**
    274      * Calls this object as if it is a function.
    275      *
    276      * Note: This function should not be called if implementsCall() returns
    277      * false, in which case it will result in an assertion failure.
    278      *
    279      * See ECMA 8.6.2.3
    280      *
    281      * @param exec The current execution state
    282      * @param thisObj The obj to be used as "this" within function execution.
    283      * Note that in most cases this will be different from the C++ "this"
    284      * object. For example, if the ECMAScript code "window.location.toString()"
    285      * is executed, call() will be invoked on the C++ object which implements
    286      * the toString method, with the thisObj being window.location
    287      * @param args List of arguments to be passed to the function
    288      * @return The return value from the function
    289      */
    290     Value call(ExecState *exec, Object &thisObj, const List &args);
    291 
    292     /**
    293      * Whether or not the object implements the hasInstance() method. If this
    294      * returns false you should not call the hasInstance() method on this
    295      * object (typically, an assertion will fail to indicate this).
    296      *
    297      * @return true if this object implements the hasInstance() method,
    298      * otherwise false
    299      */
    300     bool implementsHasInstance() const;
    301 
    302     /**
    303      * Checks whether value delegates behavior to this object. Used by the
    304      * instanceof operator.
    305      *
    306      * @param exec The current execution state
    307      * @param value The value to check
    308      * @return true if value delegates behavior to this object, otherwise
    309      * false
    310      */
    311     Boolean hasInstance(ExecState *exec, const Value &value);
    312 
    313     /**
    314      * Returns the scope of this object. This is used when execution declared
    315      * functions - the execution context for the function is initialized with
    316      * extra object in it's scope. An example of this is functions declared
    317      * inside other functions:
    318      *
    319      * \code
    320      * function f() {
    321      *
    322      *   function b() {
    323      *     return prototype;
    324      *   }
    325      *
    326      *   var x = 4;
    327      *   // do some stuff
    328      * }
    329      * f.prototype = new String();
    330      * \endcode
    331      *
    332      * When the function f.b is executed, its scope will include properties of
    333      * f. So in the example above the return value of f.b() would be the new
    334      * String object that was assigned to f.prototype.
    335      *
    336      * @param exec The current execution state
    337      * @return The function's scope
    338      */
    339     const ScopeChain &scope() const;
    340     void setScope(const ScopeChain &s);
    341 
    342     /**
    343      * Returns a List of References to all the properties of the object. Used
    344      * in "for x in y" statements. The list is created new, so it can be freely
    345      * modified without affecting the object's properties. It should be deleted
    346      * by the caller.
    347      *
    348      * Subclasses can override this method in ObjectImpl to provide the
    349      * appearance of
    350      * having extra properties other than those set specifically with put().
    351      *
    352      * @param exec The current execution state
    353      * @param recursive Whether or not properties in the object's prototype
    354      * chain should be
    355      * included in the list.
    356      * @return A List of References to properties of the object.
    357      **/
    358     ReferenceList propList(ExecState *exec, bool recursive = true);
    359 
    360     /**
    361      * Returns the internal value of the object. This is used for objects such
    362      * as String and Boolean which are wrappers for native types. The interal
    363      * value is the actual value represented by the wrapper objects.
    364      *
    365      * @see ECMA 8.6.2
    366      * @return The internal value of the object
    367      */
    368     Value internalValue() const;
    369 
    370     /**
    371      * Sets the internal value of the object
    372      *
    373      * @see internalValue()
    374      *
    375      * @param v The new internal value
    376      */
    377     void setInternalValue(const Value &v);
    378 
    379     void saveProperties(SavedProperties &p) const;
    380     void restoreProperties(const SavedProperties &p);
    381   };
    382 
    38377  inline Object Value::toObject(ExecState *exec) const { return rep->dispatchToObject(exec); }
    38478 
     
    510204    bool getProperty(ExecState *exec, unsigned propertyName, Value& result) const;
    511205
    512     virtual bool getOwnProperty(ExecState *exec, const Identifier& propertyName, Value& result) const;
    513     virtual bool getOwnProperty(ExecState *exec, unsigned propertyName, Value& result) const;
     206    bool getPropertySlot(ExecState *, const Identifier&, PropertySlot&);
     207    bool getPropertySlot(ExecState *, unsigned, PropertySlot&);
     208    virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
     209    virtual bool getOwnPropertySlot(ExecState *, unsigned index, PropertySlot&);
    514210
    515211    /**
     
    538234     * @see Object::hasProperty()
    539235     */
    540     bool hasProperty(ExecState *exec,
    541                              const Identifier &propertyName) const;
     236    bool hasProperty(ExecState *exec, const Identifier &propertyName) const;
    542237    bool hasProperty(ExecState *exec, unsigned propertyName) const;
    543238
    544     virtual bool hasOwnProperty(ExecState *exec,
    545                      const Identifier &propertyName) const;
    546     virtual bool hasOwnProperty(ExecState *exec, unsigned propertyName) const;
     239    virtual bool hasOwnProperty(ExecState *exec, const Identifier &propertyName) const;
    547240
    548241    /**
     
    624317    ValueImp *getDirect(const Identifier& propertyName) const
    625318        { return _prop.get(propertyName); }
     319    ValueImp **getDirectLocation(const Identifier& propertyName)
     320        { return _prop.getLocation(propertyName); }
    626321    void putDirect(const Identifier &propertyName, ValueImp *value, int attr = 0);
    627322    void putDirect(const Identifier &propertyName, int value, int attr = 0);
     
    639334  };
    640335
    641 
    642336  // it may seem crazy to inline a function this large but it makes a big difference
    643337  // since this is function very hot in variable lookup
    644   inline bool ObjectImp::getProperty(ExecState *exec, const Identifier& propertyName, Value& result) const
     338  inline bool ObjectImp::getPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
    645339  {
    646     const ObjectImp *imp = this;
     340    ObjectImp *imp = this;
    647341
    648342    while (true) {
    649       if (imp->getOwnProperty(exec, propertyName, result))
     343      if (imp->getOwnPropertySlot(exec, propertyName, slot))
    650344        return true;
    651345     
    652       const ValueImp *proto = imp->_proto;
     346      ValueImp *proto = imp->_proto;
    653347      if (proto->dispatchType() != ObjectType)
    654348        break;
    655349     
    656       imp = static_cast<const ObjectImp *>(proto);
     350      imp = static_cast<ObjectImp *>(proto);
    657351    }
    658352   
     
    663357  // but it makes a big difference to property lookup if subclasses can inline their
    664358  // superclass call to this
    665   inline bool ObjectImp::getOwnProperty(ExecState *exec, const Identifier &propertyName, Value &result) const
     359  inline bool ObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
    666360  {
    667       ValueImp *imp = getDirect(propertyName);
    668       if (imp) {
    669         result = Value(imp);
     361      ValueImp **impLocation = getDirectLocation(propertyName);
     362      if (impLocation) {
     363        slot.setValueSlot(this, impLocation);
    670364        return true;
    671365      }
    672366
    673367      // non-standard netscape extension
    674       if (propertyName == specialPrototypePropertyName) {
    675         result = Value(_proto);
     368      if (propertyName == exec->dynamicInterpreter()->specialPrototypeIdentifier()) {
     369        slot.setValueSlot(this, &_proto);
    676370        return true;
    677371      }
     
    760454    { return imp()->hasProperty(exec, propertyName); }
    761455
    762   inline bool Object::hasProperty(ExecState *exec, unsigned propertyName) const
    763     { return imp()->hasProperty(exec, propertyName); }
    764 
    765456  inline bool Object::hasOwnProperty(ExecState *exec, const Identifier &propertyName) const
    766     { return imp()->hasOwnProperty(exec, propertyName); }
    767 
    768   inline bool Object::hasOwnProperty(ExecState *exec, unsigned propertyName) const
    769457    { return imp()->hasOwnProperty(exec, propertyName); }
    770458
Note: See TracChangeset for help on using the changeset viewer.