summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp')
-rw-r--r--src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp66
1 files changed, 26 insertions, 40 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp
index 86f95e0db..20ba8684f 100644
--- a/src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp
+++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSString.cpp
@@ -103,54 +103,40 @@ bool JSString::getOwnPropertySlot(ExecState* exec, const Identifier& propertyNam
return true;
}
-bool JSString::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
+bool JSString::getStringPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
- // The semantics here are really getPropertySlot, not getOwnPropertySlot.
- // This function should only be called by JSValue::get.
- if (getStringPropertySlot(exec, propertyName, slot))
+ if (propertyName == exec->propertyNames().length) {
+ descriptor.setDescriptor(jsNumber(exec, m_value.size()), DontEnum | DontDelete | ReadOnly);
return true;
- return JSString::getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);
-}
-
-JSString* jsString(JSGlobalData* globalData, const UString& s)
-{
- int size = s.size();
- if (!size)
- return globalData->smallStrings.emptyString(globalData);
- if (size == 1) {
- UChar c = s.data()[0];
- if (c <= 0xFF)
- return globalData->smallStrings.singleCharacterString(globalData, c);
}
- return new (globalData) JSString(globalData, s);
-}
-JSString* jsSubstring(JSGlobalData* globalData, const UString& s, unsigned offset, unsigned length)
-{
- ASSERT(offset <= static_cast<unsigned>(s.size()));
- ASSERT(length <= static_cast<unsigned>(s.size()));
- ASSERT(offset + length <= static_cast<unsigned>(s.size()));
- if (!length)
- return globalData->smallStrings.emptyString(globalData);
- if (length == 1) {
- UChar c = s.data()[offset];
- if (c <= 0xFF)
- return globalData->smallStrings.singleCharacterString(globalData, c);
+ bool isStrictUInt32;
+ unsigned i = propertyName.toStrictUInt32(&isStrictUInt32);
+ if (isStrictUInt32 && i < static_cast<unsigned>(m_value.size())) {
+ descriptor.setDescriptor(jsSingleCharacterSubstring(exec, m_value, i), DontDelete | ReadOnly);
+ return true;
}
- return new (globalData) JSString(globalData, UString::Rep::create(s.rep(), offset, length));
+
+ return false;
}
-JSString* jsOwnedString(JSGlobalData* globalData, const UString& s)
+bool JSString::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
- int size = s.size();
- if (!size)
- return globalData->smallStrings.emptyString(globalData);
- if (size == 1) {
- UChar c = s.data()[0];
- if (c <= 0xFF)
- return globalData->smallStrings.singleCharacterString(globalData, c);
- }
- return new (globalData) JSString(globalData, s, JSString::HasOtherOwner);
+ if (getStringPropertyDescriptor(exec, propertyName, descriptor))
+ return true;
+ if (propertyName != exec->propertyNames().underscoreProto)
+ return false;
+ descriptor.setDescriptor(exec->lexicalGlobalObject()->stringPrototype(), DontEnum);
+ return true;
+}
+
+bool JSString::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
+{
+ // The semantics here are really getPropertySlot, not getOwnPropertySlot.
+ // This function should only be called by JSValue::get.
+ if (getStringPropertySlot(exec, propertyName, slot))
+ return true;
+ return JSString::getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);
}
} // namespace JSC