diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
commit | 32761a6cee1d0dee366b885b7b9c777e67885688 (patch) | |
tree | d6bec92bebfb216f4126356e55518842c2f476a1 /Source/JavaScriptCore/runtime/RegExpMatchesArray.h | |
parent | a4e969f4965059196ca948db781e52f7cfebf19e (diff) | |
download | WebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz |
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/JavaScriptCore/runtime/RegExpMatchesArray.h')
-rw-r--r-- | Source/JavaScriptCore/runtime/RegExpMatchesArray.h | 110 |
1 files changed, 108 insertions, 2 deletions
diff --git a/Source/JavaScriptCore/runtime/RegExpMatchesArray.h b/Source/JavaScriptCore/runtime/RegExpMatchesArray.h index 669dd39ed..67fdcb6e1 100644 --- a/Source/JavaScriptCore/runtime/RegExpMatchesArray.h +++ b/Source/JavaScriptCore/runtime/RegExpMatchesArray.h @@ -26,8 +26,114 @@ namespace JSC { -JSArray* createRegExpMatchesArray(ExecState*, JSString*, RegExp*, MatchResult); -Structure* createRegExpMatchesArrayStructure(VM&, JSGlobalObject&); + class RegExpMatchesArray : public JSArray { + private: + RegExpMatchesArray(VM&, Butterfly*, JSGlobalObject*, JSString*, RegExp*, MatchResult); + + enum ReifiedState { ReifiedNone, ReifiedMatch, ReifiedAll }; + + public: + typedef JSArray Base; + + static RegExpMatchesArray* create(ExecState*, JSString*, RegExp*, MatchResult); + + JSString* leftContext(ExecState*); + JSString* rightContext(ExecState*); + + DECLARE_INFO; + + static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) + { + return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info(), ArrayWithSlowPutArrayStorage); + } + + static void visitChildren(JSCell*, SlotVisitor&); + + protected: + void finishCreation(VM&); + + static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesVisitChildren | OverridesGetPropertyNames | Base::StructureFlags; + + private: + ALWAYS_INLINE void reifyAllPropertiesIfNecessary(ExecState* exec) + { + if (m_state != ReifiedAll) + reifyAllProperties(exec); + } + + ALWAYS_INLINE void reifyMatchPropertyIfNecessary(ExecState* exec) + { + if (m_state == ReifiedNone) + reifyMatchProperty(exec); + } + + static bool getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot) + { + RegExpMatchesArray* thisObject = jsCast<RegExpMatchesArray*>(object); + thisObject->reifyAllPropertiesIfNecessary(exec); + return JSArray::getOwnPropertySlot(thisObject, exec, propertyName, slot); + } + + static bool getOwnPropertySlotByIndex(JSObject* object, ExecState* exec, unsigned propertyName, PropertySlot& slot) + { + RegExpMatchesArray* thisObject = jsCast<RegExpMatchesArray*>(object); + if (propertyName) + thisObject->reifyAllPropertiesIfNecessary(exec); + else + thisObject->reifyMatchPropertyIfNecessary(exec); + return JSArray::getOwnPropertySlotByIndex(thisObject, exec, propertyName, slot); + } + + static void put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue v, PutPropertySlot& slot) + { + RegExpMatchesArray* thisObject = jsCast<RegExpMatchesArray*>(cell); + thisObject->reifyAllPropertiesIfNecessary(exec); + JSArray::put(thisObject, exec, propertyName, v, slot); + } + + static void putByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, JSValue v, bool shouldThrow) + { + RegExpMatchesArray* thisObject = jsCast<RegExpMatchesArray*>(cell); + thisObject->reifyAllPropertiesIfNecessary(exec); + JSArray::putByIndex(thisObject, exec, propertyName, v, shouldThrow); + } + + static bool deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName) + { + RegExpMatchesArray* thisObject = jsCast<RegExpMatchesArray*>(cell); + thisObject->reifyAllPropertiesIfNecessary(exec); + return JSArray::deleteProperty(thisObject, exec, propertyName); + } + + static bool deletePropertyByIndex(JSCell* cell, ExecState* exec, unsigned propertyName) + { + RegExpMatchesArray* thisObject = jsCast<RegExpMatchesArray*>(cell); + thisObject->reifyAllPropertiesIfNecessary(exec); + return JSArray::deletePropertyByIndex(thisObject, exec, propertyName); + } + + static void getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& arr, EnumerationMode mode = ExcludeDontEnumProperties) + { + RegExpMatchesArray* thisObject = jsCast<RegExpMatchesArray*>(object); + thisObject->reifyAllPropertiesIfNecessary(exec); + JSArray::getOwnPropertyNames(thisObject, exec, arr, mode); + } + + static bool defineOwnProperty(JSObject* object, ExecState* exec, PropertyName propertyName, const PropertyDescriptor& descriptor, bool shouldThrow) + { + RegExpMatchesArray* thisObject = jsCast<RegExpMatchesArray*>(object); + thisObject->reifyAllPropertiesIfNecessary(exec); + return JSArray::defineOwnProperty(object, exec, propertyName, descriptor, shouldThrow); + } + + void reifyAllProperties(ExecState*); + void reifyMatchProperty(ExecState*); + + WriteBarrier<JSString> m_input; + WriteBarrier<RegExp> m_regExp; + MatchResult m_result; + ReifiedState m_state; +}; } |