mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:07:36 +00:00
LibJS: Parse the RegExp.prototype.hasIndices flag
This commit is contained in:
parent
e801cc7afd
commit
d1e06b00e3
6 changed files with 12 additions and 3 deletions
|
@ -188,6 +188,7 @@ namespace JS {
|
|||
P(globalThis) \
|
||||
P(groups) \
|
||||
P(has) \
|
||||
P(hasIndices) \
|
||||
P(hasOwn) \
|
||||
P(hasOwnProperty) \
|
||||
P(hypot) \
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace JS {
|
|||
static Flags options_from(GlobalObject& global_object, const String& flags)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
bool g = false, i = false, m = false, s = false, u = false, y = false;
|
||||
bool d = false, g = false, i = false, m = false, s = false, u = false, y = false;
|
||||
Flags options {
|
||||
// JS regexps are all 'global' by default as per our definition, but the "global" flag enables "stateful".
|
||||
// FIXME: Enable 'BrowserExtended' only if in a browser context.
|
||||
|
@ -26,6 +26,11 @@ static Flags options_from(GlobalObject& global_object, const String& flags)
|
|||
|
||||
for (auto ch : flags) {
|
||||
switch (ch) {
|
||||
case 'd':
|
||||
if (d)
|
||||
vm.throw_exception<SyntaxError>(global_object, ErrorType::RegExpObjectRepeatedFlag, ch);
|
||||
d = true;
|
||||
break;
|
||||
case 'g':
|
||||
if (g)
|
||||
vm.throw_exception<SyntaxError>(global_object, ErrorType::RegExpObjectRepeatedFlag, ch);
|
||||
|
|
|
@ -224,6 +224,7 @@ static Value regexp_exec(GlobalObject& global_object, Object& regexp_object, Str
|
|||
return regexp_builtin_exec(global_object, static_cast<RegExpObject&>(regexp_object), string);
|
||||
}
|
||||
|
||||
// 1.1.4.3 get RegExp.prototype.hasIndices, https://tc39.es/proposal-regexp-match-indices/#sec-get-regexp.prototype.hasIndices
|
||||
// 22.2.5.3 get RegExp.prototype.dotAll, https://tc39.es/ecma262/#sec-get-regexp.prototype.dotAll
|
||||
// 22.2.5.5 get RegExp.prototype.global, https://tc39.es/ecma262/#sec-get-regexp.prototype.global
|
||||
// 22.2.5.6 get RegExp.prototype.ignoreCase, https://tc39.es/ecma262/#sec-get-regexp.prototype.ignorecase
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue