From 67566e5017cd1513353d7d5648048327c502ea0d Mon Sep 17 00:00:00 2001 From: Nick Hawke Date: Thu, 26 Oct 2023 23:57:51 -0400 Subject: [PATCH] LibJS: Migrate DeprecatedString to String This changes BasicBlock's constructor and create(). --- Userland/Libraries/LibJS/Bytecode/BasicBlock.cpp | 6 +++--- Userland/Libraries/LibJS/Bytecode/BasicBlock.h | 10 +++++----- Userland/Libraries/LibJS/Bytecode/Generator.cpp | 6 ++++-- Userland/Libraries/LibJS/Bytecode/Generator.h | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Userland/Libraries/LibJS/Bytecode/BasicBlock.cpp b/Userland/Libraries/LibJS/Bytecode/BasicBlock.cpp index 959dfc1b23..71b8214988 100644 --- a/Userland/Libraries/LibJS/Bytecode/BasicBlock.cpp +++ b/Userland/Libraries/LibJS/Bytecode/BasicBlock.cpp @@ -4,18 +4,18 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include namespace JS::Bytecode { -NonnullOwnPtr BasicBlock::create(DeprecatedString name) +NonnullOwnPtr BasicBlock::create(String name) { return adopt_own(*new BasicBlock(move(name))); } -BasicBlock::BasicBlock(DeprecatedString name) +BasicBlock::BasicBlock(String name) : m_name(move(name)) { } diff --git a/Userland/Libraries/LibJS/Bytecode/BasicBlock.h b/Userland/Libraries/LibJS/Bytecode/BasicBlock.h index 3ea5aae1ce..01315758f4 100644 --- a/Userland/Libraries/LibJS/Bytecode/BasicBlock.h +++ b/Userland/Libraries/LibJS/Bytecode/BasicBlock.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include #include @@ -24,7 +24,7 @@ class BasicBlock { AK_MAKE_NONCOPYABLE(BasicBlock); public: - static NonnullOwnPtr create(DeprecatedString name); + static NonnullOwnPtr create(String name); ~BasicBlock(); void dump(Executable const&) const; @@ -38,7 +38,7 @@ public: void terminate(Badge) { m_terminated = true; } bool is_terminated() const { return m_terminated; } - DeprecatedString const& name() const { return m_name; } + String const& name() const { return m_name; } void set_handler(BasicBlock const& handler) { m_handler = &handler; } void set_finalizer(BasicBlock const& finalizer) { m_finalizer = &finalizer; } @@ -47,12 +47,12 @@ public: BasicBlock const* finalizer() const { return m_finalizer; } private: - explicit BasicBlock(DeprecatedString name); + explicit BasicBlock(String name); Vector m_buffer; BasicBlock const* m_handler { nullptr }; BasicBlock const* m_finalizer { nullptr }; - DeprecatedString m_name; + String m_name; bool m_terminated { false }; }; diff --git a/Userland/Libraries/LibJS/Bytecode/Generator.cpp b/Userland/Libraries/LibJS/Bytecode/Generator.cpp index 773bd9ea0d..56735e7f15 100644 --- a/Userland/Libraries/LibJS/Bytecode/Generator.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Generator.cpp @@ -449,7 +449,8 @@ void Generator::generate_scoped_jump(JumpType type) VERIFY(m_current_unwind_context->finalizer().has_value()); m_current_unwind_context = m_current_unwind_context->previous(); auto jump_type_name = type == JumpType::Break ? "break"sv : "continue"sv; - auto& block = make_block(DeprecatedString::formatted("{}.{}", current_block().name(), jump_type_name)); + auto block_name = MUST(String::formatted("{}.{}", current_block().name(), jump_type_name)); + auto& block = make_block(block_name); emit(Label { block }); switch_to_basic_block(block); last_was_finally = true; @@ -485,7 +486,8 @@ void Generator::generate_labelled_jump(JumpType type, DeprecatedFlyString const& VERIFY(m_current_unwind_context->finalizer().has_value()); m_current_unwind_context = m_current_unwind_context->previous(); auto jump_type_name = type == JumpType::Break ? "break"sv : "continue"sv; - auto& block = make_block(DeprecatedString::formatted("{}.{}", current_block().name(), jump_type_name)); + auto block_name = MUST(String::formatted("{}.{}", current_block().name(), jump_type_name)); + auto& block = make_block(block_name); emit(Label { block }); switch_to_basic_block(block); last_was_finally = true; diff --git a/Userland/Libraries/LibJS/Bytecode/Generator.h b/Userland/Libraries/LibJS/Bytecode/Generator.h index 6418f93e86..d549da998d 100644 --- a/Userland/Libraries/LibJS/Bytecode/Generator.h +++ b/Userland/Libraries/LibJS/Bytecode/Generator.h @@ -128,10 +128,10 @@ public: [[nodiscard]] BasicBlock& current_block() { return *m_current_basic_block; } - BasicBlock& make_block(DeprecatedString name = {}) + BasicBlock& make_block(String name = {}) { if (name.is_empty()) - name = DeprecatedString::number(m_next_block++); + name = MUST(String::number(m_next_block++)); auto block = BasicBlock::create(name); if (auto const* context = m_current_unwind_context) { if (context->handler().has_value())