mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:48:11 +00:00
LibJS+LibWeb: Convert string view PrimitiveString instances to String
First, this adds an overload of PrimitiveString::create for StringView. This overload will throw an OOM completion if creating a String fails. This is not only a bit more convenient, but it also ensures at compile time that all PrimitiveString::create(string_view) invocations will be handled as String and OOM-aware. Next, this wraps all invocations to PrimitiveString::create(string_view) with MUST_OR_THROW_OOM. A small PrimitiveString::create(DeprecatedFlyString) overload also had to be added to disambiguate between the StringView and DeprecatedString overloads.
This commit is contained in:
parent
69a56a8e39
commit
c3abb1396c
69 changed files with 223 additions and 186 deletions
|
@ -150,7 +150,7 @@ static ThrowCompletionOr<Value> not_(VM&, Value value)
|
|||
|
||||
static ThrowCompletionOr<Value> typeof_(VM& vm, Value value)
|
||||
{
|
||||
return Value(PrimitiveString::create(vm, value.typeof()));
|
||||
return MUST_OR_THROW_OOM(PrimitiveString::create(vm, value.typeof()));
|
||||
}
|
||||
|
||||
#define JS_DEFINE_COMMON_UNARY_OP(OpTitleCase, op_snake_case) \
|
||||
|
@ -1035,7 +1035,7 @@ ThrowCompletionOr<void> TypeofVariable::execute_impl(Bytecode::Interpreter& inte
|
|||
// 2. If val is a Reference Record, then
|
||||
// a. If IsUnresolvableReference(val) is true, return "undefined".
|
||||
if (reference.is_unresolvable()) {
|
||||
interpreter.accumulator() = PrimitiveString::create(vm, "undefined"sv);
|
||||
interpreter.accumulator() = MUST_OR_THROW_OOM(PrimitiveString::create(vm, "undefined"sv));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -1044,7 +1044,7 @@ ThrowCompletionOr<void> TypeofVariable::execute_impl(Bytecode::Interpreter& inte
|
|||
|
||||
// 4. NOTE: This step is replaced in section B.3.6.3.
|
||||
// 5. Return a String according to Table 41.
|
||||
interpreter.accumulator() = PrimitiveString::create(vm, value.typeof());
|
||||
interpreter.accumulator() = MUST_OR_THROW_OOM(PrimitiveString::create(vm, value.typeof()));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue