From 185a9a750878ed1d9705fbd162dbfe9bf2e4ea0c Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Tue, 26 Nov 2019 13:37:09 +0100 Subject: Issue #1302 - Add self-hosted implementation for string regex .matchAll This resolves #1302. --- js/src/vm/SelfHosting.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'js/src/vm/SelfHosting.cpp') diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp index 8334104652..ffd707b147 100644 --- a/js/src/vm/SelfHosting.cpp +++ b/js/src/vm/SelfHosting.cpp @@ -856,6 +856,24 @@ intrinsic_NewStringIterator(JSContext* cx, unsigned argc, Value* vp) return true; } +static bool +intrinsic_NewRegExpStringIterator(JSContext* cx, unsigned argc, Value* vp) +{ + CallArgs args = CallArgsFromVp(argc, vp); + MOZ_ASSERT(args.length() == 0); + + RootedObject proto(cx, GlobalObject::getOrCreateRegExpStringIteratorPrototype(cx, cx->global())); + if (!proto) + return false; + + JSObject* obj = NewObjectWithGivenProto(cx, &RegExpStringIteratorObject::class_, proto); + if (!obj) + return false; + + args.rval().setObject(*obj); + return true; +} + static bool intrinsic_SetCanonicalName(JSContext* cx, unsigned argc, Value* vp) { @@ -2288,6 +2306,8 @@ static const JSFunctionSpec intrinsic_functions[] = { JS_INLINABLE_FN("GuardToStringIterator", intrinsic_GuardToBuiltin, 1,0, IntrinsicGuardToStringIterator), + JS_FN("GuardToRegExpStringIterator", + intrinsic_GuardToBuiltin, 1,0), JS_FN("_CreateMapIterationResultPair", intrinsic_CreateMapIterationResultPair, 0, 0), JS_INLINABLE_FN("_GetNextMapEntryForIterator", intrinsic_GetNextMapEntryForIterator, 2,0, @@ -2305,6 +2325,9 @@ static const JSFunctionSpec intrinsic_functions[] = { JS_FN("NewStringIterator", intrinsic_NewStringIterator, 0,0), JS_FN("CallStringIteratorMethodIfWrapped", CallNonGenericSelfhostedMethod>, 2,0), + JS_FN("NewRegExpStringIterator", intrinsic_NewRegExpStringIterator, 0,0), + JS_FN("CallRegExpStringIteratorMethodIfWrapped", + CallNonGenericSelfhostedMethod>, 2,0), JS_FN("IsStarGeneratorObject", intrinsic_IsInstanceOfBuiltin, 1,0), -- cgit v1.2.3