summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWasm/AbstractMachine
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-12-04 18:02:33 +0000
committerAndreas Kling <kling@serenityos.org>2022-12-06 08:54:33 +0100
commit6e19ab2bbce0b113b628e6f8e9b5c0640053933e (patch)
tree372d21b2f5dcff112f5d0089559c6af5798680d4 /Userland/Libraries/LibWasm/AbstractMachine
parentf74251606d74b504a1379ebb893fdb5529054ea5 (diff)
downloadserenity-6e19ab2bbce0b113b628e6f8e9b5c0640053933e.zip
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 :^)
Diffstat (limited to 'Userland/Libraries/LibWasm/AbstractMachine')
-rw-r--r--Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp16
-rw-r--r--Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h14
-rw-r--r--Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.cpp2
-rw-r--r--Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.h2
-rw-r--r--Userland/Libraries/LibWasm/AbstractMachine/Interpreter.h2
-rw-r--r--Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp10
-rw-r--r--Userland/Libraries/LibWasm/AbstractMachine/Validator.h18
7 files changed, 32 insertions, 32 deletions
diff --git a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp
index 5c991e68f9..ddc8cc4538 100644
--- a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp
+++ b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.cpp
@@ -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()], {});
diff --git a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h
index 6bc11c524c..d94c541826 100644
--- a/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h
+++ b/Userland/Libraries/LibWasm/AbstractMachine/AbstractMachine.h
@@ -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;
};
diff --git a/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.cpp b/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.cpp
index 83586133c9..dc0f091d15 100644
--- a/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.cpp
+++ b/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.cpp
@@ -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;
}
}
diff --git a/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.h b/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.h
index b3e46b05bb..55ffc1eeec 100644
--- a/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.h
+++ b/Userland/Libraries/LibWasm/AbstractMachine/BytecodeInterpreter.h
@@ -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 {
diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.h b/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.h
index 2cbe988982..3928c8f5c3 100644
--- a/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.h
+++ b/Userland/Libraries/LibWasm/AbstractMachine/Interpreter.h
@@ -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;
};
diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp b/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp
index 830fc7c931..557668cfb6 100644
--- a/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp
+++ b/Userland/Libraries/LibWasm/AbstractMachine/Validator.cpp
@@ -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 });
}
diff --git a/Userland/Libraries/LibWasm/AbstractMachine/Validator.h b/Userland/Libraries/LibWasm/AbstractMachine/Validator.h
index c4a9c546dc..29e08fae64 100644
--- a/Userland/Libraries/LibWasm/AbstractMachine/Validator.h
+++ b/Userland/Libraries/LibWasm/AbstractMachine/Validator.h
@@ -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 {