mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:07:36 +00:00
Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -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 { DeprecatedString::formatted("Validation failed: {}", result.error()) };
|
||||
return InstantiationError { ByteString::formatted("Validation failed: {}", result.error()) };
|
||||
|
||||
auto main_module_instance_pointer = make<ModuleInstance>();
|
||||
auto& main_module_instance = *main_module_instance_pointer;
|
||||
|
@ -187,7 +187,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
|
|||
});
|
||||
auto result = config.execute(interpreter).assert_wasm_result();
|
||||
if (result.is_trap())
|
||||
instantiation_result = InstantiationError { DeprecatedString::formatted("Global value construction trapped: {}", result.trap().reason) };
|
||||
instantiation_result = InstantiationError { ByteString::formatted("Global value construction trapped: {}", result.trap().reason) };
|
||||
else
|
||||
global_values.append(result.values().first());
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
|
|||
});
|
||||
auto result = config.execute(interpreter).assert_wasm_result();
|
||||
if (result.is_trap()) {
|
||||
instantiation_result = InstantiationError { DeprecatedString::formatted("Element construction trapped: {}", result.trap().reason) };
|
||||
instantiation_result = InstantiationError { ByteString::formatted("Element construction trapped: {}", result.trap().reason) };
|
||||
return IterationDecision::Continue;
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
|
|||
});
|
||||
auto result = config.execute(interpreter).assert_wasm_result();
|
||||
if (result.is_trap()) {
|
||||
instantiation_result = InstantiationError { DeprecatedString::formatted("Element section initialisation trapped: {}", result.trap().reason) };
|
||||
instantiation_result = InstantiationError { ByteString::formatted("Element section initialisation trapped: {}", result.trap().reason) };
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
auto d = result.values().first().to<i32>();
|
||||
|
@ -327,7 +327,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
|
|||
});
|
||||
auto result = config.execute(interpreter).assert_wasm_result();
|
||||
if (result.is_trap()) {
|
||||
instantiation_result = InstantiationError { DeprecatedString::formatted("Data section initialisation trapped: {}", result.trap().reason) };
|
||||
instantiation_result = InstantiationError { ByteString::formatted("Data section initialisation trapped: {}", result.trap().reason) };
|
||||
return;
|
||||
}
|
||||
size_t offset = 0;
|
||||
|
@ -339,7 +339,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
|
|||
return;
|
||||
if (main_module_instance.memories().size() <= data.index.value()) {
|
||||
instantiation_result = InstantiationError {
|
||||
DeprecatedString::formatted("Data segment referenced out-of-bounds memory ({}) of max {} entries",
|
||||
ByteString::formatted("Data segment referenced out-of-bounds memory ({}) of max {} entries",
|
||||
data.index.value(), main_module_instance.memories().size())
|
||||
};
|
||||
return;
|
||||
|
@ -358,7 +358,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 {
|
||||
DeprecatedString::formatted("Data segment attempted to write to out-of-bounds memory ({}) of max {} bytes",
|
||||
ByteString::formatted("Data segment attempted to write to out-of-bounds memory ({}) of max {} bytes",
|
||||
data.init.size() + offset, instance->type().limits().max().value())
|
||||
};
|
||||
return;
|
||||
|
@ -384,7 +384,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 { DeprecatedString::formatted("Start section function referenced invalid index {} of max {} entries", index.value(), functions.size()) };
|
||||
instantiation_result = InstantiationError { ByteString::formatted("Start section function referenced invalid index {} of max {} entries", index.value(), functions.size()) };
|
||||
return;
|
||||
}
|
||||
invoke(functions[index.value()], {});
|
||||
|
|
|
@ -24,13 +24,13 @@ class Configuration;
|
|||
struct Interpreter;
|
||||
|
||||
struct InstantiationError {
|
||||
DeprecatedString error { "Unknown error" };
|
||||
ByteString error { "Unknown error" };
|
||||
};
|
||||
struct LinkError {
|
||||
enum OtherErrors {
|
||||
InvalidImportedModule,
|
||||
};
|
||||
Vector<DeprecatedString> missing_imports;
|
||||
Vector<ByteString> missing_imports;
|
||||
Vector<OtherErrors> other_errors;
|
||||
};
|
||||
|
||||
|
@ -192,7 +192,7 @@ private:
|
|||
};
|
||||
|
||||
struct Trap {
|
||||
DeprecatedString reason;
|
||||
ByteString reason;
|
||||
};
|
||||
|
||||
// A variant of Result that does not include external reasons for error (JS::Completion, for now).
|
||||
|
@ -270,7 +270,7 @@ using ExternValue = Variant<FunctionAddress, TableAddress, MemoryAddress, Global
|
|||
|
||||
class ExportInstance {
|
||||
public:
|
||||
explicit ExportInstance(DeprecatedString name, ExternValue value)
|
||||
explicit ExportInstance(ByteString name, ExternValue value)
|
||||
: m_name(move(name))
|
||||
, m_value(move(value))
|
||||
{
|
||||
|
@ -280,7 +280,7 @@ public:
|
|||
auto& value() const { return m_value; }
|
||||
|
||||
private:
|
||||
DeprecatedString m_name;
|
||||
ByteString m_name;
|
||||
ExternValue m_value;
|
||||
};
|
||||
|
||||
|
@ -633,8 +633,8 @@ private:
|
|||
class Linker {
|
||||
public:
|
||||
struct Name {
|
||||
DeprecatedString module;
|
||||
DeprecatedString name;
|
||||
ByteString module;
|
||||
ByteString name;
|
||||
ImportSection::Import::ImportDesc type;
|
||||
};
|
||||
|
||||
|
|
|
@ -1250,7 +1250,7 @@ void BytecodeInterpreter::interpret(Configuration& configuration, InstructionPoi
|
|||
default:
|
||||
unimplemented:;
|
||||
dbgln_if(WASM_TRACE_DEBUG, "Instruction '{}' not implemented", instruction_name(instruction.opcode()));
|
||||
m_trap = Trap { DeprecatedString::formatted("Unimplemented instruction {}", instruction_name(instruction.opcode())) };
|
||||
m_trap = Trap { ByteString::formatted("Unimplemented instruction {}", instruction_name(instruction.opcode())) };
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,12 +21,12 @@ struct BytecodeInterpreter : public Interpreter {
|
|||
virtual void interpret(Configuration&) override;
|
||||
virtual ~BytecodeInterpreter() override = default;
|
||||
virtual bool did_trap() const override { return !m_trap.has<Empty>(); }
|
||||
virtual DeprecatedString trap_reason() const override
|
||||
virtual ByteString trap_reason() const override
|
||||
{
|
||||
return m_trap.visit(
|
||||
[](Empty) -> DeprecatedString { VERIFY_NOT_REACHED(); },
|
||||
[](Empty) -> ByteString { VERIFY_NOT_REACHED(); },
|
||||
[](Trap const& trap) { return trap.reason; },
|
||||
[](JS::Completion const& completion) { return completion.value()->to_string_without_side_effects().to_deprecated_string(); });
|
||||
[](JS::Completion const& completion) { return completion.value()->to_string_without_side_effects().to_byte_string(); });
|
||||
}
|
||||
virtual void clear_trap() override { m_trap = Empty {}; }
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ struct Interpreter {
|
|||
virtual ~Interpreter() = default;
|
||||
virtual void interpret(Configuration&) = 0;
|
||||
virtual bool did_trap() const = 0;
|
||||
virtual DeprecatedString trap_reason() const = 0;
|
||||
virtual ByteString trap_reason() const = 0;
|
||||
virtual void clear_trap() = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -328,7 +328,7 @@ ErrorOr<void, ValidationError> Validator::validate(Limits const& limits, size_t
|
|||
template<u64 opcode>
|
||||
ErrorOr<void, ValidationError> Validator::validate_instruction(Instruction const& instruction, Stack&, bool&)
|
||||
{
|
||||
return Errors::invalid(DeprecatedString::formatted("instruction opcode (0x{:x}) (missing validation!)", instruction.opcode().value()));
|
||||
return Errors::invalid(ByteString::formatted("instruction opcode (0x{:x}) (missing validation!)", instruction.opcode().value()));
|
||||
}
|
||||
|
||||
#define VALIDATE_INSTRUCTION(name) \
|
||||
|
@ -3774,7 +3774,7 @@ ErrorOr<void, ValidationError> Validator::validate(Instruction const& instructio
|
|||
#undef M
|
||||
default:
|
||||
is_constant = false;
|
||||
return Errors::invalid(DeprecatedString::formatted("instruction opcode (0x{:x})", instruction.opcode().value()));
|
||||
return Errors::invalid(ByteString::formatted("instruction opcode (0x{:x})", instruction.opcode().value()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3851,16 +3851,16 @@ bool Validator::Stack::operator==(Stack const& other) const
|
|||
return true;
|
||||
}
|
||||
|
||||
DeprecatedString Validator::Errors::find_instruction_name(SourceLocation const& location)
|
||||
ByteString 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 DeprecatedString::formatted("{}", location);
|
||||
return ByteString::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 DeprecatedString::formatted("{}", location);
|
||||
return ByteString::formatted("{}", location);
|
||||
|
||||
return instruction_name(OpCode { *opcode });
|
||||
}
|
||||
|
|
|
@ -32,13 +32,13 @@ struct Context {
|
|||
};
|
||||
|
||||
struct ValidationError : public Error {
|
||||
ValidationError(DeprecatedString error)
|
||||
ValidationError(ByteString error)
|
||||
: Error(Error::from_string_view(error.view()))
|
||||
, error_string(move(error))
|
||||
{
|
||||
}
|
||||
|
||||
DeprecatedString error_string;
|
||||
ByteString error_string;
|
||||
};
|
||||
|
||||
class Validator {
|
||||
|
@ -267,27 +267,27 @@ private:
|
|||
}
|
||||
|
||||
struct Errors {
|
||||
static ValidationError invalid(StringView name) { return DeprecatedString::formatted("Invalid {}", name); }
|
||||
static ValidationError invalid(StringView name) { return ByteString::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 DeprecatedString::formatted("Invalid {} in {}, expected {} but got {}", name, find_instruction_name(location), expected, given);
|
||||
return ByteString::formatted("Invalid {} in {}, expected {} but got {}", name, find_instruction_name(location), expected, given);
|
||||
else
|
||||
return DeprecatedString::formatted("Invalid {}, expected {} but got {}", name, expected, given);
|
||||
return ByteString::formatted("Invalid {}, expected {} but got {}", name, expected, given);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
static ValidationError non_conforming_types(StringView name, Args... args)
|
||||
{
|
||||
return DeprecatedString::formatted("Non-conforming types for {}: {}", name, Vector { args... });
|
||||
return ByteString::formatted("Non-conforming types for {}: {}", name, Vector { args... });
|
||||
}
|
||||
|
||||
static ValidationError duplicate_export_name(StringView name) { return DeprecatedString::formatted("Duplicate exported name '{}'", name); }
|
||||
static ValidationError duplicate_export_name(StringView name) { return ByteString::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 DeprecatedString::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 ByteString::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())
|
||||
|
@ -318,11 +318,11 @@ private:
|
|||
}
|
||||
}
|
||||
builder.append(']');
|
||||
return { builder.to_deprecated_string() };
|
||||
return { builder.to_byte_string() };
|
||||
}
|
||||
|
||||
private:
|
||||
static DeprecatedString find_instruction_name(SourceLocation const&);
|
||||
static ByteString find_instruction_name(SourceLocation const&);
|
||||
};
|
||||
|
||||
enum class ChildScopeKind {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue