mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibJS: Add spec comments to Value::is_regexp()
This commit is contained in:
parent
b11135cbc2
commit
1fe7984160
Notes:
sideshowbarker
2024-07-17 03:33:27 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/1fe7984160 Pull-request: https://github.com/SerenityOS/serenity/pull/16405 Reviewed-by: https://github.com/davidot ✅
1 changed files with 6 additions and 0 deletions
|
@ -277,13 +277,19 @@ bool Value::is_constructor() const
|
|||
// 7.2.8 IsRegExp ( argument ), https://tc39.es/ecma262/#sec-isregexp
|
||||
ThrowCompletionOr<bool> Value::is_regexp(VM& vm) const
|
||||
{
|
||||
// 1. If argument is not an Object, return false.
|
||||
if (!is_object())
|
||||
return false;
|
||||
|
||||
// 2. Let matcher be ? Get(argument, @@match).
|
||||
auto matcher = TRY(as_object().get(*vm.well_known_symbol_match()));
|
||||
|
||||
// 3. If matcher is not undefined, return ToBoolean(matcher).
|
||||
if (!matcher.is_undefined())
|
||||
return matcher.to_boolean();
|
||||
|
||||
// 4. If argument has a [[RegExpMatcher]] internal slot, return true.
|
||||
// 5. Return false.
|
||||
return is<RegExpObject>(as_object());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue