summaryrefslogtreecommitdiffstats
path: root/js/src/builtin/RegExp.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-11-18 12:20:44 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-11-18 12:20:44 +0100
commitf31b04a303607cd82757e7c4f60bb536658c8a30 (patch)
tree98b720782be5bc8bd77202bb4c1dc69e4927c03e /js/src/builtin/RegExp.cpp
parent36c81a978695ec3ba68af8475422bcab49ef470d (diff)
downloadUXP-f31b04a303607cd82757e7c4f60bb536658c8a30.tar
UXP-f31b04a303607cd82757e7c4f60bb536658c8a30.tar.gz
UXP-f31b04a303607cd82757e7c4f60bb536658c8a30.tar.lz
UXP-f31b04a303607cd82757e7c4f60bb536658c8a30.tar.xz
UXP-f31b04a303607cd82757e7c4f60bb536658c8a30.zip
Issue #1284 - Implement /s (dotAll) for regular expressions.
Resolves #1284.
Diffstat (limited to 'js/src/builtin/RegExp.cpp')
-rw-r--r--js/src/builtin/RegExp.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/js/src/builtin/RegExp.cpp b/js/src/builtin/RegExp.cpp
index 7cf20d23c..93a7f2b79 100644
--- a/js/src/builtin/RegExp.cpp
+++ b/js/src/builtin/RegExp.cpp
@@ -664,6 +664,29 @@ 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)
@@ -759,6 +782,7 @@ 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
};