mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:57:35 +00:00
LibJS: Remove ECMAScriptFlags value from JS_ENUMERATE_REGEXP_FLAGS
All regex flags supported by LibJS currently correspond to a LibRegex option, but this is not the case for the RegExp.prototype.hasIndices proposal, which is handled entirely in RegExpBuiltinExec. Remove the flag mapping to prepare for this. This incurs a bit of an optimization loss in the flag getters, as we now do a substring search, but we can revisit the getter implementation if it becomes an issue.
This commit is contained in:
parent
6cd966c1e1
commit
e801cc7afd
2 changed files with 16 additions and 16 deletions
|
@ -109,12 +109,12 @@
|
||||||
__JS_ENUMERATE(toStringTag, to_string_tag)
|
__JS_ENUMERATE(toStringTag, to_string_tag)
|
||||||
|
|
||||||
#define JS_ENUMERATE_REGEXP_FLAGS \
|
#define JS_ENUMERATE_REGEXP_FLAGS \
|
||||||
__JS_ENUMERATE(global, global, g, Global) \
|
__JS_ENUMERATE(global, global, g) \
|
||||||
__JS_ENUMERATE(ignoreCase, ignore_case, i, Insensitive) \
|
__JS_ENUMERATE(ignoreCase, ignore_case, i) \
|
||||||
__JS_ENUMERATE(multiline, multiline, m, Multiline) \
|
__JS_ENUMERATE(multiline, multiline, m) \
|
||||||
__JS_ENUMERATE(dotAll, dot_all, s, SingleLine) \
|
__JS_ENUMERATE(dotAll, dot_all, s) \
|
||||||
__JS_ENUMERATE(unicode, unicode, u, Unicode) \
|
__JS_ENUMERATE(unicode, unicode, u) \
|
||||||
__JS_ENUMERATE(sticky, sticky, y, Sticky)
|
__JS_ENUMERATE(sticky, sticky, y)
|
||||||
|
|
||||||
namespace JS {
|
namespace JS {
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ void RegExpPrototype::initialize(GlobalObject& global_object)
|
||||||
define_native_accessor(vm.names.flags, flags, {}, Attribute::Configurable);
|
define_native_accessor(vm.names.flags, flags, {}, Attribute::Configurable);
|
||||||
define_native_accessor(vm.names.source, source, {}, Attribute::Configurable);
|
define_native_accessor(vm.names.source, source, {}, Attribute::Configurable);
|
||||||
|
|
||||||
#define __JS_ENUMERATE(flagName, flag_name, flag_char, ECMAScriptFlagName) \
|
#define __JS_ENUMERATE(flagName, flag_name, flag_char) \
|
||||||
define_native_accessor(vm.names.flagName, flag_name, {}, Attribute::Configurable);
|
define_native_accessor(vm.names.flagName, flag_name, {}, Attribute::Configurable);
|
||||||
JS_ENUMERATE_REGEXP_FLAGS
|
JS_ENUMERATE_REGEXP_FLAGS
|
||||||
#undef __JS_ENUMERATE
|
#undef __JS_ENUMERATE
|
||||||
|
@ -230,7 +230,7 @@ static Value regexp_exec(GlobalObject& global_object, Object& regexp_object, Str
|
||||||
// 22.2.5.9 get RegExp.prototype.multiline, https://tc39.es/ecma262/#sec-get-regexp.prototype.multiline
|
// 22.2.5.9 get RegExp.prototype.multiline, https://tc39.es/ecma262/#sec-get-regexp.prototype.multiline
|
||||||
// 22.2.5.14 get RegExp.prototype.sticky, https://tc39.es/ecma262/#sec-get-regexp.prototype.sticky
|
// 22.2.5.14 get RegExp.prototype.sticky, https://tc39.es/ecma262/#sec-get-regexp.prototype.sticky
|
||||||
// 22.2.5.17 get RegExp.prototype.unicode, https://tc39.es/ecma262/#sec-get-regexp.prototype.unicode
|
// 22.2.5.17 get RegExp.prototype.unicode, https://tc39.es/ecma262/#sec-get-regexp.prototype.unicode
|
||||||
#define __JS_ENUMERATE(flagName, flag_name, flag_char, ECMAScriptFlagName) \
|
#define __JS_ENUMERATE(flagName, flag_name, flag_char) \
|
||||||
JS_DEFINE_NATIVE_GETTER(RegExpPrototype::flag_name) \
|
JS_DEFINE_NATIVE_GETTER(RegExpPrototype::flag_name) \
|
||||||
{ \
|
{ \
|
||||||
auto* regexp_object = this_object_from(vm, global_object); \
|
auto* regexp_object = this_object_from(vm, global_object); \
|
||||||
|
@ -244,8 +244,8 @@ static Value regexp_exec(GlobalObject& global_object, Object& regexp_object, Str
|
||||||
return {}; \
|
return {}; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
auto flags = static_cast<RegExpObject*>(regexp_object)->declared_options(); \
|
auto const& flags = static_cast<RegExpObject*>(regexp_object)->flags(); \
|
||||||
return Value(flags.has_flag_set(ECMAScriptFlags::ECMAScriptFlagName)); \
|
return Value(flags.contains(#flag_char##sv)); \
|
||||||
}
|
}
|
||||||
JS_ENUMERATE_REGEXP_FLAGS
|
JS_ENUMERATE_REGEXP_FLAGS
|
||||||
#undef __JS_ENUMERATE
|
#undef __JS_ENUMERATE
|
||||||
|
@ -259,7 +259,7 @@ JS_DEFINE_NATIVE_GETTER(RegExpPrototype::flags)
|
||||||
|
|
||||||
StringBuilder builder(8);
|
StringBuilder builder(8);
|
||||||
|
|
||||||
#define __JS_ENUMERATE(flagName, flag_name, flag_char, ECMAScriptFlagName) \
|
#define __JS_ENUMERATE(flagName, flag_name, flag_char) \
|
||||||
auto flag_##flag_name = this_object->get(vm.names.flagName); \
|
auto flag_##flag_name = this_object->get(vm.names.flagName); \
|
||||||
if (vm.exception()) \
|
if (vm.exception()) \
|
||||||
return {}; \
|
return {}; \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue