1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:47:45 +00:00

AK+Everywhere: Rename FlyString to DeprecatedFlyString

DeprecatedFlyString relies heavily on DeprecatedString's StringImpl, so
let's rename it to A) match the name of DeprecatedString, B) write a new
FlyString class that is tied to String.
This commit is contained in:
Timothy Flynn 2023-01-08 19:23:00 -05:00 committed by Linus Groh
parent 2eacc7aec1
commit f3db548a3d
316 changed files with 1177 additions and 1177 deletions

View file

@ -109,7 +109,7 @@ Bytecode::CodeGenerationErrorOr<void> ScopeNode::generate_bytecode(Bytecode::Gen
Vector<FunctionDeclaration const&> functions_to_initialize;
// 7. Let declaredFunctionNames be a new empty List.
HashTable<FlyString> declared_function_names;
HashTable<DeprecatedFlyString> declared_function_names;
// 8. For each element d of varDeclarations, in reverse List order, do
(void)for_each_var_function_declaration_in_reverse_order([&](FunctionDeclaration const& function) -> ThrowCompletionOr<void> {
@ -135,7 +135,7 @@ Bytecode::CodeGenerationErrorOr<void> ScopeNode::generate_bytecode(Bytecode::Gen
});
// 9. Let declaredVarNames be a new empty List.
HashTable<FlyString> declared_var_names;
HashTable<DeprecatedFlyString> declared_var_names;
// 10. For each element d of varDeclarations, do
(void)for_each_var_scoped_variable_declaration([&](Declaration const& declaration) {
@ -803,7 +803,7 @@ Bytecode::CodeGenerationErrorOr<void> LabelledStatement::generate_bytecode(Bytec
// 14.13.4 Runtime Semantics: LabelledEvaluation, https://tc39.es/ecma262/#sec-runtime-semantics-labelledevaluation
// LabelledStatement : LabelIdentifier : LabelledItem
Bytecode::CodeGenerationErrorOr<void> LabelledStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<FlyString> const& label_set) const
Bytecode::CodeGenerationErrorOr<void> LabelledStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<DeprecatedFlyString> const& label_set) const
{
// Convert the m_labelled_item NNRP to a reference early so we don't have to do it every single time we want to use it.
auto const& labelled_item = *m_labelled_item;
@ -853,7 +853,7 @@ Bytecode::CodeGenerationErrorOr<void> LabelledStatement::generate_labelled_evalu
return {};
}
Bytecode::CodeGenerationErrorOr<void> IterationStatement::generate_labelled_evaluation(Bytecode::Generator&, Vector<FlyString> const&) const
Bytecode::CodeGenerationErrorOr<void> IterationStatement::generate_labelled_evaluation(Bytecode::Generator&, Vector<DeprecatedFlyString> const&) const
{
return Bytecode::CodeGenerationError {
this,
@ -866,7 +866,7 @@ Bytecode::CodeGenerationErrorOr<void> WhileStatement::generate_bytecode(Bytecode
return generate_labelled_evaluation(generator, {});
}
Bytecode::CodeGenerationErrorOr<void> WhileStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<FlyString> const& label_set) const
Bytecode::CodeGenerationErrorOr<void> WhileStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<DeprecatedFlyString> const& label_set) const
{
// test
// jump if_false (true) end (false) body
@ -916,7 +916,7 @@ Bytecode::CodeGenerationErrorOr<void> DoWhileStatement::generate_bytecode(Byteco
return generate_labelled_evaluation(generator, {});
}
Bytecode::CodeGenerationErrorOr<void> DoWhileStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<FlyString> const& label_set) const
Bytecode::CodeGenerationErrorOr<void> DoWhileStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<DeprecatedFlyString> const& label_set) const
{
// jump always (true) body
// test
@ -967,7 +967,7 @@ Bytecode::CodeGenerationErrorOr<void> ForStatement::generate_bytecode(Bytecode::
return generate_labelled_evaluation(generator, {});
}
Bytecode::CodeGenerationErrorOr<void> ForStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<FlyString> const& label_set) const
Bytecode::CodeGenerationErrorOr<void> ForStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<DeprecatedFlyString> const& label_set) const
{
// init
// jump always (true) test
@ -2215,7 +2215,7 @@ Bytecode::CodeGenerationErrorOr<void> TryStatement::generate_bytecode(Bytecode::
generator.begin_variable_scope(Bytecode::Generator::BindingMode::Lexical, Bytecode::Generator::SurroundingScopeKind::Block);
TRY(m_handler->parameter().visit(
[&](FlyString const& parameter) -> Bytecode::CodeGenerationErrorOr<void> {
[&](DeprecatedFlyString const& parameter) -> Bytecode::CodeGenerationErrorOr<void> {
if (!parameter.is_empty()) {
auto parameter_identifier = generator.intern_identifier(parameter);
generator.register_binding(parameter_identifier);
@ -2283,7 +2283,7 @@ Bytecode::CodeGenerationErrorOr<void> SwitchStatement::generate_bytecode(Bytecod
return generate_labelled_evaluation(generator, {});
}
Bytecode::CodeGenerationErrorOr<void> SwitchStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<FlyString> const& label_set) const
Bytecode::CodeGenerationErrorOr<void> SwitchStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<DeprecatedFlyString> const& label_set) const
{
auto discriminant_reg = generator.allocate_register();
TRY(m_discriminant->generate_bytecode(generator));
@ -2516,7 +2516,7 @@ static Bytecode::CodeGenerationErrorOr<ForInOfHeadEvaluationResult> for_in_of_he
}
// 14.7.5.7 ForIn/OfBodyEvaluation ( lhs, stmt, iteratorRecord, iterationKind, lhsKind, labelSet [ , iteratorKind ] ), https://tc39.es/ecma262/#sec-runtime-semantics-forin-div-ofbodyevaluation-lhs-stmt-iterator-lhskind-labelset
static Bytecode::CodeGenerationErrorOr<void> for_in_of_body_evaluation(Bytecode::Generator& generator, ASTNode const& node, Variant<NonnullRefPtr<ASTNode>, NonnullRefPtr<BindingPattern>> const& lhs, ASTNode const& body, ForInOfHeadEvaluationResult const& head_result, Vector<FlyString> const& label_set, Bytecode::BasicBlock& loop_end, Bytecode::BasicBlock& loop_update)
static Bytecode::CodeGenerationErrorOr<void> for_in_of_body_evaluation(Bytecode::Generator& generator, ASTNode const& node, Variant<NonnullRefPtr<ASTNode>, NonnullRefPtr<BindingPattern>> const& lhs, ASTNode const& body, ForInOfHeadEvaluationResult const& head_result, Vector<DeprecatedFlyString> const& label_set, Bytecode::BasicBlock& loop_end, Bytecode::BasicBlock& loop_update)
{
auto iterator_register = generator.allocate_register();
generator.emit<Bytecode::Op::Store>(iterator_register);
@ -2719,7 +2719,7 @@ Bytecode::CodeGenerationErrorOr<void> ForInStatement::generate_bytecode(Bytecode
}
// 14.7.5.5 Runtime Semantics: ForInOfLoopEvaluation, https://tc39.es/ecma262/#sec-runtime-semantics-forinofloopevaluation
Bytecode::CodeGenerationErrorOr<void> ForInStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<FlyString> const& label_set) const
Bytecode::CodeGenerationErrorOr<void> ForInStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<DeprecatedFlyString> const& label_set) const
{
auto& loop_end = generator.make_block();
auto& loop_update = generator.make_block();
@ -2736,7 +2736,7 @@ Bytecode::CodeGenerationErrorOr<void> ForOfStatement::generate_bytecode(Bytecode
return generate_labelled_evaluation(generator, {});
}
Bytecode::CodeGenerationErrorOr<void> ForOfStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<FlyString> const& label_set) const
Bytecode::CodeGenerationErrorOr<void> ForOfStatement::generate_labelled_evaluation(Bytecode::Generator& generator, Vector<DeprecatedFlyString> const& label_set) const
{
auto& loop_end = generator.make_block();
auto& loop_update = generator.make_block();

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/FlyString.h>
#include <AK/DeprecatedFlyString.h>
#include <AK/NonnullOwnPtrVector.h>
#include <LibJS/Bytecode/BasicBlock.h>
#include <LibJS/Bytecode/IdentifierTable.h>
@ -15,7 +15,7 @@
namespace JS::Bytecode {
struct Executable {
FlyString name;
DeprecatedFlyString name;
NonnullOwnPtrVector<BasicBlock> basic_blocks;
NonnullOwnPtr<StringTable> string_table;
NonnullOwnPtr<IdentifierTable> identifier_table;
@ -23,7 +23,7 @@ struct Executable {
bool is_strict_mode { false };
DeprecatedString const& get_string(StringTableIndex index) const { return string_table->get(index); }
FlyString const& get_identifier(IdentifierTableIndex index) const { return identifier_table->get(index); }
DeprecatedFlyString const& get_identifier(IdentifierTableIndex index) const { return identifier_table->get(index); }
void dump() const;
};

View file

@ -113,7 +113,7 @@ void Generator::end_variable_scope()
}
}
void Generator::begin_continuable_scope(Label continue_target, Vector<FlyString> const& language_label_set)
void Generator::begin_continuable_scope(Label continue_target, Vector<DeprecatedFlyString> const& language_label_set)
{
m_continuable_scopes.append({ continue_target, language_label_set });
start_boundary(BlockBoundaryType::Continue);
@ -130,7 +130,7 @@ Label Generator::nearest_breakable_scope() const
return m_breakable_scopes.last().bytecode_target;
}
void Generator::begin_breakable_scope(Label breakable_target, Vector<FlyString> const& language_label_set)
void Generator::begin_breakable_scope(Label breakable_target, Vector<DeprecatedFlyString> const& language_label_set)
{
m_breakable_scopes.append({ breakable_target, language_label_set });
start_boundary(BlockBoundaryType::Break);
@ -262,7 +262,7 @@ CodeGenerationErrorOr<void> Generator::emit_delete_reference(JS::ASTNode const&
return {};
}
Label Generator::perform_needed_unwinds_for_labelled_break_and_return_target_block(FlyString const& break_label)
Label Generator::perform_needed_unwinds_for_labelled_break_and_return_target_block(DeprecatedFlyString const& break_label)
{
size_t current_boundary = m_boundaries.size();
for (auto& breakable_scope : m_breakable_scopes.in_reverse()) {
@ -294,7 +294,7 @@ Label Generator::perform_needed_unwinds_for_labelled_break_and_return_target_blo
VERIFY_NOT_REACHED();
}
Label Generator::perform_needed_unwinds_for_labelled_continue_and_return_target_block(FlyString const& continue_label)
Label Generator::perform_needed_unwinds_for_labelled_continue_and_return_target_block(DeprecatedFlyString const& continue_label)
{
size_t current_boundary = m_boundaries.size();
for (auto& continuable_scope : m_continuable_scopes.in_reverse()) {

View file

@ -84,9 +84,9 @@ public:
CodeGenerationErrorOr<void> emit_store_to_reference(JS::ASTNode const&);
CodeGenerationErrorOr<void> emit_delete_reference(JS::ASTNode const&);
void begin_continuable_scope(Label continue_target, Vector<FlyString> const& language_label_set);
void begin_continuable_scope(Label continue_target, Vector<DeprecatedFlyString> const& language_label_set);
void end_continuable_scope();
void begin_breakable_scope(Label breakable_target, Vector<FlyString> const& language_label_set);
void begin_breakable_scope(Label breakable_target, Vector<DeprecatedFlyString> const& language_label_set);
void end_breakable_scope();
[[nodiscard]] Label nearest_continuable_scope() const;
@ -117,7 +117,7 @@ public:
return m_string_table->insert(move(string));
}
IdentifierTableIndex intern_identifier(FlyString string)
IdentifierTableIndex intern_identifier(DeprecatedFlyString string)
{
return m_identifier_table->insert(move(string));
}
@ -213,8 +213,8 @@ public:
}
}
Label perform_needed_unwinds_for_labelled_break_and_return_target_block(FlyString const& break_label);
Label perform_needed_unwinds_for_labelled_continue_and_return_target_block(FlyString const& continue_label);
Label perform_needed_unwinds_for_labelled_break_and_return_target_block(DeprecatedFlyString const& break_label);
Label perform_needed_unwinds_for_labelled_continue_and_return_target_block(DeprecatedFlyString const& continue_label);
void start_boundary(BlockBoundaryType type) { m_boundaries.append(type); }
void end_boundary(BlockBoundaryType type)
@ -232,7 +232,7 @@ private:
struct LabelableScope {
Label bytecode_target;
Vector<FlyString> language_label_set;
Vector<DeprecatedFlyString> language_label_set;
};
BasicBlock* m_current_basic_block { nullptr };

View file

@ -8,7 +8,7 @@
namespace JS::Bytecode {
IdentifierTableIndex IdentifierTable::insert(FlyString string)
IdentifierTableIndex IdentifierTable::insert(DeprecatedFlyString string)
{
for (size_t i = 0; i < m_identifiers.size(); i++) {
if (m_identifiers[i] == string)
@ -18,7 +18,7 @@ IdentifierTableIndex IdentifierTable::insert(FlyString string)
return m_identifiers.size() - 1;
}
FlyString const& IdentifierTable::get(IdentifierTableIndex index) const
DeprecatedFlyString const& IdentifierTable::get(IdentifierTableIndex index) const
{
return m_identifiers[index.value()];
}

View file

@ -6,8 +6,8 @@
#pragma once
#include <AK/DeprecatedFlyString.h>
#include <AK/DistinctNumeric.h>
#include <AK/FlyString.h>
#include <AK/Vector.h>
namespace JS::Bytecode {
@ -21,13 +21,13 @@ class IdentifierTable {
public:
IdentifierTable() = default;
IdentifierTableIndex insert(FlyString);
FlyString const& get(IdentifierTableIndex) const;
IdentifierTableIndex insert(DeprecatedFlyString);
DeprecatedFlyString const& get(IdentifierTableIndex) const;
void dump() const;
bool is_empty() const { return m_identifiers.is_empty(); }
private:
Vector<FlyString> m_identifiers;
Vector<DeprecatedFlyString> m_identifiers;
};
}

View file

@ -51,7 +51,7 @@ Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Executable const& e
if (vm().execution_context_stack().is_empty() || !vm().running_execution_context().lexical_environment) {
// The "normal" interpreter pushes an execution context without environment so in that case we also want to push one.
execution_context.this_value = &m_realm.global_object();
static FlyString global_execution_context_name = "(*BC* global execution context)";
static DeprecatedFlyString global_execution_context_name = "(*BC* global execution context)";
execution_context.function_name = global_execution_context_name;
execution_context.lexical_environment = &m_realm.global_environment();
execution_context.variable_environment = &m_realm.global_environment();