diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-10-23 04:03:02 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-10-23 18:01:51 +0200 |
commit | 2ab089fa218bcafc70d703694aae8fb25d8aa324 (patch) | |
tree | 353d6c7cc1e175f529a034a4f610774bd196ddf2 /Userland | |
parent | 063ce946b7339fe249f6ff1455cc2ad47141acb6 (diff) | |
download | serenity-2ab089fa218bcafc70d703694aae8fb25d8aa324.zip |
LibJS: Convert RegExpStringIteratorPrototype to ThrowCompletionOr
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp | 20 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.h | 2 |
2 files changed, 11 insertions, 11 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp index ef9ffa0915..9181fa2426 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.cpp @@ -23,21 +23,21 @@ void RegExpStringIteratorPrototype::initialize(GlobalObject& global_object) auto& vm = this->vm(); u8 attr = Attribute::Writable | Attribute::Configurable; - define_old_native_function(vm.names.next, next, 0, attr); + define_native_function(vm.names.next, next, 0, attr); // 22.2.7.2.2 %RegExpStringIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-%regexpstringiteratorprototype%-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(global_object.heap(), "RegExp String Iterator"), Attribute::Configurable); } // 22.2.7.2.1 %RegExpStringIteratorPrototype%.next ( ), https://tc39.es/ecma262/#sec-%regexpstringiteratorprototype%.next -JS_DEFINE_OLD_NATIVE_FUNCTION(RegExpStringIteratorPrototype::next) +JS_DEFINE_NATIVE_FUNCTION(RegExpStringIteratorPrototype::next) { // For details, see the 'closure' of: https://tc39.es/ecma262/#sec-createregexpstringiterator - auto* iterator = TRY_OR_DISCARD(typed_this_value(global_object)); + auto* iterator = TRY(typed_this_value(global_object)); if (iterator->done()) return create_iterator_result_object(global_object, js_undefined(), true); - auto match = TRY_OR_DISCARD(regexp_exec(global_object, iterator->regexp_object(), iterator->string())); + auto match = TRY(regexp_exec(global_object, iterator->regexp_object(), iterator->string())); if (match.is_null()) { iterator->set_done(); @@ -49,16 +49,16 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(RegExpStringIteratorPrototype::next) return create_iterator_result_object(global_object, match, false); } - auto* match_object = TRY_OR_DISCARD(match.to_object(global_object)); - auto match_string_value = TRY_OR_DISCARD(match_object->get(0)); - auto match_string = TRY_OR_DISCARD(match_string_value.to_string(global_object)); + auto* match_object = TRY(match.to_object(global_object)); + auto match_string_value = TRY(match_object->get(0)); + auto match_string = TRY(match_string_value.to_string(global_object)); if (match_string.is_empty()) { - auto last_index_value = TRY_OR_DISCARD(iterator->regexp_object().get(vm.names.lastIndex)); - auto last_index = TRY_OR_DISCARD(last_index_value.to_length(global_object)); + auto last_index_value = TRY(iterator->regexp_object().get(vm.names.lastIndex)); + auto last_index = TRY(last_index_value.to_length(global_object)); last_index = advance_string_index(iterator->string().view(), last_index, iterator->unicode()); - TRY_OR_DISCARD(iterator->regexp_object().set(vm.names.lastIndex, Value(last_index), Object::ShouldThrowExceptions::Yes)); + TRY(iterator->regexp_object().set(vm.names.lastIndex, Value(last_index), Object::ShouldThrowExceptions::Yes)); } return create_iterator_result_object(global_object, match, false); diff --git a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.h b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.h index e6aa8154d8..17637afb6d 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpStringIteratorPrototype.h @@ -21,7 +21,7 @@ public: virtual void initialize(GlobalObject&) override; private: - JS_DECLARE_OLD_NATIVE_FUNCTION(next); + JS_DECLARE_NATIVE_FUNCTION(next); }; } |