Lines Matching defs:regexp
28 #include "ecmascript/regexp/regexp_executor.h"
29 #include "ecmascript/regexp/regexp_parser_cache.h"
205 bool BuiltinsRegExp::IsFastRegExp(JSThread *thread, JSHandle<JSTaggedValue> regexp,
210 JSHClass *hclass = JSHandle<JSObject>::Cast(regexp)->GetJSHClass();
212 // regexp instance hclass
217 JSTaggedValue lastIndex = JSHandle<JSObject>::Cast(regexp)->GetPropertyInlinedProps(LAST_INDEX_OFFSET);
256 JSTaggedValue BuiltinsRegExp::RegExpTestFast(JSThread *thread, JSHandle<JSTaggedValue> regexp,
261 uint32_t lastIndex = static_cast<uint32_t>(GetLastIndex(thread, regexp, true));
267 RegExpExecResultCache::TEST_TYPE, regexp,
276 SetLastIndex(thread, regexp, JSTaggedValue(0), true);
280 bool matchResult = RegExpExecInternal(thread, regexp, inputString, lastIndex);
281 // 2. Check whether the regexp is global or sticky, which determines whether we update last index later on.
282 bool global = GetOriginalFlag(thread, regexp, RegExpParser::FLAG_GLOBAL);
283 bool sticky = GetOriginalFlag(thread, regexp, RegExpParser::FLAG_STICKY);
287 SetLastIndex(thread, regexp, JSTaggedValue(0), true);
290 RegExpExecResultCache::AddResultInCache(thread, cacheTable, regexp, inputStr,
302 SetLastIndex(thread, regexp, endIndex, true);
305 RegExpExecResultCache::AddResultInCache(thread, cacheTable, regexp, inputStr,
333 JSHandle<JSRegExp> regexp(thread, JSRegExp::Cast(thisObj->GetTaggedObject()));
335 getSource.Update(regexp->GetOriginalSource());
338 uint8_t flagsBits = static_cast<uint8_t>(regexp->GetOriginalFlags().GetInt());
609 JSTaggedValue BuiltinsRegExp::RegExpMatch(JSThread *thread, const JSHandle<JSTaggedValue> regexp,
618 bool isGlobal = GetFlag(thread, regexp, RegExpParser::FLAG_GLOBAL, isFastPath);
624 return RegExpBuiltinExec(thread, regexp, string, isFastPath, useCache);
626 return RegExpExec(thread, regexp, string, useCache);
631 uint32_t lastIndex = static_cast<uint32_t>(GetLastIndex(thread, regexp, isFastPath));
633 RegExpExecResultCache::MATCH_TYPE, regexp,
639 bool fullUnicode = GetFlag(thread, regexp, RegExpParser::FLAG_UTF16, isFastPath);
642 SetLastIndex(thread, regexp, JSTaggedValue(0), isFastPath);
658 uint32_t lastIndex = static_cast<uint32_t>(GetLastIndex(thread, regexp, isFastPath));
660 result.Update(RegExpBuiltinExecWithoutResult(thread, regexp, string, isFastPath, lastIndex, false));
665 lastIndex = static_cast<uint32_t>(GetLastIndex(thread, regexp, isFastPath));
668 RegExpExecResultCache::AddResultInCache(thread, cacheTable, regexp, string,
674 RegExpExecResultCache::AddResultInCache(thread, cacheTable, regexp, string,
687 result.Update(RegExpExec(thread, regexp, string, useCache));
721 int64_t lastIndex = GetLastIndex(thread, regexp, isFastPath);
726 SetLastIndex(thread, regexp, nextIndex, isFastPath);
757 JSTaggedValue BuiltinsRegExp::RegExpMatchAll(JSThread *thread, const JSHandle<JSTaggedValue> regexp,
764 JSHandle<JSRegExp> jsRegExp = JSHandle<JSRegExp>::Cast(regexp);
778 JSHandle<JSObject> objHandle(regexp);
785 JSHandle<JSTaggedValue> getFlags(JSObject::GetProperty(thread, regexp, flagsString).GetValue());
794 runtimeInfo->SetCallArg(regexp.GetTaggedValue(), flagsStrHandle.GetTaggedValue());
801 JSHandle<JSTaggedValue> getLastIndex(JSObject::GetProperty(thread, regexp, lastIndexString).GetValue());
829 JSTaggedValue BuiltinsRegExp::RegExpReplaceFast(JSThread *thread, JSHandle<JSTaggedValue> regexp,
832 ASSERT(regexp->IsJSRegExp());
834 JSHandle<JSRegExp> regexpHandle(regexp);
837 JSTaggedValue bufferData = JSRegExp::Cast(regexp->GetTaggedObject())->GetByteCodeBuffer();
846 GetLastIndex(thread, regexp, lastIndex);
857 RegExpExecResultCache::REPLACE_TYPE, regexp,
866 MatchAndReplace(thread, regexp, inputString, flags,
870 RegExpExecResultCache::AddResultInCache(thread, cacheTable, regexp, tagInputString,
878 JSTaggedValue BuiltinsRegExp::GetLastIndex(JSThread *thread, JSHandle<JSTaggedValue> regexp,
881 JSTaggedValue bufferData = JSRegExp::Cast(regexp->GetTaggedObject())->GetByteCodeBuffer();
890 ObjectFastOperator::FastGetPropertyByValue(thread, regexp.GetTaggedValue(),
920 JSTaggedValue BuiltinsRegExp::MatchAndReplace(JSThread *thread, JSHandle<JSTaggedValue> regexp,
936 bool matchResult = RegExpExecInternal(thread, regexp, inputString, lastIndex);
940 ObjectFastOperator::FastSetPropertyByValue(thread, regexp.GetTaggedValue(),
957 ObjectFastOperator::FastSetPropertyByValue(thread, regexp.GetTaggedValue(),
1012 // Add cache for regexp replace
1362 const JSHandle<JSTaggedValue> regexp,
1365 bool isFastPath = IsFastRegExp(thread, regexp);
1367 return RegExpSearchFast(thread, regexp, string);
1371 JSHandle<JSTaggedValue> previousLastIndex = JSObject::GetProperty(thread, regexp, lastIndexString).GetValue();
1377 JSObject::SetProperty(thread, regexp, lastIndexString, value, true);
1381 JSHandle<JSTaggedValue> result(thread, RegExpExec(thread, regexp, string, false));
1384 JSHandle<JSTaggedValue> currentLastIndex = JSObject::GetProperty(thread, regexp, lastIndexString).GetValue();
1389 JSObject::SetProperty(thread, regexp, lastIndexString, previousLastIndex, true);
1402 const JSHandle<JSTaggedValue> regexp,
1409 RegExpExecResultCache::SEARCH_TYPE, regexp,
1415 bool matchResult = RegExpExecInternal(thread, regexp, stringHandle, 0);
1417 RegExpExecResultCache::AddResultInCache(thread, cacheTable, regexp, string,
1425 RegExpExecResultCache::AddResultInCache(thread, cacheTable, regexp, string,
1432 JSTaggedValue BuiltinsRegExp::RegExpSplit(JSThread *thread, const JSHandle<JSTaggedValue> regexp,
1440 return RegExpSplitFast(thread, regexp, jsString, MAX_SPLIT_LIMIT, useCache);
1444 return RegExpSplitFast(thread, regexp, jsString, static_cast<uint32_t>(lim), useCache);
1451 JSHandle<JSObject> objHandle(regexp);
1459 JSHandle<JSTaggedValue> taggedFlags = JSObject::GetProperty(thread, regexp, flagsString).GetValue();
1491 runtimeInfo->SetCallArg(regexp.GetTaggedValue(), newFlagsHandle.GetTaggedValue());
1659 JSTaggedValue BuiltinsRegExp::RegExpSplitFast(JSThread *thread, const JSHandle<JSTaggedValue> regexp,
1669 RegExpExecResultCache::SPLIT_TYPE, regexp,
1679 bool matchResult = RegExpExecInternal(thread, regexp, string, 0); // 0: lastIndex
1683 RegExpExecResultCache::AddResultInCache(thread, cacheTable, regexp, jsString,
1692 RegExpExecResultCache::AddResultInCache(thread, cacheTable, regexp, jsString,
1698 bool isUnicode = GetOriginalFlag(thread, regexp, RegExpParser::FLAG_UTF16);
1699 bool isSticky = GetOriginalFlag(thread, regexp, RegExpParser::FLAG_STICKY);
1710 bool matchResult = RegExpExecInternal(thread, regexp, string, nextMatchFrom);
1737 RegExpExecResultCache::AddResultInCache(thread, cacheTable, regexp, jsString,
1766 RegExpExecResultCache::AddResultInCache(thread, cacheTable, regexp, jsString,
1787 RegExpExecResultCache::AddResultInCache(thread, cacheTable, regexp, jsString,
1794 bool BuiltinsRegExp::RegExpExecInternal(JSThread *thread, const JSHandle<JSTaggedValue> regexp,
1809 bool isSuccess = Matcher(thread, regexp, strBuffer, stringLength, lastIndex, isUtf16);
1819 bool BuiltinsRegExp::Matcher(JSThread *thread, const JSHandle<JSTaggedValue> regexp,
1825 JSTaggedValue bufferData = JSRegExp::Cast(regexp->GetTaggedObject())->GetByteCodeBuffer();
1975 JSTaggedValue BuiltinsRegExp::RegExpBuiltinExec(JSThread *thread, const JSHandle<JSTaggedValue> regexp,
1979 ASSERT(regexp->IsJSRegExp());
1982 uint32_t lastIndex = static_cast<uint32_t>(GetLastIndex(thread, regexp, isFastPath));
1988 RegExpExecResultCache::EXEC_TYPE, regexp,
1994 JSTaggedValue result = RegExpBuiltinExecWithoutResult(thread, regexp, inputStr, isFastPath, lastIndex, useCache);
2040 JSHandle<JSRegExp> regexpObj(regexp);
2099 bool hasIndices = GetOriginalFlag(thread, regexp, RegExpParser::FLAG_HASINDICES);
2112 bool global = GetOriginalFlag(thread, regexp, RegExpParser::FLAG_GLOBAL);
2113 bool sticky = GetOriginalFlag(thread, regexp, RegExpParser::FLAG_STICKY);
2117 RegExpExecResultCache::AddResultInCache(thread, cacheTable, regexp, inputStr,
2125 JSTaggedValue BuiltinsRegExp::RegExpBuiltinExecWithoutResult(JSThread *thread, const JSHandle<JSTaggedValue> regexp,
2130 bool global = GetOriginalFlag(thread, regexp, RegExpParser::FLAG_GLOBAL);
2131 bool sticky = GetOriginalFlag(thread, regexp, RegExpParser::FLAG_STICKY);
2136 SetLastIndex(thread, regexp, JSTaggedValue(0), isFastPath);
2145 bool matchResult = RegExpExecInternal(thread, regexp, inputString, lastIndex);
2150 SetLastIndex(thread, regexp, JSTaggedValue(0), isFastPath);
2155 RegExpExecResultCache::AddResultInCache(thread, cacheTable, regexp, inputStr,
2165 SetLastIndex(thread, regexp, endIndex, isFastPath);
2171 JSTaggedValue BuiltinsRegExp::RegExpExec(JSThread *thread, const JSHandle<JSTaggedValue> ®exp,
2177 ASSERT(regexp->IsECMAObject());
2185 JSTaggedValue execVal = ObjectFastOperator::FastGetPropertyByValue(thread, regexp.GetTaggedValue(),
2195 EcmaRuntimeCallInfo *info = EcmaInterpreter::NewRuntimeCallInfo(thread, exec, regexp, undefined, 1);
2208 if (!regexp->IsJSRegExp()) {
2213 return RegExpBuiltinExec(thread, regexp, inputString, false, useCache, isIntermediateResult);
2376 JSHandle<JSRegExp> regexp(thread, JSRegExp::Cast(obj->GetTaggedObject()));
2378 regexp->SetOriginalSource(thread, patternStrHandle.GetTaggedValue());
2380 regexp->SetOriginalFlags(thread, JSTaggedValue(flagsBits));
2387 regexp->SetGroupName(thread, taggedArray);
2393 factory->NewJSRegExpByteCodeData(regexp, buffer, bufferSize);
2394 regExpParserCache->SetCache(*patternStrHandle, flagsBits, regexp->GetByteCodeBuffer(), bufferSize, groupName);
2396 regexp->SetByteCodeBuffer(thread, getCache.first);
2397 regexp->SetLength(static_cast<uint32_t>(getCache.second));
2484 const JSHandle<JSTaggedValue> regexp,
2488 JSHandle<JSRegExp> regexpObj(regexp);
2547 BuiltinsRegExp::SetLastIndex(thread, regexp, Get(index + LAST_INDEX_INDEX), true);
2558 const JSHandle<JSTaggedValue> regexp,
2564 JSHandle<JSRegExp> regexpObj(regexp);
2794 bool BuiltinsRegExp::GetFlag(JSThread *thread, const JSHandle<JSTaggedValue> regexp, uint32_t flag, bool isFastPath)
2797 uint8_t flagsBits = static_cast<uint8_t>(JSHandle<JSRegExp>::Cast(regexp)->GetOriginalFlags().GetInt());
2826 ObjectFastOperator::FastGetPropertyByValue(thread, regexp.GetTaggedValue(), flagStr.GetTaggedValue());
2832 bool BuiltinsRegExp::GetOriginalFlag(JSThread *thread, const JSHandle<JSTaggedValue> regexp, uint32_t flag)
2834 return GetFlag(thread, regexp, flag, true);
2837 void BuiltinsRegExp::SetLastIndex(JSThread *thread, const JSHandle<JSTaggedValue> regexp,
2841 JSHandle<JSObject>::Cast(regexp)->SetPropertyInlinedPropsWithRep(thread, LAST_INDEX_OFFSET, lastIndex);
2844 ObjectFastOperator::FastSetPropertyByValue(thread, regexp.GetTaggedValue(),
2848 int64_t BuiltinsRegExp::GetLastIndex(JSThread *thread, const JSHandle<JSTaggedValue> regexp, bool isFastPath)
2851 return JSHandle<JSObject>::Cast(regexp)->GetPropertyInlinedProps(LAST_INDEX_OFFSET).GetInt();
2854 thread, regexp.GetTaggedValue(), thread->GlobalConstants()->GetHandledLastIndexString().GetTaggedValue()));