1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:17: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:
Ali Mohammad Pur 2023-12-16 17:49:34 +03:30 committed by Ali Mohammad Pur
parent 38d62563b3
commit 5e1499d104
1615 changed files with 10257 additions and 10257 deletions

View file

@ -51,7 +51,7 @@ SourceRange ASTNode::source_range() const
return m_source_code->range_from_offsets(m_start_offset, m_end_offset);
}
DeprecatedString ASTNode::class_name() const
ByteString ASTNode::class_name() const
{
// NOTE: We strip the "JS::" prefix.
auto const* typename_ptr = typeid(*this).name();
@ -60,7 +60,7 @@ DeprecatedString ASTNode::class_name() const
static void print_indent(int indent)
{
out("{}", DeprecatedString::repeated(' ', indent * 2));
out("{}", ByteString::repeated(' ', indent * 2));
}
static void update_function_name(Value value, DeprecatedFlyString const& name)
@ -116,7 +116,7 @@ Value FunctionExpression::instantiate_ordinary_function_expression(VM& vm, Depre
return closure;
}
Optional<DeprecatedString> CallExpression::expression_string() const
Optional<ByteString> CallExpression::expression_string() const
{
if (is<Identifier>(*m_callee))
return static_cast<Identifier const&>(*m_callee).string();
@ -157,23 +157,23 @@ ThrowCompletionOr<ClassElement::ClassValue> ClassMethod::class_element_evaluatio
auto& method_function = static_cast<ECMAScriptFunctionObject&>(method_value.as_function());
method_function.make_method(target);
auto set_function_name = [&](DeprecatedString prefix = "") {
auto set_function_name = [&](ByteString prefix = "") {
auto name = property_key_or_private_name.visit(
[&](PropertyKey const& property_key) -> DeprecatedString {
[&](PropertyKey const& property_key) -> ByteString {
if (property_key.is_symbol()) {
auto description = property_key.as_symbol()->description();
if (!description.has_value() || description->is_empty())
return "";
return DeprecatedString::formatted("[{}]", *description);
return ByteString::formatted("[{}]", *description);
} else {
return property_key.to_string();
}
},
[&](PrivateName const& private_name) -> DeprecatedString {
[&](PrivateName const& private_name) -> ByteString {
return private_name.description;
});
update_function_name(method_value, DeprecatedString::formatted("{}{}{}", prefix, prefix.is_empty() ? "" : " ", name));
update_function_name(method_value, ByteString::formatted("{}{}{}", prefix, prefix.is_empty() ? "" : " ", name));
};
if (property_key_or_private_name.has<PropertyKey>()) {
@ -230,16 +230,16 @@ ThrowCompletionOr<ClassElement::ClassValue> ClassField::class_element_evaluation
if (m_initializer) {
auto copy_initializer = m_initializer;
auto name = property_key_or_private_name.visit(
[&](PropertyKey const& property_key) -> DeprecatedString {
[&](PropertyKey const& property_key) -> ByteString {
return property_key.is_number() ? property_key.to_string() : property_key.to_string_or_symbol().to_display_string();
},
[&](PrivateName const& private_name) -> DeprecatedString {
[&](PrivateName const& private_name) -> ByteString {
return private_name.description;
});
// FIXME: A potential optimization is not creating the functions here since these are never directly accessible.
auto function_code = create_ast_node<ClassFieldInitializerStatement>(m_initializer->source_range(), copy_initializer.release_nonnull(), name);
initializer = make_handle(*ECMAScriptFunctionObject::create(realm, DeprecatedString::empty(), DeprecatedString::empty(), *function_code, {}, 0, {}, vm.lexical_environment(), vm.running_execution_context().private_environment, FunctionKind::Normal, true, false, m_contains_direct_call_to_eval, false, property_key_or_private_name));
initializer = make_handle(*ECMAScriptFunctionObject::create(realm, ByteString::empty(), ByteString::empty(), *function_code, {}, 0, {}, vm.lexical_environment(), vm.running_execution_context().private_environment, FunctionKind::Normal, true, false, m_contains_direct_call_to_eval, false, property_key_or_private_name));
initializer->make_method(target);
}
@ -283,7 +283,7 @@ ThrowCompletionOr<ClassElement::ClassValue> StaticInitializer::class_element_eva
// 4. Let formalParameters be an instance of the production FormalParameters : [empty] .
// 5. Let bodyFunction be OrdinaryFunctionCreate(%Function.prototype%, sourceText, formalParameters, ClassStaticBlockBody, non-lexical-this, lex, privateEnv).
// Note: The function bodyFunction is never directly accessible to ECMAScript code.
auto body_function = ECMAScriptFunctionObject::create(realm, DeprecatedString::empty(), DeprecatedString::empty(), *m_function_body, {}, 0, m_function_body->local_variables_names(), lexical_environment, private_environment, FunctionKind::Normal, true, false, m_contains_direct_call_to_eval, false);
auto body_function = ECMAScriptFunctionObject::create(realm, ByteString::empty(), ByteString::empty(), *m_function_body, {}, 0, m_function_body->local_variables_names(), lexical_environment, private_environment, FunctionKind::Normal, true, false, m_contains_direct_call_to_eval, false);
// 6. Perform MakeMethod(bodyFunction, homeObject).
body_function->make_method(home_object);
@ -868,7 +868,7 @@ void BindingPattern::dump(int indent) const
}
}
void FunctionNode::dump(int indent, DeprecatedString const& class_name) const
void FunctionNode::dump(int indent, ByteString const& class_name) const
{
print_indent(indent);
auto is_async = m_kind == FunctionKind::Async || m_kind == FunctionKind::AsyncGenerator;
@ -1253,16 +1253,16 @@ void MemberExpression::dump(int indent) const
m_property->dump(indent + 1);
}
DeprecatedString MemberExpression::to_string_approximation() const
ByteString MemberExpression::to_string_approximation() const
{
DeprecatedString object_string = "<object>";
ByteString object_string = "<object>";
if (is<Identifier>(*m_object))
object_string = static_cast<Identifier const&>(*m_object).string();
if (is_computed())
return DeprecatedString::formatted("{}[<computed>]", object_string);
return ByteString::formatted("{}[<computed>]", object_string);
if (is<PrivateIdentifier>(*m_property))
return DeprecatedString::formatted("{}.{}", object_string, verify_cast<PrivateIdentifier>(*m_property).string());
return DeprecatedString::formatted("{}.{}", object_string, verify_cast<Identifier>(*m_property).string());
return ByteString::formatted("{}.{}", object_string, verify_cast<PrivateIdentifier>(*m_property).string());
return ByteString::formatted("{}.{}", object_string, verify_cast<Identifier>(*m_property).string());
}
bool MemberExpression::ends_in_private_name() const
@ -1309,7 +1309,7 @@ void OptionalChain::dump(int indent) const
void MetaProperty::dump(int indent) const
{
DeprecatedString name;
ByteString name;
if (m_type == MetaProperty::Type::NewTarget)
name = "new.target";
else if (m_type == MetaProperty::Type::ImportMeta)
@ -1550,11 +1550,11 @@ void ExportStatement::dump(int indent) const
print_indent(indent + 1);
outln("(ExportEntries)");
auto string_or_null = [](DeprecatedString const& string) -> DeprecatedString {
auto string_or_null = [](ByteString const& string) -> ByteString {
if (string.is_empty()) {
return "null";
}
return DeprecatedString::formatted("\"{}\"", string);
return ByteString::formatted("\"{}\"", string);
};
for (auto& entry : m_entries) {
@ -1895,9 +1895,9 @@ ModuleRequest::ModuleRequest(DeprecatedFlyString module_specifier_, Vector<Impor
});
}
DeprecatedString SourceRange::filename() const
ByteString SourceRange::filename() const
{
return code->filename().to_deprecated_string();
return code->filename().to_byte_string();
}
NonnullRefPtr<CallExpression> CallExpression::create(SourceRange source_range, NonnullRefPtr<Expression const> callee, ReadonlySpan<Argument> arguments, InvocationStyleEnum invocation_style, InsideParenthesesEnum inside_parens)

View file

@ -8,8 +8,8 @@
#pragma once
#include <AK/ByteString.h>
#include <AK/DeprecatedFlyString.h>
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>
#include <AK/RefPtr.h>
@ -69,7 +69,7 @@ public:
void set_end_offset(Badge<Parser>, u32 end_offset) { m_end_offset = end_offset; }
DeprecatedString class_name() const;
ByteString class_name() const;
template<typename T>
bool fast_is() const = delete;
@ -692,7 +692,7 @@ class FunctionNode {
public:
StringView name() const { return m_name ? m_name->string().view() : ""sv; }
RefPtr<Identifier const> name_identifier() const { return m_name; }
DeprecatedString const& source_text() const { return m_source_text; }
ByteString const& source_text() const { return m_source_text; }
Statement const& body() const { return *m_body; }
Vector<FunctionParameter> const& parameters() const { return m_parameters; }
i32 function_length() const { return m_function_length; }
@ -704,7 +704,7 @@ public:
FunctionKind kind() const { return m_kind; }
protected:
FunctionNode(RefPtr<Identifier const> name, DeprecatedString source_text, NonnullRefPtr<Statement const> body, Vector<FunctionParameter> parameters, i32 function_length, FunctionKind kind, bool is_strict_mode, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Vector<DeprecatedFlyString> local_variables_names)
FunctionNode(RefPtr<Identifier const> name, ByteString source_text, NonnullRefPtr<Statement const> body, Vector<FunctionParameter> parameters, i32 function_length, FunctionKind kind, bool is_strict_mode, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Vector<DeprecatedFlyString> local_variables_names)
: m_name(move(name))
, m_source_text(move(source_text))
, m_body(move(body))
@ -721,12 +721,12 @@ protected:
VERIFY(!m_might_need_arguments_object);
}
void dump(int indent, DeprecatedString const& class_name) const;
void dump(int indent, ByteString const& class_name) const;
RefPtr<Identifier const> m_name { nullptr };
private:
DeprecatedString m_source_text;
ByteString m_source_text;
NonnullRefPtr<Statement const> m_body;
Vector<FunctionParameter> const m_parameters;
i32 const m_function_length;
@ -745,7 +745,7 @@ class FunctionDeclaration final
public:
static bool must_have_name() { return true; }
FunctionDeclaration(SourceRange source_range, RefPtr<Identifier const> name, DeprecatedString source_text, NonnullRefPtr<Statement const> body, Vector<FunctionParameter> parameters, i32 function_length, FunctionKind kind, bool is_strict_mode, bool might_need_arguments_object, bool contains_direct_call_to_eval, Vector<DeprecatedFlyString> local_variables_names)
FunctionDeclaration(SourceRange source_range, RefPtr<Identifier const> name, ByteString source_text, NonnullRefPtr<Statement const> body, Vector<FunctionParameter> parameters, i32 function_length, FunctionKind kind, bool is_strict_mode, bool might_need_arguments_object, bool contains_direct_call_to_eval, Vector<DeprecatedFlyString> local_variables_names)
: Declaration(move(source_range))
, FunctionNode(move(name), move(source_text), move(body), move(parameters), function_length, kind, is_strict_mode, might_need_arguments_object, contains_direct_call_to_eval, false, move(local_variables_names))
{
@ -770,7 +770,7 @@ class FunctionExpression final
public:
static bool must_have_name() { return false; }
FunctionExpression(SourceRange source_range, RefPtr<Identifier const> name, DeprecatedString source_text, NonnullRefPtr<Statement const> body, Vector<FunctionParameter> parameters, i32 function_length, FunctionKind kind, bool is_strict_mode, bool might_need_arguments_object, bool contains_direct_call_to_eval, Vector<DeprecatedFlyString> local_variables_names, bool is_arrow_function = false)
FunctionExpression(SourceRange source_range, RefPtr<Identifier const> name, ByteString source_text, NonnullRefPtr<Statement const> body, Vector<FunctionParameter> parameters, i32 function_length, FunctionKind kind, bool is_strict_mode, bool might_need_arguments_object, bool contains_direct_call_to_eval, Vector<DeprecatedFlyString> local_variables_names, bool is_arrow_function = false)
: Expression(move(source_range))
, FunctionNode(move(name), move(source_text), move(body), move(parameters), function_length, kind, is_strict_mode, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(local_variables_names))
{
@ -1188,7 +1188,7 @@ private:
class BigIntLiteral final : public Expression {
public:
explicit BigIntLiteral(SourceRange source_range, DeprecatedString value)
explicit BigIntLiteral(SourceRange source_range, ByteString value)
: Expression(move(source_range))
, m_value(move(value))
{
@ -1198,12 +1198,12 @@ public:
virtual Bytecode::CodeGenerationErrorOr<void> generate_bytecode(Bytecode::Generator&) const override;
private:
DeprecatedString m_value;
ByteString m_value;
};
class StringLiteral final : public Expression {
public:
explicit StringLiteral(SourceRange source_range, DeprecatedString value)
explicit StringLiteral(SourceRange source_range, ByteString value)
: Expression(move(source_range))
, m_value(move(value))
{
@ -1217,7 +1217,7 @@ public:
private:
virtual bool is_string_literal() const override { return true; }
DeprecatedString m_value;
ByteString m_value;
};
class NullLiteral final : public PrimitiveLiteral {
@ -1235,7 +1235,7 @@ public:
class RegExpLiteral final : public Expression {
public:
RegExpLiteral(SourceRange source_range, regex::Parser::Result parsed_regex, DeprecatedString parsed_pattern, regex::RegexOptions<ECMAScriptFlags> parsed_flags, DeprecatedString pattern, DeprecatedString flags)
RegExpLiteral(SourceRange source_range, regex::Parser::Result parsed_regex, ByteString parsed_pattern, regex::RegexOptions<ECMAScriptFlags> parsed_flags, ByteString pattern, ByteString flags)
: Expression(move(source_range))
, m_parsed_regex(move(parsed_regex))
, m_parsed_pattern(move(parsed_pattern))
@ -1249,17 +1249,17 @@ public:
virtual Bytecode::CodeGenerationErrorOr<void> generate_bytecode(Bytecode::Generator&) const override;
regex::Parser::Result const& parsed_regex() const { return m_parsed_regex; }
DeprecatedString const& parsed_pattern() const { return m_parsed_pattern; }
ByteString const& parsed_pattern() const { return m_parsed_pattern; }
regex::RegexOptions<ECMAScriptFlags> const& parsed_flags() const { return m_parsed_flags; }
DeprecatedString const& pattern() const { return m_pattern; }
DeprecatedString const& flags() const { return m_flags; }
ByteString const& pattern() const { return m_pattern; }
ByteString const& flags() const { return m_flags; }
private:
regex::Parser::Result m_parsed_regex;
DeprecatedString m_parsed_pattern;
ByteString m_parsed_pattern;
regex::RegexOptions<ECMAScriptFlags> m_parsed_flags;
DeprecatedString m_pattern;
DeprecatedString m_flags;
ByteString m_pattern;
ByteString m_flags;
};
class PrivateIdentifier final : public Expression {
@ -1398,7 +1398,7 @@ public:
class ClassExpression final : public Expression {
public:
ClassExpression(SourceRange source_range, RefPtr<Identifier const> name, DeprecatedString source_text, RefPtr<FunctionExpression const> constructor, RefPtr<Expression const> super_class, Vector<NonnullRefPtr<ClassElement const>> elements)
ClassExpression(SourceRange source_range, RefPtr<Identifier const> name, ByteString source_text, RefPtr<FunctionExpression const> constructor, RefPtr<Expression const> super_class, Vector<NonnullRefPtr<ClassElement const>> elements)
: Expression(move(source_range))
, m_name(move(name))
, m_source_text(move(source_text))
@ -1410,7 +1410,7 @@ public:
StringView name() const { return m_name ? m_name->string().view() : ""sv; }
DeprecatedString const& source_text() const { return m_source_text; }
ByteString const& source_text() const { return m_source_text; }
RefPtr<FunctionExpression const> constructor() const { return m_constructor; }
virtual void dump(int indent) const override;
@ -1428,7 +1428,7 @@ private:
friend ClassDeclaration;
RefPtr<Identifier const> m_name;
DeprecatedString m_source_text;
ByteString m_source_text;
RefPtr<FunctionExpression const> m_constructor;
RefPtr<Expression const> m_super_class;
Vector<NonnullRefPtr<ClassElement const>> m_elements;
@ -1551,7 +1551,7 @@ protected:
virtual bool is_call_expression() const override { return true; }
Optional<DeprecatedString> expression_string() const;
Optional<ByteString> expression_string() const;
NonnullRefPtr<Expression const> m_callee;
};
@ -1900,7 +1900,7 @@ public:
Expression const& object() const { return *m_object; }
Expression const& property() const { return *m_property; }
DeprecatedString to_string_approximation() const;
ByteString to_string_approximation() const;
bool ends_in_private_name() const;

View file

@ -976,11 +976,11 @@ Bytecode::CodeGenerationErrorOr<void> ObjectExpression::generate_bytecode(Byteco
if (property_kind == Bytecode::Op::PropertyKind::ProtoSetter) {
TRY(property->value().generate_bytecode(generator));
} else if (property_kind != Bytecode::Op::PropertyKind::Spread) {
DeprecatedString identifier = string_literal.value();
ByteString identifier = string_literal.value();
if (property_kind == Bytecode::Op::PropertyKind::Getter)
identifier = DeprecatedString::formatted("get {}", identifier);
identifier = ByteString::formatted("get {}", identifier);
else if (property_kind == Bytecode::Op::PropertyKind::Setter)
identifier = DeprecatedString::formatted("set {}", identifier);
identifier = ByteString::formatted("set {}", identifier);
auto name = generator.intern_identifier(identifier);
TRY(generator.emit_named_evaluation_if_anonymous_function(property->value(), name));
}

View file

@ -46,7 +46,7 @@ void BasicBlock::dump(Bytecode::Executable const& executable) const
}
warnln(":");
while (!it.at_end()) {
warnln("[{:4x}] {}", it.offset(), (*it).to_deprecated_string(executable));
warnln("[{:4x}] {}", it.offset(), (*it).to_byte_string(executable));
++it;
}
}

View file

@ -225,14 +225,14 @@ ThrowCompletionOr<void> put_by_property_key(VM& vm, Value base, Value this_value
case Op::PropertyKind::Getter: {
auto& function = value.as_function();
if (function.name().is_empty() && is<ECMAScriptFunctionObject>(function))
static_cast<ECMAScriptFunctionObject*>(&function)->set_name(DeprecatedString::formatted("get {}", name));
static_cast<ECMAScriptFunctionObject*>(&function)->set_name(ByteString::formatted("get {}", name));
object->define_direct_accessor(name, &function, nullptr, Attribute::Configurable | Attribute::Enumerable);
break;
}
case Op::PropertyKind::Setter: {
auto& function = value.as_function();
if (function.name().is_empty() && is<ECMAScriptFunctionObject>(function))
static_cast<ECMAScriptFunctionObject*>(&function)->set_name(DeprecatedString::formatted("set {}", name));
static_cast<ECMAScriptFunctionObject*>(&function)->set_name(ByteString::formatted("set {}", name));
object->define_direct_accessor(name, nullptr, &function, Attribute::Configurable | Attribute::Enumerable);
break;
}
@ -511,7 +511,7 @@ ThrowCompletionOr<CalleeAndThis> get_callee_and_this_from_environment(Bytecode::
}
// 13.2.7.3 Runtime Semantics: Evaluation, https://tc39.es/ecma262/#sec-regular-expression-literals-runtime-semantics-evaluation
Value new_regexp(VM& vm, ParsedRegex const& parsed_regex, DeprecatedString const& pattern, DeprecatedString const& flags)
Value new_regexp(VM& vm, ParsedRegex const& parsed_regex, ByteString const& pattern, ByteString const& flags)
{
// 1. Let pattern be CodePointsToString(BodyText of RegularExpressionLiteral).
// 2. Let flags be CodePointsToString(FlagText of RegularExpressionLiteral).

View file

@ -30,7 +30,7 @@ struct CalleeAndThis {
Value this_value;
};
ThrowCompletionOr<CalleeAndThis> get_callee_and_this_from_environment(Bytecode::Interpreter&, DeprecatedFlyString const& name, EnvironmentVariableCache&);
Value new_regexp(VM&, ParsedRegex const&, DeprecatedString const& pattern, DeprecatedString const& flags);
Value new_regexp(VM&, ParsedRegex const&, ByteString const& pattern, ByteString const& flags);
MarkedVector<Value> argument_list_evaluation(VM&, Value arguments);
ThrowCompletionOr<void> create_variable(VM&, DeprecatedFlyString const& name, Op::EnvironmentMode, bool is_global, bool is_immutable, bool is_strict);
ThrowCompletionOr<ECMAScriptFunctionObject*> new_class(VM&, Value super_class, ClassExpression const&, Optional<IdentifierTableIndex> const& lhs_name);

View file

@ -78,7 +78,7 @@ public:
size_t number_of_registers { 0 };
bool is_strict_mode { false };
DeprecatedString const& get_string(StringTableIndex index) const { return string_table->get(index); }
ByteString const& get_string(StringTableIndex index) const { return string_table->get(index); }
DeprecatedFlyString const& get_identifier(IdentifierTableIndex index) const { return identifier_table->get(index); }
void dump() const;

View file

@ -152,7 +152,7 @@ public:
return m_current_basic_block->is_terminated();
}
StringTableIndex intern_string(DeprecatedString string)
StringTableIndex intern_string(ByteString string)
{
return m_string_table->insert(move(string));
}

View file

@ -135,7 +135,7 @@ public:
Type type() const { return m_type; }
size_t length() const { return m_length; }
DeprecatedString to_deprecated_string(Bytecode::Executable const&) const;
ByteString to_byte_string(Bytecode::Executable const&) const;
ThrowCompletionOr<void> execute(Bytecode::Interpreter&) const;
static void destroy(Instruction&);

View file

@ -502,11 +502,11 @@ Variant<NonnullOwnPtr<CallFrame>, CallFrame*> Interpreter::pop_call_frame()
namespace JS::Bytecode {
DeprecatedString Instruction::to_deprecated_string(Bytecode::Executable const& executable) const
ByteString Instruction::to_byte_string(Bytecode::Executable const& executable) const
{
#define __BYTECODE_OP(op) \
case Instruction::Type::op: \
return static_cast<Bytecode::Op::op const&>(*this).to_deprecated_string_impl(executable);
return static_cast<Bytecode::Op::op const&>(*this).to_byte_string_impl(executable);
switch (type()) {
ENUMERATE_BYTECODE_OPS(__BYTECODE_OP)
@ -568,9 +568,9 @@ static ThrowCompletionOr<Value> strict_equals(VM&, Value src1, Value src2)
interpreter.accumulator() = TRY(op_snake_case(vm, lhs, rhs)); \
return {}; \
} \
DeprecatedString OpTitleCase::to_deprecated_string_impl(Bytecode::Executable const&) const \
ByteString OpTitleCase::to_byte_string_impl(Bytecode::Executable const&) const \
{ \
return DeprecatedString::formatted(#OpTitleCase " {}", m_lhs_reg); \
return ByteString::formatted(#OpTitleCase " {}", m_lhs_reg); \
}
JS_ENUMERATE_COMMON_BINARY_OPS(JS_DEFINE_COMMON_BINARY_OP)
@ -592,7 +592,7 @@ static ThrowCompletionOr<Value> typeof_(VM& vm, Value value)
interpreter.accumulator() = TRY(op_snake_case(vm, interpreter.accumulator())); \
return {}; \
} \
DeprecatedString OpTitleCase::to_deprecated_string_impl(Bytecode::Executable const&) const \
ByteString OpTitleCase::to_byte_string_impl(Bytecode::Executable const&) const \
{ \
return #OpTitleCase; \
}
@ -671,17 +671,17 @@ ThrowCompletionOr<void> NewRegExp::execute_impl(Bytecode::Interpreter& interpret
return {};
}
#define JS_DEFINE_NEW_BUILTIN_ERROR_OP(ErrorName) \
ThrowCompletionOr<void> New##ErrorName::execute_impl(Bytecode::Interpreter& interpreter) const \
{ \
auto& vm = interpreter.vm(); \
auto& realm = *vm.current_realm(); \
interpreter.accumulator() = ErrorName::create(realm, interpreter.current_executable().get_string(m_error_string)); \
return {}; \
} \
DeprecatedString New##ErrorName::to_deprecated_string_impl(Bytecode::Executable const& executable) const \
{ \
return DeprecatedString::formatted("New" #ErrorName " {} (\"{}\")", m_error_string, executable.string_table->get(m_error_string)); \
#define JS_DEFINE_NEW_BUILTIN_ERROR_OP(ErrorName) \
ThrowCompletionOr<void> New##ErrorName::execute_impl(Bytecode::Interpreter& interpreter) const \
{ \
auto& vm = interpreter.vm(); \
auto& realm = *vm.current_realm(); \
interpreter.accumulator() = ErrorName::create(realm, interpreter.current_executable().get_string(m_error_string)); \
return {}; \
} \
ByteString New##ErrorName::to_byte_string_impl(Bytecode::Executable const& executable) const \
{ \
return ByteString::formatted("New" #ErrorName " {} (\"{}\")", m_error_string, executable.string_table->get(m_error_string)); \
}
JS_ENUMERATE_NEW_BUILTIN_ERROR_OPS(JS_DEFINE_NEW_BUILTIN_ERROR_OP)
@ -1325,69 +1325,69 @@ ThrowCompletionOr<void> BlockDeclarationInstantiation::execute_impl(Bytecode::In
return {};
}
DeprecatedString Load::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString Load::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("Load {}", m_src);
return ByteString::formatted("Load {}", m_src);
}
DeprecatedString LoadImmediate::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString LoadImmediate::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("LoadImmediate {}", m_value);
return ByteString::formatted("LoadImmediate {}", m_value);
}
DeprecatedString Store::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString Store::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("Store {}", m_dst);
return ByteString::formatted("Store {}", m_dst);
}
DeprecatedString NewBigInt::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString NewBigInt::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("NewBigInt \"{}\"", m_bigint.to_base_deprecated(10));
return ByteString::formatted("NewBigInt \"{}\"", m_bigint.to_base_deprecated(10));
}
DeprecatedString NewArray::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString NewArray::to_byte_string_impl(Bytecode::Executable const&) const
{
StringBuilder builder;
builder.append("NewArray"sv);
if (m_element_count != 0) {
builder.appendff(" [{}-{}]", m_elements[0], m_elements[1]);
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
DeprecatedString NewPrimitiveArray::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString NewPrimitiveArray::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("NewPrimitiveArray {}"sv, m_values.span());
return ByteString::formatted("NewPrimitiveArray {}"sv, m_values.span());
}
DeprecatedString Append::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString Append::to_byte_string_impl(Bytecode::Executable const&) const
{
if (m_is_spread)
return DeprecatedString::formatted("Append lhs: **{}", m_lhs);
return DeprecatedString::formatted("Append lhs: {}", m_lhs);
return ByteString::formatted("Append lhs: **{}", m_lhs);
return ByteString::formatted("Append lhs: {}", m_lhs);
}
DeprecatedString IteratorToArray::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString IteratorToArray::to_byte_string_impl(Bytecode::Executable const&) const
{
return "IteratorToArray";
}
DeprecatedString NewString::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString NewString::to_byte_string_impl(Bytecode::Executable const& executable) const
{
return DeprecatedString::formatted("NewString {} (\"{}\")", m_string, executable.string_table->get(m_string));
return ByteString::formatted("NewString {} (\"{}\")", m_string, executable.string_table->get(m_string));
}
DeprecatedString NewObject::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString NewObject::to_byte_string_impl(Bytecode::Executable const&) const
{
return "NewObject";
}
DeprecatedString NewRegExp::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString NewRegExp::to_byte_string_impl(Bytecode::Executable const& executable) const
{
return DeprecatedString::formatted("NewRegExp source:{} (\"{}\") flags:{} (\"{}\")", m_source_index, executable.get_string(m_source_index), m_flags_index, executable.get_string(m_flags_index));
return ByteString::formatted("NewRegExp source:{} (\"{}\") flags:{} (\"{}\")", m_source_index, executable.get_string(m_source_index), m_flags_index, executable.get_string(m_flags_index));
}
DeprecatedString CopyObjectExcludingProperties::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString CopyObjectExcludingProperties::to_byte_string_impl(Bytecode::Executable const&) const
{
StringBuilder builder;
builder.appendff("CopyObjectExcludingProperties from:{}", m_from_object);
@ -1396,65 +1396,65 @@ DeprecatedString CopyObjectExcludingProperties::to_deprecated_string_impl(Byteco
builder.join(", "sv, ReadonlySpan<Register>(m_excluded_names, m_excluded_names_count));
builder.append(']');
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
DeprecatedString ConcatString::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString ConcatString::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("ConcatString {}", m_lhs);
return ByteString::formatted("ConcatString {}", m_lhs);
}
DeprecatedString GetCalleeAndThisFromEnvironment::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString GetCalleeAndThisFromEnvironment::to_byte_string_impl(Bytecode::Executable const& executable) const
{
return DeprecatedString::formatted("GetCalleeAndThisFromEnvironment {} -> callee: {}, this:{} ", executable.identifier_table->get(m_identifier), m_callee_reg, m_this_reg);
return ByteString::formatted("GetCalleeAndThisFromEnvironment {} -> callee: {}, this:{} ", executable.identifier_table->get(m_identifier), m_callee_reg, m_this_reg);
}
DeprecatedString GetVariable::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString GetVariable::to_byte_string_impl(Bytecode::Executable const& executable) const
{
return DeprecatedString::formatted("GetVariable {} ({})", m_identifier, executable.identifier_table->get(m_identifier));
return ByteString::formatted("GetVariable {} ({})", m_identifier, executable.identifier_table->get(m_identifier));
}
DeprecatedString GetGlobal::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString GetGlobal::to_byte_string_impl(Bytecode::Executable const& executable) const
{
return DeprecatedString::formatted("GetGlobal {} ({})", m_identifier, executable.identifier_table->get(m_identifier));
return ByteString::formatted("GetGlobal {} ({})", m_identifier, executable.identifier_table->get(m_identifier));
}
DeprecatedString GetLocal::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString GetLocal::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("GetLocal {}", m_index);
return ByteString::formatted("GetLocal {}", m_index);
}
DeprecatedString DeleteVariable::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString DeleteVariable::to_byte_string_impl(Bytecode::Executable const& executable) const
{
return DeprecatedString::formatted("DeleteVariable {} ({})", m_identifier, executable.identifier_table->get(m_identifier));
return ByteString::formatted("DeleteVariable {} ({})", m_identifier, executable.identifier_table->get(m_identifier));
}
DeprecatedString CreateLexicalEnvironment::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString CreateLexicalEnvironment::to_byte_string_impl(Bytecode::Executable const&) const
{
return "CreateLexicalEnvironment"sv;
}
DeprecatedString CreateVariable::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString CreateVariable::to_byte_string_impl(Bytecode::Executable const& executable) const
{
auto mode_string = m_mode == EnvironmentMode::Lexical ? "Lexical" : "Variable";
return DeprecatedString::formatted("CreateVariable env:{} immutable:{} global:{} {} ({})", mode_string, m_is_immutable, m_is_global, m_identifier, executable.identifier_table->get(m_identifier));
return ByteString::formatted("CreateVariable env:{} immutable:{} global:{} {} ({})", mode_string, m_is_immutable, m_is_global, m_identifier, executable.identifier_table->get(m_identifier));
}
DeprecatedString EnterObjectEnvironment::to_deprecated_string_impl(Executable const&) const
ByteString EnterObjectEnvironment::to_byte_string_impl(Executable const&) const
{
return DeprecatedString::formatted("EnterObjectEnvironment");
return ByteString::formatted("EnterObjectEnvironment");
}
DeprecatedString SetVariable::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString SetVariable::to_byte_string_impl(Bytecode::Executable const& executable) const
{
auto initialization_mode_name = m_initialization_mode == InitializationMode::Initialize ? "Initialize" : "Set";
auto mode_string = m_mode == EnvironmentMode::Lexical ? "Lexical" : "Variable";
return DeprecatedString::formatted("SetVariable env:{} init:{} {} ({})", mode_string, initialization_mode_name, m_identifier, executable.identifier_table->get(m_identifier));
return ByteString::formatted("SetVariable env:{} init:{} {} ({})", mode_string, initialization_mode_name, m_identifier, executable.identifier_table->get(m_identifier));
}
DeprecatedString SetLocal::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString SetLocal::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("SetLocal {}", m_index);
return ByteString::formatted("SetLocal {}", m_index);
}
static StringView property_kind_to_string(PropertyKind kind)
@ -1476,80 +1476,80 @@ static StringView property_kind_to_string(PropertyKind kind)
VERIFY_NOT_REACHED();
}
DeprecatedString PutById::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString PutById::to_byte_string_impl(Bytecode::Executable const& executable) const
{
auto kind = property_kind_to_string(m_kind);
return DeprecatedString::formatted("PutById kind:{} base:{}, property:{} ({})", kind, m_base, m_property, executable.identifier_table->get(m_property));
return ByteString::formatted("PutById kind:{} base:{}, property:{} ({})", kind, m_base, m_property, executable.identifier_table->get(m_property));
}
DeprecatedString PutByIdWithThis::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString PutByIdWithThis::to_byte_string_impl(Bytecode::Executable const& executable) const
{
auto kind = property_kind_to_string(m_kind);
return DeprecatedString::formatted("PutByIdWithThis kind:{} base:{}, property:{} ({}) this_value:{}", kind, m_base, m_property, executable.identifier_table->get(m_property), m_this_value);
return ByteString::formatted("PutByIdWithThis kind:{} base:{}, property:{} ({}) this_value:{}", kind, m_base, m_property, executable.identifier_table->get(m_property), m_this_value);
}
DeprecatedString PutPrivateById::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString PutPrivateById::to_byte_string_impl(Bytecode::Executable const& executable) const
{
auto kind = property_kind_to_string(m_kind);
return DeprecatedString::formatted("PutPrivateById kind:{} base:{}, property:{} ({})", kind, m_base, m_property, executable.identifier_table->get(m_property));
return ByteString::formatted("PutPrivateById kind:{} base:{}, property:{} ({})", kind, m_base, m_property, executable.identifier_table->get(m_property));
}
DeprecatedString GetById::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString GetById::to_byte_string_impl(Bytecode::Executable const& executable) const
{
return DeprecatedString::formatted("GetById {} ({})", m_property, executable.identifier_table->get(m_property));
return ByteString::formatted("GetById {} ({})", m_property, executable.identifier_table->get(m_property));
}
DeprecatedString GetByIdWithThis::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString GetByIdWithThis::to_byte_string_impl(Bytecode::Executable const& executable) const
{
return DeprecatedString::formatted("GetByIdWithThis {} ({}) this_value:{}", m_property, executable.identifier_table->get(m_property), m_this_value);
return ByteString::formatted("GetByIdWithThis {} ({}) this_value:{}", m_property, executable.identifier_table->get(m_property), m_this_value);
}
DeprecatedString GetPrivateById::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString GetPrivateById::to_byte_string_impl(Bytecode::Executable const& executable) const
{
return DeprecatedString::formatted("GetPrivateById {} ({})", m_property, executable.identifier_table->get(m_property));
return ByteString::formatted("GetPrivateById {} ({})", m_property, executable.identifier_table->get(m_property));
}
DeprecatedString HasPrivateId::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString HasPrivateId::to_byte_string_impl(Bytecode::Executable const& executable) const
{
return DeprecatedString::formatted("HasPrivateId {} ({})", m_property, executable.identifier_table->get(m_property));
return ByteString::formatted("HasPrivateId {} ({})", m_property, executable.identifier_table->get(m_property));
}
DeprecatedString DeleteById::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString DeleteById::to_byte_string_impl(Bytecode::Executable const& executable) const
{
return DeprecatedString::formatted("DeleteById {} ({})", m_property, executable.identifier_table->get(m_property));
return ByteString::formatted("DeleteById {} ({})", m_property, executable.identifier_table->get(m_property));
}
DeprecatedString DeleteByIdWithThis::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString DeleteByIdWithThis::to_byte_string_impl(Bytecode::Executable const& executable) const
{
return DeprecatedString::formatted("DeleteByIdWithThis {} ({}) this_value:{}", m_property, executable.identifier_table->get(m_property), m_this_value);
return ByteString::formatted("DeleteByIdWithThis {} ({}) this_value:{}", m_property, executable.identifier_table->get(m_property), m_this_value);
}
DeprecatedString Jump::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString Jump::to_byte_string_impl(Bytecode::Executable const&) const
{
if (m_true_target.has_value())
return DeprecatedString::formatted("Jump {}", *m_true_target);
return DeprecatedString::formatted("Jump <empty>");
return ByteString::formatted("Jump {}", *m_true_target);
return ByteString::formatted("Jump <empty>");
}
DeprecatedString JumpConditional::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString JumpConditional::to_byte_string_impl(Bytecode::Executable const&) const
{
auto true_string = m_true_target.has_value() ? DeprecatedString::formatted("{}", *m_true_target) : "<empty>";
auto false_string = m_false_target.has_value() ? DeprecatedString::formatted("{}", *m_false_target) : "<empty>";
return DeprecatedString::formatted("JumpConditional true:{} false:{}", true_string, false_string);
auto true_string = m_true_target.has_value() ? ByteString::formatted("{}", *m_true_target) : "<empty>";
auto false_string = m_false_target.has_value() ? ByteString::formatted("{}", *m_false_target) : "<empty>";
return ByteString::formatted("JumpConditional true:{} false:{}", true_string, false_string);
}
DeprecatedString JumpNullish::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString JumpNullish::to_byte_string_impl(Bytecode::Executable const&) const
{
auto true_string = m_true_target.has_value() ? DeprecatedString::formatted("{}", *m_true_target) : "<empty>";
auto false_string = m_false_target.has_value() ? DeprecatedString::formatted("{}", *m_false_target) : "<empty>";
return DeprecatedString::formatted("JumpNullish null:{} nonnull:{}", true_string, false_string);
auto true_string = m_true_target.has_value() ? ByteString::formatted("{}", *m_true_target) : "<empty>";
auto false_string = m_false_target.has_value() ? ByteString::formatted("{}", *m_false_target) : "<empty>";
return ByteString::formatted("JumpNullish null:{} nonnull:{}", true_string, false_string);
}
DeprecatedString JumpUndefined::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString JumpUndefined::to_byte_string_impl(Bytecode::Executable const&) const
{
auto true_string = m_true_target.has_value() ? DeprecatedString::formatted("{}", *m_true_target) : "<empty>";
auto false_string = m_false_target.has_value() ? DeprecatedString::formatted("{}", *m_false_target) : "<empty>";
return DeprecatedString::formatted("JumpUndefined undefined:{} not undefined:{}", true_string, false_string);
auto true_string = m_true_target.has_value() ? ByteString::formatted("{}", *m_true_target) : "<empty>";
auto false_string = m_false_target.has_value() ? ByteString::formatted("{}", *m_false_target) : "<empty>";
return ByteString::formatted("JumpUndefined undefined:{} not undefined:{}", true_string, false_string);
}
static StringView call_type_to_string(CallType type)
@ -1565,30 +1565,30 @@ static StringView call_type_to_string(CallType type)
VERIFY_NOT_REACHED();
}
DeprecatedString Call::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString Call::to_byte_string_impl(Bytecode::Executable const& executable) const
{
auto type = call_type_to_string(m_type);
if (m_builtin.has_value())
return DeprecatedString::formatted("Call{} callee:{}, this:{}, first_arg:{} (builtin {})", type, m_callee, m_this_value, m_first_argument, m_builtin.value());
return ByteString::formatted("Call{} callee:{}, this:{}, first_arg:{} (builtin {})", type, m_callee, m_this_value, m_first_argument, m_builtin.value());
if (m_expression_string.has_value())
return DeprecatedString::formatted("Call{} callee:{}, this:{}, first_arg:{} ({})", type, m_callee, m_this_value, m_first_argument, executable.get_string(m_expression_string.value()));
return DeprecatedString::formatted("Call{} callee:{}, this:{}, first_arg:{}", type, m_callee, m_first_argument, m_this_value);
return ByteString::formatted("Call{} callee:{}, this:{}, first_arg:{} ({})", type, m_callee, m_this_value, m_first_argument, executable.get_string(m_expression_string.value()));
return ByteString::formatted("Call{} callee:{}, this:{}, first_arg:{}", type, m_callee, m_first_argument, m_this_value);
}
DeprecatedString CallWithArgumentArray::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString CallWithArgumentArray::to_byte_string_impl(Bytecode::Executable const& executable) const
{
auto type = call_type_to_string(m_type);
if (m_expression_string.has_value())
return DeprecatedString::formatted("CallWithArgumentArray{} callee:{}, this:{}, arguments:[...acc] ({})", type, m_callee, m_this_value, executable.get_string(m_expression_string.value()));
return DeprecatedString::formatted("CallWithArgumentArray{} callee:{}, this:{}, arguments:[...acc]", type, m_callee, m_this_value);
return ByteString::formatted("CallWithArgumentArray{} callee:{}, this:{}, arguments:[...acc] ({})", type, m_callee, m_this_value, executable.get_string(m_expression_string.value()));
return ByteString::formatted("CallWithArgumentArray{} callee:{}, this:{}, arguments:[...acc]", type, m_callee, m_this_value);
}
DeprecatedString SuperCallWithArgumentArray::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString SuperCallWithArgumentArray::to_byte_string_impl(Bytecode::Executable const&) const
{
return "SuperCallWithArgumentArray arguments:[...acc]"sv;
}
DeprecatedString NewFunction::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString NewFunction::to_byte_string_impl(Bytecode::Executable const&) const
{
StringBuilder builder;
builder.append("NewFunction"sv);
@ -1598,215 +1598,215 @@ DeprecatedString NewFunction::to_deprecated_string_impl(Bytecode::Executable con
builder.appendff(" lhs_name:{}"sv, m_lhs_name.value());
if (m_home_object.has_value())
builder.appendff(" home_object:{}"sv, m_home_object.value());
return builder.to_deprecated_string();
return builder.to_byte_string();
}
DeprecatedString NewClass::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString NewClass::to_byte_string_impl(Bytecode::Executable const&) const
{
StringBuilder builder;
auto name = m_class_expression.name();
builder.appendff("NewClass '{}'"sv, name.is_null() ? ""sv : name);
if (m_lhs_name.has_value())
builder.appendff(" lhs_name:{}"sv, m_lhs_name.value());
return builder.to_deprecated_string();
return builder.to_byte_string();
}
DeprecatedString Return::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString Return::to_byte_string_impl(Bytecode::Executable const&) const
{
return "Return";
}
DeprecatedString Increment::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString Increment::to_byte_string_impl(Bytecode::Executable const&) const
{
return "Increment";
}
DeprecatedString Decrement::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString Decrement::to_byte_string_impl(Bytecode::Executable const&) const
{
return "Decrement";
}
DeprecatedString Throw::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString Throw::to_byte_string_impl(Bytecode::Executable const&) const
{
return "Throw";
}
DeprecatedString ThrowIfNotObject::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString ThrowIfNotObject::to_byte_string_impl(Bytecode::Executable const&) const
{
return "ThrowIfNotObject";
}
DeprecatedString ThrowIfNullish::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString ThrowIfNullish::to_byte_string_impl(Bytecode::Executable const&) const
{
return "ThrowIfNullish";
}
DeprecatedString EnterUnwindContext::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString EnterUnwindContext::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("EnterUnwindContext entry:{}", m_entry_point);
return ByteString::formatted("EnterUnwindContext entry:{}", m_entry_point);
}
DeprecatedString ScheduleJump::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString ScheduleJump::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("ScheduleJump {}", m_target);
return ByteString::formatted("ScheduleJump {}", m_target);
}
DeprecatedString LeaveLexicalEnvironment::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString LeaveLexicalEnvironment::to_byte_string_impl(Bytecode::Executable const&) const
{
return "LeaveLexicalEnvironment"sv;
}
DeprecatedString LeaveUnwindContext::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString LeaveUnwindContext::to_byte_string_impl(Bytecode::Executable const&) const
{
return "LeaveUnwindContext";
}
DeprecatedString ContinuePendingUnwind::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString ContinuePendingUnwind::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("ContinuePendingUnwind resume:{}", m_resume_target);
return ByteString::formatted("ContinuePendingUnwind resume:{}", m_resume_target);
}
DeprecatedString Yield::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString Yield::to_byte_string_impl(Bytecode::Executable const&) const
{
if (m_continuation_label.has_value())
return DeprecatedString::formatted("Yield continuation:@{}", m_continuation_label->block().name());
return DeprecatedString::formatted("Yield return");
return ByteString::formatted("Yield continuation:@{}", m_continuation_label->block().name());
return ByteString::formatted("Yield return");
}
DeprecatedString Await::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString Await::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("Await continuation:@{}", m_continuation_label.block().name());
return ByteString::formatted("Await continuation:@{}", m_continuation_label.block().name());
}
DeprecatedString GetByValue::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString GetByValue::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("GetByValue base:{}", m_base);
return ByteString::formatted("GetByValue base:{}", m_base);
}
DeprecatedString GetByValueWithThis::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString GetByValueWithThis::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("GetByValueWithThis base:{} this_value:{}", m_base, m_this_value);
return ByteString::formatted("GetByValueWithThis base:{} this_value:{}", m_base, m_this_value);
}
DeprecatedString PutByValue::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString PutByValue::to_byte_string_impl(Bytecode::Executable const&) const
{
auto kind = property_kind_to_string(m_kind);
return DeprecatedString::formatted("PutByValue kind:{} base:{}, property:{}", kind, m_base, m_property);
return ByteString::formatted("PutByValue kind:{} base:{}, property:{}", kind, m_base, m_property);
}
DeprecatedString PutByValueWithThis::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString PutByValueWithThis::to_byte_string_impl(Bytecode::Executable const&) const
{
auto kind = property_kind_to_string(m_kind);
return DeprecatedString::formatted("PutByValueWithThis kind:{} base:{}, property:{} this_value:{}", kind, m_base, m_property, m_this_value);
return ByteString::formatted("PutByValueWithThis kind:{} base:{}, property:{} this_value:{}", kind, m_base, m_property, m_this_value);
}
DeprecatedString DeleteByValue::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString DeleteByValue::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("DeleteByValue base:{}", m_base);
return ByteString::formatted("DeleteByValue base:{}", m_base);
}
DeprecatedString DeleteByValueWithThis::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString DeleteByValueWithThis::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("DeleteByValueWithThis base:{} this_value:{}", m_base, m_this_value);
return ByteString::formatted("DeleteByValueWithThis base:{} this_value:{}", m_base, m_this_value);
}
DeprecatedString GetIterator::to_deprecated_string_impl(Executable const&) const
ByteString GetIterator::to_byte_string_impl(Executable const&) const
{
auto hint = m_hint == IteratorHint::Sync ? "sync" : "async";
return DeprecatedString::formatted("GetIterator hint:{}", hint);
return ByteString::formatted("GetIterator hint:{}", hint);
}
DeprecatedString GetMethod::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString GetMethod::to_byte_string_impl(Bytecode::Executable const& executable) const
{
return DeprecatedString::formatted("GetMethod {} ({})", m_property, executable.identifier_table->get(m_property));
return ByteString::formatted("GetMethod {} ({})", m_property, executable.identifier_table->get(m_property));
}
DeprecatedString GetObjectPropertyIterator::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString GetObjectPropertyIterator::to_byte_string_impl(Bytecode::Executable const&) const
{
return "GetObjectPropertyIterator";
}
DeprecatedString IteratorClose::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString IteratorClose::to_byte_string_impl(Bytecode::Executable const&) const
{
if (!m_completion_value.has_value())
return DeprecatedString::formatted("IteratorClose completion_type={} completion_value=<empty>", to_underlying(m_completion_type));
return ByteString::formatted("IteratorClose completion_type={} completion_value=<empty>", to_underlying(m_completion_type));
auto completion_value_string = m_completion_value->to_string_without_side_effects();
return DeprecatedString::formatted("IteratorClose completion_type={} completion_value={}", to_underlying(m_completion_type), completion_value_string);
return ByteString::formatted("IteratorClose completion_type={} completion_value={}", to_underlying(m_completion_type), completion_value_string);
}
DeprecatedString AsyncIteratorClose::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString AsyncIteratorClose::to_byte_string_impl(Bytecode::Executable const&) const
{
if (!m_completion_value.has_value())
return DeprecatedString::formatted("AsyncIteratorClose completion_type={} completion_value=<empty>", to_underlying(m_completion_type));
return ByteString::formatted("AsyncIteratorClose completion_type={} completion_value=<empty>", to_underlying(m_completion_type));
auto completion_value_string = m_completion_value->to_string_without_side_effects();
return DeprecatedString::formatted("AsyncIteratorClose completion_type={} completion_value={}", to_underlying(m_completion_type), completion_value_string);
return ByteString::formatted("AsyncIteratorClose completion_type={} completion_value={}", to_underlying(m_completion_type), completion_value_string);
}
DeprecatedString IteratorNext::to_deprecated_string_impl(Executable const&) const
ByteString IteratorNext::to_byte_string_impl(Executable const&) const
{
return "IteratorNext";
}
DeprecatedString ResolveThisBinding::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString ResolveThisBinding::to_byte_string_impl(Bytecode::Executable const&) const
{
return "ResolveThisBinding"sv;
}
DeprecatedString ResolveSuperBase::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString ResolveSuperBase::to_byte_string_impl(Bytecode::Executable const&) const
{
return "ResolveSuperBase"sv;
}
DeprecatedString GetNewTarget::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString GetNewTarget::to_byte_string_impl(Bytecode::Executable const&) const
{
return "GetNewTarget"sv;
}
DeprecatedString GetImportMeta::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString GetImportMeta::to_byte_string_impl(Bytecode::Executable const&) const
{
return "GetImportMeta"sv;
}
DeprecatedString TypeofVariable::to_deprecated_string_impl(Bytecode::Executable const& executable) const
ByteString TypeofVariable::to_byte_string_impl(Bytecode::Executable const& executable) const
{
return DeprecatedString::formatted("TypeofVariable {} ({})", m_identifier, executable.identifier_table->get(m_identifier));
return ByteString::formatted("TypeofVariable {} ({})", m_identifier, executable.identifier_table->get(m_identifier));
}
DeprecatedString TypeofLocal::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString TypeofLocal::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("TypeofLocal {}", m_index);
return ByteString::formatted("TypeofLocal {}", m_index);
}
DeprecatedString ToNumeric::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString ToNumeric::to_byte_string_impl(Bytecode::Executable const&) const
{
return "ToNumeric"sv;
}
DeprecatedString BlockDeclarationInstantiation::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString BlockDeclarationInstantiation::to_byte_string_impl(Bytecode::Executable const&) const
{
return "BlockDeclarationInstantiation"sv;
}
DeprecatedString ImportCall::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString ImportCall::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("ImportCall specifier:{} options:{}"sv, m_specifier, m_options);
return ByteString::formatted("ImportCall specifier:{} options:{}"sv, m_specifier, m_options);
}
DeprecatedString Catch::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString Catch::to_byte_string_impl(Bytecode::Executable const&) const
{
return "Catch"sv;
}
DeprecatedString GetObjectFromIteratorRecord::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString GetObjectFromIteratorRecord::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("GetObjectFromIteratorRecord object:{} <- iterator_record:{}", m_object, m_iterator_record);
return ByteString::formatted("GetObjectFromIteratorRecord object:{} <- iterator_record:{}", m_object, m_iterator_record);
}
DeprecatedString GetNextMethodFromIteratorRecord::to_deprecated_string_impl(Bytecode::Executable const&) const
ByteString GetNextMethodFromIteratorRecord::to_byte_string_impl(Bytecode::Executable const&) const
{
return DeprecatedString::formatted("GetNextMethodFromIteratorRecord next_method:{} <- iterator_record:{}", m_next_method, m_iterator_record);
return ByteString::formatted("GetNextMethodFromIteratorRecord next_method:{} <- iterator_record:{}", m_next_method, m_iterator_record);
}
}

View file

@ -39,7 +39,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Register src() const { return m_src; }
@ -56,7 +56,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Value value() const { return m_value; }
@ -73,7 +73,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Register dst() const { return m_dst; }
@ -105,22 +105,22 @@ private:
O(RightShift, right_shift) \
O(UnsignedRightShift, unsigned_right_shift)
#define JS_DECLARE_COMMON_BINARY_OP(OpTitleCase, op_snake_case) \
class OpTitleCase final : public Instruction { \
public: \
explicit OpTitleCase(Register lhs_reg) \
: Instruction(Type::OpTitleCase, sizeof(*this)) \
, m_lhs_reg(lhs_reg) \
{ \
} \
\
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const; \
\
Register lhs() const { return m_lhs_reg; } \
\
private: \
Register m_lhs_reg; \
#define JS_DECLARE_COMMON_BINARY_OP(OpTitleCase, op_snake_case) \
class OpTitleCase final : public Instruction { \
public: \
explicit OpTitleCase(Register lhs_reg) \
: Instruction(Type::OpTitleCase, sizeof(*this)) \
, m_lhs_reg(lhs_reg) \
{ \
} \
\
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
ByteString to_byte_string_impl(Bytecode::Executable const&) const; \
\
Register lhs() const { return m_lhs_reg; } \
\
private: \
Register m_lhs_reg; \
};
JS_ENUMERATE_COMMON_BINARY_OPS(JS_DECLARE_COMMON_BINARY_OP)
@ -133,16 +133,16 @@ JS_ENUMERATE_COMMON_BINARY_OPS(JS_DECLARE_COMMON_BINARY_OP)
O(UnaryMinus, unary_minus) \
O(Typeof, typeof_)
#define JS_DECLARE_COMMON_UNARY_OP(OpTitleCase, op_snake_case) \
class OpTitleCase final : public Instruction { \
public: \
OpTitleCase() \
: Instruction(Type::OpTitleCase, sizeof(*this)) \
{ \
} \
\
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const; \
#define JS_DECLARE_COMMON_UNARY_OP(OpTitleCase, op_snake_case) \
class OpTitleCase final : public Instruction { \
public: \
OpTitleCase() \
: Instruction(Type::OpTitleCase, sizeof(*this)) \
{ \
} \
\
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
ByteString to_byte_string_impl(Bytecode::Executable const&) const; \
};
JS_ENUMERATE_COMMON_UNARY_OPS(JS_DECLARE_COMMON_UNARY_OP)
@ -157,7 +157,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
StringTableIndex index() const { return m_string; }
@ -173,7 +173,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class NewRegExp final : public Instruction {
@ -187,7 +187,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
StringTableIndex source_index() const { return m_source_index; }
StringTableIndex flags_index() const { return m_flags_index; }
@ -202,22 +202,22 @@ private:
#define JS_ENUMERATE_NEW_BUILTIN_ERROR_OPS(O) \
O(TypeError)
#define JS_DECLARE_NEW_BUILTIN_ERROR_OP(ErrorName) \
class New##ErrorName final : public Instruction { \
public: \
explicit New##ErrorName(StringTableIndex error_string) \
: Instruction(Type::New##ErrorName, sizeof(*this)) \
, m_error_string(error_string) \
{ \
} \
\
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const; \
\
StringTableIndex error_string() const { return m_error_string; } \
\
private: \
StringTableIndex m_error_string; \
#define JS_DECLARE_NEW_BUILTIN_ERROR_OP(ErrorName) \
class New##ErrorName final : public Instruction { \
public: \
explicit New##ErrorName(StringTableIndex error_string) \
: Instruction(Type::New##ErrorName, sizeof(*this)) \
, m_error_string(error_string) \
{ \
} \
\
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
ByteString to_byte_string_impl(Bytecode::Executable const&) const; \
\
StringTableIndex error_string() const { return m_error_string; } \
\
private: \
StringTableIndex m_error_string; \
};
JS_ENUMERATE_NEW_BUILTIN_ERROR_OPS(JS_DECLARE_NEW_BUILTIN_ERROR_OP)
@ -236,7 +236,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
size_t length_impl(size_t excluded_names_count) const
{
@ -262,7 +262,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Crypto::SignedBigInteger const& bigint() const { return m_bigint; }
@ -288,7 +288,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
size_t length_impl(size_t element_count) const
{
@ -323,7 +323,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
ReadonlySpan<Value> values() const { return m_values.span(); }
@ -341,7 +341,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Register lhs() const { return m_lhs; }
bool is_spread() const { return m_is_spread; }
@ -361,7 +361,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Register specifier() const { return m_specifier; }
Register options() const { return m_options; }
@ -379,7 +379,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class ConcatString final : public Instruction {
@ -391,7 +391,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Register lhs() const { return m_lhs; }
@ -412,7 +412,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class EnterObjectEnvironment final : public Instruction {
@ -423,7 +423,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class Catch final : public Instruction {
@ -434,7 +434,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class CreateVariable final : public Instruction {
@ -450,7 +450,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
IdentifierTableIndex identifier() const { return m_identifier; }
EnvironmentMode mode() const { return m_mode; }
@ -482,7 +482,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
IdentifierTableIndex identifier() const { return m_identifier; }
EnvironmentMode mode() const { return m_mode; }
@ -505,7 +505,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
size_t index() const { return m_index; }
@ -525,7 +525,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
IdentifierTableIndex identifier() const { return m_identifier; }
u32 cache_index() const { return m_cache_index; }
@ -549,7 +549,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
IdentifierTableIndex identifier() const { return m_identifier; }
u32 cache_index() const { return m_cache_index; }
@ -569,7 +569,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
IdentifierTableIndex identifier() const { return m_identifier; }
u32 cache_index() const { return m_cache_index; }
@ -588,7 +588,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
size_t index() const { return m_index; }
@ -605,7 +605,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
IdentifierTableIndex identifier() const { return m_identifier; }
@ -623,7 +623,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
IdentifierTableIndex property() const { return m_property; }
u32 cache_index() const { return m_cache_index; }
@ -644,7 +644,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
IdentifierTableIndex property() const { return m_property; }
Register this_value() const { return m_this_value; }
@ -665,7 +665,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
IdentifierTableIndex property() const { return m_property; }
@ -682,7 +682,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
IdentifierTableIndex property() const { return m_property; }
@ -711,7 +711,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Register base() const { return m_base; }
IdentifierTableIndex property() const { return m_property; }
@ -738,7 +738,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Register base() const { return m_base; }
Register this_value() const { return m_this_value; }
@ -765,7 +765,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Register base() const { return m_base; }
IdentifierTableIndex property() const { return m_property; }
@ -785,7 +785,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
IdentifierTableIndex property() const { return m_property; }
@ -803,7 +803,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Register this_value() const { return m_this_value; }
IdentifierTableIndex property() const { return m_property; }
@ -822,7 +822,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Register base() const { return m_base; }
@ -840,7 +840,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Register base() const { return m_base; }
Register this_value() const { return m_this_value; }
@ -861,7 +861,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Register base() const { return m_base; }
Register property() const { return m_property; }
@ -885,7 +885,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Register base() const { return m_base; }
Register property() const { return m_property; }
@ -908,7 +908,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Register base() const { return m_base; }
@ -929,7 +929,7 @@ public:
Register this_value() const { return m_this_value; }
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
private:
Register m_base;
@ -955,7 +955,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
auto& true_target() const { return m_true_target; }
auto& false_target() const { return m_false_target; }
@ -973,7 +973,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class JumpNullish final : public Jump {
@ -984,7 +984,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class JumpUndefined final : public Jump {
@ -995,7 +995,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
enum class CallType {
@ -1029,7 +1029,7 @@ public:
Optional<Builtin> const& builtin() const { return m_builtin; }
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
private:
Register m_callee;
@ -1058,7 +1058,7 @@ public:
Optional<StringTableIndex> const& expression_string() const { return m_expression_string; }
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
private:
Register m_callee;
@ -1076,7 +1076,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
bool is_synthetic() const { return m_is_synthetic; }
@ -1094,7 +1094,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
ClassExpression const& class_expression() const { return m_class_expression; }
Optional<IdentifierTableIndex> const& lhs_name() const { return m_lhs_name; }
@ -1115,7 +1115,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
FunctionExpression const& function_node() const { return m_function_node; }
Optional<IdentifierTableIndex> const& lhs_name() const { return m_lhs_name; }
@ -1136,7 +1136,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
ScopeNode const& scope_node() const { return m_scope_node; }
@ -1154,7 +1154,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class Increment final : public Instruction {
@ -1165,7 +1165,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class Decrement final : public Instruction {
@ -1176,7 +1176,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class ToNumeric final : public Instruction {
@ -1187,7 +1187,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class Throw final : public Instruction {
@ -1200,7 +1200,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class ThrowIfNotObject final : public Instruction {
@ -1211,7 +1211,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class ThrowIfNullish final : public Instruction {
@ -1222,7 +1222,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class EnterUnwindContext final : public Instruction {
@ -1236,7 +1236,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
auto& entry_point() const { return m_entry_point; }
@ -1266,7 +1266,7 @@ public:
Label target() const { return m_target; }
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
private:
Label m_target;
@ -1280,7 +1280,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class LeaveUnwindContext final : public Instruction {
@ -1291,7 +1291,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class ContinuePendingUnwind final : public Instruction {
@ -1305,7 +1305,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
auto& resume_target() const { return m_resume_target; }
@ -1329,7 +1329,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
auto& continuation() const { return m_continuation_label; }
@ -1348,7 +1348,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
auto& continuation() const { return m_continuation_label; }
@ -1365,7 +1365,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
IteratorHint hint() const { return m_hint; }
@ -1383,7 +1383,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Register object() const { return m_object; }
Register iterator_record() const { return m_iterator_record; }
@ -1403,7 +1403,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Register next_method() const { return m_next_method; }
Register iterator_record() const { return m_iterator_record; }
@ -1422,7 +1422,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
IdentifierTableIndex property() const { return m_property; }
@ -1438,7 +1438,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class IteratorClose final : public Instruction {
@ -1451,7 +1451,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Completion::Type completion_type() const { return m_completion_type; }
Optional<Value> const& completion_value() const { return m_completion_value; }
@ -1471,7 +1471,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
Completion::Type completion_type() const { return m_completion_type; }
Optional<Value> const& completion_value() const { return m_completion_value; }
@ -1489,7 +1489,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class ResolveThisBinding final : public Instruction {
@ -1500,7 +1500,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class ResolveSuperBase final : public Instruction {
@ -1511,7 +1511,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class GetNewTarget final : public Instruction {
@ -1522,7 +1522,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class GetImportMeta final : public Instruction {
@ -1533,7 +1533,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
};
class TypeofVariable final : public Instruction {
@ -1545,7 +1545,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
IdentifierTableIndex identifier() const { return m_identifier; }
@ -1562,7 +1562,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;
size_t index() const { return m_index; }

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/DistinctNumeric.h>
#include <AK/Vector.h>
#include <LibRegex/RegexParser.h>
@ -17,7 +17,7 @@ AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(size_t, RegexTableIndex, Comparison);
struct ParsedRegex {
regex::Parser::Result regex;
DeprecatedString pattern;
ByteString pattern;
regex::RegexOptions<ECMAScriptFlags> flags;
};

View file

@ -8,13 +8,13 @@
namespace JS::Bytecode {
StringTableIndex StringTable::insert(DeprecatedString string)
StringTableIndex StringTable::insert(ByteString string)
{
m_strings.append(move(string));
return m_strings.size() - 1;
}
DeprecatedString const& StringTable::get(StringTableIndex index) const
ByteString const& StringTable::get(StringTableIndex index) const
{
return m_strings[index.value()];
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/DistinctNumeric.h>
#include <AK/Vector.h>
@ -21,13 +21,13 @@ class StringTable {
public:
StringTable() = default;
StringTableIndex insert(DeprecatedString);
DeprecatedString const& get(StringTableIndex) const;
StringTableIndex insert(ByteString);
ByteString const& get(StringTableIndex) const;
void dump() const;
bool is_empty() const { return m_strings.is_empty(); }
private:
Vector<DeprecatedString> m_strings;
Vector<ByteString> m_strings;
};
}

View file

@ -84,7 +84,7 @@ JS_DEFINE_NATIVE_FUNCTION($262Object::detach_array_buffer)
JS_DEFINE_NATIVE_FUNCTION($262Object::eval_script)
{
auto source_text = TRY(vm.argument(0).to_deprecated_string(vm));
auto source_text = TRY(vm.argument(0).to_byte_string(vm));
// 1. Let hostDefined be any host-defined values for the provided sourceText (obtained in an implementation dependent manner)

View file

@ -36,7 +36,7 @@ void GlobalObject::visit_edges(Cell::Visitor& visitor)
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::print)
{
auto string = TRY(vm.argument(0).to_deprecated_string(vm));
auto string = TRY(vm.argument(0).to_byte_string(vm));
outln("{}", string);
return js_undefined();
}

View file

@ -214,7 +214,7 @@ ThrowCompletionOr<u32> CyclicModule::inner_module_linking(VM& vm, Vector<Module*
// b. Return index.
// Note: Step 1, 1.a and 1.b are handled in Module.cpp
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] inner_module_linking[{}](vm, {}, {})", this, DeprecatedString::join(',', stack), index);
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] inner_module_linking[{}](vm, {}, {})", this, ByteString::join(',', stack), index);
// 2. If module.[[Status]] is linking, linked, evaluating-async, or evaluated, then
if (m_status == ModuleStatus::Linking || m_status == ModuleStatus::Linked || m_status == ModuleStatus::EvaluatingAsync || m_status == ModuleStatus::Evaluated) {
@ -418,7 +418,7 @@ ThrowCompletionOr<Promise*> CyclicModule::evaluate(VM& vm)
// 16.2.1.5.2.1 InnerModuleEvaluation ( module, stack, index ), https://tc39.es/ecma262/#sec-innermoduleevaluation
ThrowCompletionOr<u32> CyclicModule::inner_module_evaluation(VM& vm, Vector<Module*>& stack, u32 index)
{
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] inner_module_evaluation[{}](vm, {}, {})", this, DeprecatedString::join(", "sv, stack), index);
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] inner_module_evaluation[{}](vm, {}, {})", this, ByteString::join(", "sv, stack), index);
// Note: Step 1 is performed in Module.cpp
// 2. If module.[[Status]] is evaluating-async or evaluated, then

View file

@ -66,7 +66,7 @@ Heap::Heap(VM& vm)
Heap::~Heap()
{
vm().string_cache().clear();
vm().deprecated_string_cache().clear();
vm().byte_string_cache().clear();
collect_garbage(CollectionType::CollectEverything);
}
@ -198,7 +198,7 @@ public:
for (auto& it : m_graph) {
AK::JsonArray edges;
for (auto const& value : it.value.edges) {
edges.must_append(DeprecatedString::formatted("{}", value));
edges.must_append(ByteString::formatted("{}", value));
}
auto node = AK::JsonObject();
@ -207,7 +207,7 @@ public:
auto location = it.value.root_origin->location;
switch (type) {
case HeapRoot::Type::Handle:
node.set("root"sv, DeprecatedString::formatted("Handle {} {}:{}", location->function_name(), location->filename(), location->line_number()));
node.set("root"sv, ByteString::formatted("Handle {} {}:{}", location->function_name(), location->filename(), location->line_number()));
break;
case HeapRoot::Type::MarkedVector:
node.set("root"sv, "MarkedVector");
@ -222,7 +222,7 @@ public:
node.set("root"sv, "VM");
break;
case HeapRoot::Type::SafeFunction:
node.set("root"sv, DeprecatedString::formatted("SafeFunction {} {}:{}", location->function_name(), location->filename(), location->line_number()));
node.set("root"sv, ByteString::formatted("SafeFunction {} {}:{}", location->function_name(), location->filename(), location->line_number()));
break;
default:
VERIFY_NOT_REACHED();
@ -230,7 +230,7 @@ public:
}
node.set("class_name"sv, it.value.class_name);
node.set("edges"sv, edges);
graph.set(DeprecatedString::number(it.key), node);
graph.set(ByteString::number(it.key), node);
}
return graph;

View file

@ -1470,7 +1470,7 @@ void Compiler::compile_return(Bytecode::Op::Return const&)
}
}
static Value cxx_new_string(VM& vm, DeprecatedString const& string)
static Value cxx_new_string(VM& vm, ByteString const& string)
{
return PrimitiveString::create(vm, string);
}
@ -3428,7 +3428,7 @@ void Compiler::compile_has_private_id(Bytecode::Op::HasPrivateId const& op)
}
# define COMPILE_NEW_BUILTIN_ERROR_OP(NewErrorName, new_error_name, ErrorName) \
static Value cxx_##new_error_name(VM& vm, DeprecatedString const& error_string) \
static Value cxx_##new_error_name(VM& vm, ByteString const& error_string) \
{ \
return ErrorName::create(*vm.current_realm(), error_string); \
} \
@ -3663,7 +3663,7 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
default:
if constexpr (LOG_JIT_FAILURE) {
dbgln("\033[31;1mJIT compilation failed\033[0m: {}", bytecode_executable.name);
dbgln("Unsupported bytecode op: {}", op.to_deprecated_string(bytecode_executable));
dbgln("Unsupported bytecode op: {}", op.to_byte_string(bytecode_executable));
}
return nullptr;
}

View file

@ -67,7 +67,7 @@ public:
virtual ~JITSymbolProvider() override = default;
virtual DeprecatedString symbolicate(FlatPtr address, u32* offset = nullptr) const override
virtual ByteString symbolicate(FlatPtr address, u32* offset = nullptr) const override
{
auto base = bit_cast<FlatPtr>(m_executable.code_bytes().data());
auto native_offset = static_cast<u32>(address - base);
@ -83,9 +83,9 @@ public:
return BytecodeMapping::EXECUTABLE_LABELS[entry.bytecode_offset];
if (entry.bytecode_offset == 0)
return DeprecatedString::formatted("Block {}", entry.block_index + 1);
return ByteString::formatted("Block {}", entry.block_index + 1);
return DeprecatedString::formatted("{}:{:x}", entry.block_index + 1, entry.bytecode_offset);
return ByteString::formatted("{}:{:x}", entry.block_index + 1, entry.bytecode_offset);
}
private:
@ -127,7 +127,7 @@ void NativeExecutable::dump_disassembly([[maybe_unused]] Bytecode::Executable co
if (block.size() != 0) {
VERIFY(mapping->bytecode_offset < block.size());
auto const& instruction = *reinterpret_cast<Bytecode::Instruction const*>(block.data() + mapping->bytecode_offset);
dbgln("{}:{:x} {}:", mapping->block_index + 1, mapping->bytecode_offset, instruction.to_deprecated_string(executable));
dbgln("{}:{:x} {}:", mapping->block_index + 1, mapping->bytecode_offset, instruction.to_byte_string(executable));
}
}
}
@ -146,7 +146,7 @@ void NativeExecutable::dump_disassembly([[maybe_unused]] Bytecode::Executable co
builder.append(" "sv);
}
builder.append(" "sv);
builder.append(insn.value().to_deprecated_string(virtual_offset, &symbol_provider));
builder.append(insn.value().to_byte_string(virtual_offset, &symbol_provider));
dbgln("{}", builder.string_view());
for (size_t bytes_printed = 7; bytes_printed < length; bytes_printed += 7) {

View file

@ -17,8 +17,8 @@
namespace JS {
HashMap<DeprecatedFlyString, TokenType> Lexer::s_keywords;
HashMap<DeprecatedString, TokenType> Lexer::s_three_char_tokens;
HashMap<DeprecatedString, TokenType> Lexer::s_two_char_tokens;
HashMap<ByteString, TokenType> Lexer::s_three_char_tokens;
HashMap<ByteString, TokenType> Lexer::s_two_char_tokens;
HashMap<char, TokenType> Lexer::s_single_char_tokens;
Lexer::Lexer(StringView source, StringView filename, size_t line_number, size_t line_column)
@ -159,7 +159,7 @@ void Lexer::consume()
if (is_line_terminator()) {
if constexpr (LEXER_DEBUG) {
DeprecatedString type;
ByteString type;
if (m_current_char == '\n')
type = "LINE FEED";
else if (m_current_char == '\r')
@ -567,7 +567,7 @@ Token Lexer::next()
// This is being used to communicate info about invalid tokens to the parser, which then
// can turn that into more specific error messages - instead of us having to make up a
// bunch of Invalid* tokens (bad numeric literals, unterminated comments etc.)
DeprecatedString token_message;
ByteString token_message;
Optional<DeprecatedFlyString> identifier;
size_t identifier_length = 0;
@ -844,7 +844,7 @@ Token Lexer::next()
} else {
m_current_token = Token(
token_type,
String::from_deprecated_string(token_message).release_value_but_fixme_should_propagate_errors(),
String::from_byte_string(token_message).release_value_but_fixme_should_propagate_errors(),
m_source.substring_view(trivia_start - 1, value_start - trivia_start),
m_source.substring_view(value_start - 1, m_position - value_start),
m_filename,

View file

@ -8,7 +8,7 @@
#include "Token.h"
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/HashMap.h>
#include <AK/String.h>
#include <AK/StringView.h>
@ -21,7 +21,7 @@ public:
Token next();
DeprecatedString const& source() const { return m_source; }
ByteString const& source() const { return m_source; }
String const& filename() const { return m_filename; }
void disallow_html_comments() { m_allow_html_comments = false; }
@ -58,7 +58,7 @@ private:
TokenType consume_regex_literal();
DeprecatedString m_source;
ByteString m_source;
size_t m_position { 0 };
Token m_current_token;
char m_current_char { 0 };
@ -81,8 +81,8 @@ private:
Optional<size_t> m_hit_invalid_unicode;
static HashMap<DeprecatedFlyString, TokenType> s_keywords;
static HashMap<DeprecatedString, TokenType> s_three_char_tokens;
static HashMap<DeprecatedString, TokenType> s_two_char_tokens;
static HashMap<ByteString, TokenType> s_three_char_tokens;
static HashMap<ByteString, TokenType> s_two_char_tokens;
static HashMap<char, TokenType> s_single_char_tokens;
struct ParsedIdentifiers : public RefCounted<ParsedIdentifiers> {

View file

@ -17,7 +17,7 @@ namespace JS {
JS_DEFINE_ALLOCATOR(Module);
Module::Module(Realm& realm, DeprecatedString filename, Script::HostDefined* host_defined)
Module::Module(Realm& realm, ByteString filename, Script::HostDefined* host_defined)
: m_realm(realm)
, m_host_defined(host_defined)
, m_filename(move(filename))

View file

@ -117,7 +117,7 @@ public:
virtual PromiseCapability& load_requested_modules(GCPtr<GraphLoadingState::HostDefined>) = 0;
protected:
Module(Realm&, DeprecatedString filename, Script::HostDefined* host_defined = nullptr);
Module(Realm&, ByteString filename, Script::HostDefined* host_defined = nullptr);
virtual void visit_edges(Cell::Visitor&) override;
@ -140,7 +140,7 @@ private:
Script::HostDefined* m_host_defined { nullptr }; // [[HostDefined]]
// Needed for potential lookups of modules.
DeprecatedString m_filename;
ByteString m_filename;
};
class CyclicModule;

View file

@ -438,7 +438,7 @@ public:
private:
void throw_identifier_declared(DeprecatedFlyString const& name, NonnullRefPtr<Declaration const> const& declaration)
{
m_parser.syntax_error(DeprecatedString::formatted("Identifier '{}' already declared", name), declaration->source_range().start);
m_parser.syntax_error(ByteString::formatted("Identifier '{}' already declared", name), declaration->source_range().start);
}
Parser& m_parser;
@ -612,7 +612,7 @@ Parser::ParserState::ParserState(Lexer l, Program::Type program_type)
}
Parser::Parser(Lexer lexer, Program::Type program_type, Optional<EvalInitialState> initial_state_for_eval)
: m_source_code(SourceCode::create(lexer.filename(), String::from_deprecated_string(lexer.source()).release_value_but_fixme_should_propagate_errors()))
: m_source_code(SourceCode::create(lexer.filename(), String::from_byte_string(lexer.source()).release_value_but_fixme_should_propagate_errors()))
, m_state(move(lexer), program_type)
, m_program_type(program_type)
{
@ -790,7 +790,7 @@ void Parser::parse_module(Program& program)
}
if (!found)
syntax_error(DeprecatedString::formatted("'{}' in export is not declared", exported_name), export_statement->source_range().start);
syntax_error(ByteString::formatted("'{}' in export is not declared", exported_name), export_statement->source_range().start);
}
}
}
@ -883,9 +883,9 @@ NonnullRefPtr<Statement const> Parser::parse_statement(AllowLabelledFunction all
if (lookahead_token.type() == TokenType::Function && !lookahead_token.trivia_contains_line_terminator())
syntax_error("Async function declaration not allowed in single-statement context");
} else if (match(TokenType::Function) || match(TokenType::Class)) {
syntax_error(DeprecatedString::formatted("{} declaration not allowed in single-statement context", m_state.current_token.name()));
syntax_error(ByteString::formatted("{} declaration not allowed in single-statement context", m_state.current_token.name()));
} else if (match(TokenType::Let) && next_token().type() == TokenType::BracketOpen) {
syntax_error(DeprecatedString::formatted("let followed by [ is not allowed in single-statement context"));
syntax_error(ByteString::formatted("let followed by [ is not allowed in single-statement context"));
}
auto expr = parse_expression(0);
@ -1078,7 +1078,7 @@ RefPtr<FunctionExpression const> Parser::try_parse_arrow_function_expression(boo
auto function_start_offset = rule_start.position().offset;
auto function_end_offset = position().offset - m_state.current_token.trivia().length();
auto source_text = DeprecatedString { m_state.lexer.source().substring_view(function_start_offset, function_end_offset - function_start_offset) };
auto source_text = ByteString { m_state.lexer.source().substring_view(function_start_offset, function_end_offset - function_start_offset) };
return create_ast_node<FunctionExpression>(
{ m_source_code, rule_start.position(), position() }, nullptr, move(source_text),
move(body), move(parameters), function_length, function_kind, body->in_strict_mode(),
@ -1134,7 +1134,7 @@ RefPtr<LabelledStatement const> Parser::try_parse_labelled_statement(AllowLabell
}
if (m_state.labels_in_scope.contains(identifier))
syntax_error(DeprecatedString::formatted("Label '{}' has already been declared", identifier));
syntax_error(ByteString::formatted("Label '{}' has already been declared", identifier));
RefPtr<Statement const> labelled_item;
@ -1401,7 +1401,7 @@ NonnullRefPtr<ClassExpression const> Parser::parse_class_expression(bool expect_
if (element->class_element_kind() != ClassElement::ElementKind::Method
|| element->is_static() != is_static) {
syntax_error(DeprecatedString::formatted("Duplicate private field or method named '{}'", name));
syntax_error(ByteString::formatted("Duplicate private field or method named '{}'", name));
break;
}
@ -1409,14 +1409,14 @@ NonnullRefPtr<ClassExpression const> Parser::parse_class_expression(bool expect_
auto& class_method_element = static_cast<ClassMethod const&>(*element);
if (class_method_element.kind() == ClassMethod::Kind::Method || class_method_element.kind() == method_kind) {
syntax_error(DeprecatedString::formatted("Duplicate private field or method named '{}'", name));
syntax_error(ByteString::formatted("Duplicate private field or method named '{}'", name));
break;
}
}
found_private_names.set(name);
} else if (found_private_names.set(name) != AK::HashSetResult::InsertedNewEntry) {
syntax_error(DeprecatedString::formatted("Duplicate private field or method named '{}'", name));
syntax_error(ByteString::formatted("Duplicate private field or method named '{}'", name));
}
property_key = create_ast_node<PrivateIdentifier>({ m_source_code, rule_start.position(), position() }, name);
@ -1590,12 +1590,12 @@ NonnullRefPtr<ClassExpression const> Parser::parse_class_expression(bool expect_
if (outer_referenced_private_names)
outer_referenced_private_names->set(private_name);
else // FIXME: Make these error appear in the appropriate places.
syntax_error(DeprecatedString::formatted("Reference to undeclared private field or method '{}'", private_name));
syntax_error(ByteString::formatted("Reference to undeclared private field or method '{}'", private_name));
}
auto function_start_offset = rule_start.position().offset;
auto function_end_offset = position().offset - m_state.current_token.trivia().length();
auto source_text = DeprecatedString { m_state.lexer.source().substring_view(function_start_offset, function_end_offset - function_start_offset) };
auto source_text = ByteString { m_state.lexer.source().substring_view(function_start_offset, function_end_offset - function_start_offset) };
return create_ast_node<ClassExpression>({ m_source_code, rule_start.position(), position() }, move(class_name), move(source_text), move(constructor), move(super_class), move(elements));
}
@ -1661,7 +1661,7 @@ Parser::PrimaryExpressionParseResult Parser::parse_primary_expression()
auto string = m_state.current_token.value();
// This could be 'eval' or 'arguments' and thus needs a custom check (`eval[1] = true`)
if (m_state.strict_mode && (string == "let" || is_strict_reserved_word(string)))
syntax_error(DeprecatedString::formatted("Identifier must not be a reserved word in strict mode ('{}')", string));
syntax_error(ByteString::formatted("Identifier must not be a reserved word in strict mode ('{}')", string));
return { parse_identifier() };
}
case TokenType::NumericLiteral:
@ -1740,7 +1740,7 @@ Parser::PrimaryExpressionParseResult Parser::parse_primary_expression()
return { parse_await_expression() };
case TokenType::PrivateIdentifier:
if (!is_private_identifier_valid())
syntax_error(DeprecatedString::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
syntax_error(ByteString::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
if (next_token().type() != TokenType::In)
syntax_error("Cannot have a private identifier in expression if not followed by 'in'");
return { create_ast_node<PrivateIdentifier>({ m_source_code, rule_start.position(), position() }, consume().value()) };
@ -1761,7 +1761,7 @@ NonnullRefPtr<RegExpLiteral const> Parser::parse_regexp_literal()
// Remove leading and trailing slash.
pattern = pattern.substring_view(1, pattern.length() - 2);
auto flags = DeprecatedString::empty();
auto flags = ByteString::empty();
auto parsed_flags = RegExpObject::default_flags;
if (match(TokenType::RegexFlags)) {
@ -1775,21 +1775,21 @@ NonnullRefPtr<RegExpLiteral const> Parser::parse_regexp_literal()
parsed_flags = parsed_flags_or_error.release_value();
}
DeprecatedString parsed_pattern;
ByteString parsed_pattern;
auto parsed_pattern_result = parse_regex_pattern(pattern, parsed_flags.has_flag_set(ECMAScriptFlags::Unicode), parsed_flags.has_flag_set(ECMAScriptFlags::UnicodeSets));
if (parsed_pattern_result.is_error()) {
syntax_error(parsed_pattern_result.release_error().error, rule_start.position());
parsed_pattern = DeprecatedString::empty();
parsed_pattern = ByteString::empty();
} else {
parsed_pattern = parsed_pattern_result.release_value();
}
auto parsed_regex = Regex<ECMA262>::parse_pattern(parsed_pattern, parsed_flags);
if (parsed_regex.error != regex::Error::NoError)
syntax_error(DeprecatedString::formatted("RegExp compile error: {}", Regex<ECMA262>(parsed_regex, parsed_pattern, parsed_flags).error_string()), rule_start.position());
syntax_error(ByteString::formatted("RegExp compile error: {}", Regex<ECMA262>(parsed_regex, parsed_pattern, parsed_flags).error_string()), rule_start.position());
SourceRange range { m_source_code, rule_start.position(), position() };
return create_ast_node<RegExpLiteral>(move(range), move(parsed_regex), move(parsed_pattern), move(parsed_flags), pattern.to_deprecated_string(), move(flags));
return create_ast_node<RegExpLiteral>(move(range), move(parsed_regex), move(parsed_pattern), move(parsed_flags), pattern.to_byte_string(), move(flags));
}
static bool is_simple_assignment_target(Expression const& expression, bool allow_web_reality_call_expression = true)
@ -1815,7 +1815,7 @@ NonnullRefPtr<Expression const> Parser::parse_unary_prefixed_expression()
auto rhs_start = position();
auto rhs = parse_expression(precedence, associativity);
if (!is_simple_assignment_target(*rhs))
syntax_error(DeprecatedString::formatted("Right-hand side of prefix increment operator must be identifier or member expression, got {}", rhs->class_name()), rhs_start);
syntax_error(ByteString::formatted("Right-hand side of prefix increment operator must be identifier or member expression, got {}", rhs->class_name()), rhs_start);
if (m_state.strict_mode && is<Identifier>(*rhs)) {
auto& identifier = static_cast<Identifier const&>(*rhs);
@ -1830,7 +1830,7 @@ NonnullRefPtr<Expression const> Parser::parse_unary_prefixed_expression()
auto rhs_start = position();
auto rhs = parse_expression(precedence, associativity);
if (!is_simple_assignment_target(*rhs))
syntax_error(DeprecatedString::formatted("Right-hand side of prefix decrement operator must be identifier or member expression, got {}", rhs->class_name()), rhs_start);
syntax_error(ByteString::formatted("Right-hand side of prefix decrement operator must be identifier or member expression, got {}", rhs->class_name()), rhs_start);
if (m_state.strict_mode && is<Identifier>(*rhs)) {
auto& identifier = static_cast<Identifier const&>(*rhs);
@ -2034,7 +2034,7 @@ NonnullRefPtr<ObjectExpression const> Parser::parse_object_expression()
if (m_state.strict_mode && is<StringLiteral>(*property_key)) {
auto& string_literal = static_cast<StringLiteral const&>(*property_key);
if (is_strict_reserved_word(string_literal.value()))
syntax_error(DeprecatedString::formatted("'{}' is a reserved keyword", string_literal.value()));
syntax_error(ByteString::formatted("'{}' is a reserved keyword", string_literal.value()));
}
properties.append(create_ast_node<ObjectProperty>({ m_source_code, rule_start.position(), position() }, *property_key, *property_value, property_type, false));
@ -2098,7 +2098,7 @@ NonnullRefPtr<StringLiteral const> Parser::parse_string_literal(Token const& tok
auto string = token.string_value(status);
// NOTE: Tagged templates should not fail on invalid strings as their raw contents can still be accessed.
if (status != Token::StringValueStatus::Ok) {
DeprecatedString message;
ByteString message;
if (status == Token::StringValueStatus::LegacyOctalEscapeSequence) {
m_state.string_legacy_octal_escape_sequence_in_scope = true;
// It is a Syntax Error if the [Tagged] parameter was not set and Template{Head, Middle, Tail} Contains NotEscapeSequence.
@ -2108,7 +2108,7 @@ NonnullRefPtr<StringLiteral const> Parser::parse_string_literal(Token const& tok
message = "Octal escape sequence in string literal not allowed in strict mode";
} else if (status == Token::StringValueStatus::MalformedHexEscape || status == Token::StringValueStatus::MalformedUnicodeEscape) {
auto type = status == Token::StringValueStatus::MalformedUnicodeEscape ? "unicode" : "hexadecimal";
message = DeprecatedString::formatted("Malformed {} escape sequence", type);
message = ByteString::formatted("Malformed {} escape sequence", type);
} else if (status == Token::StringValueStatus::UnicodeEscapeOverflow) {
message = "Unicode code_point must not be greater than 0x10ffff in escape sequence";
} else {
@ -2373,9 +2373,9 @@ Parser::ExpressionResult Parser::parse_secondary_expression(NonnullRefPtr<Expres
consume();
if (match(TokenType::PrivateIdentifier)) {
if (!is_private_identifier_valid())
syntax_error(DeprecatedString::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
syntax_error(ByteString::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
else if (is<SuperExpression>(*lhs))
syntax_error(DeprecatedString::formatted("Cannot access private field or method '{}' on super", m_state.current_token.value()));
syntax_error(ByteString::formatted("Cannot access private field or method '{}' on super", m_state.current_token.value()));
return create_ast_node<MemberExpression>({ m_source_code, rule_start.position(), position() }, move(lhs), create_ast_node<PrivateIdentifier>({ m_source_code, rule_start.position(), position() }, consume().value()));
} else if (!match_identifier_name()) {
@ -2391,7 +2391,7 @@ Parser::ExpressionResult Parser::parse_secondary_expression(NonnullRefPtr<Expres
}
case TokenType::PlusPlus:
if (!is_simple_assignment_target(*lhs))
syntax_error(DeprecatedString::formatted("Left-hand side of postfix increment operator must be identifier or member expression, got {}", lhs->class_name()));
syntax_error(ByteString::formatted("Left-hand side of postfix increment operator must be identifier or member expression, got {}", lhs->class_name()));
if (m_state.strict_mode && is<Identifier>(*lhs)) {
auto& identifier = static_cast<Identifier const&>(*lhs);
@ -2403,7 +2403,7 @@ Parser::ExpressionResult Parser::parse_secondary_expression(NonnullRefPtr<Expres
return create_ast_node<UpdateExpression>({ m_source_code, rule_start.position(), position() }, UpdateOp::Increment, move(lhs));
case TokenType::MinusMinus:
if (!is_simple_assignment_target(*lhs))
syntax_error(DeprecatedString::formatted("Left-hand side of postfix increment operator must be identifier or member expression, got {}", lhs->class_name()));
syntax_error(ByteString::formatted("Left-hand side of postfix increment operator must be identifier or member expression, got {}", lhs->class_name()));
if (m_state.strict_mode && is<Identifier>(*lhs)) {
auto& identifier = static_cast<Identifier const&>(*lhs);
@ -2760,7 +2760,7 @@ NonnullRefPtr<FunctionBody const> Parser::parse_function_body(Vector<FunctionPar
for (auto& previous_name : parameter_names) {
if (previous_name == parameter_name) {
syntax_error(DeprecatedString::formatted("Duplicate parameter '{}' not allowed in strict mode", parameter_name));
syntax_error(ByteString::formatted("Duplicate parameter '{}' not allowed in strict mode", parameter_name));
}
}
@ -2779,7 +2779,7 @@ NonnullRefPtr<FunctionBody const> Parser::parse_function_body(Vector<FunctionPar
for (auto& previous_name : parameter_names) {
if (previous_name == bound_name) {
syntax_error(DeprecatedString::formatted("Duplicate parameter '{}' not allowed in strict mode", bound_name));
syntax_error(ByteString::formatted("Duplicate parameter '{}' not allowed in strict mode", bound_name));
break;
}
}
@ -2864,7 +2864,7 @@ NonnullRefPtr<FunctionNodeType> Parser::parse_function_node(u16 parse_options, O
check_identifier_name_for_assignment_validity(name->string());
if (function_kind == FunctionKind::AsyncGenerator && (name->string() == "await"sv || name->string() == "yield"sv))
syntax_error(DeprecatedString::formatted("async generator function is not allowed to be called '{}'", name->string()));
syntax_error(ByteString::formatted("async generator function is not allowed to be called '{}'", name->string()));
if (m_state.in_class_static_init_block && name->string() == "await"sv)
syntax_error("'await' is a reserved word");
@ -2910,7 +2910,7 @@ NonnullRefPtr<FunctionNodeType> Parser::parse_function_node(u16 parse_options, O
auto function_start_offset = rule_start.position().offset;
auto function_end_offset = position().offset - m_state.current_token.trivia().length();
auto source_text = DeprecatedString { m_state.lexer.source().substring_view(function_start_offset, function_end_offset - function_start_offset) };
auto source_text = ByteString { m_state.lexer.source().substring_view(function_start_offset, function_end_offset - function_start_offset) };
return create_ast_node<FunctionNodeType>(
{ m_source_code, rule_start.position(), position() },
name, move(source_text), move(body), move(parameters), function_length,
@ -2955,15 +2955,15 @@ Vector<FunctionParameter> Parser::parse_formal_parameters(int& function_length,
if (!has_same_name)
continue;
DeprecatedString message;
ByteString message;
if (parse_options & FunctionNodeParseOptions::IsArrowFunction)
message = DeprecatedString::formatted("Duplicate parameter '{}' not allowed in arrow function", parameter_name);
message = ByteString::formatted("Duplicate parameter '{}' not allowed in arrow function", parameter_name);
else if (m_state.strict_mode)
message = DeprecatedString::formatted("Duplicate parameter '{}' not allowed in strict mode", parameter_name);
message = ByteString::formatted("Duplicate parameter '{}' not allowed in strict mode", parameter_name);
else if (has_default_parameter || match(TokenType::Equals))
message = DeprecatedString::formatted("Duplicate parameter '{}' not allowed in function with default parameter", parameter_name);
message = ByteString::formatted("Duplicate parameter '{}' not allowed in function with default parameter", parameter_name);
else if (has_rest_parameter)
message = DeprecatedString::formatted("Duplicate parameter '{}' not allowed in function with rest parameter", parameter_name);
message = ByteString::formatted("Duplicate parameter '{}' not allowed in function with rest parameter", parameter_name);
if (!message.is_empty())
syntax_error(message, Position { token.line_number(), token.line_column() });
break;
@ -3406,7 +3406,7 @@ NonnullRefPtr<BreakStatement const> Parser::parse_break_statement()
auto label = m_state.labels_in_scope.find(target_label);
if (label == m_state.labels_in_scope.end())
syntax_error(DeprecatedString::formatted("Label '{}' not found", target_label));
syntax_error(ByteString::formatted("Label '{}' not found", target_label));
}
consume_or_insert_semicolon();
}
@ -3435,7 +3435,7 @@ NonnullRefPtr<ContinueStatement const> Parser::parse_continue_statement()
auto label = m_state.labels_in_scope.find(target_label);
if (label == m_state.labels_in_scope.end())
syntax_error(DeprecatedString::formatted("Label '{}' not found or invalid", target_label));
syntax_error(ByteString::formatted("Label '{}' not found or invalid", target_label));
else
label->value = label_position;
}
@ -3471,7 +3471,7 @@ NonnullRefPtr<OptionalChain const> Parser::parse_optional_chain(NonnullRefPtr<Ex
break;
case TokenType::PrivateIdentifier: {
if (!is_private_identifier_valid())
syntax_error(DeprecatedString::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
syntax_error(ByteString::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
auto start = position();
auto private_identifier = consume();
@ -3507,7 +3507,7 @@ NonnullRefPtr<OptionalChain const> Parser::parse_optional_chain(NonnullRefPtr<Ex
consume();
if (match(TokenType::PrivateIdentifier)) {
if (!is_private_identifier_valid())
syntax_error(DeprecatedString::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
syntax_error(ByteString::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
auto start = position();
auto private_identifier = consume();
@ -3728,7 +3728,7 @@ NonnullRefPtr<CatchClause const> Parser::parse_catch_clause()
// NOTE: Nothing in the callback throws an exception.
MUST(body->for_each_lexically_declared_identifier([&](auto const& identifier) {
if (bound_names.contains(identifier.string()))
syntax_error(DeprecatedString::formatted("Identifier '{}' already declared as catch parameter", identifier.string()));
syntax_error(ByteString::formatted("Identifier '{}' already declared as catch parameter", identifier.string()));
}));
if (pattern_parameter) {
@ -3951,7 +3951,7 @@ NonnullRefPtr<Statement const> Parser::parse_for_in_of_statement(NonnullRefPtr<A
}
}
if (!valid)
syntax_error(DeprecatedString::formatted("Invalid left-hand side in for-loop ('{}')", lhs->class_name()));
syntax_error(ByteString::formatted("Invalid left-hand side in for-loop ('{}')", lhs->class_name()));
}
auto in_or_of = consume();
auto is_in = in_or_of.type() == TokenType::In;
@ -4341,7 +4341,7 @@ Token Parser::consume_identifier_reference()
if (match(TokenType::EscapedKeyword)) {
auto name = m_state.current_token.value();
if (m_state.strict_mode && (name == "let"sv || name == "yield"sv))
syntax_error(DeprecatedString::formatted("'{}' is not allowed as an identifier in strict mode", name));
syntax_error(ByteString::formatted("'{}' is not allowed as an identifier in strict mode", name));
if (m_program_type == Program::Type::Module && name == "await"sv)
syntax_error("'await' is not allowed as an identifier in module");
@ -4382,7 +4382,7 @@ Token Parser::consume(TokenType expected_type)
auto token = expected_type == TokenType::Identifier ? consume_and_allow_division() : consume();
if (expected_type == TokenType::Identifier) {
if (m_state.strict_mode && is_strict_reserved_word(token.value()))
syntax_error(DeprecatedString::formatted("Identifier must not be a reserved word in strict mode ('{}')", token.value()));
syntax_error(ByteString::formatted("Identifier must not be a reserved word in strict mode ('{}')", token.value()));
}
return token;
}
@ -4403,9 +4403,9 @@ Token Parser::consume_and_validate_numeric_literal()
void Parser::expected(char const* what)
{
auto message = m_state.current_token.message().to_deprecated_string();
auto message = m_state.current_token.message().to_byte_string();
if (message.is_empty())
message = DeprecatedString::formatted("Unexpected token {}. Expected {}", m_state.current_token.name(), what);
message = ByteString::formatted("Unexpected token {}. Expected {}", m_state.current_token.name(), what);
syntax_error(message);
}
@ -4432,7 +4432,7 @@ void Parser::set_try_parse_arrow_function_expression_failed_at_position(Position
m_token_memoizations.set(position, { failed });
}
void Parser::syntax_error(DeprecatedString const& message, Optional<Position> position)
void Parser::syntax_error(ByteString const& message, Optional<Position> position)
{
if (!position.has_value())
position = this->position();
@ -4464,7 +4464,7 @@ void Parser::check_identifier_name_for_assignment_validity(DeprecatedFlyString c
if (name.is_one_of("arguments"sv, "eval"sv))
syntax_error("Binding pattern target may not be called 'arguments' or 'eval' in strict mode");
else if (is_strict_reserved_word(name))
syntax_error(DeprecatedString::formatted("Binding pattern target may not be called '{}' in strict mode", name));
syntax_error(ByteString::formatted("Binding pattern target may not be called '{}' in strict mode", name));
}
}
@ -4517,9 +4517,9 @@ ModuleRequest Parser::parse_module_request()
consume(TokenType::CurlyOpen);
while (!done() && !match(TokenType::CurlyClose)) {
DeprecatedString key;
ByteString key;
if (match(TokenType::StringLiteral)) {
key = parse_string_literal(m_state.current_token)->value().to_deprecated_string();
key = parse_string_literal(m_state.current_token)->value().to_byte_string();
consume();
} else if (match_identifier_name()) {
key = consume().value();
@ -4533,9 +4533,9 @@ ModuleRequest Parser::parse_module_request()
if (match(TokenType::StringLiteral)) {
for (auto& entries : request.attributes) {
if (entries.key == key)
syntax_error(DeprecatedString::formatted("Duplicate attribute clauses with name: {}", key));
syntax_error(ByteString::formatted("Duplicate attribute clauses with name: {}", key));
}
request.add_attribute(move(key), parse_string_literal(m_state.current_token)->value().to_deprecated_string());
request.add_attribute(move(key), parse_string_literal(m_state.current_token)->value().to_byte_string());
}
consume(TokenType::StringLiteral);
@ -4617,7 +4617,7 @@ NonnullRefPtr<ImportStatement const> Parser::parse_import_statement(Program& pro
consume(TokenType::Asterisk);
if (!match_as())
syntax_error(DeprecatedString::formatted("Unexpected token: {}", m_state.current_token.name()));
syntax_error(ByteString::formatted("Unexpected token: {}", m_state.current_token.name()));
consume(TokenType::Identifier);
@ -4626,7 +4626,7 @@ NonnullRefPtr<ImportStatement const> Parser::parse_import_statement(Program& pro
auto namespace_name = consume().value();
entries_with_location.append({ ImportEntry({}, namespace_name, true), namespace_position });
} else {
syntax_error(DeprecatedString::formatted("Unexpected token: {}", m_state.current_token.name()));
syntax_error(ByteString::formatted("Unexpected token: {}", m_state.current_token.name()));
}
} else if (match(TokenType::CurlyOpen)) {
@ -4650,7 +4650,7 @@ NonnullRefPtr<ImportStatement const> Parser::parse_import_statement(Program& pro
entries_with_location.append({ { name, alias }, alias_position });
} else if (require_as) {
syntax_error(DeprecatedString::formatted("Unexpected reserved word '{}'", name));
syntax_error(ByteString::formatted("Unexpected reserved word '{}'", name));
} else {
check_identifier_name_for_assignment_validity(name);
@ -4688,7 +4688,7 @@ NonnullRefPtr<ImportStatement const> Parser::parse_import_statement(Program& pro
auto from_statement = consume(TokenType::Identifier).original_value();
if (from_statement != "from"sv)
syntax_error(DeprecatedString::formatted("Expected 'from' got {}", from_statement));
syntax_error(ByteString::formatted("Expected 'from' got {}", from_statement));
auto module_request = parse_module_request();
@ -4698,12 +4698,12 @@ NonnullRefPtr<ImportStatement const> Parser::parse_import_statement(Program& pro
for (auto& entry : entries_with_location) {
for (auto& import_statement : program.imports()) {
if (import_statement->has_bound_name(entry.entry.local_name))
syntax_error(DeprecatedString::formatted("Identifier '{}' already declared", entry.entry.local_name), entry.position);
syntax_error(ByteString::formatted("Identifier '{}' already declared", entry.entry.local_name), entry.position);
}
for (auto& new_entry : entries) {
if (new_entry.local_name == entry.entry.local_name)
syntax_error(DeprecatedString::formatted("Identifier '{}' already declared", entry.entry.local_name), entry.position);
syntax_error(ByteString::formatted("Identifier '{}' already declared", entry.entry.local_name), entry.position);
}
entries.append(move(entry.entry));
@ -5002,12 +5002,12 @@ NonnullRefPtr<ExportStatement const> Parser::parse_export_statement(Program& pro
for (auto& entry : entries_with_location) {
for (auto& export_statement : program.exports()) {
if (export_statement->has_export(entry.entry.export_name))
syntax_error(DeprecatedString::formatted("Duplicate export with name: '{}'", entry.entry.export_name), entry.position);
syntax_error(ByteString::formatted("Duplicate export with name: '{}'", entry.entry.export_name), entry.position);
}
for (auto& new_entry : entries) {
if (new_entry.kind != ExportEntry::Kind::EmptyNamedExport && new_entry.export_name == entry.entry.export_name)
syntax_error(DeprecatedString::formatted("Duplicate export with name: '{}'", entry.entry.export_name), entry.position);
syntax_error(ByteString::formatted("Duplicate export with name: '{}'", entry.entry.export_name), entry.position);
}
entries.append(move(entry.entry));
@ -5101,7 +5101,7 @@ NonnullRefPtr<Identifier const> Parser::create_identifier_and_register_in_curren
return id;
}
Parser Parser::parse_function_body_from_string(DeprecatedString const& body_string, u16 parse_options, Vector<FunctionParameter> const& parameters, FunctionKind kind, bool& contains_direct_call_to_eval)
Parser Parser::parse_function_body_from_string(ByteString const& body_string, u16 parse_options, Vector<FunctionParameter> const& parameters, FunctionKind kind, bool& contains_direct_call_to_eval)
{
RefPtr<FunctionBody const> function_body;

View file

@ -200,7 +200,7 @@ public:
if (!hint.is_empty())
warnln("{}", hint);
}
warnln("SyntaxError: {}", error.to_deprecated_string());
warnln("SyntaxError: {}", error.to_byte_string());
}
}
@ -211,7 +211,7 @@ public:
// Needs to mess with m_state, and we're not going to expose a non-const getter for that :^)
friend ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic_function(VM&, FunctionObject&, FunctionObject*, FunctionKind, MarkedVector<Value> const&);
static Parser parse_function_body_from_string(DeprecatedString const& body_string, u16 parse_options, Vector<FunctionParameter> const& parameters, FunctionKind kind, bool& contains_direct_call_to_eval);
static Parser parse_function_body_from_string(ByteString const& body_string, u16 parse_options, Vector<FunctionParameter> const& parameters, FunctionKind kind, bool& contains_direct_call_to_eval);
private:
friend class ScopePusher;
@ -244,7 +244,7 @@ private:
bool match(TokenType type) const;
bool done() const;
void expected(char const* what);
void syntax_error(DeprecatedString const& message, Optional<Position> = {});
void syntax_error(ByteString const& message, Optional<Position> = {});
Token consume();
Token consume_and_allow_division();
Token consume_identifier();

View file

@ -15,31 +15,31 @@ namespace JS {
ErrorOr<String> ParserError::to_string() const
{
if (!position.has_value())
return String::from_deprecated_string(message);
return String::from_byte_string(message);
return String::formatted("{} (line: {}, column: {})", message, position.value().line, position.value().column);
}
DeprecatedString ParserError::to_deprecated_string() const
ByteString ParserError::to_byte_string() const
{
if (!position.has_value())
return message;
return DeprecatedString::formatted("{} (line: {}, column: {})", message, position.value().line, position.value().column);
return ByteString::formatted("{} (line: {}, column: {})", message, position.value().line, position.value().column);
}
DeprecatedString ParserError::source_location_hint(StringView source, char const spacer, char const indicator) const
ByteString ParserError::source_location_hint(StringView source, char const spacer, char const indicator) const
{
if (!position.has_value())
return {};
// We need to modify the source to match what the lexer considers one line - normalizing
// line terminators to \n is easier than splitting using all different LT characters.
DeprecatedString source_string = source.replace("\r\n"sv, "\n"sv, ReplaceMode::All).replace("\r"sv, "\n"sv, ReplaceMode::All).replace(LINE_SEPARATOR_STRING, "\n"sv, ReplaceMode::All).replace(PARAGRAPH_SEPARATOR_STRING, "\n"sv, ReplaceMode::All);
ByteString source_string = source.replace("\r\n"sv, "\n"sv, ReplaceMode::All).replace("\r"sv, "\n"sv, ReplaceMode::All).replace(LINE_SEPARATOR_STRING, "\n"sv, ReplaceMode::All).replace(PARAGRAPH_SEPARATOR_STRING, "\n"sv, ReplaceMode::All);
StringBuilder builder;
builder.append(source_string.split_view('\n', SplitBehavior::KeepEmpty)[position.value().line - 1]);
builder.append('\n');
for (size_t i = 0; i < position.value().column - 1; ++i)
builder.append(spacer);
builder.append(indicator);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
}

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Error.h>
#include <AK/Optional.h>
#include <AK/String.h>
@ -16,12 +16,12 @@
namespace JS {
struct ParserError {
DeprecatedString message;
ByteString message;
Optional<Position> position;
ErrorOr<String> to_string() const;
DeprecatedString to_deprecated_string() const;
DeprecatedString source_location_hint(StringView source, char const spacer = ' ', char const indicator = '^') const;
ByteString to_byte_string() const;
ByteString source_location_hint(StringView source, char const spacer = ' ', char const indicator = '^') const;
};
}

View file

@ -579,7 +579,7 @@ ThrowCompletionOr<Value> perform_eval(VM& vm, Value x, CallerMode strict_caller,
.in_class_field_initializer = in_class_field_initializer,
};
Parser parser { Lexer { code_string.deprecated_string() }, Program::Type::Script, move(initial_state) };
Parser parser { Lexer { code_string.byte_string() }, Program::Type::Script, move(initial_state) };
auto program = parser.parse_program(strict_caller == CallerMode::Strict);
// b. If script is a List of errors, throw a SyntaxError exception.
@ -1289,7 +1289,7 @@ ThrowCompletionOr<String> get_substitution(VM& vm, Utf16View const& matched, Utf
TRY_OR_THROW_OOM(vm, result.try_append(curr));
} else {
auto group_name_view = replace_view.substring_view(start_position, *end_position - start_position);
auto group_name = TRY_OR_THROW_OOM(vm, group_name_view.to_deprecated_string(Utf16View::AllowInvalidCodeUnits::Yes));
auto group_name = TRY_OR_THROW_OOM(vm, group_name_view.to_byte_string(Utf16View::AllowInvalidCodeUnits::Yes));
auto capture = TRY(named_captures.as_object().get(group_name));
@ -1505,7 +1505,7 @@ ThrowCompletionOr<Value> perform_import_call(VM& vm, Value specifier, Value opti
// 8. Let specifierString be Completion(ToString(specifier)).
// 9. IfAbruptRejectPromise(specifierString, promiseCapability).
auto specifier_string = TRY_OR_REJECT_WITH_VALUE(vm, promise_capability, specifier.to_deprecated_string(vm));
auto specifier_string = TRY_OR_REJECT_WITH_VALUE(vm, promise_capability, specifier.to_byte_string(vm));
// 10. Let attributes be a new empty List.
Vector<ImportAttribute> attributes;
@ -1569,7 +1569,7 @@ ThrowCompletionOr<Value> perform_import_call(VM& vm, Value specifier, Value opti
}
// 4. Append the ImportAttribute Record { [[Key]]: key, [[Value]]: value } to attributes.
attributes.empend(key.as_string().deprecated_string(), value.as_string().deprecated_string());
attributes.empend(key.as_string().byte_string(), value.as_string().byte_string());
}
}

View file

@ -55,7 +55,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> AggregateErrorConstructor::construct(Fun
// 3. If message is not undefined, then
if (!message.is_undefined()) {
// a. Let msg be ? ToString(message).
auto msg = TRY(message.to_deprecated_string(vm));
auto msg = TRY(message.to_byte_string(vm));
// b. Perform CreateNonEnumerableDataPropertyOrThrow(O, "message", msg).
aggregate_error->create_non_enumerable_data_property_or_throw(vm.names.message, PrimitiveString::create(vm, msg));

View file

@ -261,10 +261,10 @@ ThrowCompletionOr<double> compare_array_elements(VM& vm, Value x, Value y, Funct
}
// 5. Let xString be ? ToString(x).
auto x_string = PrimitiveString::create(vm, TRY(x.to_deprecated_string(vm)));
auto x_string = PrimitiveString::create(vm, TRY(x.to_byte_string(vm)));
// 6. Let yString be ? ToString(y).
auto y_string = PrimitiveString::create(vm, TRY(y.to_deprecated_string(vm)));
auto y_string = PrimitiveString::create(vm, TRY(y.to_byte_string(vm)));
// 7. Let xSmaller be ! IsLessThan(xString, yString, true).
auto x_smaller = MUST(is_less_than(vm, x_string, y_string, true));

View file

@ -838,9 +838,9 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::join)
};
auto length = TRY(length_of_array_like(vm, this_object));
DeprecatedString separator = ",";
ByteString separator = ",";
if (!vm.argument(0).is_undefined())
separator = TRY(vm.argument(0).to_deprecated_string(vm));
separator = TRY(vm.argument(0).to_byte_string(vm));
StringBuilder builder;
for (size_t i = 0; i < length; ++i) {
if (i > 0)
@ -848,11 +848,11 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::join)
auto value = TRY(this_object->get(i));
if (value.is_nullish())
continue;
auto string = TRY(value.to_deprecated_string(vm));
auto string = TRY(value.to_byte_string(vm));
builder.append(string);
}
return PrimitiveString::create(vm, builder.to_deprecated_string());
return PrimitiveString::create(vm, builder.to_byte_string());
}
// 23.1.3.19 Array.prototype.keys ( ), https://tc39.es/ecma262/#sec-array.prototype.keys
@ -1650,7 +1650,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::to_locale_string)
auto locale_string_result = TRY(value.invoke(vm, vm.names.toLocaleString, locales, options));
// ii. Set R to the string-concatenation of R and S.
auto string = TRY(locale_string_result.to_deprecated_string(vm));
auto string = TRY(locale_string_result.to_byte_string(vm));
builder.append(string);
}
@ -1658,7 +1658,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::to_locale_string)
}
// 7. Return R.
return PrimitiveString::create(vm, builder.to_deprecated_string());
return PrimitiveString::create(vm, builder.to_byte_string());
}
// 23.1.3.33 Array.prototype.toReversed ( ), https://tc39.es/ecma262/#sec-array.prototype.toreversed

View file

@ -27,7 +27,7 @@ public:
Crypto::SignedBigInteger const& big_integer() const { return m_big_integer; }
ErrorOr<String> to_string() const;
DeprecatedString to_deprecated_string() const { return DeprecatedString::formatted("{}n", m_big_integer.to_base_deprecated(10)); }
ByteString to_byte_string() const { return ByteString::formatted("{}n", m_big_integer.to_base_deprecated(10)); }
private:
explicit BigInt(Crypto::SignedBigInteger);

View file

@ -40,7 +40,7 @@ BoundFunction::BoundFunction(Realm& realm, FunctionObject& bound_target_function
, m_bound_this(bound_this)
, m_bound_arguments(move(bound_arguments))
// FIXME: Non-standard and redundant, remove.
, m_name(DeprecatedString::formatted("bound {}", bound_target_function.name()))
, m_name(ByteString::formatted("bound {}", bound_target_function.name()))
{
}

View file

@ -719,7 +719,7 @@ double parse_time_zone_offset_string(StringView offset_string)
auto parsed_fraction = *parse_result->time_zone_utc_offset_fraction;
// b. Let fraction be the string-concatenation of CodePointsToString(parsedFraction) and "000000000".
auto fraction = DeprecatedString::formatted("{}000000000", parsed_fraction);
auto fraction = ByteString::formatted("{}000000000", parsed_fraction);
// c. Let nanosecondsString be the substring of fraction from 1 to 10.
auto nanoseconds_string = fraction.substring_view(1, 9);

View file

@ -26,7 +26,7 @@ namespace JS {
JS_DEFINE_ALLOCATOR(DateConstructor);
// 21.4.3.2 Date.parse ( string ), https://tc39.es/ecma262/#sec-date.parse
static double parse_simplified_iso8601(DeprecatedString const& iso_8601)
static double parse_simplified_iso8601(ByteString const& iso_8601)
{
// 21.4.1.15 Date Time String Format, https://tc39.es/ecma262/#sec-date-time-string-format
GenericLexer lexer(iso_8601);
@ -150,7 +150,7 @@ static double parse_simplified_iso8601(DeprecatedString const& iso_8601)
return time_clip(time_ms);
}
static double parse_date_string(DeprecatedString const& date_string)
static double parse_date_string(ByteString const& date_string)
{
auto value = parse_simplified_iso8601(date_string);
if (isfinite(value))
@ -246,7 +246,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> DateConstructor::construct(FunctionObjec
if (primitive.is_string()) {
// 1. Assert: The next step never returns an abrupt completion because Type(v) is String.
// 2. Let tv be the result of parsing v as a date, in exactly the same manner as for the parse method (21.4.3.2).
time_value = parse_date_string(primitive.as_string().deprecated_string());
time_value = parse_date_string(primitive.as_string().byte_string());
}
// iii. Else,
else {
@ -321,7 +321,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateConstructor::parse)
if (!vm.argument_count())
return js_nan();
auto date_string = TRY(vm.argument(0).to_deprecated_string(vm));
auto date_string = TRY(vm.argument(0).to_byte_string(vm));
return Value(parse_date_string(date_string));
}

View file

@ -7,8 +7,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/ByteString.h>
#include <AK/DateConstants.h>
#include <AK/DeprecatedString.h>
#include <AK/Function.h>
#include <AK/TypeCasts.h>
#include <LibCore/DateTime.h>
@ -1068,7 +1068,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_string)
}
// 21.4.4.41.1 TimeString ( tv ), https://tc39.es/ecma262/#sec-timestring
DeprecatedString time_string(double time)
ByteString time_string(double time)
{
// 1. Let hour be ToZeroPaddedDecimalString((HourFromTime(tv)), 2).
auto hour = hour_from_time(time);
@ -1080,11 +1080,11 @@ DeprecatedString time_string(double time)
auto second = sec_from_time(time);
// 4. Return the string-concatenation of hour, ":", minute, ":", second, the code unit 0x0020 (SPACE), and "GMT".
return DeprecatedString::formatted("{:02}:{:02}:{:02} GMT", hour, minute, second);
return ByteString::formatted("{:02}:{:02}:{:02} GMT", hour, minute, second);
}
// 21.4.4.41.2 DateString ( tv ), https://tc39.es/ecma262/#sec-datestring
DeprecatedString date_string(double time)
ByteString date_string(double time)
{
// 1. Let weekday be the Name of the entry in Table 62 with the Number WeekDay(tv).
auto weekday = short_day_names[week_day(time)];
@ -1103,11 +1103,11 @@ DeprecatedString date_string(double time)
// 6. Let paddedYear be ToZeroPaddedDecimalString(abs((yv)), 4).
// 7. Return the string-concatenation of weekday, the code unit 0x0020 (SPACE), month, the code unit 0x0020 (SPACE), day, the code unit 0x0020 (SPACE), yearSign, and paddedYear.
return DeprecatedString::formatted("{} {} {:02} {}{:04}", weekday, month, day, year_sign, abs(year));
return ByteString::formatted("{} {} {:02} {}{:04}", weekday, month, day, year_sign, abs(year));
}
// 21.4.4.41.3 TimeZoneString ( tv ), https://tc39.es/ecma262/#sec-timezoneestring
DeprecatedString time_zone_string(double time)
ByteString time_zone_string(double time)
{
// 1. Let systemTimeZoneIdentifier be SystemTimeZoneIdentifier().
auto system_time_zone_identifier = JS::system_time_zone_identifier();
@ -1161,11 +1161,11 @@ DeprecatedString time_zone_string(double time)
}
// 10. Return the string-concatenation of offsetSign, offsetHour, offsetMin, and tzName.
return DeprecatedString::formatted("{}{:02}{:02} ({})", offset_sign, offset_hour, offset_min, tz_name);
return ByteString::formatted("{}{:02}{:02} ({})", offset_sign, offset_hour, offset_min, tz_name);
}
// 21.4.4.41.4 ToDateString ( tv ), https://tc39.es/ecma262/#sec-todatestring
DeprecatedString to_date_string(double time)
ByteString to_date_string(double time)
{
// 1. If tv is NaN, return "Invalid Date".
if (Value(time).is_nan())
@ -1175,7 +1175,7 @@ DeprecatedString to_date_string(double time)
time = local_time(time);
// 3. Return the string-concatenation of DateString(t), the code unit 0x0020 (SPACE), TimeString(t), and TimeZoneString(tv).
return DeprecatedString::formatted("{} {}{}", date_string(time), time_string(time), time_zone_string(time));
return ByteString::formatted("{} {}{}", date_string(time), time_string(time), time_zone_string(time));
}
// 14.1.1 Date.prototype.toTemporalInstant ( ), https://tc39.es/proposal-temporal/#sec-date.prototype.totemporalinstant
@ -1205,7 +1205,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_time_string)
// 4. Let t be LocalTime(tv).
// 5. Return the string-concatenation of TimeString(t) and TimeZoneString(tv).
auto string = DeprecatedString::formatted("{}{}", time_string(local_time(time)), time_zone_string(time));
auto string = ByteString::formatted("{}{}", time_string(local_time(time)), time_zone_string(time));
return PrimitiveString::create(vm, move(string));
}
@ -1237,7 +1237,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_utc_string)
// 9. Let paddedYear be ToZeroPaddedDecimalString(abs((yv)), 4).
// 10. Return the string-concatenation of weekday, ",", the code unit 0x0020 (SPACE), day, the code unit 0x0020 (SPACE), month, the code unit 0x0020 (SPACE), yearSign, paddedYear, the code unit 0x0020 (SPACE), and TimeString(tv).
auto string = DeprecatedString::formatted("{}, {:02} {} {}{:04} {}", weekday, day, month, year_sign, abs(year), time_string(time));
auto string = ByteString::formatted("{}, {:02} {} {}{:04} {}", weekday, day, month, year_sign, abs(year), time_string(time));
return PrimitiveString::create(vm, move(string));
}
@ -1250,7 +1250,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::symbol_to_primitive)
auto hint_value = vm.argument(0);
if (!hint_value.is_string())
return vm.throw_completion<TypeError>(ErrorType::InvalidHint, hint_value.to_string_without_side_effects());
auto hint = hint_value.as_string().deprecated_string();
auto hint = hint_value.as_string().byte_string();
Value::PreferredType try_first;
if (hint == "string" || hint == "default")
try_first = Value::PreferredType::String;

View file

@ -74,9 +74,9 @@ private:
};
ThrowCompletionOr<double> this_time_value(VM&, Value value);
DeprecatedString time_string(double time);
DeprecatedString date_string(double time);
DeprecatedString time_zone_string(double time);
DeprecatedString to_date_string(double time);
ByteString time_string(double time);
ByteString date_string(double time);
ByteString time_zone_string(double time);
ByteString to_date_string(double time);
}

View file

@ -33,7 +33,7 @@ namespace JS {
JS_DEFINE_ALLOCATOR(ECMAScriptFunctionObject);
NonnullGCPtr<ECMAScriptFunctionObject> ECMAScriptFunctionObject::create(Realm& realm, DeprecatedFlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind kind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name)
NonnullGCPtr<ECMAScriptFunctionObject> ECMAScriptFunctionObject::create(Realm& realm, DeprecatedFlyString name, ByteString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind kind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name)
{
Object* prototype = nullptr;
switch (kind) {
@ -53,12 +53,12 @@ NonnullGCPtr<ECMAScriptFunctionObject> ECMAScriptFunctionObject::create(Realm& r
return realm.heap().allocate<ECMAScriptFunctionObject>(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, move(local_variables_names), parent_environment, private_environment, *prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name));
}
NonnullGCPtr<ECMAScriptFunctionObject> ECMAScriptFunctionObject::create(Realm& realm, DeprecatedFlyString name, Object& prototype, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind kind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name)
NonnullGCPtr<ECMAScriptFunctionObject> ECMAScriptFunctionObject::create(Realm& realm, DeprecatedFlyString name, Object& prototype, ByteString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind kind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name)
{
return realm.heap().allocate<ECMAScriptFunctionObject>(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, move(local_variables_names), parent_environment, private_environment, prototype, kind, is_strict, might_need_arguments_object, contains_direct_call_to_eval, is_arrow_function, move(class_field_initializer_name));
}
ECMAScriptFunctionObject::ECMAScriptFunctionObject(DeprecatedFlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> formal_parameters, i32 function_length, Vector<DeprecatedFlyString> local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, Object& prototype, FunctionKind kind, bool strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name)
ECMAScriptFunctionObject::ECMAScriptFunctionObject(DeprecatedFlyString name, ByteString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> formal_parameters, i32 function_length, Vector<DeprecatedFlyString> local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, Object& prototype, FunctionKind kind, bool strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name)
: FunctionObject(prototype)
, m_name(move(name))
, m_function_length(function_length)
@ -1186,7 +1186,7 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body()
if (!parameter.default_value)
continue;
if (parameter.bytecode_executable.is_null()) {
auto executable = TRY(Bytecode::compile(vm, *parameter.default_value, FunctionKind::Normal, DeprecatedString::formatted("default parameter #{} for {}", default_parameter_index++, m_name)));
auto executable = TRY(Bytecode::compile(vm, *parameter.default_value, FunctionKind::Normal, ByteString::formatted("default parameter #{} for {}", default_parameter_index++, m_name)));
const_cast<FunctionParameter&>(parameter).bytecode_executable = executable;
m_default_parameter_bytecode_executables.append(move(executable));
} else {

View file

@ -38,8 +38,8 @@ public:
Global,
};
static NonnullGCPtr<ECMAScriptFunctionObject> create(Realm&, DeprecatedFlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind, bool is_strict, bool might_need_arguments_object = true, bool contains_direct_call_to_eval = true, bool is_arrow_function = false, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name = {});
static NonnullGCPtr<ECMAScriptFunctionObject> create(Realm&, DeprecatedFlyString name, Object& prototype, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind, bool is_strict, bool might_need_arguments_object = true, bool contains_direct_call_to_eval = true, bool is_arrow_function = false, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name = {});
static NonnullGCPtr<ECMAScriptFunctionObject> create(Realm&, DeprecatedFlyString name, ByteString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind, bool is_strict, bool might_need_arguments_object = true, bool contains_direct_call_to_eval = true, bool is_arrow_function = false, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name = {});
static NonnullGCPtr<ECMAScriptFunctionObject> create(Realm&, DeprecatedFlyString name, Object& prototype, ByteString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, FunctionKind, bool is_strict, bool might_need_arguments_object = true, bool contains_direct_call_to_eval = true, bool is_arrow_function = false, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name = {});
virtual void initialize(Realm&) override;
virtual ~ECMAScriptFunctionObject() override = default;
@ -73,8 +73,8 @@ public:
Object* home_object() const { return m_home_object; }
void set_home_object(Object* home_object) { m_home_object = home_object; }
DeprecatedString const& source_text() const { return m_source_text; }
void set_source_text(DeprecatedString source_text) { m_source_text = move(source_text); }
ByteString const& source_text() const { return m_source_text; }
void set_source_text(ByteString source_text) { m_source_text = move(source_text); }
Vector<ClassFieldDefinition> const& fields() const { return m_fields; }
void add_field(ClassFieldDefinition field) { m_fields.append(move(field)); }
@ -104,7 +104,7 @@ protected:
virtual Completion ordinary_call_evaluate_body();
private:
ECMAScriptFunctionObject(DeprecatedFlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, Object& prototype, FunctionKind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name);
ECMAScriptFunctionObject(DeprecatedFlyString name, ByteString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, Vector<DeprecatedFlyString> local_variables_names, Environment* parent_environment, PrivateEnvironment* private_environment, Object& prototype, FunctionKind, bool is_strict, bool might_need_arguments_object, bool contains_direct_call_to_eval, bool is_arrow_function, Variant<PropertyKey, PrivateName, Empty> class_field_initializer_name);
virtual bool is_ecmascript_function_object() const override { return true; }
virtual void visit_edges(Visitor&) override;
@ -130,7 +130,7 @@ private:
GCPtr<Realm> m_realm; // [[Realm]]
ScriptOrModule m_script_or_module; // [[ScriptOrModule]]
GCPtr<Object> m_home_object; // [[HomeObject]]
DeprecatedString m_source_text; // [[SourceText]]
ByteString m_source_text; // [[SourceText]]
Vector<ClassFieldDefinition> m_fields; // [[Fields]]
Vector<PrivateElement> m_private_methods; // [[PrivateMethods]]
Variant<PropertyKey, PrivateName, Empty> m_class_field_initializer_name; // [[ClassFieldInitializerName]]

View file

@ -85,7 +85,7 @@ void Error::populate_stack()
if (element.source_range.has_value())
range = element.source_range.value();
TracebackFrame frame {
.function_name = context->function_name ? context->function_name->deprecated_string() : "",
.function_name = context->function_name ? context->function_name->byte_string() : "",
.source_range_storage = range,
};

View file

@ -115,7 +115,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
auto arg_count = args.size();
// 9. Let P be the empty String.
DeprecatedString parameters_string = "";
ByteString parameters_string = "";
Optional<Value> body_arg;
@ -140,29 +140,29 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
size_t k = 0;
// e. Repeat, while k < argCount - 1,
Vector<DeprecatedString> parameters;
Vector<ByteString> parameters;
for (; k < arg_count - 1; ++k) {
// i. Let nextArg be args[k].
auto next_arg = args[k];
// ii. Let nextArgString be ? ToString(nextArg).
// iii. Set P to the string-concatenation of P, "," (a comma), and nextArgString.
parameters.append(TRY(next_arg.to_deprecated_string(vm)));
parameters.append(TRY(next_arg.to_byte_string(vm)));
// iv. Set k to k + 1.
}
parameters_string = DeprecatedString::join(',', parameters);
parameters_string = ByteString::join(',', parameters);
// f. Let bodyArg be args[k].
body_arg = args[k];
}
// 13. Let bodyString be the string-concatenation of 0x000A (LINE FEED), ? ToString(bodyArg), and 0x000A (LINE FEED).
auto body_string = DeprecatedString::formatted("\n{}\n", body_arg.has_value() ? TRY(body_arg->to_deprecated_string(vm)) : "");
auto body_string = ByteString::formatted("\n{}\n", body_arg.has_value() ? TRY(body_arg->to_byte_string(vm)) : "");
// 14. Let sourceString be the string-concatenation of prefix, " anonymous(", P, 0x000A (LINE FEED), ") {", bodyString, and "}".
// 15. Let sourceText be StringToCodePoints(sourceString).
auto source_text = DeprecatedString::formatted("{} anonymous({}\n) {{{}}}", prefix, parameters_string, body_string);
auto source_text = ByteString::formatted("{} anonymous({}\n) {{{}}}", prefix, parameters_string, body_string);
u8 parse_options = FunctionNodeParseOptions::CheckForFunctionAndName;
if (kind == FunctionKind::Async || kind == FunctionKind::AsyncGenerator)

View file

@ -32,7 +32,7 @@ void FunctionObject::set_function_name(Variant<PropertyKey, PrivateName> const&
VERIFY(m_is_extensible);
VERIFY(!storage_has(vm.names.name));
DeprecatedString name;
ByteString name;
// 2. If Type(name) is Symbol, then
if (auto const* property_key = name_arg.get_pointer<PropertyKey>(); property_key && property_key->is_symbol()) {
@ -41,10 +41,10 @@ void FunctionObject::set_function_name(Variant<PropertyKey, PrivateName> const&
// b. If description is undefined, set name to the empty String.
if (!description.has_value())
name = DeprecatedString::empty();
name = ByteString::empty();
// c. Else, set name to the string-concatenation of "[", description, and "]".
else
name = DeprecatedString::formatted("[{}]", *description);
name = ByteString::formatted("[{}]", *description);
}
// 3. Else if name is a Private Name, then
else if (auto const* private_name = name_arg.get_pointer<PrivateName>()) {
@ -65,7 +65,7 @@ void FunctionObject::set_function_name(Variant<PropertyKey, PrivateName> const&
// 5. If prefix is present, then
if (prefix.has_value()) {
// a. Set name to the string-concatenation of prefix, the code unit 0x0020 (SPACE), and name.
name = DeprecatedString::formatted("{} {}", *prefix, name);
name = ByteString::formatted("{} {}", *prefix, name);
// b. If F has an [[InitialName]] internal slot, then
if (is<NativeFunction>(this)) {

View file

@ -160,7 +160,7 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::to_string)
// NOTE: once we remove name(), the fallback here can simply be an empty string.
auto const& native_function = static_cast<NativeFunction&>(function);
auto const name = native_function.initial_name().value_or(native_function.name());
return PrimitiveString::create(vm, DeprecatedString::formatted("function {}() {{ [native code] }}", name));
return PrimitiveString::create(vm, ByteString::formatted("function {}() {{ [native code] }}", name));
}
// 4. If Type(func) is Object and IsCallable(func) is true, return an implementation-defined String source code representation of func. The representation must have the syntax of a NativeFunction.

View file

@ -387,7 +387,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::parse_int)
}
// 19.2.6.5 Encode ( string, extraUnescaped ), https://tc39.es/ecma262/#sec-encode
static ThrowCompletionOr<DeprecatedString> encode(VM& vm, DeprecatedString const& string, StringView unescaped_set)
static ThrowCompletionOr<ByteString> encode(VM& vm, ByteString const& string, StringView unescaped_set)
{
auto utf16_string = Utf16String::create(string);
@ -441,12 +441,12 @@ static ThrowCompletionOr<DeprecatedString> encode(VM& vm, DeprecatedString const
VERIFY(nwritten > 0);
}
}
return encoded_builder.to_deprecated_string();
return encoded_builder.to_byte_string();
}
// 19.2.6.6 Decode ( string, preserveEscapeSet ), https://tc39.es/ecma262/#sec-decode
// FIXME: Add spec comments to this implementation. It deviates a lot, so that's a bit tricky.
static ThrowCompletionOr<DeprecatedString> decode(VM& vm, DeprecatedString const& string, StringView reserved_set)
static ThrowCompletionOr<ByteString> decode(VM& vm, ByteString const& string, StringView reserved_set)
{
StringBuilder decoded_builder;
auto code_point_start_offset = 0u;
@ -500,14 +500,14 @@ static ThrowCompletionOr<DeprecatedString> decode(VM& vm, DeprecatedString const
}
if (expected_continuation_bytes > 0)
return vm.throw_completion<URIError>(ErrorType::URIMalformed);
return decoded_builder.to_deprecated_string();
return decoded_builder.to_byte_string();
}
// 19.2.6.1 decodeURI ( encodedURI ), https://tc39.es/ecma262/#sec-decodeuri-encodeduri
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::decode_uri)
{
// 1. Let uriString be ? ToString(encodedURI).
auto uri_string = TRY(vm.argument(0).to_deprecated_string(vm));
auto uri_string = TRY(vm.argument(0).to_byte_string(vm));
// 2. Let preserveEscapeSet be ";/?:@&=+$,#".
// 3. Return ? Decode(uriString, preserveEscapeSet).
@ -521,7 +521,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::decode_uri_component)
auto encoded_uri_component = vm.argument(0);
// 1. Let componentString be ? ToString(encodedURIComponent).
auto uri_string = TRY(encoded_uri_component.to_deprecated_string(vm));
auto uri_string = TRY(encoded_uri_component.to_byte_string(vm));
// 2. Let preserveEscapeSet be the empty String.
// 3. Return ? Decode(componentString, preserveEscapeSet).
@ -535,7 +535,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::encode_uri)
auto uri = vm.argument(0);
// 1. Let uriString be ? ToString(uri).
auto uri_string = TRY(uri.to_deprecated_string(vm));
auto uri_string = TRY(uri.to_byte_string(vm));
// 2. Let extraUnescaped be ";/?:@&=+$,#".
// 3. Return ? Encode(uriString, extraUnescaped).
@ -549,7 +549,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::encode_uri_component)
auto uri_component = vm.argument(0);
// 1. Let componentString be ? ToString(uriComponent).
auto uri_string = TRY(uri_component.to_deprecated_string(vm));
auto uri_string = TRY(uri_component.to_byte_string(vm));
// 2. Let extraUnescaped be the empty String.
// 3. Return ? Encode(componentString, extraUnescaped).
@ -561,7 +561,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::encode_uri_component)
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::escape)
{
// 1. Set string to ? ToString(string).
auto string = TRY(vm.argument(0).to_deprecated_string(vm));
auto string = TRY(vm.argument(0).to_byte_string(vm));
// 3. Let R be the empty String.
StringBuilder escaped;
@ -601,14 +601,14 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::escape)
}
// 7. Return R.
return PrimitiveString::create(vm, escaped.to_deprecated_string());
return PrimitiveString::create(vm, escaped.to_byte_string());
}
// B.2.1.2 unescape ( string ), https://tc39.es/ecma262/#sec-unescape-string
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::unescape)
{
// 1. Set string to ? ToString(string).
auto string = TRY(vm.argument(0).to_deprecated_string(vm));
auto string = TRY(vm.argument(0).to_byte_string(vm));
// 2. Let length be the length of string.
ssize_t length = string.length();
@ -658,7 +658,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::unescape)
}
// 6. Return R.
return PrimitiveString::create(vm, unescaped.to_deprecated_string());
return PrimitiveString::create(vm, unescaped.to_byte_string());
}
}

View file

@ -275,7 +275,7 @@ bool is_valid_duration_record(Temporal::DurationRecord const& record)
ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, String const& unit, Object const& options, StringView base_style, ReadonlySpan<StringView> styles_list, StringView digital_base, StringView previous_style)
{
// 1. Let style be ? GetOption(options, unit, string, stylesList, undefined).
auto style_value = TRY(get_option(vm, options, unit.to_deprecated_string(), OptionType::String, styles_list, Empty {}));
auto style_value = TRY(get_option(vm, options, unit.to_byte_string(), OptionType::String, styles_list, Empty {}));
// 2. Let displayDefault be "always".
auto display_default = "always"sv;
@ -319,7 +319,7 @@ ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, String
auto display_field = MUST(String::formatted("{}Display", unit));
// 5. Let display be ? GetOption(options, displayField, string, « "auto", "always" », displayDefault).
auto display = TRY(get_option(vm, options, display_field.to_deprecated_string(), OptionType::String, { "auto"sv, "always"sv }, display_default));
auto display = TRY(get_option(vm, options, display_field.to_byte_string(), OptionType::String, { "auto"sv, "always"sv }, display_default));
// 6. If prevStyle is "numeric" or "2-digit", then
if (previous_style == "numeric"sv || previous_style == "2-digit"sv) {

View file

@ -47,7 +47,7 @@ void JSONObject::initialize(Realm& realm)
}
// 25.5.2 JSON.stringify ( value [ , replacer [ , space ] ] ), https://tc39.es/ecma262/#sec-json.stringify
ThrowCompletionOr<Optional<DeprecatedString>> JSONObject::stringify_impl(VM& vm, Value value, Value replacer, Value space)
ThrowCompletionOr<Optional<ByteString>> JSONObject::stringify_impl(VM& vm, Value value, Value replacer, Value space)
{
auto& realm = *vm.current_realm();
@ -61,18 +61,18 @@ ThrowCompletionOr<Optional<DeprecatedString>> JSONObject::stringify_impl(VM& vm,
if (is_array) {
auto& replacer_object = replacer.as_object();
auto replacer_length = TRY(length_of_array_like(vm, replacer_object));
Vector<DeprecatedString> list;
Vector<ByteString> list;
for (size_t i = 0; i < replacer_length; ++i) {
auto replacer_value = TRY(replacer_object.get(i));
Optional<DeprecatedString> item;
Optional<ByteString> item;
if (replacer_value.is_string()) {
item = replacer_value.as_string().deprecated_string();
item = replacer_value.as_string().byte_string();
} else if (replacer_value.is_number()) {
item = MUST(replacer_value.to_deprecated_string(vm));
item = MUST(replacer_value.to_byte_string(vm));
} else if (replacer_value.is_object()) {
auto& value_object = replacer_value.as_object();
if (is<StringObject>(value_object) || is<NumberObject>(value_object))
item = TRY(replacer_value.to_deprecated_string(vm));
item = TRY(replacer_value.to_byte_string(vm));
}
if (item.has_value() && !list.contains_slow(*item)) {
list.append(*item);
@ -94,20 +94,20 @@ ThrowCompletionOr<Optional<DeprecatedString>> JSONObject::stringify_impl(VM& vm,
if (space.is_number()) {
auto space_mv = MUST(space.to_integer_or_infinity(vm));
space_mv = min(10, space_mv);
state.gap = space_mv < 1 ? DeprecatedString::empty() : DeprecatedString::repeated(' ', space_mv);
state.gap = space_mv < 1 ? ByteString::empty() : ByteString::repeated(' ', space_mv);
} else if (space.is_string()) {
auto string = space.as_string().deprecated_string();
auto string = space.as_string().byte_string();
if (string.length() <= 10)
state.gap = string;
else
state.gap = string.substring(0, 10);
} else {
state.gap = DeprecatedString::empty();
state.gap = ByteString::empty();
}
auto wrapper = Object::create(realm, realm.intrinsics().object_prototype());
MUST(wrapper->create_data_property_or_throw(DeprecatedString::empty(), value));
return serialize_json_property(vm, state, DeprecatedString::empty(), wrapper);
MUST(wrapper->create_data_property_or_throw(ByteString::empty(), value));
return serialize_json_property(vm, state, ByteString::empty(), wrapper);
}
// 25.5.2 JSON.stringify ( value [ , replacer [ , space ] ] ), https://tc39.es/ecma262/#sec-json.stringify
@ -128,7 +128,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::stringify)
}
// 25.5.2.1 SerializeJSONProperty ( state, key, holder ), https://tc39.es/ecma262/#sec-serializejsonproperty
ThrowCompletionOr<Optional<DeprecatedString>> JSONObject::serialize_json_property(VM& vm, StringifyState& state, PropertyKey const& key, Object* holder)
ThrowCompletionOr<Optional<ByteString>> JSONObject::serialize_json_property(VM& vm, StringifyState& state, PropertyKey const& key, Object* holder)
{
// 1. Let value be ? Get(holder, key).
auto value = TRY(holder->get(key));
@ -188,13 +188,13 @@ ThrowCompletionOr<Optional<DeprecatedString>> JSONObject::serialize_json_propert
// 8. If Type(value) is String, return QuoteJSONString(value).
if (value.is_string())
return quote_json_string(value.as_string().deprecated_string());
return quote_json_string(value.as_string().byte_string());
// 9. If Type(value) is Number, then
if (value.is_number()) {
// a. If value is finite, return ! ToString(value).
if (value.is_finite_number())
return MUST(value.to_deprecated_string(vm));
return MUST(value.to_byte_string(vm));
// b. Return "null".
return "null"sv;
@ -218,26 +218,26 @@ ThrowCompletionOr<Optional<DeprecatedString>> JSONObject::serialize_json_propert
}
// 12. Return undefined.
return Optional<DeprecatedString> {};
return Optional<ByteString> {};
}
// 25.5.2.4 SerializeJSONObject ( state, value ), https://tc39.es/ecma262/#sec-serializejsonobject
ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_object(VM& vm, StringifyState& state, Object& object)
ThrowCompletionOr<ByteString> JSONObject::serialize_json_object(VM& vm, StringifyState& state, Object& object)
{
if (state.seen_objects.contains(&object))
return vm.throw_completion<TypeError>(ErrorType::JsonCircular);
state.seen_objects.set(&object);
DeprecatedString previous_indent = state.indent;
state.indent = DeprecatedString::formatted("{}{}", state.indent, state.gap);
Vector<DeprecatedString> property_strings;
ByteString previous_indent = state.indent;
state.indent = ByteString::formatted("{}{}", state.indent, state.gap);
Vector<ByteString> property_strings;
auto process_property = [&](PropertyKey const& key) -> ThrowCompletionOr<void> {
if (key.is_symbol())
return {};
auto serialized_property_string = TRY(serialize_json_property(vm, state, key, &object));
if (serialized_property_string.has_value()) {
property_strings.append(DeprecatedString::formatted(
property_strings.append(ByteString::formatted(
"{}:{}{}",
quote_json_string(key.to_string()),
state.gap.is_empty() ? "" : " ",
@ -253,7 +253,7 @@ ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_object(VM& vm, St
} else {
auto property_list = TRY(object.enumerable_own_property_names(PropertyKind::Key));
for (auto& property : property_list)
TRY(process_property(property.as_string().deprecated_string()));
TRY(process_property(property.as_string().byte_string()));
}
StringBuilder builder;
if (property_strings.is_empty()) {
@ -271,7 +271,7 @@ ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_object(VM& vm, St
} else {
builder.append('\n');
builder.append(state.indent);
auto separator = DeprecatedString::formatted(",\n{}", state.indent);
auto separator = ByteString::formatted(",\n{}", state.indent);
for (auto& property_string : property_strings) {
if (!first)
builder.append(separator);
@ -286,19 +286,19 @@ ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_object(VM& vm, St
state.seen_objects.remove(&object);
state.indent = previous_indent;
return builder.to_deprecated_string();
return builder.to_byte_string();
}
// 25.5.2.5 SerializeJSONArray ( state, value ), https://tc39.es/ecma262/#sec-serializejsonarray
ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_array(VM& vm, StringifyState& state, Object& object)
ThrowCompletionOr<ByteString> JSONObject::serialize_json_array(VM& vm, StringifyState& state, Object& object)
{
if (state.seen_objects.contains(&object))
return vm.throw_completion<TypeError>(ErrorType::JsonCircular);
state.seen_objects.set(&object);
DeprecatedString previous_indent = state.indent;
state.indent = DeprecatedString::formatted("{}{}", state.indent, state.gap);
Vector<DeprecatedString> property_strings;
ByteString previous_indent = state.indent;
state.indent = ByteString::formatted("{}{}", state.indent, state.gap);
Vector<ByteString> property_strings;
auto length = TRY(length_of_array_like(vm, object));
@ -331,7 +331,7 @@ ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_array(VM& vm, Str
} else {
builder.append("[\n"sv);
builder.append(state.indent);
auto separator = DeprecatedString::formatted(",\n{}", state.indent);
auto separator = ByteString::formatted(",\n{}", state.indent);
bool first = true;
for (auto& property_string : property_strings) {
if (!first)
@ -347,11 +347,11 @@ ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_array(VM& vm, Str
state.seen_objects.remove(&object);
state.indent = previous_indent;
return builder.to_deprecated_string();
return builder.to_byte_string();
}
// 25.5.2.2 QuoteJSONString ( value ), https://tc39.es/ecma262/#sec-quotejsonstring
DeprecatedString JSONObject::quote_json_string(DeprecatedString string)
ByteString JSONObject::quote_json_string(ByteString string)
{
// 1. Let product be the String value consisting solely of the code unit 0x0022 (QUOTATION MARK).
StringBuilder builder;
@ -402,7 +402,7 @@ DeprecatedString JSONObject::quote_json_string(DeprecatedString string)
builder.append('"');
// 4. Return product.
return builder.to_deprecated_string();
return builder.to_byte_string();
}
// 25.5.1 JSON.parse ( text [ , reviver ] ), https://tc39.es/ecma262/#sec-json.parse
@ -410,7 +410,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::parse)
{
auto& realm = *vm.current_realm();
auto string = TRY(vm.argument(0).to_deprecated_string(vm));
auto string = TRY(vm.argument(0).to_byte_string(vm));
auto reviver = vm.argument(1);
auto json = JsonValue::from_string(string);
@ -419,7 +419,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::parse)
Value unfiltered = parse_json_value(vm, json.value());
if (reviver.is_function()) {
auto root = Object::create(realm, realm.intrinsics().object_prototype());
auto root_name = DeprecatedString::empty();
auto root_name = ByteString::empty();
MUST(root->create_data_property_or_throw(root_name, unfiltered));
return internalize_json_property(vm, root, root_name, reviver.as_function());
}
@ -439,7 +439,7 @@ Value JSONObject::parse_json_value(VM& vm, JsonValue const& value)
if (value.is_number())
return Value(value.to_double(0));
if (value.is_string())
return PrimitiveString::create(vm, value.to_deprecated_string());
return PrimitiveString::create(vm, value.to_byte_string());
if (value.is_bool())
return Value(static_cast<bool>(value.as_bool()));
VERIFY_NOT_REACHED();
@ -490,7 +490,7 @@ ThrowCompletionOr<Value> JSONObject::internalize_json_property(VM& vm, Object* h
} else {
auto property_list = TRY(value_object.enumerable_own_property_names(Object::PropertyKind::Key));
for (auto& property_key : property_list)
TRY(process_property(property_key.as_string().deprecated_string()));
TRY(process_property(property_key.as_string().byte_string()));
}
}

View file

@ -20,7 +20,7 @@ public:
// The base implementation of stringify is exposed because it is used by
// test-js to communicate between the JS tests and the C++ test runner.
static ThrowCompletionOr<Optional<DeprecatedString>> stringify_impl(VM&, Value value, Value replacer, Value space);
static ThrowCompletionOr<Optional<ByteString>> stringify_impl(VM&, Value value, Value replacer, Value space);
static Value parse_json_value(VM&, JsonValue const&);
@ -30,16 +30,16 @@ private:
struct StringifyState {
GCPtr<FunctionObject> replacer_function;
HashTable<GCPtr<Object>> seen_objects;
DeprecatedString indent { DeprecatedString::empty() };
DeprecatedString gap;
Optional<Vector<DeprecatedString>> property_list;
ByteString indent { ByteString::empty() };
ByteString gap;
Optional<Vector<ByteString>> property_list;
};
// Stringify helpers
static ThrowCompletionOr<Optional<DeprecatedString>> serialize_json_property(VM&, StringifyState&, PropertyKey const& key, Object* holder);
static ThrowCompletionOr<DeprecatedString> serialize_json_object(VM&, StringifyState&, Object&);
static ThrowCompletionOr<DeprecatedString> serialize_json_array(VM&, StringifyState&, Object&);
static DeprecatedString quote_json_string(DeprecatedString);
static ThrowCompletionOr<Optional<ByteString>> serialize_json_property(VM&, StringifyState&, PropertyKey const& key, Object* holder);
static ThrowCompletionOr<ByteString> serialize_json_object(VM&, StringifyState&, Object&);
static ThrowCompletionOr<ByteString> serialize_json_array(VM&, StringifyState&, Object&);
static ByteString quote_json_string(ByteString);
// Parse helpers
static Object* parse_json_object(VM&, JsonObject const&);

View file

@ -60,7 +60,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> MapConstructor::construct(FunctionObject
(void)TRY(get_iterator_values(vm, vm.argument(0), [&](Value iterator_value) -> Optional<Completion> {
if (!iterator_value.is_object())
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, DeprecatedString::formatted("Iterator value {}", iterator_value.to_string_without_side_effects()));
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, ByteString::formatted("Iterator value {}", iterator_value.to_string_without_side_effects()));
auto key = TRY(iterator_value.as_object().get(0));
auto value = TRY(iterator_value.as_object().get(1));

View file

@ -14,14 +14,14 @@
namespace JS {
struct ModuleWithSpecifier {
DeprecatedString specifier; // [[Specifier]]
ByteString specifier; // [[Specifier]]
NonnullGCPtr<Module> module; // [[Module]]
};
// https://tc39.es/proposal-import-attributes/#importattribute-record
struct ImportAttribute {
DeprecatedString key;
DeprecatedString value;
ByteString key;
ByteString value;
};
// https://tc39.es/proposal-import-attributes/#modulerequest-record
@ -35,7 +35,7 @@ struct ModuleRequest {
ModuleRequest(DeprecatedFlyString specifier, Vector<ImportAttribute> attributes);
void add_attribute(DeprecatedString key, DeprecatedString value)
void add_attribute(ByteString key, ByteString value)
{
attributes.empend(move(key), move(value));
}

View file

@ -92,7 +92,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential)
// 4. If x is not finite, return Number::toString(x).
if (!number_value.is_finite_number())
return PrimitiveString::create(vm, MUST(number_value.to_deprecated_string(vm)));
return PrimitiveString::create(vm, MUST(number_value.to_byte_string(vm)));
// 5. If f < 0 or f > 100, throw a RangeError exception.
if (fraction_digits < 0 || fraction_digits > 100)
@ -104,7 +104,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential)
// 7. Let s be the empty String.
auto sign = ""sv;
DeprecatedString number_string;
ByteString number_string;
int exponent = 0;
// 8. If x < 0, then
@ -119,7 +119,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential)
// 9. If x = 0, then
if (number == 0) {
// a. Let m be the String value consisting of f + 1 occurrences of the code unit 0x0030 (DIGIT ZERO).
number_string = DeprecatedString::repeated('0', fraction_digits + 1);
number_string = ByteString::repeated('0', fraction_digits + 1);
// b. Let e be 0.
exponent = 0;
@ -147,7 +147,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential)
number = round(number / pow(10, exponent - fraction_digits));
// c. Let m be the String value consisting of the digits of the decimal representation of n (in order, with no leading zeroes).
number_string = number_to_deprecated_string(number, NumberToStringMode::WithoutExponent);
number_string = number_to_byte_string(number, NumberToStringMode::WithoutExponent);
}
// 11. If f ≠ 0, then
@ -159,11 +159,11 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential)
auto second = number_string.substring_view(1);
// c. Set m to the string-concatenation of a, ".", and b.
number_string = DeprecatedString::formatted("{}.{}", first, second);
number_string = ByteString::formatted("{}.{}", first, second);
}
char exponent_sign = 0;
DeprecatedString exponent_string;
ByteString exponent_string;
// 12. If e = 0, then
if (exponent == 0) {
@ -192,12 +192,12 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential)
}
// c. Let d be the String value consisting of the digits of the decimal representation of e (in order, with no leading zeroes).
exponent_string = DeprecatedString::number(exponent);
exponent_string = ByteString::number(exponent);
}
// 14. Set m to the string-concatenation of m, "e", c, and d.
// 15. Return the string-concatenation of s and m.
return PrimitiveString::create(vm, DeprecatedString::formatted("{}{}e{}{}", sign, number_string, exponent_sign, exponent_string));
return PrimitiveString::create(vm, ByteString::formatted("{}{}e{}{}", sign, number_string, exponent_sign, exponent_string));
}
// 21.1.3.3 Number.prototype.toFixed ( fractionDigits ), https://tc39.es/ecma262/#sec-number.prototype.tofixed
@ -220,7 +220,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed)
// 6. If x is not finite, return Number::toString(x).
if (!number_value.is_finite_number())
return PrimitiveString::create(vm, TRY(number_value.to_deprecated_string(vm)));
return PrimitiveString::create(vm, TRY(number_value.to_byte_string(vm)));
// 7. Set x to (x).
auto number = number_value.as_double();
@ -236,7 +236,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed)
// 10. If x ≥ 10^21, then
// a. Let m be ! ToString(𝔽(x)).
if (number >= 1e+21)
return PrimitiveString::create(vm, MUST(number_value.to_deprecated_string(vm)));
return PrimitiveString::create(vm, MUST(number_value.to_byte_string(vm)));
// 11. Else,
// a. Let n be an integer for which n / (10^f) - x is as close to zero as possible. If there are two such n, pick the larger n.
@ -256,8 +256,8 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed)
// `number` double. Instead of generating a huge, unwieldy `n`, we format
// the double using our existing formatting code.
auto number_format_string = DeprecatedString::formatted("{{}}{{:.{}f}}", fraction_digits);
return PrimitiveString::create(vm, DeprecatedString::formatted(number_format_string, s, number));
auto number_format_string = ByteString::formatted("{{}}{{:.{}f}}", fraction_digits);
return PrimitiveString::create(vm, ByteString::formatted(number_format_string, s, number));
}
// 19.2.1 Number.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sup-number.prototype.tolocalestring
@ -289,14 +289,14 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision)
// 2. If precision is undefined, return ! ToString(x).
if (precision_value.is_undefined())
return PrimitiveString::create(vm, MUST(number_value.to_deprecated_string(vm)));
return PrimitiveString::create(vm, MUST(number_value.to_byte_string(vm)));
// 3. Let p be ? ToIntegerOrInfinity(precision).
auto precision = TRY(precision_value.to_integer_or_infinity(vm));
// 4. If x is not finite, return Number::toString(x).
if (!number_value.is_finite_number())
return PrimitiveString::create(vm, MUST(number_value.to_deprecated_string(vm)));
return PrimitiveString::create(vm, MUST(number_value.to_byte_string(vm)));
// 5. If p < 1 or p > 100, throw a RangeError exception.
if ((precision < 1) || (precision > 100))
@ -308,7 +308,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision)
// 7. Let s be the empty String.
auto sign = ""sv;
DeprecatedString number_string;
ByteString number_string;
int exponent = 0;
// 8. If x < 0, then
@ -323,7 +323,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision)
// 9. If x = 0, then
if (number == 0) {
// a. Let m be the String value consisting of p occurrences of the code unit 0x0030 (DIGIT ZERO).
number_string = DeprecatedString::repeated('0', precision);
number_string = ByteString::repeated('0', precision);
// b. Let e be 0.
exponent = 0;
@ -336,7 +336,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision)
number = round(number / pow(10, exponent - precision + 1));
// b. Let m be the String value consisting of the digits of the decimal representation of n (in order, with no leading zeroes).
number_string = number_to_deprecated_string(number, NumberToStringMode::WithoutExponent);
number_string = number_to_byte_string(number, NumberToStringMode::WithoutExponent);
// c. If e < -6 or e ≥ p, then
if ((exponent < -6) || (exponent >= precision)) {
@ -352,7 +352,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision)
auto second = number_string.substring_view(1);
// 3. Set m to the string-concatenation of a, ".", and b.
number_string = DeprecatedString::formatted("{}.{}", first, second);
number_string = ByteString::formatted("{}.{}", first, second);
}
char exponent_sign = 0;
@ -375,21 +375,21 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision)
}
// v. Let d be the String value consisting of the digits of the decimal representation of e (in order, with no leading zeroes).
auto exponent_string = DeprecatedString::number(exponent);
auto exponent_string = ByteString::number(exponent);
// vi. Return the string-concatenation of s, m, the code unit 0x0065 (LATIN SMALL LETTER E), c, and d.
return PrimitiveString::create(vm, DeprecatedString::formatted("{}{}e{}{}", sign, number_string, exponent_sign, exponent_string));
return PrimitiveString::create(vm, ByteString::formatted("{}{}e{}{}", sign, number_string, exponent_sign, exponent_string));
}
}
// 11. If e = p - 1, return the string-concatenation of s and m.
if (exponent == precision - 1)
return PrimitiveString::create(vm, DeprecatedString::formatted("{}{}", sign, number_string));
return PrimitiveString::create(vm, ByteString::formatted("{}{}", sign, number_string));
// 12. If e ≥ 0, then
if (exponent >= 0) {
// a. Set m to the string-concatenation of the first e + 1 code units of m, the code unit 0x002E (FULL STOP), and the remaining p - (e + 1) code units of m.
number_string = DeprecatedString::formatted(
number_string = ByteString::formatted(
"{}.{}",
number_string.substring_view(0, exponent + 1),
number_string.substring_view(exponent + 1));
@ -397,14 +397,14 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision)
// 13. Else,
else {
// a. Set m to the string-concatenation of the code unit 0x0030 (DIGIT ZERO), the code unit 0x002E (FULL STOP), -(e + 1) occurrences of the code unit 0x0030 (DIGIT ZERO), and the String m.
number_string = DeprecatedString::formatted(
number_string = ByteString::formatted(
"0.{}{}",
DeprecatedString::repeated('0', -1 * (exponent + 1)),
ByteString::repeated('0', -1 * (exponent + 1)),
number_string);
}
// 14. Return the string-concatenation of s and m.
return PrimitiveString::create(vm, DeprecatedString::formatted("{}{}", sign, number_string));
return PrimitiveString::create(vm, ByteString::formatted("{}{}", sign, number_string));
}
// 21.1.3.6 Number.prototype.toString ( [ radix ] ), https://tc39.es/ecma262/#sec-number.prototype.tostring
@ -428,7 +428,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_string)
// 5. If radixMV = 10, return ! ToString(x).
if (radix_mv == 10)
return PrimitiveString::create(vm, MUST(number_value.to_deprecated_string(vm)));
return PrimitiveString::create(vm, MUST(number_value.to_byte_string(vm)));
// 6. Return the String representation of this Number value using the radix specified by radixMV. Letters a-z are used for digits with values 10 through 35. The precise algorithm is implementation-defined, however the algorithm should be a generalization of that specified in 6.1.6.1.20.
if (number_value.is_positive_infinity())
@ -487,7 +487,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_string)
characters.take_last();
}
return PrimitiveString::create(vm, DeprecatedString(characters.data(), characters.size()));
return PrimitiveString::create(vm, ByteString(characters.data(), characters.size()));
}
// 21.1.3.7 Number.prototype.valueOf ( ), https://tc39.es/ecma262/#sec-number.prototype.valueof

View file

@ -5,7 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/TypeCasts.h>
#include <LibJS/Runtime/AbstractOperations.h>
#include <LibJS/Runtime/Accessor.h>
@ -1042,7 +1042,7 @@ ThrowCompletionOr<MarkedVector<Value>> Object::internal_own_property_keys() cons
// 2. For each own property key P of O such that P is an array index, in ascending numeric index order, do
for (auto& entry : m_indexed_properties) {
// a. Add P as the last element of keys.
keys.append(PrimitiveString::create(vm, DeprecatedString::number(entry.index())));
keys.append(PrimitiveString::create(vm, ByteString::number(entry.index())));
}
// 3. For each own property key P of O such that Type(P) is String and P is not an array index, in ascending chronological order of property creation, do
@ -1347,7 +1347,7 @@ Optional<Completion> Object::enumerate_object_properties(Function<Optional<Compl
for (auto& key : own_keys) {
if (!key.is_string())
continue;
DeprecatedFlyString property_key = key.as_string().deprecated_string();
DeprecatedFlyString property_key = key.as_string().byte_string();
if (visited.contains(property_key))
continue;
auto descriptor = TRY(target->internal_get_own_property(property_key));

View file

@ -278,7 +278,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::from_entries)
// 6. Return ? AddEntriesFromIterable(obj, iterable, adder).
(void)TRY(get_iterator_values(vm, iterable, [&](Value iterator_value) -> Optional<Completion> {
if (!iterator_value.is_object())
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, DeprecatedString::formatted("Iterator value {}", iterator_value.to_string_without_side_effects()));
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, ByteString::formatted("Iterator value {}", iterator_value.to_string_without_side_effects()));
auto key = TRY(iterator_value.as_object().get(0));
auto value = TRY(iterator_value.as_object().get(1));

View file

@ -5,7 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Function.h>
#include <LibJS/Runtime/AbstractOperations.h>
#include <LibJS/Runtime/Accessor.h>
@ -147,7 +147,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::to_string)
// 4. Let isArray be ? IsArray(O).
auto is_array = TRY(Value(object).is_array(vm));
DeprecatedString builtin_tag;
ByteString builtin_tag;
// 5. If isArray is true, let builtinTag be "Array".
if (is_array)
@ -184,16 +184,16 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::to_string)
auto to_string_tag = TRY(object->get(vm.well_known_symbol_to_string_tag()));
// Optimization: Instead of creating another PrimitiveString from builtin_tag, we separate tag and to_string_tag and add an additional branch to step 16.
DeprecatedString tag;
ByteString tag;
// 16. If Type(tag) is not String, set tag to builtinTag.
if (!to_string_tag.is_string())
tag = move(builtin_tag);
else
tag = to_string_tag.as_string().deprecated_string();
tag = to_string_tag.as_string().byte_string();
// 17. Return the string-concatenation of "[object ", tag, and "]".
return PrimitiveString::create(vm, DeprecatedString::formatted("[object {}]", tag));
return PrimitiveString::create(vm, ByteString::formatted("[object {}]", tag));
}
// 20.1.3.7 Object.prototype.valueOf ( ), https://tc39.es/ecma262/#sec-object.prototype.valueof

View file

@ -33,8 +33,8 @@ PrimitiveString::PrimitiveString(String string)
{
}
PrimitiveString::PrimitiveString(DeprecatedString string)
: m_deprecated_string(move(string))
PrimitiveString::PrimitiveString(ByteString string)
: m_byte_string(move(string))
{
}
@ -47,8 +47,8 @@ PrimitiveString::~PrimitiveString()
{
if (has_utf8_string())
vm().string_cache().remove(*m_utf8_string);
if (has_deprecated_string())
vm().deprecated_string_cache().remove(*m_deprecated_string);
if (has_byte_string())
vm().byte_string_cache().remove(*m_byte_string);
}
void PrimitiveString::visit_edges(Cell::Visitor& visitor)
@ -71,8 +71,8 @@ bool PrimitiveString::is_empty() const
return m_utf16_string->is_empty();
if (has_utf8_string())
return m_utf8_string->is_empty();
if (has_deprecated_string())
return m_deprecated_string->is_empty();
if (has_byte_string())
return m_byte_string->is_empty();
VERIFY_NOT_REACHED();
}
@ -81,8 +81,8 @@ String PrimitiveString::utf8_string() const
resolve_rope_if_needed(EncodingPreference::UTF8);
if (!has_utf8_string()) {
if (has_deprecated_string())
m_utf8_string = MUST(String::from_deprecated_string(*m_deprecated_string));
if (has_byte_string())
m_utf8_string = MUST(String::from_byte_string(*m_byte_string));
else if (has_utf16_string())
m_utf8_string = m_utf16_string->to_utf8();
else
@ -98,20 +98,20 @@ StringView PrimitiveString::utf8_string_view() const
return m_utf8_string->bytes_as_string_view();
}
DeprecatedString PrimitiveString::deprecated_string() const
ByteString PrimitiveString::byte_string() const
{
resolve_rope_if_needed(EncodingPreference::UTF8);
if (!has_deprecated_string()) {
if (!has_byte_string()) {
if (has_utf8_string())
m_deprecated_string = m_utf8_string->to_deprecated_string();
m_byte_string = m_utf8_string->to_byte_string();
else if (has_utf16_string())
m_deprecated_string = m_utf16_string->to_deprecated_string();
m_byte_string = m_utf16_string->to_byte_string();
else
VERIFY_NOT_REACHED();
}
return *m_deprecated_string;
return *m_byte_string;
}
Utf16String PrimitiveString::utf16_string() const
@ -122,8 +122,8 @@ Utf16String PrimitiveString::utf16_string() const
if (has_utf8_string()) {
m_utf16_string = Utf16String::create(m_utf8_string->bytes_as_string_view());
} else {
VERIFY(has_deprecated_string());
m_utf16_string = Utf16String::create(*m_deprecated_string);
VERIFY(has_byte_string());
m_utf16_string = Utf16String::create(*m_byte_string);
}
}
@ -200,7 +200,7 @@ NonnullGCPtr<PrimitiveString> PrimitiveString::create(VM& vm, StringView string)
return create(vm, String::from_utf8(string).release_value());
}
NonnullGCPtr<PrimitiveString> PrimitiveString::create(VM& vm, DeprecatedString string)
NonnullGCPtr<PrimitiveString> PrimitiveString::create(VM& vm, ByteString string)
{
if (string.is_empty())
return vm.empty_string();
@ -211,7 +211,7 @@ NonnullGCPtr<PrimitiveString> PrimitiveString::create(VM& vm, DeprecatedString s
return vm.single_ascii_character_string(ch);
}
auto& string_cache = vm.deprecated_string_cache();
auto& string_cache = vm.byte_string_cache();
auto it = string_cache.find(string);
if (it == string_cache.end()) {
auto new_string = vm.heap().allocate_without_realm<PrimitiveString>(string);

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/StringView.h>
@ -28,7 +28,7 @@ public:
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, Utf16String);
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, String);
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, FlyString const&);
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, DeprecatedString);
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, ByteString);
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, DeprecatedFlyString const&);
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, PrimitiveString&, PrimitiveString&);
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, StringView);
@ -44,8 +44,8 @@ public:
[[nodiscard]] StringView utf8_string_view() const;
bool has_utf8_string() const { return m_utf8_string.has_value(); }
[[nodiscard]] DeprecatedString deprecated_string() const;
bool has_deprecated_string() const { return m_deprecated_string.has_value(); }
[[nodiscard]] ByteString byte_string() const;
bool has_byte_string() const { return m_byte_string.has_value(); }
[[nodiscard]] Utf16String utf16_string() const;
[[nodiscard]] Utf16View utf16_string_view() const;
@ -56,7 +56,7 @@ public:
private:
explicit PrimitiveString(PrimitiveString&, PrimitiveString&);
explicit PrimitiveString(String);
explicit PrimitiveString(DeprecatedString);
explicit PrimitiveString(ByteString);
explicit PrimitiveString(Utf16String);
virtual void visit_edges(Cell::Visitor&) override;
@ -73,7 +73,7 @@ private:
mutable GCPtr<PrimitiveString> m_rhs;
mutable Optional<String> m_utf8_string;
mutable Optional<DeprecatedString> m_deprecated_string;
mutable Optional<ByteString> m_byte_string;
mutable Optional<Utf16String> m_utf16_string;
};

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Format.h>
#include <AK/Types.h>
#include <AK/Vector.h>
@ -76,11 +76,11 @@ template<>
struct Formatter<JS::PropertyAttributes> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& builder, JS::PropertyAttributes const& property_attributes)
{
Vector<DeprecatedString> parts;
parts.append(DeprecatedString::formatted("[[Writable]]: {}", property_attributes.is_writable()));
parts.append(DeprecatedString::formatted("[[Enumerable]]: {}", property_attributes.is_enumerable()));
parts.append(DeprecatedString::formatted("[[Configurable]]: {}", property_attributes.is_configurable()));
return Formatter<StringView>::format(builder, DeprecatedString::formatted("PropertyAttributes {{ {} }}", DeprecatedString::join(", "sv, parts)));
Vector<ByteString> parts;
parts.append(ByteString::formatted("[[Writable]]: {}", property_attributes.is_writable()));
parts.append(ByteString::formatted("[[Enumerable]]: {}", property_attributes.is_enumerable()));
parts.append(ByteString::formatted("[[Configurable]]: {}", property_attributes.is_configurable()));
return Formatter<StringView>::format(builder, ByteString::formatted("PropertyAttributes {{ {} }}", ByteString::join(", "sv, parts)));
}
};

View file

@ -35,7 +35,7 @@ public:
return PropertyKey { value.as_symbol() };
if (value.is_integral_number() && value.as_double() >= 0 && value.as_double() < NumericLimits<u32>::max())
return static_cast<u32>(value.as_double());
return TRY(value.to_deprecated_string(vm));
return TRY(value.to_byte_string(vm));
}
PropertyKey() = default;
@ -48,7 +48,7 @@ public:
VERIFY(index >= 0);
if constexpr (NumericLimits<T>::max() >= NumericLimits<u32>::max()) {
if (index >= NumericLimits<u32>::max()) {
m_string = DeprecatedString::number(index);
m_string = ByteString::number(index);
m_type = Type::String;
m_string_may_be_number = false;
return;
@ -65,7 +65,7 @@ public:
{
}
PropertyKey(DeprecatedString const& string)
PropertyKey(ByteString const& string)
: m_type(Type::String)
, m_string(DeprecatedFlyString(string))
{
@ -164,13 +164,13 @@ public:
return m_symbol;
}
DeprecatedString to_string() const
ByteString to_string() const
{
VERIFY(is_valid());
VERIFY(!is_symbol());
if (is_string())
return as_string();
return DeprecatedString::number(as_number());
return ByteString::number(as_number());
}
StringOrSymbol to_string_or_symbol() const

View file

@ -40,7 +40,7 @@ static Value property_key_to_value(VM& vm, PropertyKey const& property_key)
return PrimitiveString::create(vm, property_key.as_string());
VERIFY(property_key.is_number());
return PrimitiveString::create(vm, DeprecatedString::number(property_key.as_number()));
return PrimitiveString::create(vm, ByteString::number(property_key.as_number()));
}
// 10.5.1 [[GetPrototypeOf]] ( ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-getprototypeof

View file

@ -18,7 +18,7 @@ namespace JS {
JS_DEFINE_ALLOCATOR(RegExpObject);
Result<regex::RegexOptions<ECMAScriptFlags>, DeprecatedString> regex_flags_from_string(StringView flags)
Result<regex::RegexOptions<ECMAScriptFlags>, ByteString> regex_flags_from_string(StringView flags)
{
bool d = false, g = false, i = false, m = false, s = false, u = false, y = false, v = false;
auto options = RegExpObject::default_flags;
@ -27,42 +27,42 @@ Result<regex::RegexOptions<ECMAScriptFlags>, DeprecatedString> regex_flags_from_
switch (ch) {
case 'd':
if (d)
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
d = true;
break;
case 'g':
if (g)
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
g = true;
options |= regex::ECMAScriptFlags::Global;
break;
case 'i':
if (i)
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
i = true;
options |= regex::ECMAScriptFlags::Insensitive;
break;
case 'm':
if (m)
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
m = true;
options |= regex::ECMAScriptFlags::Multiline;
break;
case 's':
if (s)
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
s = true;
options |= regex::ECMAScriptFlags::SingleLine;
break;
case 'u':
if (u)
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
u = true;
options |= regex::ECMAScriptFlags::Unicode;
break;
case 'y':
if (y)
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
y = true;
// Now for the more interesting flag, 'sticky' actually unsets 'global', part of which is the default.
options.reset_flag(regex::ECMAScriptFlags::Global);
@ -74,12 +74,12 @@ Result<regex::RegexOptions<ECMAScriptFlags>, DeprecatedString> regex_flags_from_
break;
case 'v':
if (v)
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
v = true;
options |= regex::ECMAScriptFlags::UnicodeSets;
break;
default:
return DeprecatedString::formatted(ErrorType::RegExpObjectBadFlag.message(), ch);
return ByteString::formatted(ErrorType::RegExpObjectBadFlag.message(), ch);
}
}
@ -87,10 +87,10 @@ Result<regex::RegexOptions<ECMAScriptFlags>, DeprecatedString> regex_flags_from_
}
// 22.2.3.4 Static Semantics: ParsePattern ( patternText, u, v ), https://tc39.es/ecma262/#sec-parsepattern
ErrorOr<DeprecatedString, ParseRegexPatternError> parse_regex_pattern(StringView pattern, bool unicode, bool unicode_sets)
ErrorOr<ByteString, ParseRegexPatternError> parse_regex_pattern(StringView pattern, bool unicode, bool unicode_sets)
{
if (unicode && unicode_sets)
return ParseRegexPatternError { DeprecatedString::formatted(ErrorType::RegExpObjectIncompatibleFlags.message(), 'u', 'v') };
return ParseRegexPatternError { ByteString::formatted(ErrorType::RegExpObjectIncompatibleFlags.message(), 'u', 'v') };
auto utf16_pattern_result = AK::utf8_to_utf16(pattern);
if (utf16_pattern_result.is_error())
@ -132,11 +132,11 @@ ErrorOr<DeprecatedString, ParseRegexPatternError> parse_regex_pattern(StringView
previous_code_unit_was_backslash = false;
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
// 22.2.3.4 Static Semantics: ParsePattern ( patternText, u, v ), https://tc39.es/ecma262/#sec-parsepattern
ThrowCompletionOr<DeprecatedString> parse_regex_pattern(VM& vm, StringView pattern, bool unicode, bool unicode_sets)
ThrowCompletionOr<ByteString> parse_regex_pattern(VM& vm, StringView pattern, bool unicode, bool unicode_sets)
{
auto result = parse_regex_pattern(pattern, unicode, unicode_sets);
if (result.is_error())
@ -150,7 +150,7 @@ NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm)
return realm.heap().allocate<RegExpObject>(realm, realm.intrinsics().regexp_prototype());
}
NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm, Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags)
NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm, Regex<ECMA262> regex, ByteString pattern, ByteString flags)
{
return realm.heap().allocate<RegExpObject>(realm, move(regex), move(pattern), move(flags), realm.intrinsics().regexp_prototype());
}
@ -160,7 +160,7 @@ RegExpObject::RegExpObject(Object& prototype)
{
}
RegExpObject::RegExpObject(Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags, Object& prototype)
RegExpObject::RegExpObject(Regex<ECMA262> regex, ByteString pattern, ByteString flags, Object& prototype)
: Object(ConstructWithPrototypeTag::Tag, prototype)
, m_pattern(move(pattern))
, m_flags(move(flags))
@ -183,14 +183,14 @@ ThrowCompletionOr<NonnullGCPtr<RegExpObject>> RegExpObject::regexp_initialize(VM
// 1. If pattern is undefined, let P be the empty String.
// 2. Else, let P be ? ToString(pattern).
auto pattern = pattern_value.is_undefined()
? DeprecatedString::empty()
: TRY(pattern_value.to_deprecated_string(vm));
? ByteString::empty()
: TRY(pattern_value.to_byte_string(vm));
// 3. If flags is undefined, let F be the empty String.
// 4. Else, let F be ? ToString(flags).
auto flags = flags_value.is_undefined()
? DeprecatedString::empty()
: TRY(flags_value.to_deprecated_string(vm));
? ByteString::empty()
: TRY(flags_value.to_byte_string(vm));
// 5. If F contains any code unit other than "d", "g", "i", "m", "s", "u", "v", or "y", or if F contains any code unit more than once, throw a SyntaxError exception.
// 6. If F contains "i", let i be true; else let i be false.
@ -203,7 +203,7 @@ ThrowCompletionOr<NonnullGCPtr<RegExpObject>> RegExpObject::regexp_initialize(VM
return vm.throw_completion<SyntaxError>(parsed_flags_or_error.release_error());
auto parsed_flags = parsed_flags_or_error.release_value();
auto parsed_pattern = DeprecatedString::empty();
auto parsed_pattern = ByteString::empty();
if (!pattern.is_empty()) {
bool unicode = parsed_flags.has_flag_set(regex::ECMAScriptFlags::Unicode);
bool unicode_sets = parsed_flags.has_flag_set(regex::ECMAScriptFlags::UnicodeSets);
@ -244,7 +244,7 @@ ThrowCompletionOr<NonnullGCPtr<RegExpObject>> RegExpObject::regexp_initialize(VM
}
// 22.2.6.13.1 EscapeRegExpPattern ( P, F ), https://tc39.es/ecma262/#sec-escaperegexppattern
DeprecatedString RegExpObject::escape_regexp_pattern() const
ByteString RegExpObject::escape_regexp_pattern() const
{
// 1. Let S be a String in the form of a Pattern[~UnicodeMode] (Pattern[+UnicodeMode] if F contains "u") equivalent
// to P interpreted as UTF-16 encoded Unicode code points (6.1.4), in which certain code points are escaped as
@ -301,7 +301,7 @@ DeprecatedString RegExpObject::escape_regexp_pattern() const
}
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
// 22.2.3.1 RegExpCreate ( P, F ), https://tc39.es/ecma262/#sec-regexpcreate

View file

@ -16,12 +16,12 @@ namespace JS {
ThrowCompletionOr<NonnullGCPtr<RegExpObject>> regexp_create(VM&, Value pattern, Value flags);
ThrowCompletionOr<NonnullGCPtr<RegExpObject>> regexp_alloc(VM&, FunctionObject& new_target);
Result<regex::RegexOptions<ECMAScriptFlags>, DeprecatedString> regex_flags_from_string(StringView flags);
Result<regex::RegexOptions<ECMAScriptFlags>, ByteString> regex_flags_from_string(StringView flags);
struct ParseRegexPatternError {
DeprecatedString error;
ByteString error;
};
ErrorOr<DeprecatedString, ParseRegexPatternError> parse_regex_pattern(StringView pattern, bool unicode, bool unicode_sets);
ThrowCompletionOr<DeprecatedString> parse_regex_pattern(VM& vm, StringView pattern, bool unicode, bool unicode_sets);
ErrorOr<ByteString, ParseRegexPatternError> parse_regex_pattern(StringView pattern, bool unicode, bool unicode_sets);
ThrowCompletionOr<ByteString> parse_regex_pattern(VM& vm, StringView pattern, bool unicode, bool unicode_sets);
class RegExpObject : public Object {
JS_OBJECT(RegExpObject, Object);
@ -38,16 +38,16 @@ public:
};
static NonnullGCPtr<RegExpObject> create(Realm&);
static NonnullGCPtr<RegExpObject> create(Realm&, Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags);
static NonnullGCPtr<RegExpObject> create(Realm&, Regex<ECMA262> regex, ByteString pattern, ByteString flags);
ThrowCompletionOr<NonnullGCPtr<RegExpObject>> regexp_initialize(VM&, Value pattern, Value flags);
DeprecatedString escape_regexp_pattern() const;
ByteString escape_regexp_pattern() const;
virtual void initialize(Realm&) override;
virtual ~RegExpObject() override = default;
DeprecatedString const& pattern() const { return m_pattern; }
DeprecatedString const& flags() const { return m_flags; }
ByteString const& pattern() const { return m_pattern; }
ByteString const& flags() const { return m_flags; }
Regex<ECMA262> const& regex() { return *m_regex; }
Regex<ECMA262> const& regex() const { return *m_regex; }
Realm& realm() { return *m_realm; }
@ -58,10 +58,10 @@ public:
private:
RegExpObject(Object& prototype);
RegExpObject(Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags, Object& prototype);
RegExpObject(Regex<ECMA262> regex, ByteString pattern, ByteString flags, Object& prototype);
DeprecatedString m_pattern;
DeprecatedString m_flags;
ByteString m_pattern;
ByteString m_flags;
bool m_legacy_features_enabled { false }; // [[LegacyFeaturesEnabled]]
// Note: This is initialized in RegExpAlloc, but will be non-null afterwards
GCPtr<Realm> m_realm; // [[Realm]]

View file

@ -513,7 +513,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::flags)
#undef __JS_ENUMERATE
// 20. Return result.
return PrimitiveString::create(vm, builder.to_deprecated_string());
return PrimitiveString::create(vm, builder.to_byte_string());
}
// 22.2.6.8 RegExp.prototype [ @@match ] ( string ), https://tc39.es/ecma262/#sec-regexp.prototype-@@match
@ -530,7 +530,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_match)
// 4. Let flags be ? ToString(? Get(rx, "flags")).
auto flags_value = TRY(regexp_object->get(vm.names.flags));
auto flags = TRY(flags_value.to_deprecated_string(vm));
auto flags = TRY(flags_value.to_byte_string(vm));
// 5. If flags does not contain "g", then
if (!flags.contains('g')) {
@ -573,7 +573,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_match)
// 1. Let matchStr be ? ToString(? Get(result, "0")).
auto match_value = TRY(result.get(0));
auto match_str = TRY(match_value.to_deprecated_string(vm));
auto match_str = TRY(match_value.to_byte_string(vm));
// 2. Perform ! CreateDataPropertyOrThrow(A, ! ToString(𝔽(n)), matchStr).
MUST(array->create_data_property_or_throw(n, PrimitiveString::create(vm, match_str)));
@ -606,7 +606,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_match_all)
// 5. Let flags be ? ToString(? Get(R, "flags")).
auto flags_value = TRY(regexp_object->get(vm.names.flags));
auto flags = TRY(flags_value.to_deprecated_string(vm));
auto flags = TRY(flags_value.to_byte_string(vm));
// Steps 9-12 are performed early so that flags can be moved.
@ -651,13 +651,13 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
// 6. If functionalReplace is false, then
if (!replace_value.is_function()) {
// a. Set replaceValue to ? ToString(replaceValue).
auto replace_string = TRY(replace_value.to_deprecated_string(vm));
auto replace_string = TRY(replace_value.to_byte_string(vm));
replace_value = PrimitiveString::create(vm, move(replace_string));
}
// 7. Let flags be ? ToString(? Get(rx, "flags")).
auto flags_value = TRY(regexp_object->get(vm.names.flags));
auto flags = TRY(flags_value.to_deprecated_string(vm));
auto flags = TRY(flags_value.to_byte_string(vm));
// 8. If flags contains "g", let global be true. Otherwise, let global be false.
bool global = flags.contains('g');
@ -694,7 +694,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
// 1. Let matchStr be ? ToString(? Get(result, "0")).
auto match_value = TRY(result.get(vm, 0));
auto match_str = TRY(match_value.to_deprecated_string(vm));
auto match_str = TRY(match_value.to_byte_string(vm));
// 2. If matchStr is the empty String, then
if (match_str.is_empty()) {
@ -746,7 +746,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
// ii. If capN is not undefined, then
if (!capture.is_undefined()) {
// 1. Set capN to ? ToString(capN).
capture = PrimitiveString::create(vm, TRY(capture.to_deprecated_string(vm)));
capture = PrimitiveString::create(vm, TRY(capture.to_byte_string(vm)));
}
// iii. Append capN as the last element of captures.
@ -810,13 +810,13 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_replace)
// 16. If nextSourcePosition ≥ lengthS, return accumulatedResult.
if (next_source_position >= string.length_in_code_units())
return PrimitiveString::create(vm, accumulated_result.to_deprecated_string());
return PrimitiveString::create(vm, accumulated_result.to_byte_string());
// 17. Return the string-concatenation of accumulatedResult and the substring of S from nextSourcePosition.
auto substring = string.substring_view(next_source_position);
accumulated_result.append(substring);
return PrimitiveString::create(vm, accumulated_result.to_deprecated_string());
return PrimitiveString::create(vm, accumulated_result.to_byte_string());
}
// 22.2.6.12 RegExp.prototype [ @@search ] ( string ), https://tc39.es/ecma262/#sec-regexp.prototype-@@search
@ -901,7 +901,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_split)
// 5. Let flags be ? ToString(? Get(rx, "flags")).
auto flags_value = TRY(regexp_object->get(vm.names.flags));
auto flags = TRY(flags_value.to_deprecated_string(vm));
auto flags = TRY(flags_value.to_byte_string(vm));
// 6. If flags contains "u" or flags contains "v", let unicodeMatching be true.
// 7. Else, let unicodeMatching be false.
@ -909,7 +909,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_split)
// 8. If flags contains "y", let newFlags be flags.
// 9. Else, let newFlags be the string-concatenation of flags and "y".
auto new_flags = flags.find('y').has_value() ? move(flags) : DeprecatedString::formatted("{}y", flags);
auto new_flags = flags.find('y').has_value() ? move(flags) : ByteString::formatted("{}y", flags);
// 10. Let splitter be ? Construct(C, « rx, newFlags »).
auto splitter = TRY(construct(vm, *constructor, regexp_object, PrimitiveString::create(vm, move(new_flags))));
@ -1066,15 +1066,15 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::to_string)
// 3. Let pattern be ? ToString(? Get(R, "source")).
auto source_attr = TRY(regexp_object->get(vm.names.source));
auto pattern = TRY(source_attr.to_deprecated_string(vm));
auto pattern = TRY(source_attr.to_byte_string(vm));
// 4. Let flags be ? ToString(? Get(R, "flags")).
auto flags_attr = TRY(regexp_object->get(vm.names.flags));
auto flags = TRY(flags_attr.to_deprecated_string(vm));
auto flags = TRY(flags_attr.to_byte_string(vm));
// 5. Let result be the string-concatenation of "/", pattern, "/", and flags.
// 6. Return result.
return PrimitiveString::create(vm, DeprecatedString::formatted("/{}/{}", pattern, flags));
return PrimitiveString::create(vm, ByteString::formatted("/{}/{}", pattern, flags));
}
// B.2.4.1 RegExp.prototype.compile ( pattern, flags ), https://tc39.es/ecma262/#sec-regexp.prototype.compile

View file

@ -53,7 +53,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpStringIteratorPrototype::next)
auto match_object = TRY(match.to_object(vm));
auto match_string_value = TRY(match_object->get(0));
auto match_string = TRY(match_string_value.to_deprecated_string(vm));
auto match_string = TRY(match_string_value.to_byte_string(vm));
if (match_string.is_empty()) {
auto last_index_value = TRY(iterator->regexp_object().get(vm.names.lastIndex));
auto last_index = TRY(last_index_value.to_length(vm));

View file

@ -89,7 +89,7 @@ ThrowCompletionOr<void> copy_name_and_length(VM& vm, FunctionObject& function, F
target_name = PrimitiveString::create(vm, String {});
// 8. Perform SetFunctionName(F, targetName, prefix).
function.set_function_name({ target_name.as_string().deprecated_string() }, move(prefix));
function.set_function_name({ target_name.as_string().byte_string() }, move(prefix));
return {};
}
@ -214,7 +214,7 @@ ThrowCompletionOr<Value> perform_shadow_realm_eval(VM& vm, StringView source_tex
}
// 3.1.4 ShadowRealmImportValue ( specifierString: a String, exportNameString: a String, callerRealm: a Realm Record, evalRealm: a Realm Record, evalContext: an execution context, ), https://tc39.es/proposal-shadowrealm/#sec-shadowrealmimportvalue
ThrowCompletionOr<Value> shadow_realm_import_value(VM& vm, DeprecatedString specifier_string, DeprecatedString export_name_string, Realm& caller_realm, Realm& eval_realm, ExecutionContext& eval_context)
ThrowCompletionOr<Value> shadow_realm_import_value(VM& vm, ByteString specifier_string, ByteString export_name_string, Realm& caller_realm, Realm& eval_realm, ExecutionContext& eval_context)
{
// FIXME: evalRealm isn't being used anywhere in this AO (spec issue)
(void)eval_realm;

View file

@ -37,7 +37,7 @@ private:
ThrowCompletionOr<void> copy_name_and_length(VM&, FunctionObject& function, FunctionObject& target, Optional<StringView> prefix = {}, Optional<unsigned> arg_count = {});
ThrowCompletionOr<Value> perform_shadow_realm_eval(VM&, StringView source_text, Realm& caller_realm, Realm& eval_realm);
ThrowCompletionOr<Value> shadow_realm_import_value(VM&, DeprecatedString specifier_string, DeprecatedString export_name_string, Realm& caller_realm, Realm& eval_realm, ExecutionContext& eval_context);
ThrowCompletionOr<Value> shadow_realm_import_value(VM&, ByteString specifier_string, ByteString export_name_string, Realm& caller_realm, Realm& eval_realm, ExecutionContext& eval_context);
ThrowCompletionOr<Value> get_wrapped_value(VM&, Realm& caller_realm, Value);
}

View file

@ -51,7 +51,7 @@ JS_DEFINE_NATIVE_FUNCTION(ShadowRealmPrototype::evaluate)
auto& eval_realm = object->shadow_realm();
// 6. Return ? PerformShadowRealmEval(sourceText, callerRealm, evalRealm).
return perform_shadow_realm_eval(vm, source_text.as_string().deprecated_string(), *caller_realm, eval_realm);
return perform_shadow_realm_eval(vm, source_text.as_string().byte_string(), *caller_realm, eval_realm);
}
// 3.4.2 ShadowRealm.prototype.importValue ( specifier, exportName ), https://tc39.es/proposal-shadowrealm/#sec-shadowrealm.prototype.importvalue
@ -65,7 +65,7 @@ JS_DEFINE_NATIVE_FUNCTION(ShadowRealmPrototype::import_value)
auto object = TRY(typed_this_object(vm));
// 3. Let specifierString be ? ToString(specifier).
auto specifier_string = TRY(specifier.to_deprecated_string(vm));
auto specifier_string = TRY(specifier.to_byte_string(vm));
// 4. If Type(exportName) is not String, throw a TypeError exception.
if (!export_name.is_string())
@ -81,7 +81,7 @@ JS_DEFINE_NATIVE_FUNCTION(ShadowRealmPrototype::import_value)
auto& eval_context = object->execution_context();
// 8. Return ? ShadowRealmImportValue(specifierString, exportNameString, callerRealm, evalRealm, evalContext).
return shadow_realm_import_value(vm, move(specifier_string), export_name.as_string().deprecated_string(), *caller_realm, eval_realm, eval_context);
return shadow_realm_import_value(vm, move(specifier_string), export_name.as_string().byte_string(), *caller_realm, eval_realm, eval_context);
}
}

View file

@ -167,13 +167,13 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw)
// 7. Let nextIndex be 0.
// 8. Repeat,
for (size_t i = 0; i < literal_count; ++i) {
auto next_key = DeprecatedString::number(i);
auto next_key = ByteString::number(i);
// a. Let nextLiteralVal be ? Get(literals, ! ToString(𝔽(nextIndex))).
auto next_literal_value = TRY(literals->get(next_key));
// b. Let nextLiteral be ? ToString(nextLiteralVal).
auto next_literal = TRY(next_literal_value.to_deprecated_string(vm));
auto next_literal = TRY(next_literal_value.to_byte_string(vm));
// c. Set R to the string-concatenation of R and nextLiteral.
builder.append(next_literal);
@ -188,7 +188,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw)
auto next_substitution_value = vm.argument(i + 1);
// ii. Let nextSub be ? ToString(nextSubVal).
auto next_substitution = TRY(next_substitution_value.to_deprecated_string(vm));
auto next_substitution = TRY(next_substitution_value.to_byte_string(vm));
// iii. Set R to the string-concatenation of R and nextSub.
builder.append(next_substitution);
@ -196,7 +196,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw)
// f. Set nextIndex to nextIndex + 1.
}
return PrimitiveString::create(vm, builder.to_deprecated_string());
return PrimitiveString::create(vm, builder.to_byte_string());
}
}

View file

@ -22,7 +22,7 @@ public:
{
}
StringOrSymbol(DeprecatedString const& string)
StringOrSymbol(ByteString const& string)
: StringOrSymbol(DeprecatedFlyString(string))
{
}
@ -74,12 +74,12 @@ public:
return reinterpret_cast<Symbol const*>(bits() & ~1ul);
}
DeprecatedString to_display_string() const
ByteString to_display_string() const
{
if (is_string())
return as_string();
if (is_symbol())
return as_symbol()->descriptive_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
return as_symbol()->descriptive_string().release_value_but_fixme_should_propagate_errors().to_byte_string();
VERIFY_NOT_REACHED();
}

View file

@ -527,7 +527,7 @@ ThrowCompletionOr<Optional<String>> get_temporal_unit(VM& vm, Object const& norm
// 10. If value is undefined and default is required, throw a RangeError exception.
if (option_value.is_undefined() && default_.has<TemporalUnitRequired>())
return vm.throw_completion<RangeError>(ErrorType::IsUndefined, DeprecatedString::formatted("{} option value", key.as_string()));
return vm.throw_completion<RangeError>(ErrorType::IsUndefined, ByteString::formatted("{} option value", key.as_string()));
auto value = option_value.is_undefined()
? Optional<String> {}
@ -1794,7 +1794,7 @@ ThrowCompletionOr<Object*> prepare_temporal_fields(VM& vm, Object const& fields,
// 3. For each value property of fieldNames, do
for (auto& property : field_names) {
// a. Let value be ? Get(fields, property).
auto value = TRY(fields.get(property.to_deprecated_string()));
auto value = TRY(fields.get(property.to_byte_string()));
// b. If value is not undefined, then
if (!value.is_undefined()) {
@ -1823,7 +1823,7 @@ ThrowCompletionOr<Object*> prepare_temporal_fields(VM& vm, Object const& fields,
}
// iii. Perform ! CreateDataPropertyOrThrow(result, property, value).
MUST(result->create_data_property_or_throw(property.to_deprecated_string(), value));
MUST(result->create_data_property_or_throw(property.to_byte_string(), value));
}
// c. Else if requiredFields is a List, then
else if (required_fields.has<Vector<StringView>>()) {
@ -1840,7 +1840,7 @@ ThrowCompletionOr<Object*> prepare_temporal_fields(VM& vm, Object const& fields,
}
// iii. Perform ! CreateDataPropertyOrThrow(result, property, value).
MUST(result->create_data_property_or_throw(property.to_deprecated_string(), value));
MUST(result->create_data_property_or_throw(property.to_byte_string(), value));
}
}

View file

@ -787,7 +787,7 @@ ThrowCompletionOr<double> resolve_iso_month(VM& vm, Object const& fields)
// 6. Assert: Type(monthCode) is String.
VERIFY(month_code.is_string());
auto month_code_string = month_code.as_string().deprecated_string();
auto month_code_string = month_code.as_string().byte_string();
// 7. If the length of monthCode is not 3, throw a RangeError exception.
auto month_length = month_code_string.length();
@ -963,7 +963,7 @@ ThrowCompletionOr<Object*> default_merge_calendar_fields(VM& vm, Object const& f
// 3. For each element key of fieldsKeys, do
for (auto& key : fields_keys) {
// a. If key is not "month" or "monthCode", then
if (!key.as_string().deprecated_string().is_one_of(vm.names.month.as_string(), vm.names.monthCode.as_string())) {
if (!key.as_string().byte_string().is_one_of(vm.names.month.as_string(), vm.names.monthCode.as_string())) {
auto property_key = MUST(PropertyKey::from_value(vm, key));
// i. Let propValue be ? Get(fields, key).
@ -997,7 +997,7 @@ ThrowCompletionOr<Object*> default_merge_calendar_fields(VM& vm, Object const& f
}
// See comment above.
additional_fields_keys_contains_month_or_month_code_property |= key.as_string().deprecated_string() == vm.names.month.as_string() || key.as_string().deprecated_string() == vm.names.monthCode.as_string();
additional_fields_keys_contains_month_or_month_code_property |= key.as_string().byte_string() == vm.names.month.as_string() || key.as_string().byte_string() == vm.names.monthCode.as_string();
}
// 6. If additionalFieldsKeys does not contain either "month" or "monthCode", then

View file

@ -402,7 +402,7 @@ public:
// a. For each integer i starting with 0 such that i < O.[[ArrayLength]], in ascending order, do
for (size_t i = 0; i < m_array_length; ++i) {
// i. Add ! ToString(𝔽(i)) as the last element of keys.
keys.append(PrimitiveString::create(vm, DeprecatedString::number(i)));
keys.append(PrimitiveString::create(vm, ByteString::number(i)));
}
}

View file

@ -90,7 +90,7 @@ static ThrowCompletionOr<TypedArrayBase*> validate_typed_array_from_this(VM& vm)
return typed_array;
}
static ThrowCompletionOr<FunctionObject*> callback_from_args(VM& vm, DeprecatedString const& name)
static ThrowCompletionOr<FunctionObject*> callback_from_args(VM& vm, ByteString const& name)
{
if (vm.argument_count() < 1)
return vm.throw_completion<TypeError>(ErrorType::TypedArrayPrototypeOneArg, name);
@ -100,7 +100,7 @@ static ThrowCompletionOr<FunctionObject*> callback_from_args(VM& vm, DeprecatedS
return &callback.as_function();
}
static ThrowCompletionOr<void> for_each_item(VM& vm, DeprecatedString const& name, Function<IterationDecision(size_t index, Value value, Value callback_result)> callback)
static ThrowCompletionOr<void> for_each_item(VM& vm, ByteString const& name, Function<IterationDecision(size_t index, Value value, Value callback_result)> callback)
{
auto* typed_array = TRY(validate_typed_array_from_this(vm));
@ -122,7 +122,7 @@ static ThrowCompletionOr<void> for_each_item(VM& vm, DeprecatedString const& nam
return {};
}
static ThrowCompletionOr<void> for_each_item_from_last(VM& vm, DeprecatedString const& name, Function<IterationDecision(size_t index, Value value, Value callback_result)> callback)
static ThrowCompletionOr<void> for_each_item_from_last(VM& vm, ByteString const& name, Function<IterationDecision(size_t index, Value value, Value callback_result)> callback)
{
auto* typed_array = TRY(validate_typed_array_from_this(vm));
@ -803,9 +803,9 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::join)
// 4. If separator is undefined, let sep be ",".
// 5. Else, let sep be ? ToString(separator).
DeprecatedString separator = ",";
ByteString separator = ",";
if (!vm.argument(0).is_undefined())
separator = TRY(vm.argument(0).to_deprecated_string(vm));
separator = TRY(vm.argument(0).to_byte_string(vm));
// 6. Let R be the empty String.
StringBuilder builder;
@ -823,7 +823,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::join)
// c. If element is undefined, let next be the empty String; otherwise, let next be ! ToString(element).
if (element.is_undefined())
continue;
auto next = MUST(element.to_deprecated_string(vm));
auto next = MUST(element.to_byte_string(vm));
// d. Set R to the string-concatenation of R and next.
builder.append(next);
@ -832,7 +832,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::join)
}
// 9. Return R.
return PrimitiveString::create(vm, builder.to_deprecated_string());
return PrimitiveString::create(vm, builder.to_byte_string());
}
// 23.2.3.19 %TypedArray%.prototype.keys ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.keys
@ -1643,7 +1643,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::to_locale_string)
if (!next_element.is_nullish()) {
// i. Let S be ? ToString(? Invoke(nextElement, "toLocaleString", « locales, options »)).
auto locale_string_value = TRY(next_element.invoke(vm, vm.names.toLocaleString, locales, options));
auto locale_string = TRY(locale_string_value.to_deprecated_string(vm));
auto locale_string = TRY(locale_string_value.to_byte_string(vm));
// ii. Set R to the string-concatenation of R and S.
builder.append(locale_string);
@ -1653,7 +1653,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::to_locale_string)
}
// 7. Return R.
return PrimitiveString::create(vm, builder.to_deprecated_string());
return PrimitiveString::create(vm, builder.to_byte_string());
}
// 23.2.3.32 %TypedArray%.prototype.toReversed ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.toreversed

View file

@ -107,9 +107,9 @@ String Utf16String::to_utf8() const
return MUST(view().to_utf8(Utf16View::AllowInvalidCodeUnits::Yes));
}
DeprecatedString Utf16String::to_deprecated_string() const
ByteString Utf16String::to_byte_string() const
{
return MUST(view().to_deprecated_string(Utf16View::AllowInvalidCodeUnits::Yes));
return MUST(view().to_byte_string(Utf16View::AllowInvalidCodeUnits::Yes));
}
u16 Utf16String::code_unit_at(size_t index) const

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/NonnullRefPtr.h>
#include <AK/RefCounted.h>
#include <AK/Types.h>
@ -51,7 +51,7 @@ public:
Utf16View substring_view(size_t code_unit_offset) const;
[[nodiscard]] String to_utf8() const;
[[nodiscard]] DeprecatedString to_deprecated_string() const;
[[nodiscard]] ByteString to_byte_string() const;
u16 code_unit_at(size_t index) const;
size_t length_in_code_units() const;

View file

@ -106,7 +106,7 @@ VM::VM(OwnPtr<CustomData> custom_data, ErrorMessages error_messages)
};
host_get_supported_import_attributes = [&] {
return Vector<DeprecatedString> { "type" };
return Vector<ByteString> { "type" };
};
// 19.2.1.2 HostEnsureCanCompileStrings ( callerRealm, calleeRealm ), https://tc39.es/ecma262/#sec-hostensurecancompilestrings
@ -746,7 +746,7 @@ ScriptOrModule VM::get_active_script_or_module() const
return m_execution_context_stack[0]->script_or_module;
}
VM::StoredModule* VM::get_stored_module(ImportedModuleReferrer const&, DeprecatedString const& filename, DeprecatedString const&)
VM::StoredModule* VM::get_stored_module(ImportedModuleReferrer const&, ByteString const& filename, ByteString const&)
{
// Note the spec says:
// If this operation is called multiple times with the same (referrer, specifier) pair and it performs
@ -803,7 +803,7 @@ ThrowCompletionOr<void> VM::link_and_eval_module(CyclicModule& module)
return {};
}
static DeprecatedString resolve_module_filename(StringView filename, StringView module_type)
static ByteString resolve_module_filename(StringView filename, StringView module_type)
{
auto extensions = Vector<StringView, 2> { "js"sv, "mjs"sv };
if (module_type == "json"sv)
@ -811,14 +811,14 @@ static DeprecatedString resolve_module_filename(StringView filename, StringView
if (!FileSystem::exists(filename)) {
for (auto extension : extensions) {
// import "./foo" -> import "./foo.ext"
auto resolved_filepath = DeprecatedString::formatted("{}.{}", filename, extension);
auto resolved_filepath = ByteString::formatted("{}.{}", filename, extension);
if (FileSystem::exists(resolved_filepath))
return resolved_filepath;
}
} else if (FileSystem::is_directory(filename)) {
for (auto extension : extensions) {
// import "./foo" -> import "./foo/index.ext"
auto resolved_filepath = LexicalPath::join(filename, DeprecatedString::formatted("index.{}", extension)).string();
auto resolved_filepath = LexicalPath::join(filename, ByteString::formatted("index.{}", extension)).string();
if (FileSystem::exists(resolved_filepath))
return resolved_filepath;
}
@ -853,7 +853,7 @@ void VM::load_imported_module(ImportedModuleReferrer referrer, ModuleRequest con
return;
}
DeprecatedString module_type;
ByteString module_type;
for (auto& attribute : module_request.attributes) {
if (attribute.key == "type"sv) {
module_type = attribute.value;
@ -890,15 +890,15 @@ void VM::load_imported_module(ImportedModuleReferrer referrer, ModuleRequest con
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] resolved filename: '{}'", filename);
#if JS_MODULE_DEBUG
DeprecatedString referencing_module_string = referrer.visit(
[&](Empty) -> DeprecatedString {
ByteString referencing_module_string = referrer.visit(
[&](Empty) -> ByteString {
return ".";
},
[&](auto& script_or_module) {
if constexpr (IsSame<Script*, decltype(script_or_module)>) {
return DeprecatedString::formatted("Script @ {}", script_or_module.ptr());
return ByteString::formatted("Script @ {}", script_or_module.ptr());
}
return DeprecatedString::formatted("Module @ {}", script_or_module.ptr());
return ByteString::formatted("Module @ {}", script_or_module.ptr());
});
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] load_imported_module({}, {})", referencing_module_string, filename);
@ -949,14 +949,14 @@ void VM::load_imported_module(ImportedModuleReferrer referrer, ModuleRequest con
if (module_or_errors.is_error()) {
VERIFY(module_or_errors.error().size() > 0);
return throw_completion<SyntaxError>(module_or_errors.error().first().to_deprecated_string());
return throw_completion<SyntaxError>(module_or_errors.error().first().to_byte_string());
}
auto module = module_or_errors.release_value();
m_loaded_modules.empend(
referrer,
module->filename(),
DeprecatedString {}, // Null type
ByteString {}, // Null type
make_handle<Module>(*module),
true);

View file

@ -65,9 +65,9 @@ public:
return m_string_cache;
}
HashMap<DeprecatedString, GCPtr<PrimitiveString>>& deprecated_string_cache()
HashMap<ByteString, GCPtr<PrimitiveString>>& byte_string_cache()
{
return m_deprecated_string_cache;
return m_byte_string_cache;
}
PrimitiveString& empty_string() { return *m_empty_string; }
@ -186,7 +186,7 @@ public:
template<typename T, typename... Args>
Completion throw_completion(ErrorType type, Args&&... args)
{
return throw_completion<T>(DeprecatedString::formatted(type.message(), forward<Args>(args)...));
return throw_completion<T>(ByteString::formatted(type.message(), forward<Args>(args)...));
}
Value get_new_target();
@ -234,7 +234,7 @@ public:
Function<HashMap<PropertyKey, Value>(SourceTextModule&)> host_get_import_meta_properties;
Function<void(Object*, SourceTextModule const&)> host_finalize_import_meta;
Function<Vector<DeprecatedString>()> host_get_supported_import_attributes;
Function<Vector<ByteString>()> host_get_supported_import_attributes;
void set_dynamic_imports_allowed(bool value) { m_dynamic_imports_allowed = value; }
@ -275,7 +275,7 @@ private:
Vector<FlatPtr> get_native_stack_trace() const;
HashMap<String, GCPtr<PrimitiveString>> m_string_cache;
HashMap<DeprecatedString, GCPtr<PrimitiveString>> m_deprecated_string_cache;
HashMap<ByteString, GCPtr<PrimitiveString>> m_byte_string_cache;
Heap m_heap;
@ -298,13 +298,13 @@ private:
struct StoredModule {
ImportedModuleReferrer referrer;
DeprecatedString filename;
DeprecatedString type;
ByteString filename;
ByteString type;
Handle<Module> module;
bool has_once_started_linking { false };
};
StoredModule* get_stored_module(ImportedModuleReferrer const& script_or_module, DeprecatedString const& filename, DeprecatedString const& type);
StoredModule* get_stored_module(ImportedModuleReferrer const& script_or_module, ByteString const& filename, ByteString const& type);
Vector<StoredModule> m_loaded_modules;

View file

@ -8,8 +8,8 @@
#include <AK/AllOf.h>
#include <AK/Assertions.h>
#include <AK/ByteString.h>
#include <AK/CharacterTypes.h>
#include <AK/DeprecatedString.h>
#include <AK/FloatingPointStringConversions.h>
#include <AK/StringBuilder.h>
#include <AK/StringFloatingPointConversions.h>
@ -212,11 +212,11 @@ String number_to_string(double d, NumberToStringMode mode)
return builder.to_string().release_value();
}
DeprecatedString number_to_deprecated_string(double d, NumberToStringMode mode)
ByteString number_to_byte_string(double d, NumberToStringMode mode)
{
StringBuilder builder;
number_to_string_impl(builder, d, mode);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
// 7.2.2 IsArray ( argument ), https://tc39.es/ecma262/#sec-isarray
@ -439,9 +439,9 @@ ThrowCompletionOr<String> Value::to_string(VM& vm) const
}
// 7.1.17 ToString ( argument ), https://tc39.es/ecma262/#sec-tostring
ThrowCompletionOr<DeprecatedString> Value::to_deprecated_string(VM& vm) const
ThrowCompletionOr<ByteString> Value::to_byte_string(VM& vm) const
{
return TRY(to_string(vm)).to_deprecated_string();
return TRY(to_string(vm)).to_byte_string();
}
ThrowCompletionOr<Utf16String> Value::to_utf16_string(VM& vm) const
@ -500,7 +500,7 @@ ThrowCompletionOr<Value> Value::to_primitive_slow_case(VM& vm, PreferredType pre
// b. If exoticToPrim is not undefined, then
if (exotic_to_primitive) {
auto hint = [&]() -> DeprecatedString {
auto hint = [&]() -> ByteString {
switch (preferred_type) {
// i. If preferredType is not present, let hint be "default".
case PreferredType::Default:
@ -655,7 +655,7 @@ static Optional<NumberParseResult> parse_number_text(StringView text)
double string_to_number(StringView string)
{
// 1. Let text be StringToCodePoints(str).
DeprecatedString text = Utf8View(string).trim(whitespace_characters, AK::TrimMode::Both).as_string();
ByteString text = Utf8View(string).trim(whitespace_characters, AK::TrimMode::Both).as_string();
// 2. Let literal be ParseText(text, StringNumericLiteral).
if (text.is_empty())
@ -710,7 +710,7 @@ ThrowCompletionOr<Value> Value::to_number_slow_case(VM& vm) const
return Value(as_bool() ? 1 : 0);
// 6. If argument is a String, return StringToNumber(argument).
case STRING_TAG:
return string_to_number(as_string().deprecated_string());
return string_to_number(as_string().byte_string());
// 7. Assert: argument is an Object.
case OBJECT_TAG: {
// 8. Let primValue be ? ToPrimitive(argument, number).
@ -764,7 +764,7 @@ ThrowCompletionOr<NonnullGCPtr<BigInt>> Value::to_bigint(VM& vm) const
return primitive.as_bigint();
case STRING_TAG: {
// 1. Let n be ! StringToBigInt(prim).
auto bigint = string_to_bigint(vm, primitive.as_string().deprecated_string());
auto bigint = string_to_bigint(vm, primitive.as_string().byte_string());
// 2. If n is undefined, throw a SyntaxError exception.
if (!bigint.has_value())
@ -894,7 +894,7 @@ ThrowCompletionOr<PropertyKey> Value::to_property_key(VM& vm) const
}
// 3. Return ! ToString(key).
return MUST(key.to_deprecated_string(vm));
return MUST(key.to_byte_string(vm));
}
// 7.1.6 ToInt32 ( argument ), https://tc39.es/ecma262/#sec-toint32
@ -2212,7 +2212,7 @@ bool same_value_non_number(Value lhs, Value rhs)
// 5. If x is a String, then
if (lhs.is_string()) {
// a. If x and y are exactly the same sequence of code units (same length and same code units at corresponding indices), return true; otherwise, return false.
return lhs.as_string().deprecated_string() == rhs.as_string().deprecated_string();
return lhs.as_string().byte_string() == rhs.as_string().byte_string();
}
// 3. If x is undefined, return true.
@ -2293,7 +2293,7 @@ ThrowCompletionOr<bool> is_loosely_equal(VM& vm, Value lhs, Value rhs)
// 7. If Type(x) is BigInt and Type(y) is String, then
if (lhs.is_bigint() && rhs.is_string()) {
// a. Let n be StringToBigInt(y).
auto bigint = string_to_bigint(vm, rhs.as_string().deprecated_string());
auto bigint = string_to_bigint(vm, rhs.as_string().byte_string());
// b. If n is undefined, return false.
if (!bigint.has_value())
@ -2374,8 +2374,8 @@ ThrowCompletionOr<TriState> is_less_than(VM& vm, Value lhs, Value rhs, bool left
// 3. If px is a String and py is a String, then
if (x_primitive.is_string() && y_primitive.is_string()) {
auto x_string = x_primitive.as_string().deprecated_string();
auto y_string = y_primitive.as_string().deprecated_string();
auto x_string = x_primitive.as_string().byte_string();
auto y_string = y_primitive.as_string().byte_string();
Utf8View x_code_points { x_string };
Utf8View y_code_points { y_string };
@ -2410,7 +2410,7 @@ ThrowCompletionOr<TriState> is_less_than(VM& vm, Value lhs, Value rhs, bool left
// a. If px is a BigInt and py is a String, then
if (x_primitive.is_bigint() && y_primitive.is_string()) {
// i. Let ny be StringToBigInt(py).
auto y_bigint = string_to_bigint(vm, y_primitive.as_string().deprecated_string());
auto y_bigint = string_to_bigint(vm, y_primitive.as_string().byte_string());
// ii. If ny is undefined, return undefined.
if (!y_bigint.has_value())
@ -2425,7 +2425,7 @@ ThrowCompletionOr<TriState> is_less_than(VM& vm, Value lhs, Value rhs, bool left
// b. If px is a String and py is a BigInt, then
if (x_primitive.is_string() && y_primitive.is_bigint()) {
// i. Let nx be StringToBigInt(px).
auto x_bigint = string_to_bigint(vm, x_primitive.as_string().deprecated_string());
auto x_bigint = string_to_bigint(vm, x_primitive.as_string().byte_string());
// ii. If nx is undefined, return undefined.
if (!x_bigint.has_value())

View file

@ -10,7 +10,7 @@
#include <AK/Assertions.h>
#include <AK/BitCast.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Format.h>
#include <AK/Forward.h>
#include <AK/Function.h>
@ -374,7 +374,7 @@ public:
u64 encoded() const { return m_value.encoded; }
ThrowCompletionOr<String> to_string(VM&) const;
ThrowCompletionOr<DeprecatedString> to_deprecated_string(VM&) const;
ThrowCompletionOr<ByteString> to_byte_string(VM&) const;
ThrowCompletionOr<Utf16String> to_utf16_string(VM&) const;
ThrowCompletionOr<NonnullGCPtr<PrimitiveString>> to_primitive_string(VM&);
ThrowCompletionOr<Value> to_primitive(VM&, PreferredType preferred_type = PreferredType::Default) const;
@ -575,7 +575,7 @@ enum class NumberToStringMode {
WithoutExponent,
};
[[nodiscard]] String number_to_string(double, NumberToStringMode = NumberToStringMode::WithExponent);
[[nodiscard]] DeprecatedString number_to_deprecated_string(double, NumberToStringMode = NumberToStringMode::WithExponent);
[[nodiscard]] ByteString number_to_byte_string(double, NumberToStringMode = NumberToStringMode::WithExponent);
double string_to_number(StringView);
inline bool Value::operator==(Value const& value) const { return same_value(*this, value); }

View file

@ -19,7 +19,7 @@ struct ValueTraits : public Traits<Value> {
VERIFY(!value.is_empty());
if (value.is_string()) {
// FIXME: Propagate this error.
return value.as_string().deprecated_string().hash();
return value.as_string().byte_string().hash();
}
if (value.is_bigint())

View file

@ -64,7 +64,7 @@ ThrowCompletionOr<NonnullGCPtr<Object>> WeakMapConstructor::construct(FunctionOb
// 7. Return ? AddEntriesFromIterable(map, iterable, adder).
(void)TRY(get_iterator_values(vm, iterable, [&](Value iterator_value) -> Optional<Completion> {
if (!iterator_value.is_object())
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, DeprecatedString::formatted("Iterator value {}", iterator_value.to_string_without_side_effects()));
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, ByteString::formatted("Iterator value {}", iterator_value.to_string_without_side_effects()));
auto key = TRY(iterator_value.as_object().get(0));
auto value = TRY(iterator_value.as_object().get(1));

View file

@ -47,7 +47,7 @@ private:
Vector<ModuleWithSpecifier> m_loaded_modules; // [[LoadedModules]]
// Needed for potential lookups of modules.
DeprecatedString m_filename;
ByteString m_filename;
HostDefined* m_host_defined { nullptr }; // [[HostDefined]]
};

View file

@ -22,7 +22,7 @@ struct SourceRange {
Position start;
Position end;
DeprecatedString filename() const;
ByteString filename() const;
};
struct UnrealizedSourceRange {

View file

@ -93,14 +93,14 @@ static u32 hex2int(char x)
return 10u + (to_ascii_lowercase(x) - 'a');
}
DeprecatedString Token::string_value(StringValueStatus& status) const
ByteString Token::string_value(StringValueStatus& status) const
{
VERIFY(type() == TokenType::StringLiteral || type() == TokenType::TemplateLiteralString);
auto is_template = type() == TokenType::TemplateLiteralString;
GenericLexer lexer(is_template ? value() : value().substring_view(1, value().length() - 2));
auto encoding_failure = [&status](StringValueStatus parse_status) -> DeprecatedString {
auto encoding_failure = [&status](StringValueStatus parse_status) -> ByteString {
status = parse_status;
return {};
};
@ -174,7 +174,7 @@ DeprecatedString Token::string_value(StringValueStatus& status) const
// In non-strict mode LegacyOctalEscapeSequence is allowed in strings:
// https://tc39.es/ecma262/#sec-additional-syntax-string-literals
Optional<DeprecatedString> octal_str;
Optional<ByteString> octal_str;
auto is_octal_digit = [](char ch) { return ch >= '0' && ch <= '7'; };
auto is_zero_to_three = [](char ch) { return ch >= '0' && ch <= '3'; };
@ -210,11 +210,11 @@ DeprecatedString Token::string_value(StringValueStatus& status) const
lexer.retreat();
builder.append(lexer.consume_escaped_character('\\', "b\bf\fn\nr\rt\tv\v"sv));
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
// 12.8.6.2 Static Semantics: TRV, https://tc39.es/ecma262/#sec-static-semantics-trv
DeprecatedString Token::raw_template_value() const
ByteString Token::raw_template_value() const
{
return value().replace("\r\n"sv, "\n"sv, ReplaceMode::All).replace("\r"sv, "\n"sv, ReplaceMode::All);
}

View file

@ -233,8 +233,8 @@ public:
UnicodeEscapeOverflow,
LegacyOctalEscapeSequence,
};
DeprecatedString string_value(StringValueStatus& status) const;
DeprecatedString raw_template_value() const;
ByteString string_value(StringValueStatus& status) const;
ByteString raw_template_value() const;
void set_identifier_value(DeprecatedFlyString value)
{