X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/6fe7ccc865dc7d7541b93c5bcaf6368d2c98a174..ed1e77d3adeb83d26fd1dfb16dd84cabdcefd250:/runtime/RegExpMatchesArray.h?ds=inline diff --git a/runtime/RegExpMatchesArray.h b/runtime/RegExpMatchesArray.h index 595457b..669dd39 100644 --- a/runtime/RegExpMatchesArray.h +++ b/runtime/RegExpMatchesArray.h @@ -26,135 +26,8 @@ namespace JSC { - class RegExpMatchesArray : public JSArray { - private: - RegExpMatchesArray(JSGlobalData& globalData, JSGlobalObject* globalObject, JSString* input, RegExp* regExp, MatchResult result) - : JSArray(globalData, globalObject->regExpMatchesArrayStructure()) - , m_result(result) - , m_state(ReifiedNone) - { - m_input.set(globalData, this, input); - m_regExp.set(globalData, this, regExp); - } - - enum ReifiedState { ReifiedNone, ReifiedMatch, ReifiedAll }; - - public: - typedef JSArray Base; - - static RegExpMatchesArray* create(ExecState* exec, JSString* input, RegExp* regExp, MatchResult result) - { - ASSERT(result); - JSGlobalData& globalData = exec->globalData(); - RegExpMatchesArray* array = new (NotNull, allocateCell(globalData.heap)) RegExpMatchesArray(globalData, exec->lexicalGlobalObject(), input, regExp, result); - array->finishCreation(globalData); - return array; - } - - JSString* leftContext(ExecState*); - JSString* rightContext(ExecState*); - - static const ClassInfo s_info; - - static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype) - { - return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info); - } - - static void visitChildren(JSCell*, SlotVisitor&); - - protected: - void finishCreation(JSGlobalData&); - - 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(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot) - { - RegExpMatchesArray* thisObject = jsCast(cell); - thisObject->reifyAllPropertiesIfNecessary(exec); - return JSArray::getOwnPropertySlot(thisObject, exec, propertyName, slot); - } - - static bool getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot) - { - RegExpMatchesArray* thisObject = jsCast(cell); - if (propertyName) - thisObject->reifyAllPropertiesIfNecessary(exec); - else - thisObject->reifyMatchPropertyIfNecessary(exec); - return JSArray::getOwnPropertySlotByIndex(thisObject, exec, propertyName, slot); - } - - static bool getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) - { - RegExpMatchesArray* thisObject = jsCast(object); - thisObject->reifyAllPropertiesIfNecessary(exec); - return JSArray::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); - } - - static void put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue v, PutPropertySlot& slot) - { - RegExpMatchesArray* thisObject = jsCast(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(cell); - thisObject->reifyAllPropertiesIfNecessary(exec); - JSArray::putByIndex(thisObject, exec, propertyName, v, shouldThrow); - } - - static bool deleteProperty(JSCell* cell, ExecState* exec, const Identifier& propertyName) - { - RegExpMatchesArray* thisObject = jsCast(cell); - thisObject->reifyAllPropertiesIfNecessary(exec); - return JSArray::deleteProperty(thisObject, exec, propertyName); - } - - static bool deletePropertyByIndex(JSCell* cell, ExecState* exec, unsigned propertyName) - { - RegExpMatchesArray* thisObject = jsCast(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(object); - thisObject->reifyAllPropertiesIfNecessary(exec); - JSArray::getOwnPropertyNames(thisObject, exec, arr, mode); - } - - static bool defineOwnProperty(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool shouldThrow) - { - RegExpMatchesArray* thisObject = jsCast(object); - thisObject->reifyAllPropertiesIfNecessary(exec); - return JSArray::defineOwnProperty(object, exec, propertyName, descriptor, shouldThrow); - } - - void reifyAllProperties(ExecState*); - void reifyMatchProperty(ExecState*); - - WriteBarrier m_input; - WriteBarrier m_regExp; - MatchResult m_result; - ReifiedState m_state; -}; +JSArray* createRegExpMatchesArray(ExecState*, JSString*, RegExp*, MatchResult); +Structure* createRegExpMatchesArrayStructure(VM&, JSGlobalObject&); }