From c23be3111ec279b4e19ca9c37a0d9eddb756f402 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 3 Jul 2009 14:00:27 +0200 Subject: Attributes and deletion of String object properties As per ECMA-262. --- src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp | 15 +++++++++++++++ src/3rdparty/webkit/JavaScriptCore/runtime/JSString.h | 2 ++ .../webkit/JavaScriptCore/runtime/StringObject.cpp | 11 +++++++++++ src/3rdparty/webkit/JavaScriptCore/runtime/StringObject.h | 1 + 4 files changed, 29 insertions(+) diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp index 86f95e0..e1fc66d 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp @@ -112,6 +112,21 @@ bool JSString::getOwnPropertySlot(ExecState* exec, unsigned propertyName, Proper return JSString::getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot); } +bool JSString::getStringPropertyAttributes(ExecState* exec, const Identifier& propertyName, unsigned& attributes) const +{ + if (propertyName == exec->propertyNames().length) { + attributes = DontEnum | DontDelete | ReadOnly; + return true; + } + bool isStrictUInt32; + unsigned i = propertyName.toStrictUInt32(&isStrictUInt32); + if (isStrictUInt32 && i < static_cast(m_value.size())) { + attributes = DontDelete | ReadOnly; + return true; + } + return false; +} + JSString* jsString(JSGlobalData* globalData, const UString& s) { int size = s.size(); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSString.h b/src/3rdparty/webkit/JavaScriptCore/runtime/JSString.h index 900c565..6db9322 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSString.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSString.h @@ -87,6 +87,8 @@ namespace JSC { bool getStringPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); bool getStringPropertySlot(ExecState*, unsigned propertyName, PropertySlot&); + bool getStringPropertyAttributes(ExecState*, const Identifier& propertyName, unsigned&) const; + bool canGetIndex(unsigned i) { return i < static_cast(m_value.size()); } JSString* getIndex(JSGlobalData*, unsigned); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/StringObject.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/StringObject.cpp index fb44498..df40691 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/StringObject.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/StringObject.cpp @@ -72,6 +72,10 @@ bool StringObject::deleteProperty(ExecState* exec, const Identifier& propertyNam { if (propertyName == exec->propertyNames().length) return false; + bool isStrictUInt32; + unsigned i = propertyName.toStrictUInt32(&isStrictUInt32); + if (isStrictUInt32 && internalValue()->canGetIndex(i)) + return false; return JSObject::deleteProperty(exec, propertyName); } @@ -83,6 +87,13 @@ void StringObject::getPropertyNames(ExecState* exec, PropertyNameArray& property return JSObject::getPropertyNames(exec, propertyNames); } +bool StringObject::getPropertyAttributes(ExecState* exec, const Identifier& propertyName, unsigned& attributes) const +{ + if (internalValue()->getStringPropertyAttributes(exec, propertyName, attributes)) + return true; + return JSObject::getPropertyAttributes(exec, propertyName, attributes); +} + UString StringObject::toString(ExecState*) const { return internalValue()->value(); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/StringObject.h b/src/3rdparty/webkit/JavaScriptCore/runtime/StringObject.h index ea3a045..0b643a6 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/StringObject.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/StringObject.h @@ -39,6 +39,7 @@ namespace JSC { virtual void put(ExecState* exec, const Identifier& propertyName, JSValue, PutPropertySlot&); virtual bool deleteProperty(ExecState*, const Identifier& propertyName); virtual void getPropertyNames(ExecState*, PropertyNameArray&); + virtual bool getPropertyAttributes(ExecState*, const Identifier& propertyName, unsigned& attributes) const; virtual const ClassInfo* classInfo() const { return &info; } static const JS_EXPORTDATA ClassInfo info; -- cgit v0.12