Commit graph

5 commits

Author SHA1 Message Date
Timothy Flynn
4d10911f96 LibJS: Pre-allocate the out-of-memory error string on the VM
If we are out of memory, we can't try to allocate a string that could
fail as well. When Error is converted to String, this would result in an
endless OOM-throwing loop. Instead, pre-allocate the string on the VM,
and use it to construct the Error.

Note that as of this commit, the OOM string is still a DeprecatedString.
This is just preporatory for Error's conversion to String.
2023-02-17 09:14:23 -05:00
Timothy Flynn
519a1cd23d LibJS: Add a fallible ThrowableStringBuilder::appendff 2023-02-10 17:26:20 +00:00
Timothy Flynn
7163e4d456 LibJS: Change ThrowableStringBuilder to privately inherit StringBuilder
Not an issue currently, but while developing, it's easy to miss cases
where an infallible AK::StringBuilder method is still used. By making
this inheritance private, and explicitly pulling in base methods we
can safely use, we get extra help from the compiler to indicate such
mistakes immediately.
2023-02-10 17:26:20 +00:00
Timothy Flynn
79e81e8a15 LibJS: Add ThrowableStringBuilder::to_string to create a new String
This wraps around the base class method to throw an OOM completion.
2023-01-15 01:00:20 +00:00
Timothy Flynn
76b9d06b19 LibJS: Add and begin using a completion-compatible string builder
ThrowableStringBuilder is a thin wrapper around StringBuilder to map
results from the try_* methods to a throw completion. This will let us
try to throw on OOM conditions rather than just blowing up.
2023-01-05 22:07:44 +01:00