RegExpGlobalData.cpp [plain text]
#include "config.h"
#include "RegExpGlobalData.h"
#include "JSCInlines.h"
namespace JSC {
void RegExpGlobalData::visitAggregate(SlotVisitor& visitor)
{
m_cachedResult.visitAggregate(visitor);
}
JSValue RegExpGlobalData::getBackref(JSGlobalObject* globalObject, unsigned i)
{
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSArray* array = m_cachedResult.lastResult(globalObject, globalObject);
RETURN_IF_EXCEPTION(scope, { });
if (i < array->length()) {
JSValue result = JSValue(array).get(globalObject, i);
RETURN_IF_EXCEPTION(scope, { });
ASSERT(result.isString() || result.isUndefined());
if (!result.isUndefined())
return result;
}
return jsEmptyString(vm);
}
JSValue RegExpGlobalData::getLastParen(JSGlobalObject* globalObject)
{
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSArray* array = m_cachedResult.lastResult(globalObject, globalObject);
RETURN_IF_EXCEPTION(scope, { });
unsigned length = array->length();
if (length > 1) {
JSValue result = JSValue(array).get(globalObject, length - 1);
RETURN_IF_EXCEPTION(scope, { });
ASSERT(result.isString() || result.isUndefined());
if (!result.isUndefined())
return result;
}
return jsEmptyString(vm);
}
JSValue RegExpGlobalData::getLeftContext(JSGlobalObject* globalObject)
{
return m_cachedResult.leftContext(globalObject, globalObject);
}
JSValue RegExpGlobalData::getRightContext(JSGlobalObject* globalObject)
{
return m_cachedResult.rightContext(globalObject, globalObject);
}
}