RegExpGlobalDataInlines.h [plain text]
#pragma once
#include "RegExpGlobalData.h"
namespace JSC {
inline void RegExpGlobalData::setInput(JSGlobalObject* globalObject, JSString* string)
{
m_cachedResult.setInput(globalObject, globalObject, string);
}
ALWAYS_INLINE MatchResult RegExpGlobalData::performMatch(JSGlobalObject* owner, RegExp* regExp, JSString* string, const String& input, int startOffset, int** ovector)
{
ASSERT(owner);
VM& vm = owner->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
int position = regExp->match(owner, input, startOffset, m_ovector);
RETURN_IF_EXCEPTION(scope, MatchResult::failed());
if (ovector)
*ovector = m_ovector.data();
if (position == -1)
return MatchResult::failed();
ASSERT(!m_ovector.isEmpty());
ASSERT(m_ovector[0] == position);
ASSERT(m_ovector[1] >= position);
size_t end = m_ovector[1];
m_cachedResult.record(vm, owner, regExp, string, MatchResult(position, end));
return MatchResult(position, end);
}
ALWAYS_INLINE MatchResult RegExpGlobalData::performMatch(JSGlobalObject* owner, RegExp* regExp, JSString* string, const String& input, int startOffset)
{
ASSERT(owner);
VM& vm = owner->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
MatchResult result = regExp->match(owner, input, startOffset);
RETURN_IF_EXCEPTION(scope, MatchResult::failed());
if (result)
m_cachedResult.record(vm, owner, regExp, string, result);
return result;
}
ALWAYS_INLINE void RegExpGlobalData::recordMatch(VM& vm, JSGlobalObject* owner, RegExp* regExp, JSString* string, const MatchResult& result)
{
ASSERT(result);
m_cachedResult.record(vm, owner, regExp, string, result);
}
}