X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/ba379fdc102753d6be2c4d937058fe40257329fe..14957cd040308e3eeec43d26bae5d76da13fcd85:/runtime/StringObject.cpp?ds=sidebyside diff --git a/runtime/StringObject.cpp b/runtime/StringObject.cpp index fb44498..67dc291 100644 --- a/runtime/StringObject.cpp +++ b/runtime/StringObject.cpp @@ -27,24 +27,27 @@ namespace JSC { ASSERT_CLASS_FITS_IN_CELL(StringObject); -const ClassInfo StringObject::info = { "String", 0, 0, 0 }; +const ClassInfo StringObject::s_info = { "String", &JSWrapperObject::s_info, 0, 0 }; -StringObject::StringObject(ExecState* exec, PassRefPtr structure) - : JSWrapperObject(structure) +StringObject::StringObject(ExecState* exec, Structure* structure) + : JSWrapperObject(exec->globalData(), structure) { - setInternalValue(jsEmptyString(exec)); + ASSERT(inherits(&s_info)); + setInternalValue(exec->globalData(), jsEmptyString(exec)); } -StringObject::StringObject(PassRefPtr structure, JSString* string) - : JSWrapperObject(structure) +StringObject::StringObject(JSGlobalData& globalData, Structure* structure, JSString* string) + : JSWrapperObject(globalData, structure) { - setInternalValue(string); + ASSERT(inherits(&s_info)); + setInternalValue(globalData, string); } -StringObject::StringObject(ExecState* exec, PassRefPtr structure, const UString& string) - : JSWrapperObject(structure) +StringObject::StringObject(ExecState* exec, Structure* structure, const UString& string) + : JSWrapperObject(exec->globalData(), structure) { - setInternalValue(jsString(exec, string)); + ASSERT(inherits(&s_info)); + setInternalValue(exec->globalData(), jsString(exec, string)); } bool StringObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) @@ -61,6 +64,13 @@ bool StringObject::getOwnPropertySlot(ExecState* exec, unsigned propertyName, Pr return JSObject::getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot); } +bool StringObject::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + if (internalValue()->getStringPropertyDescriptor(exec, propertyName, descriptor)) + return true; + return JSObject::getOwnPropertyDescriptor(exec, propertyName, descriptor); +} + void StringObject::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) { if (propertyName == exec->propertyNames().length) @@ -72,30 +82,21 @@ bool StringObject::deleteProperty(ExecState* exec, const Identifier& propertyNam { if (propertyName == exec->propertyNames().length) return false; + bool isStrictUInt32; + unsigned i = propertyName.toUInt32(isStrictUInt32); + if (isStrictUInt32 && internalValue()->canGetIndex(i)) + return false; return JSObject::deleteProperty(exec, propertyName); } -void StringObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) +void StringObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) { - int size = internalValue()->value().size(); + int size = internalValue()->length(); for (int i = 0; i < size; ++i) - propertyNames.add(Identifier(exec, UString::from(i))); - return JSObject::getPropertyNames(exec, propertyNames); -} - -UString StringObject::toString(ExecState*) const -{ - return internalValue()->value(); -} - -UString StringObject::toThisString(ExecState*) const -{ - return internalValue()->value(); -} - -JSString* StringObject::toThisJSString(ExecState*) -{ - return internalValue(); + propertyNames.add(Identifier(exec, UString::number(i))); + if (mode == IncludeDontEnumProperties) + propertyNames.add(exec->propertyNames().length); + return JSObject::getOwnPropertyNames(exec, propertyNames, mode); } } // namespace JSC