haikuwebkit/LayoutTests/js/regexp-named-capture-groups...

11 lines
265 B
HTML
Raw Permalink Normal View History

Add support for RegExp named capture groups https://bugs.webkit.org/show_bug.cgi?id=176435 Reviewed by Filip Pizlo. Source/JavaScriptCore: Added parsing for both naming a captured parenthesis as well and using a named group in a back reference. Also added support for using named groups with String.prototype.replace(). This patch does not throw Syntax Errors as described in the current spec text for the two cases of malformed back references in String.prototype.replace() as I believe that it is inconsistent with the current semantics for handling of other malformed replacement tokens. I filed an issue for the requested change to the proposed spec and also filed a FIXME bug https://bugs.webkit.org/show_bug.cgi?id=176434. This patch does not implement strength reduction in the optimizing JITs for named capture groups. Filed https://bugs.webkit.org/show_bug.cgi?id=176464. * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): * dfg/DFGStrengthReductionPhase.cpp: (JSC::DFG::StrengthReductionPhase::handleNode): * runtime/CommonIdentifiers.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::haveABadTime): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::regExpMatchesArrayWithGroupsStructure const): * runtime/RegExp.cpp: (JSC::RegExp::finishCreation): * runtime/RegExp.h: * runtime/RegExpMatchesArray.cpp: (JSC::createStructureImpl): (JSC::createRegExpMatchesArrayWithGroupsStructure): (JSC::createRegExpMatchesArrayWithGroupsSlowPutStructure): * runtime/RegExpMatchesArray.h: (JSC::createRegExpMatchesArray): * runtime/StringPrototype.cpp: (JSC::substituteBackreferencesSlow): (JSC::replaceUsingRegExpSearch): * yarr/YarrParser.h: (JSC::Yarr::Parser::CharacterClassParserDelegate::atomNamedBackReference): (JSC::Yarr::Parser::parseEscape): (JSC::Yarr::Parser::parseParenthesesBegin): (JSC::Yarr::Parser::tryConsumeUnicodeEscape): (JSC::Yarr::Parser::tryConsumeIdentifierCharacter): (JSC::Yarr::Parser::isIdentifierStart): (JSC::Yarr::Parser::isIdentifierPart): (JSC::Yarr::Parser::tryConsumeGroupName): * yarr/YarrPattern.cpp: (JSC::Yarr::YarrPatternConstructor::atomParenthesesSubpatternBegin): (JSC::Yarr::YarrPatternConstructor::atomNamedBackReference): (JSC::Yarr::YarrPattern::errorMessage): * yarr/YarrPattern.h: (JSC::Yarr::YarrPattern::reset): * yarr/YarrSyntaxChecker.cpp: (JSC::Yarr::SyntaxChecker::atomParenthesesSubpatternBegin): (JSC::Yarr::SyntaxChecker::atomNamedBackReference): Source/WebCore: Implemented stub routines to support named capture groups. These are no-ops just like for number capture group. No new tests as this is covered by existing tests. * contentextensions/URLFilterParser.cpp: (WebCore::ContentExtensions::PatternParser::atomNamedBackReference): (WebCore::ContentExtensions::PatternParser::atomParenthesesSubpatternBegin): LayoutTests: New regression tests. * js/regexp-named-capture-groups-expected.txt: Added. * js/regexp-named-capture-groups.html: Added. * js/script-tests/regexp-named-capture-groups.js: Added. Canonical link: https://commits.webkit.org/193122@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221769 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-09-07 23:13:38 +00:00
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<script src="script-tests/regexp-named-capture-groups.js"></script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>