1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:47:35 +00:00

AK+Everywhere: Rename String to DeprecatedString

We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
This commit is contained in:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -141,7 +141,7 @@ ErrorOr<void, ValidationError> AbstractMachine::validate(Module& module)
InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<ExternValue> externs)
{
if (auto result = validate(const_cast<Module&>(module)); result.is_error())
return InstantiationError { String::formatted("Validation failed: {}", result.error()) };
return InstantiationError { DeprecatedString::formatted("Validation failed: {}", result.error()) };
auto main_module_instance_pointer = make<ModuleInstance>();
auto& main_module_instance = *main_module_instance_pointer;
@ -177,7 +177,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
});
auto result = config.execute(interpreter);
if (result.is_trap())
instantiation_result = InstantiationError { String::formatted("Global value construction trapped: {}", result.trap().reason) };
instantiation_result = InstantiationError { DeprecatedString::formatted("Global value construction trapped: {}", result.trap().reason) };
else
global_values.append(result.values().first());
}
@ -204,7 +204,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
});
auto result = config.execute(interpreter);
if (result.is_trap()) {
instantiation_result = InstantiationError { String::formatted("Element construction trapped: {}", result.trap().reason) };
instantiation_result = InstantiationError { DeprecatedString::formatted("Element construction trapped: {}", result.trap().reason) };
return IterationDecision::Continue;
}
@ -257,7 +257,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
});
auto result = config.execute(interpreter);
if (result.is_trap()) {
instantiation_result = InstantiationError { String::formatted("Element section initialisation trapped: {}", result.trap().reason) };
instantiation_result = InstantiationError { DeprecatedString::formatted("Element section initialisation trapped: {}", result.trap().reason) };
return IterationDecision::Break;
}
auto d = result.values().first().to<i32>();
@ -317,7 +317,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
});
auto result = config.execute(interpreter);
if (result.is_trap()) {
instantiation_result = InstantiationError { String::formatted("Data section initialisation trapped: {}", result.trap().reason) };
instantiation_result = InstantiationError { DeprecatedString::formatted("Data section initialisation trapped: {}", result.trap().reason) };
return;
}
size_t offset = 0;
@ -328,7 +328,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
return;
if (main_module_instance.memories().size() <= data.index.value()) {
instantiation_result = InstantiationError {
String::formatted("Data segment referenced out-of-bounds memory ({}) of max {} entries",
DeprecatedString::formatted("Data segment referenced out-of-bounds memory ({}) of max {} entries",
data.index.value(), main_module_instance.memories().size())
};
return;
@ -347,7 +347,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
if (auto max = instance->type().limits().max(); max.has_value()) {
if (*max * Constants::page_size < data.init.size() + offset) {
instantiation_result = InstantiationError {
String::formatted("Data segment attempted to write to out-of-bounds memory ({}) of max {} bytes",
DeprecatedString::formatted("Data segment attempted to write to out-of-bounds memory ({}) of max {} bytes",
data.init.size() + offset, instance->type().limits().max().value())
};
return;
@ -373,7 +373,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
auto& functions = main_module_instance.functions();
auto index = section.function().index();
if (functions.size() <= index.value()) {
instantiation_result = InstantiationError { String::formatted("Start section function referenced invalid index {} of max {} entries", index.value(), functions.size()) };
instantiation_result = InstantiationError { DeprecatedString::formatted("Start section function referenced invalid index {} of max {} entries", index.value(), functions.size()) };
return;
}
invoke(functions[index.value()], {});

View file

@ -19,13 +19,13 @@ class Configuration;
struct Interpreter;
struct InstantiationError {
String error { "Unknown error" };
DeprecatedString error { "Unknown error" };
};
struct LinkError {
enum OtherErrors {
InvalidImportedModule,
};
Vector<String> missing_imports;
Vector<DeprecatedString> missing_imports;
Vector<OtherErrors> other_errors;
};
@ -168,7 +168,7 @@ private:
};
struct Trap {
String reason;
DeprecatedString reason;
};
class Result {
@ -197,7 +197,7 @@ using ExternValue = Variant<FunctionAddress, TableAddress, MemoryAddress, Global
class ExportInstance {
public:
explicit ExportInstance(String name, ExternValue value)
explicit ExportInstance(DeprecatedString name, ExternValue value)
: m_name(move(name))
, m_value(move(value))
{
@ -207,7 +207,7 @@ public:
auto& value() const { return m_value; }
private:
String m_name;
DeprecatedString m_name;
ExternValue m_value;
};
@ -546,8 +546,8 @@ private:
class Linker {
public:
struct Name {
String module;
String name;
DeprecatedString module;
DeprecatedString name;
ImportSection::Import::ImportDesc type;
};

View file

@ -961,7 +961,7 @@ void BytecodeInterpreter::interpret(Configuration& configuration, InstructionPoi
default:
unimplemented:;
dbgln("Instruction '{}' not implemented", instruction_name(instruction.opcode()));
m_trap = Trap { String::formatted("Unimplemented instruction {}", instruction_name(instruction.opcode())) };
m_trap = Trap { DeprecatedString::formatted("Unimplemented instruction {}", instruction_name(instruction.opcode())) };
return;
}
}

View file

@ -16,7 +16,7 @@ struct BytecodeInterpreter : public Interpreter {
virtual void interpret(Configuration&) override;
virtual ~BytecodeInterpreter() override = default;
virtual bool did_trap() const override { return m_trap.has_value(); }
virtual String trap_reason() const override { return m_trap.value().reason; }
virtual DeprecatedString trap_reason() const override { return m_trap.value().reason; }
virtual void clear_trap() override { m_trap.clear(); }
struct CallFrameHandle {

View file

@ -14,7 +14,7 @@ struct Interpreter {
virtual ~Interpreter() = default;
virtual void interpret(Configuration&) = 0;
virtual bool did_trap() const = 0;
virtual String trap_reason() const = 0;
virtual DeprecatedString trap_reason() const = 0;
virtual void clear_trap() = 0;
};

View file

@ -320,7 +320,7 @@ ErrorOr<void, ValidationError> Validator::validate(Limits const& limits, size_t
template<u32 opcode>
ErrorOr<void, ValidationError> Validator::validate_instruction(Instruction const& instruction, Stack&, bool&)
{
return Errors::invalid(String::formatted("instruction opcode (0x{:x}) (missing validation!)", instruction.opcode().value()));
return Errors::invalid(DeprecatedString::formatted("instruction opcode (0x{:x}) (missing validation!)", instruction.opcode().value()));
}
#define VALIDATE_INSTRUCTION(name) \
@ -2179,7 +2179,7 @@ ErrorOr<void, ValidationError> Validator::validate(Instruction const& instructio
#undef M
default:
is_constant = false;
return Errors::invalid(String::formatted("instruction opcode (0x{:x})", instruction.opcode().value()));
return Errors::invalid(DeprecatedString::formatted("instruction opcode (0x{:x})", instruction.opcode().value()));
}
}
@ -2256,16 +2256,16 @@ bool Validator::Stack::operator==(Stack const& other) const
return true;
}
String Validator::Errors::find_instruction_name(SourceLocation const& location)
DeprecatedString Validator::Errors::find_instruction_name(SourceLocation const& location)
{
auto index = location.function_name().find('<');
auto end_index = location.function_name().find('>');
if (!index.has_value() || !end_index.has_value())
return String::formatted("{}", location);
return DeprecatedString::formatted("{}", location);
auto opcode = location.function_name().substring_view(index.value() + 1, end_index.value() - index.value() - 1).to_uint();
if (!opcode.has_value())
return String::formatted("{}", location);
return DeprecatedString::formatted("{}", location);
return instruction_name(OpCode { *opcode });
}

View file

@ -30,13 +30,13 @@ struct Context {
};
struct ValidationError : public Error {
ValidationError(String error)
ValidationError(DeprecatedString error)
: Error(Error::from_string_view(error))
, error_string(move(error))
{
}
String error_string;
DeprecatedString error_string;
};
class Validator {
@ -255,27 +255,27 @@ private:
}
struct Errors {
static ValidationError invalid(StringView name) { return String::formatted("Invalid {}", name); }
static ValidationError invalid(StringView name) { return DeprecatedString::formatted("Invalid {}", name); }
template<typename Expected, typename Given>
static ValidationError invalid(StringView name, Expected expected, Given given, SourceLocation location = SourceLocation::current())
{
if constexpr (WASM_VALIDATOR_DEBUG)
return String::formatted("Invalid {} in {}, expected {} but got {}", name, find_instruction_name(location), expected, given);
return DeprecatedString::formatted("Invalid {} in {}, expected {} but got {}", name, find_instruction_name(location), expected, given);
else
return String::formatted("Invalid {}, expected {} but got {}", name, expected, given);
return DeprecatedString::formatted("Invalid {}, expected {} but got {}", name, expected, given);
}
template<typename... Args>
static ValidationError non_conforming_types(StringView name, Args... args)
{
return String::formatted("Non-conforming types for {}: {}", name, Vector { args... });
return DeprecatedString::formatted("Non-conforming types for {}: {}", name, Vector { args... });
}
static ValidationError duplicate_export_name(StringView name) { return String::formatted("Duplicate exported name '{}'", name); }
static ValidationError duplicate_export_name(StringView name) { return DeprecatedString::formatted("Duplicate exported name '{}'", name); }
template<typename T, typename U, typename V>
static ValidationError out_of_bounds(StringView name, V value, T min, U max) { return String::formatted("Value {} for {} is out of bounds ({},{})", value, name, min, max); }
static ValidationError out_of_bounds(StringView name, V value, T min, U max) { return DeprecatedString::formatted("Value {} for {} is out of bounds ({},{})", value, name, min, max); }
template<typename... Expected>
static ValidationError invalid_stack_state(Stack const& stack, Tuple<Expected...> expected, SourceLocation location = SourceLocation::current())
@ -310,7 +310,7 @@ private:
}
private:
static String find_instruction_name(SourceLocation const&);
static DeprecatedString find_instruction_name(SourceLocation const&);
};
enum class ChildScopeKind {