mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-11-01 03:57:30 +09:00
Issue #1284 - Implement /s (dotAll) for regular expressions, v2.
Resolves #1284.
This commit is contained in:
parent
8e5c2bcaaa
commit
8148cf0001
11 changed files with 117 additions and 23 deletions
|
|
@ -178,7 +178,7 @@ CheckPatternSyntax(JSContext* cx, HandleAtom pattern, RegExpFlag flags)
|
|||
CompileOptions options(cx);
|
||||
frontend::TokenStream dummyTokenStream(cx, options, nullptr, 0, nullptr);
|
||||
return irregexp::ParsePatternSyntax(dummyTokenStream, cx->tempLifoAlloc(), pattern,
|
||||
flags & UnicodeFlag);
|
||||
flags & UnicodeFlag, flags & DotAllFlag);
|
||||
}
|
||||
|
||||
enum RegExpSharedUse {
|
||||
|
|
@ -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
|
||||
};
|
||||
|
||||
|
|
@ -1642,6 +1666,13 @@ js::RegExpPrototypeOptimizableRaw(JSContext* cx, JSObject* proto)
|
|||
if (unicodeGetter != regexp_unicode)
|
||||
return false;
|
||||
|
||||
JSNative dotAllGetter;
|
||||
if (!GetOwnNativeGetterPure(cx, proto, NameToId(cx->names().dotall), &dotAllGetter))
|
||||
return false;
|
||||
|
||||
if (dotAllGetter != regexp_dotall)
|
||||
return false;
|
||||
|
||||
// Check if @@match, @@search, and exec are own data properties,
|
||||
// those values should be tested in selfhosted JS.
|
||||
bool has = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue