diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-11-18 13:34:18 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-11-18 13:34:18 +0100 |
commit | bd529c60c67af685de029e2408da3d2bc6980291 (patch) | |
tree | 4410771482d5ac6239a9952cb5d15a06cd294ff0 /js/src | |
parent | f31b04a303607cd82757e7c4f60bb536658c8a30 (diff) | |
download | UXP-bd529c60c67af685de029e2408da3d2bc6980291.tar UXP-bd529c60c67af685de029e2408da3d2bc6980291.tar.gz UXP-bd529c60c67af685de029e2408da3d2bc6980291.tar.lz UXP-bd529c60c67af685de029e2408da3d2bc6980291.tar.xz UXP-bd529c60c67af685de029e2408da3d2bc6980291.zip |
Revert "Issue #1284 - Implement /s (dotAll) for regular expressions."
This reverts commit f31b04a303607cd82757e7c4f60bb536658c8a30.
Diffstat (limited to 'js/src')
-rw-r--r-- | js/src/builtin/RegExp.cpp | 24 | ||||
-rw-r--r-- | js/src/builtin/RegExp.h | 2 | ||||
-rw-r--r-- | js/src/builtin/RegExp.js | 5 | ||||
-rw-r--r-- | js/src/builtin/SelfHostingDefines.h | 1 | ||||
-rw-r--r-- | js/src/frontend/TokenStream.cpp | 2 | ||||
-rw-r--r-- | js/src/irregexp/RegExpParser.cpp | 52 | ||||
-rw-r--r-- | js/src/irregexp/RegExpParser.h | 1 | ||||
-rw-r--r-- | js/src/vm/RegExpObject.h | 7 |
8 files changed, 6 insertions, 88 deletions
diff --git a/js/src/builtin/RegExp.cpp b/js/src/builtin/RegExp.cpp index 93a7f2b79..7cf20d23c 100644 --- a/js/src/builtin/RegExp.cpp +++ b/js/src/builtin/RegExp.cpp @@ -664,29 +664,6 @@ js::regexp_multiline(JSContext* cx, unsigned argc, JS::Value* vp) return CallNonGenericMethod<IsRegExpInstanceOrPrototype, regexp_multiline_impl>(cx, args); } -// ES 2018 dotAll -MOZ_ALWAYS_INLINE bool -regexp_dotall_impl(JSContext* cx, const CallArgs& args) -{ - MOZ_ASSERT(IsRegExpInstanceOrPrototype(args.thisv())); - - if (!IsRegExpObject(args.thisv())) { - args.rval().setUndefined(); - return true; - } - - Rooted<RegExpObject*> reObj(cx, &args.thisv().toObject().as<RegExpObject>()); - args.rval().setBoolean(reObj->dotall()); - return true; -} - -bool -js::regexp_dotall(JSContext* cx, unsigned argc, JS::Value* vp) -{ - CallArgs args = CallArgsFromVp(argc, vp); - return CallNonGenericMethod<IsRegExpInstanceOrPrototype, regexp_dotall_impl>(cx, args); -} - // ES 2017 draft rev32 21.2.5.10. MOZ_ALWAYS_INLINE bool regexp_source_impl(JSContext* cx, const CallArgs& args) @@ -782,7 +759,6 @@ const JSPropertySpec js::regexp_properties[] = { JS_PSG("source", regexp_source, 0), JS_PSG("sticky", regexp_sticky, 0), JS_PSG("unicode", regexp_unicode, 0), - JS_PSG("dotall", regexp_dotall, 0), JS_PS_END }; diff --git a/js/src/builtin/RegExp.h b/js/src/builtin/RegExp.h index f808f5146..4e0ff6948 100644 --- a/js/src/builtin/RegExp.h +++ b/js/src/builtin/RegExp.h @@ -153,8 +153,6 @@ extern MOZ_MUST_USE bool regexp_sticky(JSContext* cx, unsigned argc, JS::Value* vp); extern MOZ_MUST_USE bool regexp_unicode(JSContext* cx, unsigned argc, JS::Value* vp); -extern MOZ_MUST_USE bool -regexp_dotall(JSContext* cx, unsigned argc, JS::Value* vp); } /* namespace js */ diff --git a/js/src/builtin/RegExp.js b/js/src/builtin/RegExp.js index 1a2276594..0b849292c 100644 --- a/js/src/builtin/RegExp.js +++ b/js/src/builtin/RegExp.js @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // ES6 draft rev34 (2015/02/20) 21.2.5.3 get RegExp.prototype.flags -// Updated for ES2018 /s (dotAll) function RegExpFlagsGetter() { // Steps 1-2. var R = this; @@ -32,10 +31,6 @@ function RegExpFlagsGetter() { // Steps 16-18. if (R.sticky) result += "y"; - - // ES2018 - if (R.dotall) - result += "s"; // Step 19. return result; diff --git a/js/src/builtin/SelfHostingDefines.h b/js/src/builtin/SelfHostingDefines.h index 6512810ca..d676270a1 100644 --- a/js/src/builtin/SelfHostingDefines.h +++ b/js/src/builtin/SelfHostingDefines.h @@ -90,7 +90,6 @@ #define REGEXP_MULTILINE_FLAG 0x04 #define REGEXP_STICKY_FLAG 0x08 #define REGEXP_UNICODE_FLAG 0x10 -#define REGEXP_DOTALL_FLAG 0x20 #define MODULE_OBJECT_ENVIRONMENT_SLOT 2 diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp index e07f8df8a..b8623d545 100644 --- a/js/src/frontend/TokenStream.cpp +++ b/js/src/frontend/TokenStream.cpp @@ -1843,8 +1843,6 @@ TokenStream::getTokenInternal(TokenKind* ttp, Modifier modifier) reflags = RegExpFlag(reflags | StickyFlag); else if (c == 'u' && !(reflags & UnicodeFlag)) reflags = RegExpFlag(reflags | UnicodeFlag); - else if (c == 's' && !(reflags & DotAllFlag)) - reflags = RegExpFlag(reflags | DotAllFlag); else break; getChar(); diff --git a/js/src/irregexp/RegExpParser.cpp b/js/src/irregexp/RegExpParser.cpp index 28abdb0b4..9ef9fe3e2 100644 --- a/js/src/irregexp/RegExpParser.cpp +++ b/js/src/irregexp/RegExpParser.cpp @@ -1384,7 +1384,7 @@ UnicodeEverythingAtom(LifoAlloc* alloc) { RegExpBuilder* builder = alloc->newInfallible<RegExpBuilder>(alloc); - // Everything except \x0a, \x0d, \u2028 and \u2029 + // everything except \x0a, \x0d, \u2028 and \u2029 CharacterRangeVector* ranges = alloc->newInfallible<CharacterRangeVector>(*alloc); ranges->append(CharacterRange::Range(0x0, 0x09)); @@ -1414,38 +1414,6 @@ UnicodeEverythingAtom(LifoAlloc* alloc) return builder->ToRegExp(); } -static inline RegExpTree* -UnicodeDotAllAtom(LifoAlloc* alloc) -{ - RegExpBuilder* builder = alloc->newInfallible<RegExpBuilder>(alloc); - - // Full range excluding surrogates because /s was specified - - CharacterRangeVector* ranges = alloc->newInfallible<CharacterRangeVector>(*alloc); - ranges->append(CharacterRange::Range(0x0, unicode::LeadSurrogateMin - 1)); - ranges->append(CharacterRange::Range(unicode::TrailSurrogateMax + 1, unicode::UTF16Max)); - builder->AddAtom(alloc->newInfallible<RegExpCharacterClass>(ranges, false)); - - builder->NewAlternative(); - - builder->AddAtom(RangeAtom(alloc, unicode::LeadSurrogateMin, unicode::LeadSurrogateMax)); - builder->AddAtom(NegativeLookahead(alloc, unicode::TrailSurrogateMin, - unicode::TrailSurrogateMax)); - - builder->NewAlternative(); - - builder->AddAssertion(alloc->newInfallible<RegExpAssertion>( - RegExpAssertion::NOT_AFTER_LEAD_SURROGATE)); - builder->AddAtom(RangeAtom(alloc, unicode::TrailSurrogateMin, unicode::TrailSurrogateMax)); - - builder->NewAlternative(); - - builder->AddAtom(RangeAtom(alloc, unicode::LeadSurrogateMin, unicode::LeadSurrogateMax)); - builder->AddAtom(RangeAtom(alloc, unicode::TrailSurrogateMin, unicode::TrailSurrogateMax)); - - return builder->ToRegExp(); -} - RegExpTree* UnicodeCharacterClassEscapeAtom(LifoAlloc* alloc, char16_t char_class, bool ignore_case) { @@ -1573,25 +1541,13 @@ RegExpParser<CharT>::ParseDisjunction() } case '.': { Advance(); - + // everything except \x0a, \x0d, \u2028 and \u2029 if (unicode_) { - if (dotall_) { - // Everything - builder->AddAtom(UnicodeDotAllAtom(alloc)); - } else { - // Everything except \x0a, \x0d, \u2028 and \u2029 - builder->AddAtom(UnicodeEverythingAtom(alloc)); - } + builder->AddAtom(UnicodeEverythingAtom(alloc)); break; } CharacterRangeVector* ranges = alloc->newInfallible<CharacterRangeVector>(*alloc); - if (dotall_) { - // Everything - CharacterRange::AddClassEscape(alloc, '*', ranges); - } else { - // Everything except \x0a, \x0d, \u2028 and \u2029 - CharacterRange::AddClassEscape(alloc, '.', ranges); - } + CharacterRange::AddClassEscape(alloc, '.', ranges); RegExpTree* atom = alloc->newInfallible<RegExpCharacterClass>(ranges, false); builder->AddAtom(atom); break; diff --git a/js/src/irregexp/RegExpParser.h b/js/src/irregexp/RegExpParser.h index 36c24cd7c..2f02625b5 100644 --- a/js/src/irregexp/RegExpParser.h +++ b/js/src/irregexp/RegExpParser.h @@ -313,7 +313,6 @@ class RegExpParser bool multiline_; bool unicode_; bool ignore_case_; - bool dotall_; bool simple_; bool contains_anchor_; bool is_scanned_for_captures_; diff --git a/js/src/vm/RegExpObject.h b/js/src/vm/RegExpObject.h index 4548521df..f1ea101ed 100644 --- a/js/src/vm/RegExpObject.h +++ b/js/src/vm/RegExpObject.h @@ -53,18 +53,16 @@ enum RegExpFlag MultilineFlag = 0x04, StickyFlag = 0x08, UnicodeFlag = 0x10, - DotAllFlag = 0x20, NoFlags = 0x00, - AllFlags = 0x3f + AllFlags = 0x1f }; static_assert(IgnoreCaseFlag == REGEXP_IGNORECASE_FLAG && GlobalFlag == REGEXP_GLOBAL_FLAG && MultilineFlag == REGEXP_MULTILINE_FLAG && StickyFlag == REGEXP_STICKY_FLAG && - UnicodeFlag == REGEXP_UNICODE_FLAG && - DotAllFlag == REGEXP_DOTALL_FLAG, + UnicodeFlag == REGEXP_UNICODE_FLAG, "Flag values should be in sync with self-hosted JS"); enum RegExpRunStatus @@ -482,7 +480,6 @@ class RegExpObject : public NativeObject bool multiline() const { return getFlags() & MultilineFlag; } bool sticky() const { return getFlags() & StickyFlag; } bool unicode() const { return getFlags() & UnicodeFlag; } - bool dotall() const { return getFlags() & DotAllFlag; } static bool isOriginalFlagGetter(JSNative native, RegExpFlag* mask); |