1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:27:35 +00:00

AK+Everywhere: Rename String to DeprecatedString

We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
This commit is contained in:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -73,7 +73,7 @@ SourceRange ASTNode::source_range() const
return m_source_code->range_from_offsets(m_start_offset, m_end_offset);
}
String ASTNode::class_name() const
DeprecatedString ASTNode::class_name() const
{
// NOTE: We strip the "JS::" prefix.
auto const* typename_ptr = typeid(*this).name();
@ -82,7 +82,7 @@ String ASTNode::class_name() const
static void print_indent(int indent)
{
out("{}", String::repeated(' ', indent * 2));
out("{}", DeprecatedString::repeated(' ', indent * 2));
}
static void update_function_name(Value value, FlyString const& name)
@ -94,10 +94,10 @@ static void update_function_name(Value value, FlyString const& name)
static_cast<ECMAScriptFunctionObject&>(function).set_name(name);
}
static ThrowCompletionOr<String> get_function_property_name(PropertyKey key)
static ThrowCompletionOr<DeprecatedString> get_function_property_name(PropertyKey key)
{
if (key.is_symbol())
return String::formatted("[{}]", key.as_symbol()->description());
return DeprecatedString::formatted("[{}]", key.as_symbol()->description());
return key.to_string();
}
@ -416,7 +416,7 @@ Completion NewExpression::execute(Interpreter& interpreter) const
return Value { TRY(construct(vm, constructor.as_function(), move(arg_list))) };
}
Optional<String> CallExpression::expression_string() const
Optional<DeprecatedString> CallExpression::expression_string() const
{
if (is<Identifier>(*m_callee))
return static_cast<Identifier const&>(*m_callee).string();
@ -1592,23 +1592,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 = [&](String prefix = "") {
auto set_function_name = [&](DeprecatedString prefix = "") {
auto name = property_key_or_private_name.visit(
[&](PropertyKey const& property_key) -> String {
[&](PropertyKey const& property_key) -> DeprecatedString {
if (property_key.is_symbol()) {
auto description = property_key.as_symbol()->description();
if (description.is_empty())
return "";
return String::formatted("[{}]", description);
return DeprecatedString::formatted("[{}]", description);
} else {
return property_key.to_string();
}
},
[&](PrivateName const& private_name) -> String {
[&](PrivateName const& private_name) -> DeprecatedString {
return private_name.description;
});
update_function_name(method_value, String::formatted("{}{}{}", prefix, prefix.is_empty() ? "" : " ", name));
update_function_name(method_value, DeprecatedString::formatted("{}{}{}", prefix, prefix.is_empty() ? "" : " ", name));
};
if (property_key_or_private_name.has<PropertyKey>()) {
@ -1701,16 +1701,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) -> String {
[&](PropertyKey const& property_key) -> DeprecatedString {
return property_key.is_number() ? property_key.to_string() : property_key.to_string_or_symbol().to_display_string();
},
[&](PrivateName const& private_name) -> String {
[&](PrivateName const& private_name) -> DeprecatedString {
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, String::empty(), String::empty(), *function_code, {}, 0, interpreter.lexical_environment(), interpreter.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, DeprecatedString::empty(), DeprecatedString::empty(), *function_code, {}, 0, interpreter.lexical_environment(), interpreter.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);
}
@ -1755,7 +1755,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, String::empty(), String::empty(), *m_function_body, {}, 0, lexical_environment, private_environment, FunctionKind::Normal, true, false, m_contains_direct_call_to_eval, false);
auto* body_function = ECMAScriptFunctionObject::create(realm, DeprecatedString::empty(), DeprecatedString::empty(), *m_function_body, {}, 0, 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);
@ -2392,7 +2392,7 @@ void BindingPattern::dump(int indent) const
}
}
void FunctionNode::dump(int indent, String const& class_name) const
void FunctionNode::dump(int indent, DeprecatedString const& class_name) const
{
print_indent(indent);
auto is_async = m_kind == FunctionKind::Async || m_kind == FunctionKind::AsyncGenerator;
@ -3101,9 +3101,9 @@ Completion ObjectExpression::execute(Interpreter& interpreter) const
auto property_key = TRY(PropertyKey::from_value(vm, key));
auto name = TRY(get_function_property_name(property_key));
if (property.type() == ObjectProperty::Type::Getter) {
name = String::formatted("get {}", name);
name = DeprecatedString::formatted("get {}", name);
} else if (property.type() == ObjectProperty::Type::Setter) {
name = String::formatted("set {}", name);
name = DeprecatedString::formatted("set {}", name);
}
update_function_name(value, name);
@ -3138,14 +3138,14 @@ void MemberExpression::dump(int indent) const
m_property->dump(indent + 1);
}
String MemberExpression::to_string_approximation() const
DeprecatedString MemberExpression::to_string_approximation() const
{
String object_string = "<object>";
DeprecatedString object_string = "<object>";
if (is<Identifier>(*m_object))
object_string = static_cast<Identifier const&>(*m_object).string();
if (is_computed())
return String::formatted("{}[<computed>]", object_string);
return String::formatted("{}.{}", object_string, verify_cast<Identifier>(*m_property).string());
return DeprecatedString::formatted("{}[<computed>]", object_string);
return DeprecatedString::formatted("{}.{}", object_string, verify_cast<Identifier>(*m_property).string());
}
// 13.3.2.1 Runtime Semantics: Evaluation, https://tc39.es/ecma262/#sec-property-accessors-runtime-semantics-evaluation
@ -3264,7 +3264,7 @@ ThrowCompletionOr<JS::Reference> OptionalChain::to_reference(Interpreter& interp
void MetaProperty::dump(int indent) const
{
String name;
DeprecatedString name;
if (m_type == MetaProperty::Type::NewTarget)
name = "new.target";
else if (m_type == MetaProperty::Type::ImportMeta)
@ -3391,7 +3391,7 @@ Completion ImportCall::execute(Interpreter& interpreter) const
if (!options_value.is_undefined()) {
// a. If Type(options) is not Object,
if (!options_value.is_object()) {
auto* error = TypeError::create(realm, String::formatted(ErrorType::NotAnObject.message(), "ImportOptions"));
auto* error = TypeError::create(realm, DeprecatedString::formatted(ErrorType::NotAnObject.message(), "ImportOptions"));
// i. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
MUST(call(vm, *promise_capability->reject(), js_undefined(), error));
@ -3407,7 +3407,7 @@ Completion ImportCall::execute(Interpreter& interpreter) const
if (!assertion_object.is_undefined()) {
// i. If Type(assertionsObj) is not Object,
if (!assertion_object.is_object()) {
auto* error = TypeError::create(realm, String::formatted(ErrorType::NotAnObject.message(), "ImportOptionsAssertions"));
auto* error = TypeError::create(realm, DeprecatedString::formatted(ErrorType::NotAnObject.message(), "ImportOptionsAssertions"));
// 1. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
MUST(call(vm, *promise_capability->reject(), js_undefined(), error));
@ -3432,7 +3432,7 @@ Completion ImportCall::execute(Interpreter& interpreter) const
// 3. If Type(value) is not String, then
if (!value.is_string()) {
auto* error = TypeError::create(realm, String::formatted(ErrorType::NotAString.message(), "Import Assertion option value"));
auto* error = TypeError::create(realm, DeprecatedString::formatted(ErrorType::NotAString.message(), "Import Assertion option value"));
// a. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
MUST(call(vm, *promise_capability->reject(), js_undefined(), error));
@ -4504,11 +4504,11 @@ void ExportStatement::dump(int indent) const
print_indent(indent + 1);
outln("(ExportEntries)");
auto string_or_null = [](String const& string) -> String {
auto string_or_null = [](DeprecatedString const& string) -> DeprecatedString {
if (string.is_empty()) {
return "null";
}
return String::formatted("\"{}\"", string);
return DeprecatedString::formatted("\"{}\"", string);
};
for (auto& entry : m_entries) {
@ -4816,7 +4816,7 @@ ModuleRequest::ModuleRequest(FlyString module_specifier_, Vector<Assertion> asse
});
}
String const& SourceRange::filename() const
DeprecatedString const& SourceRange::filename() const
{
return code->filename();
}

View file

@ -8,12 +8,12 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/FlyString.h>
#include <AK/HashMap.h>
#include <AK/NonnullRefPtrVector.h>
#include <AK/OwnPtr.h>
#include <AK/RefPtr.h>
#include <AK/String.h>
#include <AK/Variant.h>
#include <AK/Vector.h>
#include <LibJS/Bytecode/CodeGenerationError.h>
@ -58,7 +58,7 @@ public:
void set_end_offset(Badge<Parser>, u32 end_offset) { m_end_offset = end_offset; }
String class_name() const;
DeprecatedString class_name() const;
template<typename T>
bool fast_is() const = delete;
@ -596,7 +596,7 @@ struct FunctionParameter {
class FunctionNode {
public:
FlyString const& name() const { return m_name; }
String const& source_text() const { return m_source_text; }
DeprecatedString 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; }
@ -607,7 +607,7 @@ public:
FunctionKind kind() const { return m_kind; }
protected:
FunctionNode(FlyString name, String source_text, NonnullRefPtr<Statement> 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)
FunctionNode(FlyString name, DeprecatedString source_text, NonnullRefPtr<Statement> 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)
: m_name(move(name))
, m_source_text(move(source_text))
, m_body(move(body))
@ -623,11 +623,11 @@ protected:
VERIFY(!m_might_need_arguments_object);
}
void dump(int indent, String const& class_name) const;
void dump(int indent, DeprecatedString const& class_name) const;
private:
FlyString m_name;
String m_source_text;
DeprecatedString m_source_text;
NonnullRefPtr<Statement> m_body;
Vector<FunctionParameter> const m_parameters;
const i32 m_function_length;
@ -644,7 +644,7 @@ class FunctionDeclaration final
public:
static bool must_have_name() { return true; }
FunctionDeclaration(SourceRange source_range, FlyString const& name, String source_text, NonnullRefPtr<Statement> body, Vector<FunctionParameter> parameters, i32 function_length, FunctionKind kind, bool is_strict_mode, bool might_need_arguments_object, bool contains_direct_call_to_eval)
FunctionDeclaration(SourceRange source_range, FlyString const& name, DeprecatedString source_text, NonnullRefPtr<Statement> body, Vector<FunctionParameter> parameters, i32 function_length, FunctionKind kind, bool is_strict_mode, bool might_need_arguments_object, bool contains_direct_call_to_eval)
: Declaration(source_range)
, FunctionNode(name, move(source_text), move(body), move(parameters), function_length, kind, is_strict_mode, might_need_arguments_object, contains_direct_call_to_eval, false)
{
@ -670,7 +670,7 @@ class FunctionExpression final
public:
static bool must_have_name() { return false; }
FunctionExpression(SourceRange source_range, FlyString const& name, String source_text, NonnullRefPtr<Statement> 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 = false)
FunctionExpression(SourceRange source_range, FlyString const& name, DeprecatedString source_text, NonnullRefPtr<Statement> 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 = false)
: Expression(source_range)
, FunctionNode(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)
{
@ -1104,7 +1104,7 @@ private:
class BigIntLiteral final : public Literal {
public:
explicit BigIntLiteral(SourceRange source_range, String value)
explicit BigIntLiteral(SourceRange source_range, DeprecatedString value)
: Literal(source_range)
, m_value(move(value))
{
@ -1115,12 +1115,12 @@ public:
virtual Bytecode::CodeGenerationErrorOr<void> generate_bytecode(Bytecode::Generator&) const override;
private:
String m_value;
DeprecatedString m_value;
};
class StringLiteral final : public Literal {
public:
explicit StringLiteral(SourceRange source_range, String value)
explicit StringLiteral(SourceRange source_range, DeprecatedString value)
: Literal(source_range)
, m_value(move(value))
{
@ -1135,7 +1135,7 @@ public:
private:
virtual bool is_string_literal() const override { return true; }
String m_value;
DeprecatedString m_value;
};
class NullLiteral final : public Literal {
@ -1152,7 +1152,7 @@ public:
class RegExpLiteral final : public Literal {
public:
RegExpLiteral(SourceRange source_range, regex::Parser::Result parsed_regex, String parsed_pattern, regex::RegexOptions<ECMAScriptFlags> parsed_flags, String pattern, String flags)
RegExpLiteral(SourceRange source_range, regex::Parser::Result parsed_regex, DeprecatedString parsed_pattern, regex::RegexOptions<ECMAScriptFlags> parsed_flags, DeprecatedString pattern, DeprecatedString flags)
: Literal(source_range)
, m_parsed_regex(move(parsed_regex))
, m_parsed_pattern(move(parsed_pattern))
@ -1167,17 +1167,17 @@ public:
virtual Bytecode::CodeGenerationErrorOr<void> generate_bytecode(Bytecode::Generator&) const override;
regex::Parser::Result const& parsed_regex() const { return m_parsed_regex; }
String const& parsed_pattern() const { return m_parsed_pattern; }
DeprecatedString const& parsed_pattern() const { return m_parsed_pattern; }
regex::RegexOptions<ECMAScriptFlags> const& parsed_flags() const { return m_parsed_flags; }
String const& pattern() const { return m_pattern; }
String const& flags() const { return m_flags; }
DeprecatedString const& pattern() const { return m_pattern; }
DeprecatedString const& flags() const { return m_flags; }
private:
regex::Parser::Result m_parsed_regex;
String m_parsed_pattern;
DeprecatedString m_parsed_pattern;
regex::RegexOptions<ECMAScriptFlags> m_parsed_flags;
String m_pattern;
String m_flags;
DeprecatedString m_pattern;
DeprecatedString m_flags;
};
class Identifier final : public Expression {
@ -1341,7 +1341,7 @@ public:
class ClassExpression final : public Expression {
public:
ClassExpression(SourceRange source_range, String name, String source_text, RefPtr<FunctionExpression> constructor, RefPtr<Expression> super_class, NonnullRefPtrVector<ClassElement> elements)
ClassExpression(SourceRange source_range, DeprecatedString name, DeprecatedString source_text, RefPtr<FunctionExpression> constructor, RefPtr<Expression> super_class, NonnullRefPtrVector<ClassElement> elements)
: Expression(source_range)
, m_name(move(name))
, m_source_text(move(source_text))
@ -1352,7 +1352,7 @@ public:
}
StringView name() const { return m_name; }
String const& source_text() const { return m_source_text; }
DeprecatedString const& source_text() const { return m_source_text; }
RefPtr<FunctionExpression> constructor() const { return m_constructor; }
virtual Completion execute(Interpreter&) const override;
@ -1366,8 +1366,8 @@ public:
private:
virtual bool is_class_expression() const override { return true; }
String m_name;
String m_source_text;
DeprecatedString m_name;
DeprecatedString m_source_text;
RefPtr<FunctionExpression> m_constructor;
RefPtr<Expression> m_super_class;
NonnullRefPtrVector<ClassElement> m_elements;
@ -1450,7 +1450,7 @@ protected:
virtual bool is_call_expression() const override { return true; }
Completion throw_type_error_for_callee(Interpreter&, Value callee_value, StringView call_type) const;
Optional<String> expression_string() const;
Optional<DeprecatedString> expression_string() const;
NonnullRefPtr<Expression> m_callee;
Vector<Argument> const m_arguments;
@ -1795,7 +1795,7 @@ public:
Expression const& object() const { return *m_object; }
Expression const& property() const { return *m_property; }
String to_string_approximation() const;
DeprecatedString to_string_approximation() const;
bool ends_in_private_name() const;

View file

@ -82,7 +82,7 @@ Bytecode::CodeGenerationErrorOr<void> ScopeNode::generate_bytecode(Bytecode::Gen
// b. If env.HasLexicalDeclaration(name) is true, throw a SyntaxError exception.
if (generator.has_binding(identifier)) {
// FIXME: Throw an actual SyntaxError instance.
generator.emit<Bytecode::Op::NewString>(generator.intern_string(String::formatted("SyntaxError: toplevel variable already declared: {}", name)));
generator.emit<Bytecode::Op::NewString>(generator.intern_string(DeprecatedString::formatted("SyntaxError: toplevel variable already declared: {}", name)));
generator.emit<Bytecode::Op::Throw>();
return {};
}
@ -98,7 +98,7 @@ Bytecode::CodeGenerationErrorOr<void> ScopeNode::generate_bytecode(Bytecode::Gen
// a. If env.HasLexicalDeclaration(name) is true, throw a SyntaxError exception.
if (generator.has_binding(identifier)) {
// FIXME: Throw an actual SyntaxError instance.
generator.emit<Bytecode::Op::NewString>(generator.intern_string(String::formatted("SyntaxError: toplevel variable already declared: {}", name)));
generator.emit<Bytecode::Op::NewString>(generator.intern_string(DeprecatedString::formatted("SyntaxError: toplevel variable already declared: {}", name)));
generator.emit<Bytecode::Op::Throw>();
}
return {};

View file

@ -4,19 +4,19 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <LibJS/Bytecode/BasicBlock.h>
#include <LibJS/Bytecode/Op.h>
#include <sys/mman.h>
namespace JS::Bytecode {
NonnullOwnPtr<BasicBlock> BasicBlock::create(String name, size_t size)
NonnullOwnPtr<BasicBlock> BasicBlock::create(DeprecatedString name, size_t size)
{
return adopt_own(*new BasicBlock(move(name), max(size, static_cast<size_t>(4 * KiB))));
}
BasicBlock::BasicBlock(String name, size_t size)
BasicBlock::BasicBlock(DeprecatedString name, size_t size)
: m_name(move(name))
{
// FIXME: This is not the smartest solution ever. Find something cleverer!

View file

@ -7,8 +7,8 @@
#pragma once
#include <AK/Badge.h>
#include <AK/DeprecatedString.h>
#include <AK/NonnullOwnPtrVector.h>
#include <AK/String.h>
#include <LibJS/Forward.h>
namespace JS::Bytecode {
@ -23,7 +23,7 @@ class BasicBlock {
AK_MAKE_NONCOPYABLE(BasicBlock);
public:
static NonnullOwnPtr<BasicBlock> create(String name, size_t size = 4 * KiB);
static NonnullOwnPtr<BasicBlock> create(DeprecatedString name, size_t size = 4 * KiB);
~BasicBlock();
void seal();
@ -40,16 +40,16 @@ public:
bool is_terminated() const { return m_terminator != nullptr; }
Instruction const* terminator() const { return m_terminator; }
String const& name() const { return m_name; }
DeprecatedString const& name() const { return m_name; }
private:
BasicBlock(String name, size_t size);
BasicBlock(DeprecatedString name, size_t size);
u8* m_buffer { nullptr };
Instruction const* m_terminator { nullptr };
size_t m_buffer_capacity { 0 };
size_t m_buffer_size { 0 };
String m_name;
DeprecatedString m_name;
};
}

View file

@ -16,7 +16,7 @@ struct CodeGenerationError {
ASTNode const* failing_node { nullptr };
StringView reason_literal;
String to_string();
DeprecatedString to_string();
};
template<typename T>

View file

@ -22,7 +22,7 @@ struct Executable {
size_t number_of_registers { 0 };
bool is_strict_mode { false };
String const& get_string(StringTableIndex index) const { return string_table->get(index); }
DeprecatedString const& get_string(StringTableIndex index) const { return string_table->get(index); }
FlyString const& get_identifier(IdentifierTableIndex index) const { return identifier_table->get(index); }
void dump() const;

View file

@ -316,9 +316,9 @@ Label Generator::perform_needed_unwinds_for_labelled_continue_and_return_target_
VERIFY_NOT_REACHED();
}
String CodeGenerationError::to_string()
DeprecatedString CodeGenerationError::to_string()
{
return String::formatted("CodeGenerationError in {}: {}", failing_node ? failing_node->class_name() : "<unknown node>", reason_literal);
return DeprecatedString::formatted("CodeGenerationError in {}: {}", failing_node ? failing_node->class_name() : "<unknown node>", reason_literal);
}
}

View file

@ -99,10 +99,10 @@ public:
[[nodiscard]] BasicBlock& current_block() { return *m_current_basic_block; }
BasicBlock& make_block(String name = {})
BasicBlock& make_block(DeprecatedString name = {})
{
if (name.is_empty())
name = String::number(m_next_block++);
name = DeprecatedString::number(m_next_block++);
m_root_basic_blocks.append(BasicBlock::create(name));
return m_root_basic_blocks.last();
}
@ -112,7 +112,7 @@ public:
return m_current_basic_block->is_terminated();
}
StringTableIndex intern_string(String string)
StringTableIndex intern_string(DeprecatedString string)
{
return m_string_table->insert(move(string));
}

View file

@ -106,7 +106,7 @@ public:
bool is_terminator() const;
Type type() const { return m_type; }
size_t length() const;
String to_string(Bytecode::Executable const&) const;
DeprecatedString to_string(Bytecode::Executable const&) const;
ThrowCompletionOr<void> execute(Bytecode::Interpreter&) const;
void replace_references(BasicBlock const&, BasicBlock const&);
void replace_references(Register, Register);

View file

@ -136,7 +136,7 @@ Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Executable const& e
if constexpr (JS_BYTECODE_DEBUG) {
for (size_t i = 0; i < registers().size(); ++i) {
String value_string;
DeprecatedString value_string;
if (registers()[i].is_empty())
value_string = "(empty)";
else

View file

@ -68,9 +68,9 @@ public:
Executable const& current_executable() { return *m_current_executable; }
BasicBlock const& current_block() const { return *m_current_block; }
size_t pc() const { return m_pc ? m_pc->offset() : 0; }
String debug_position()
DeprecatedString debug_position()
{
return String::formatted("{}:{:2}:{:4x}", m_current_executable->name, m_current_block->name(), pc());
return DeprecatedString::formatted("{}:{:2}:{:4x}", m_current_executable->name, m_current_block->name(), pc());
}
enum class OptimizationLevel {

View file

@ -29,7 +29,7 @@
namespace JS::Bytecode {
String Instruction::to_string(Bytecode::Executable const& executable) const
DeprecatedString Instruction::to_string(Bytecode::Executable const& executable) const
{
#define __BYTECODE_OP(op) \
case Instruction::Type::op: \
@ -60,14 +60,14 @@ static ThrowCompletionOr<void> put_by_property_key(Object* object, Value value,
case PropertyKind::Getter: {
auto& function = value.as_function();
if (function.name().is_empty() && is<ECMAScriptFunctionObject>(function))
static_cast<ECMAScriptFunctionObject*>(&function)->set_name(String::formatted("get {}", name));
static_cast<ECMAScriptFunctionObject*>(&function)->set_name(DeprecatedString::formatted("get {}", name));
object->define_direct_accessor(name, &function, nullptr, Attribute::Configurable | Attribute::Enumerable);
break;
}
case PropertyKind::Setter: {
auto& function = value.as_function();
if (function.name().is_empty() && is<ECMAScriptFunctionObject>(function))
static_cast<ECMAScriptFunctionObject*>(&function)->set_name(String::formatted("set {}", name));
static_cast<ECMAScriptFunctionObject*>(&function)->set_name(DeprecatedString::formatted("set {}", name));
object->define_direct_accessor(name, nullptr, &function, Attribute::Configurable | Attribute::Enumerable);
break;
}
@ -136,9 +136,9 @@ static ThrowCompletionOr<Value> typed_equals(VM&, Value src1, Value src2)
interpreter.accumulator() = TRY(op_snake_case(vm, lhs, rhs)); \
return {}; \
} \
String OpTitleCase::to_string_impl(Bytecode::Executable const&) const \
DeprecatedString OpTitleCase::to_string_impl(Bytecode::Executable const&) const \
{ \
return String::formatted(#OpTitleCase " {}", m_lhs_reg); \
return DeprecatedString::formatted(#OpTitleCase " {}", m_lhs_reg); \
}
JS_ENUMERATE_COMMON_BINARY_OPS(JS_DEFINE_COMMON_BINARY_OP)
@ -160,7 +160,7 @@ static ThrowCompletionOr<Value> typeof_(VM& vm, Value value)
interpreter.accumulator() = TRY(op_snake_case(vm, interpreter.accumulator())); \
return {}; \
} \
String OpTitleCase::to_string_impl(Bytecode::Executable const&) const \
DeprecatedString OpTitleCase::to_string_impl(Bytecode::Executable const&) const \
{ \
return #OpTitleCase; \
}
@ -430,7 +430,7 @@ ThrowCompletionOr<void> CreateVariable::execute_impl(Bytecode::Interpreter& inte
// Note: This is papering over an issue where "FunctionDeclarationInstantiation" creates these bindings for us.
// Instead of crashing in there, we'll just raise an exception here.
if (TRY(vm.lexical_environment()->has_binding(name)))
return vm.throw_completion<InternalError>(String::formatted("Lexical environment already has binding '{}'", name));
return vm.throw_completion<InternalError>(DeprecatedString::formatted("Lexical environment already has binding '{}'", name));
if (m_is_immutable)
vm.lexical_environment()->create_immutable_binding(vm, name, vm.in_strict_mode());
@ -1017,27 +1017,27 @@ ThrowCompletionOr<void> TypeofVariable::execute_impl(Bytecode::Interpreter& inte
return {};
}
String Load::to_string_impl(Bytecode::Executable const&) const
DeprecatedString Load::to_string_impl(Bytecode::Executable const&) const
{
return String::formatted("Load {}", m_src);
return DeprecatedString::formatted("Load {}", m_src);
}
String LoadImmediate::to_string_impl(Bytecode::Executable const&) const
DeprecatedString LoadImmediate::to_string_impl(Bytecode::Executable const&) const
{
return String::formatted("LoadImmediate {}", m_value);
return DeprecatedString::formatted("LoadImmediate {}", m_value);
}
String Store::to_string_impl(Bytecode::Executable const&) const
DeprecatedString Store::to_string_impl(Bytecode::Executable const&) const
{
return String::formatted("Store {}", m_dst);
return DeprecatedString::formatted("Store {}", m_dst);
}
String NewBigInt::to_string_impl(Bytecode::Executable const&) const
DeprecatedString NewBigInt::to_string_impl(Bytecode::Executable const&) const
{
return String::formatted("NewBigInt \"{}\"", m_bigint.to_base(10));
return DeprecatedString::formatted("NewBigInt \"{}\"", m_bigint.to_base(10));
}
String NewArray::to_string_impl(Bytecode::Executable const&) const
DeprecatedString NewArray::to_string_impl(Bytecode::Executable const&) const
{
StringBuilder builder;
builder.append("NewArray"sv);
@ -1047,34 +1047,34 @@ String NewArray::to_string_impl(Bytecode::Executable const&) const
return builder.to_string();
}
String Append::to_string_impl(Bytecode::Executable const&) const
DeprecatedString Append::to_string_impl(Bytecode::Executable const&) const
{
if (m_is_spread)
return String::formatted("Append lhs: **{}", m_lhs);
return String::formatted("Append lhs: {}", m_lhs);
return DeprecatedString::formatted("Append lhs: **{}", m_lhs);
return DeprecatedString::formatted("Append lhs: {}", m_lhs);
}
String IteratorToArray::to_string_impl(Bytecode::Executable const&) const
DeprecatedString IteratorToArray::to_string_impl(Bytecode::Executable const&) const
{
return "IteratorToArray";
}
String NewString::to_string_impl(Bytecode::Executable const& executable) const
DeprecatedString NewString::to_string_impl(Bytecode::Executable const& executable) const
{
return String::formatted("NewString {} (\"{}\")", m_string, executable.string_table->get(m_string));
return DeprecatedString::formatted("NewString {} (\"{}\")", m_string, executable.string_table->get(m_string));
}
String NewObject::to_string_impl(Bytecode::Executable const&) const
DeprecatedString NewObject::to_string_impl(Bytecode::Executable const&) const
{
return "NewObject";
}
String NewRegExp::to_string_impl(Bytecode::Executable const& executable) const
DeprecatedString NewRegExp::to_string_impl(Bytecode::Executable const& executable) const
{
return String::formatted("NewRegExp source:{} (\"{}\") flags:{} (\"{}\")", m_source_index, executable.get_string(m_source_index), m_flags_index, executable.get_string(m_flags_index));
return DeprecatedString::formatted("NewRegExp source:{} (\"{}\") flags:{} (\"{}\")", m_source_index, executable.get_string(m_source_index), m_flags_index, executable.get_string(m_flags_index));
}
String CopyObjectExcludingProperties::to_string_impl(Bytecode::Executable const&) const
DeprecatedString CopyObjectExcludingProperties::to_string_impl(Bytecode::Executable const&) const
{
StringBuilder builder;
builder.appendff("CopyObjectExcludingProperties from:{}", m_from_object);
@ -1086,50 +1086,50 @@ String CopyObjectExcludingProperties::to_string_impl(Bytecode::Executable const&
return builder.to_string();
}
String ConcatString::to_string_impl(Bytecode::Executable const&) const
DeprecatedString ConcatString::to_string_impl(Bytecode::Executable const&) const
{
return String::formatted("ConcatString {}", m_lhs);
return DeprecatedString::formatted("ConcatString {}", m_lhs);
}
String GetVariable::to_string_impl(Bytecode::Executable const& executable) const
DeprecatedString GetVariable::to_string_impl(Bytecode::Executable const& executable) const
{
return String::formatted("GetVariable {} ({})", m_identifier, executable.identifier_table->get(m_identifier));
return DeprecatedString::formatted("GetVariable {} ({})", m_identifier, executable.identifier_table->get(m_identifier));
}
String DeleteVariable::to_string_impl(Bytecode::Executable const& executable) const
DeprecatedString DeleteVariable::to_string_impl(Bytecode::Executable const& executable) const
{
return String::formatted("DeleteVariable {} ({})", m_identifier, executable.identifier_table->get(m_identifier));
return DeprecatedString::formatted("DeleteVariable {} ({})", m_identifier, executable.identifier_table->get(m_identifier));
}
String CreateEnvironment::to_string_impl(Bytecode::Executable const&) const
DeprecatedString CreateEnvironment::to_string_impl(Bytecode::Executable const&) const
{
auto mode_string = m_mode == EnvironmentMode::Lexical
? "Lexical"
: "Variable";
return String::formatted("CreateEnvironment mode:{}", mode_string);
return DeprecatedString::formatted("CreateEnvironment mode:{}", mode_string);
}
String CreateVariable::to_string_impl(Bytecode::Executable const& executable) const
DeprecatedString CreateVariable::to_string_impl(Bytecode::Executable const& executable) const
{
auto mode_string = m_mode == EnvironmentMode::Lexical ? "Lexical" : "Variable";
return String::formatted("CreateVariable env:{} immutable:{} global:{} {} ({})", mode_string, m_is_immutable, m_is_global, m_identifier, executable.identifier_table->get(m_identifier));
return DeprecatedString::formatted("CreateVariable env:{} immutable:{} global:{} {} ({})", mode_string, m_is_immutable, m_is_global, m_identifier, executable.identifier_table->get(m_identifier));
}
String EnterObjectEnvironment::to_string_impl(Executable const&) const
DeprecatedString EnterObjectEnvironment::to_string_impl(Executable const&) const
{
return String::formatted("EnterObjectEnvironment");
return DeprecatedString::formatted("EnterObjectEnvironment");
}
String SetVariable::to_string_impl(Bytecode::Executable const& executable) const
DeprecatedString SetVariable::to_string_impl(Bytecode::Executable const& executable) const
{
auto initialization_mode_name = m_initialization_mode == InitializationMode ::Initialize ? "Initialize"
: m_initialization_mode == InitializationMode::Set ? "Set"
: "InitializeOrSet";
auto mode_string = m_mode == EnvironmentMode::Lexical ? "Lexical" : "Variable";
return String::formatted("SetVariable env:{} init:{} {} ({})", mode_string, initialization_mode_name, m_identifier, executable.identifier_table->get(m_identifier));
return DeprecatedString::formatted("SetVariable env:{} init:{} {} ({})", mode_string, initialization_mode_name, m_identifier, executable.identifier_table->get(m_identifier));
}
String PutById::to_string_impl(Bytecode::Executable const& executable) const
DeprecatedString PutById::to_string_impl(Bytecode::Executable const& executable) const
{
auto kind = m_kind == PropertyKind::Getter
? "getter"
@ -1137,128 +1137,128 @@ String PutById::to_string_impl(Bytecode::Executable const& executable) const
? "setter"
: "property";
return String::formatted("PutById kind:{} base:{}, property:{} ({})", kind, m_base, m_property, executable.identifier_table->get(m_property));
return DeprecatedString::formatted("PutById kind:{} base:{}, property:{} ({})", kind, m_base, m_property, executable.identifier_table->get(m_property));
}
String GetById::to_string_impl(Bytecode::Executable const& executable) const
DeprecatedString GetById::to_string_impl(Bytecode::Executable const& executable) const
{
return String::formatted("GetById {} ({})", m_property, executable.identifier_table->get(m_property));
return DeprecatedString::formatted("GetById {} ({})", m_property, executable.identifier_table->get(m_property));
}
String DeleteById::to_string_impl(Bytecode::Executable const& executable) const
DeprecatedString DeleteById::to_string_impl(Bytecode::Executable const& executable) const
{
return String::formatted("DeleteById {} ({})", m_property, executable.identifier_table->get(m_property));
return DeprecatedString::formatted("DeleteById {} ({})", m_property, executable.identifier_table->get(m_property));
}
String Jump::to_string_impl(Bytecode::Executable const&) const
DeprecatedString Jump::to_string_impl(Bytecode::Executable const&) const
{
if (m_true_target.has_value())
return String::formatted("Jump {}", *m_true_target);
return String::formatted("Jump <empty>");
return DeprecatedString::formatted("Jump {}", *m_true_target);
return DeprecatedString::formatted("Jump <empty>");
}
String JumpConditional::to_string_impl(Bytecode::Executable const&) const
DeprecatedString JumpConditional::to_string_impl(Bytecode::Executable const&) const
{
auto true_string = m_true_target.has_value() ? String::formatted("{}", *m_true_target) : "<empty>";
auto false_string = m_false_target.has_value() ? String::formatted("{}", *m_false_target) : "<empty>";
return String::formatted("JumpConditional true:{} false:{}", true_string, false_string);
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);
}
String JumpNullish::to_string_impl(Bytecode::Executable const&) const
DeprecatedString JumpNullish::to_string_impl(Bytecode::Executable const&) const
{
auto true_string = m_true_target.has_value() ? String::formatted("{}", *m_true_target) : "<empty>";
auto false_string = m_false_target.has_value() ? String::formatted("{}", *m_false_target) : "<empty>";
return String::formatted("JumpNullish null:{} nonnull:{}", true_string, false_string);
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);
}
String JumpUndefined::to_string_impl(Bytecode::Executable const&) const
DeprecatedString JumpUndefined::to_string_impl(Bytecode::Executable const&) const
{
auto true_string = m_true_target.has_value() ? String::formatted("{}", *m_true_target) : "<empty>";
auto false_string = m_false_target.has_value() ? String::formatted("{}", *m_false_target) : "<empty>";
return String::formatted("JumpUndefined undefined:{} not undefined:{}", true_string, false_string);
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);
}
String Call::to_string_impl(Bytecode::Executable const& executable) const
DeprecatedString Call::to_string_impl(Bytecode::Executable const& executable) const
{
if (m_expression_string.has_value())
return String::formatted("Call callee:{}, this:{}, arguments:[...acc] ({})", m_callee, m_this_value, executable.get_string(m_expression_string.value()));
return DeprecatedString::formatted("Call callee:{}, this:{}, arguments:[...acc] ({})", m_callee, m_this_value, executable.get_string(m_expression_string.value()));
return String::formatted("Call callee:{}, this:{}, arguments:[...acc]", m_callee, m_this_value);
return DeprecatedString::formatted("Call callee:{}, this:{}, arguments:[...acc]", m_callee, m_this_value);
}
String SuperCall::to_string_impl(Bytecode::Executable const&) const
DeprecatedString SuperCall::to_string_impl(Bytecode::Executable const&) const
{
return "SuperCall arguments:[...acc]"sv;
}
String NewFunction::to_string_impl(Bytecode::Executable const&) const
DeprecatedString NewFunction::to_string_impl(Bytecode::Executable const&) const
{
return "NewFunction";
}
String NewClass::to_string_impl(Bytecode::Executable const&) const
DeprecatedString NewClass::to_string_impl(Bytecode::Executable const&) const
{
auto name = m_class_expression.name();
return String::formatted("NewClass '{}'", name.is_null() ? ""sv : name);
return DeprecatedString::formatted("NewClass '{}'", name.is_null() ? ""sv : name);
}
String Return::to_string_impl(Bytecode::Executable const&) const
DeprecatedString Return::to_string_impl(Bytecode::Executable const&) const
{
return "Return";
}
String Increment::to_string_impl(Bytecode::Executable const&) const
DeprecatedString Increment::to_string_impl(Bytecode::Executable const&) const
{
return "Increment";
}
String Decrement::to_string_impl(Bytecode::Executable const&) const
DeprecatedString Decrement::to_string_impl(Bytecode::Executable const&) const
{
return "Decrement";
}
String Throw::to_string_impl(Bytecode::Executable const&) const
DeprecatedString Throw::to_string_impl(Bytecode::Executable const&) const
{
return "Throw";
}
String EnterUnwindContext::to_string_impl(Bytecode::Executable const&) const
DeprecatedString EnterUnwindContext::to_string_impl(Bytecode::Executable const&) const
{
auto handler_string = m_handler_target.has_value() ? String::formatted("{}", *m_handler_target) : "<empty>";
auto finalizer_string = m_finalizer_target.has_value() ? String::formatted("{}", *m_finalizer_target) : "<empty>";
return String::formatted("EnterUnwindContext handler:{} finalizer:{} entry:{}", handler_string, finalizer_string, m_entry_point);
auto handler_string = m_handler_target.has_value() ? DeprecatedString::formatted("{}", *m_handler_target) : "<empty>";
auto finalizer_string = m_finalizer_target.has_value() ? DeprecatedString::formatted("{}", *m_finalizer_target) : "<empty>";
return DeprecatedString::formatted("EnterUnwindContext handler:{} finalizer:{} entry:{}", handler_string, finalizer_string, m_entry_point);
}
String FinishUnwind::to_string_impl(Bytecode::Executable const&) const
DeprecatedString FinishUnwind::to_string_impl(Bytecode::Executable const&) const
{
return String::formatted("FinishUnwind next:{}", m_next_target);
return DeprecatedString::formatted("FinishUnwind next:{}", m_next_target);
}
String LeaveEnvironment::to_string_impl(Bytecode::Executable const&) const
DeprecatedString LeaveEnvironment::to_string_impl(Bytecode::Executable const&) const
{
auto mode_string = m_mode == EnvironmentMode::Lexical
? "Lexical"
: "Variable";
return String::formatted("LeaveEnvironment env:{}", mode_string);
return DeprecatedString::formatted("LeaveEnvironment env:{}", mode_string);
}
String LeaveUnwindContext::to_string_impl(Bytecode::Executable const&) const
DeprecatedString LeaveUnwindContext::to_string_impl(Bytecode::Executable const&) const
{
return "LeaveUnwindContext";
}
String ContinuePendingUnwind::to_string_impl(Bytecode::Executable const&) const
DeprecatedString ContinuePendingUnwind::to_string_impl(Bytecode::Executable const&) const
{
return String::formatted("ContinuePendingUnwind resume:{}", m_resume_target);
return DeprecatedString::formatted("ContinuePendingUnwind resume:{}", m_resume_target);
}
String PushDeclarativeEnvironment::to_string_impl(Bytecode::Executable const& executable) const
DeprecatedString PushDeclarativeEnvironment::to_string_impl(Bytecode::Executable const& executable) const
{
StringBuilder builder;
builder.append("PushDeclarativeEnvironment"sv);
if (!m_variables.is_empty()) {
builder.append(" {"sv);
Vector<String> names;
Vector<DeprecatedString> names;
for (auto& it : m_variables)
names.append(executable.get_string(it.key));
builder.append('}');
@ -1267,19 +1267,19 @@ String PushDeclarativeEnvironment::to_string_impl(Bytecode::Executable const& ex
return builder.to_string();
}
String Yield::to_string_impl(Bytecode::Executable const&) const
DeprecatedString Yield::to_string_impl(Bytecode::Executable const&) const
{
if (m_continuation_label.has_value())
return String::formatted("Yield continuation:@{}", m_continuation_label->block().name());
return String::formatted("Yield return");
return DeprecatedString::formatted("Yield continuation:@{}", m_continuation_label->block().name());
return DeprecatedString::formatted("Yield return");
}
String GetByValue::to_string_impl(Bytecode::Executable const&) const
DeprecatedString GetByValue::to_string_impl(Bytecode::Executable const&) const
{
return String::formatted("GetByValue base:{}", m_base);
return DeprecatedString::formatted("GetByValue base:{}", m_base);
}
String PutByValue::to_string_impl(Bytecode::Executable const&) const
DeprecatedString PutByValue::to_string_impl(Bytecode::Executable const&) const
{
auto kind = m_kind == PropertyKind::Getter
? "getter"
@ -1287,52 +1287,52 @@ String PutByValue::to_string_impl(Bytecode::Executable const&) const
? "setter"
: "property";
return String::formatted("PutByValue kind:{} base:{}, property:{}", kind, m_base, m_property);
return DeprecatedString::formatted("PutByValue kind:{} base:{}, property:{}", kind, m_base, m_property);
}
String DeleteByValue::to_string_impl(Bytecode::Executable const&) const
DeprecatedString DeleteByValue::to_string_impl(Bytecode::Executable const&) const
{
return String::formatted("DeleteByValue base:{}", m_base);
return DeprecatedString::formatted("DeleteByValue base:{}", m_base);
}
String GetIterator::to_string_impl(Executable const&) const
DeprecatedString GetIterator::to_string_impl(Executable const&) const
{
return "GetIterator";
}
String GetObjectPropertyIterator::to_string_impl(Bytecode::Executable const&) const
DeprecatedString GetObjectPropertyIterator::to_string_impl(Bytecode::Executable const&) const
{
return "GetObjectPropertyIterator";
}
String IteratorNext::to_string_impl(Executable const&) const
DeprecatedString IteratorNext::to_string_impl(Executable const&) const
{
return "IteratorNext";
}
String IteratorResultDone::to_string_impl(Executable const&) const
DeprecatedString IteratorResultDone::to_string_impl(Executable const&) const
{
return "IteratorResultDone";
}
String IteratorResultValue::to_string_impl(Executable const&) const
DeprecatedString IteratorResultValue::to_string_impl(Executable const&) const
{
return "IteratorResultValue";
}
String ResolveThisBinding::to_string_impl(Bytecode::Executable const&) const
DeprecatedString ResolveThisBinding::to_string_impl(Bytecode::Executable const&) const
{
return "ResolveThisBinding"sv;
}
String GetNewTarget::to_string_impl(Bytecode::Executable const&) const
DeprecatedString GetNewTarget::to_string_impl(Bytecode::Executable const&) const
{
return "GetNewTarget"sv;
}
String TypeofVariable::to_string_impl(Bytecode::Executable const& executable) const
DeprecatedString TypeofVariable::to_string_impl(Bytecode::Executable const& executable) const
{
return String::formatted("TypeofVariable {} ({})", m_identifier, executable.identifier_table->get(m_identifier));
return DeprecatedString::formatted("TypeofVariable {} ({})", m_identifier, executable.identifier_table->get(m_identifier));
}
}

View file

@ -32,7 +32,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register from, Register to)
{
@ -53,7 +53,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
@ -70,7 +70,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
@ -114,7 +114,7 @@ private:
} \
\
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
String to_string_impl(Bytecode::Executable const&) const; \
DeprecatedString to_string_impl(Bytecode::Executable const&) const; \
void replace_references_impl(BasicBlock const&, BasicBlock const&) \
{ \
} \
@ -147,7 +147,7 @@ JS_ENUMERATE_COMMON_BINARY_OPS(JS_DECLARE_COMMON_BINARY_OP)
} \
\
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
String to_string_impl(Bytecode::Executable const&) const; \
DeprecatedString to_string_impl(Bytecode::Executable const&) const; \
void replace_references_impl(BasicBlock const&, BasicBlock const&) \
{ \
} \
@ -168,7 +168,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
@ -184,7 +184,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
};
@ -199,7 +199,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
@ -221,7 +221,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register from, Register to);
@ -242,7 +242,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
@ -268,7 +268,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
// Note: The underlying element range shall never be changed item, by item
// shifting it may be done in the future
@ -308,7 +308,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
// Note: This should never do anything, the lhs should always be an array, that is currently being constructed
@ -327,7 +327,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
};
@ -341,7 +341,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
// Note: lhs should always be a string in construction, so this should never do anything
void replace_references_impl(Register from, Register) { VERIFY(from != m_lhs); }
@ -364,7 +364,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
@ -380,7 +380,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
};
@ -397,7 +397,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
@ -424,7 +424,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
@ -445,7 +445,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
@ -466,7 +466,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
@ -485,7 +485,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
@ -512,7 +512,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register from, Register to)
{
@ -535,7 +535,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
@ -552,7 +552,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register from, Register to)
{
@ -575,7 +575,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register from, Register to)
{
@ -598,7 +598,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register from, Register to)
{
@ -635,7 +635,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&);
void replace_references_impl(Register, Register) { }
@ -655,7 +655,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
};
class JumpNullish final : public Jump {
@ -666,7 +666,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
};
class JumpUndefined final : public Jump {
@ -677,7 +677,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
};
// NOTE: This instruction is variable-width depending on the number of arguments!
@ -698,7 +698,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register);
@ -721,7 +721,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
@ -738,7 +738,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
@ -755,7 +755,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
@ -773,7 +773,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
};
@ -786,7 +786,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
};
@ -799,7 +799,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
};
@ -814,7 +814,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
};
@ -832,7 +832,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&);
void replace_references_impl(Register, Register) { }
@ -855,7 +855,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
@ -871,7 +871,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
};
@ -887,7 +887,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&);
void replace_references_impl(Register, Register) { }
@ -908,7 +908,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&);
void replace_references_impl(Register, Register) { }
@ -934,7 +934,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&);
void replace_references_impl(Register, Register) { }
@ -953,7 +953,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
@ -969,7 +969,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
};
@ -982,7 +982,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
};
@ -995,7 +995,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
};
@ -1008,7 +1008,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
};
@ -1021,7 +1021,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
};
@ -1034,7 +1034,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
};
@ -1047,7 +1047,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
};
@ -1061,7 +1061,7 @@ public:
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
DeprecatedString to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }

View file

@ -8,7 +8,7 @@
namespace JS::Bytecode {
StringTableIndex StringTable::insert(String string)
StringTableIndex StringTable::insert(DeprecatedString string)
{
for (size_t i = 0; i < m_strings.size(); i++) {
if (m_strings[i] == string)
@ -18,7 +18,7 @@ StringTableIndex StringTable::insert(String string)
return m_strings.size() - 1;
}
String const& StringTable::get(StringTableIndex index) const
DeprecatedString const& StringTable::get(StringTableIndex index) const
{
return m_strings[index.value()];
}

View file

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

View file

@ -135,7 +135,7 @@ ThrowCompletionOr<Value> Console::count()
}
// 4. Let concat be the concatenation of label, U+003A (:), U+0020 SPACE, and ToString(map[label]).
String concat = String::formatted("{}: {}", label, map.get(label).value());
DeprecatedString concat = DeprecatedString::formatted("{}: {}", label, map.get(label).value());
// 5. Perform Logger("count", « concat »).
MarkedVector<Value> concat_as_vector { vm.heap() };
@ -164,7 +164,7 @@ ThrowCompletionOr<Value> Console::count_reset()
else {
// 1. Let message be a string without any formatting specifiers indicating generically
// that the given label does not have an associated count.
auto message = String::formatted("\"{}\" doesn't have a count", label);
auto message = DeprecatedString::formatted("\"{}\" doesn't have a count", label);
// 2. Perform Logger("countReset", « message »);
MarkedVector<Value> message_as_vector { vm.heap() };
message_as_vector.append(js_string(vm, message));
@ -212,7 +212,7 @@ ThrowCompletionOr<Value> Console::assert_()
// 3. Otherwise:
else {
// 1. Let concat be the concatenation of message, U+003A (:), U+0020 SPACE, and first.
auto concat = js_string(vm, String::formatted("{}: {}", message->string(), first.to_string(vm).value()));
auto concat = js_string(vm, DeprecatedString::formatted("{}: {}", message->string(), first.to_string(vm).value()));
// 2. Set data[0] to concat.
data[0] = concat;
}
@ -231,7 +231,7 @@ ThrowCompletionOr<Value> Console::group()
Group group;
// 2. If data is not empty, let groupLabel be the result of Formatter(data).
String group_label;
DeprecatedString group_label;
auto data = vm_arguments();
if (!data.is_empty()) {
auto formatted_data = TRY(m_client->formatter(data));
@ -265,7 +265,7 @@ ThrowCompletionOr<Value> Console::group_collapsed()
Group group;
// 2. If data is not empty, let groupLabel be the result of Formatter(data).
String group_label;
DeprecatedString group_label;
auto data = vm_arguments();
if (!data.is_empty()) {
auto formatted_data = TRY(m_client->formatter(data));
@ -319,7 +319,7 @@ ThrowCompletionOr<Value> Console::time()
if (m_timer_table.contains(label)) {
if (m_client) {
MarkedVector<Value> timer_already_exists_warning_message_as_vector { vm.heap() };
timer_already_exists_warning_message_as_vector.append(js_string(vm, String::formatted("Timer '{}' already exists.", label)));
timer_already_exists_warning_message_as_vector.append(js_string(vm, DeprecatedString::formatted("Timer '{}' already exists.", label)));
TRY(m_client->printer(LogLevel::Warn, move(timer_already_exists_warning_message_as_vector)));
}
return js_undefined();
@ -347,7 +347,7 @@ ThrowCompletionOr<Value> Console::time_log()
if (maybe_start_time == m_timer_table.end()) {
if (m_client) {
MarkedVector<Value> timer_does_not_exist_warning_message_as_vector { vm.heap() };
timer_does_not_exist_warning_message_as_vector.append(js_string(vm, String::formatted("Timer '{}' does not exist.", label)));
timer_does_not_exist_warning_message_as_vector.append(js_string(vm, DeprecatedString::formatted("Timer '{}' does not exist.", label)));
TRY(m_client->printer(LogLevel::Warn, move(timer_does_not_exist_warning_message_as_vector)));
}
return js_undefined();
@ -358,7 +358,7 @@ ThrowCompletionOr<Value> Console::time_log()
auto duration = TRY(format_time_since(start_time));
// 4. Let concat be the concatenation of label, U+003A (:), U+0020 SPACE, and duration.
auto concat = String::formatted("{}: {}", label, duration);
auto concat = DeprecatedString::formatted("{}: {}", label, duration);
// 5. Prepend concat to data.
MarkedVector<Value> data { vm.heap() };
@ -390,7 +390,7 @@ ThrowCompletionOr<Value> Console::time_end()
if (maybe_start_time == m_timer_table.end()) {
if (m_client) {
MarkedVector<Value> timer_does_not_exist_warning_message_as_vector { vm.heap() };
timer_does_not_exist_warning_message_as_vector.append(js_string(vm, String::formatted("Timer '{}' does not exist.", label)));
timer_does_not_exist_warning_message_as_vector.append(js_string(vm, DeprecatedString::formatted("Timer '{}' does not exist.", label)));
TRY(m_client->printer(LogLevel::Warn, move(timer_does_not_exist_warning_message_as_vector)));
}
return js_undefined();
@ -404,7 +404,7 @@ ThrowCompletionOr<Value> Console::time_end()
auto duration = TRY(format_time_since(start_time));
// 5. Let concat be the concatenation of label, U+003A (:), U+0020 SPACE, and duration.
auto concat = String::formatted("{}: {}", label, duration);
auto concat = DeprecatedString::formatted("{}: {}", label, duration);
// 6. Perform Printer("timeEnd", « concat »).
if (m_client) {
@ -427,7 +427,7 @@ MarkedVector<Value> Console::vm_arguments()
return arguments;
}
void Console::output_debug_message(LogLevel log_level, String const& output) const
void Console::output_debug_message(LogLevel log_level, DeprecatedString const& output) const
{
switch (log_level) {
case Console::LogLevel::Debug:
@ -457,7 +457,7 @@ void Console::report_exception(JS::Error const& exception, bool in_promise) cons
m_client->report_exception(exception, in_promise);
}
ThrowCompletionOr<String> Console::value_vector_to_string(MarkedVector<Value> const& values)
ThrowCompletionOr<DeprecatedString> Console::value_vector_to_string(MarkedVector<Value> const& values)
{
auto& vm = realm().vm();
StringBuilder builder;
@ -469,7 +469,7 @@ ThrowCompletionOr<String> Console::value_vector_to_string(MarkedVector<Value> co
return builder.to_string();
}
ThrowCompletionOr<String> Console::format_time_since(Core::ElapsedTimer timer)
ThrowCompletionOr<DeprecatedString> Console::format_time_since(Core::ElapsedTimer timer)
{
auto& vm = realm().vm();

View file

@ -45,12 +45,12 @@ public:
};
struct Group {
String label;
DeprecatedString label;
};
struct Trace {
String label;
Vector<String> stack;
DeprecatedString label;
Vector<DeprecatedString> stack;
};
explicit Console(Realm&);
@ -61,8 +61,8 @@ public:
MarkedVector<Value> vm_arguments();
HashMap<String, unsigned>& counters() { return m_counters; }
HashMap<String, unsigned> const& counters() const { return m_counters; }
HashMap<DeprecatedString, unsigned>& counters() { return m_counters; }
HashMap<DeprecatedString, unsigned> const& counters() const { return m_counters; }
ThrowCompletionOr<Value> debug();
ThrowCompletionOr<Value> error();
@ -81,18 +81,18 @@ public:
ThrowCompletionOr<Value> time_log();
ThrowCompletionOr<Value> time_end();
void output_debug_message(LogLevel log_level, String const& output) const;
void output_debug_message(LogLevel log_level, DeprecatedString const& output) const;
void report_exception(JS::Error const&, bool) const;
private:
ThrowCompletionOr<String> value_vector_to_string(MarkedVector<Value> const&);
ThrowCompletionOr<String> format_time_since(Core::ElapsedTimer timer);
ThrowCompletionOr<DeprecatedString> value_vector_to_string(MarkedVector<Value> const&);
ThrowCompletionOr<DeprecatedString> format_time_since(Core::ElapsedTimer timer);
Realm& m_realm;
ConsoleClient* m_client { nullptr };
HashMap<String, unsigned> m_counters;
HashMap<String, Core::ElapsedTimer> m_timer_table;
HashMap<DeprecatedString, unsigned> m_counters;
HashMap<DeprecatedString, Core::ElapsedTimer> m_timer_table;
Vector<Group> m_group_stack;
};

View file

@ -78,7 +78,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, String::join(',', stack), index);
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] inner_module_linking[{}](vm, {}, {})", this, DeprecatedString::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) {
@ -282,7 +282,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, String::join(", "sv, stack), index);
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] inner_module_evaluation[{}](vm, {}, {})", this, DeprecatedString::join(", "sv, stack), index);
// Note: Step 1 is performed in Module.cpp
// 2. If module.[[Status]] is evaluating-async or evaluated, then

View file

@ -7,9 +7,9 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/FlyString.h>
#include <AK/HashMap.h>
#include <AK/String.h>
#include <AK/Weakable.h>
#include <LibJS/Forward.h>
#include <LibJS/Heap/DeferGC.h>

View file

@ -17,8 +17,8 @@
namespace JS {
HashMap<FlyString, TokenType> Lexer::s_keywords;
HashMap<String, TokenType> Lexer::s_three_char_tokens;
HashMap<String, TokenType> Lexer::s_two_char_tokens;
HashMap<DeprecatedString, TokenType> Lexer::s_three_char_tokens;
HashMap<DeprecatedString, 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) {
String type;
DeprecatedString type;
if (m_current_char == '\n')
type = "LINE FEED";
else if (m_current_char == '\r')
@ -572,7 +572,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.)
String token_message;
DeprecatedString token_message;
Optional<FlyString> identifier;
size_t identifier_length = 0;

View file

@ -8,8 +8,8 @@
#include "Token.h"
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/String.h>
#include <AK/StringView.h>
namespace JS {
@ -20,8 +20,8 @@ public:
Token next();
String const& source() const { return m_source; };
String const& filename() const { return m_filename; };
DeprecatedString const& source() const { return m_source; };
DeprecatedString const& filename() const { return m_filename; };
void disallow_html_comments() { m_allow_html_comments = false; };
@ -57,13 +57,13 @@ private:
TokenType consume_regex_literal();
String m_source;
DeprecatedString m_source;
size_t m_position { 0 };
Token m_current_token;
char m_current_char { 0 };
bool m_eof { false };
String m_filename;
DeprecatedString m_filename;
size_t m_line_number { 1 };
size_t m_line_column { 0 };
@ -80,8 +80,8 @@ private:
Optional<size_t> m_hit_invalid_unicode;
static HashMap<FlyString, TokenType> s_keywords;
static HashMap<String, TokenType> s_three_char_tokens;
static HashMap<String, TokenType> s_two_char_tokens;
static HashMap<DeprecatedString, TokenType> s_three_char_tokens;
static HashMap<DeprecatedString, TokenType> s_two_char_tokens;
static HashMap<char, TokenType> s_single_char_tokens;
struct ParsedIdentifiers : public RefCounted<ParsedIdentifiers> {

View file

@ -18,7 +18,7 @@
namespace JS {
String MarkupGenerator::html_from_source(StringView source)
DeprecatedString MarkupGenerator::html_from_source(StringView source)
{
StringBuilder builder;
auto lexer = Lexer(source);
@ -29,14 +29,14 @@ String MarkupGenerator::html_from_source(StringView source)
return builder.to_string();
}
String MarkupGenerator::html_from_value(Value value)
DeprecatedString MarkupGenerator::html_from_value(Value value)
{
StringBuilder output_html;
value_to_html(value, output_html);
return output_html.to_string();
}
String MarkupGenerator::html_from_error(Error const& object, bool in_promise)
DeprecatedString MarkupGenerator::html_from_error(Error const& object, bool in_promise)
{
StringBuilder output_html;
error_to_html(object, output_html, in_promise);
@ -110,7 +110,7 @@ void MarkupGenerator::object_to_html(Object const& object, StringBuilder& html_o
if (!first)
html_output.append(wrap_string_in_style(", ", StyleType::Punctuation));
first = false;
html_output.append(wrap_string_in_style(String::number(entry.index()), StyleType::Number));
html_output.append(wrap_string_in_style(DeprecatedString::number(entry.index()), StyleType::Number));
html_output.append(wrap_string_in_style(": ", StyleType::Punctuation));
// FIXME: Exception check
value_to_html(object.get(entry.index()).release_value(), html_output, seen_objects);
@ -121,7 +121,7 @@ void MarkupGenerator::object_to_html(Object const& object, StringBuilder& html_o
size_t index = 0;
for (auto& it : object.shape().property_table_ordered()) {
html_output.append(wrap_string_in_style(String::formatted("\"{}\"", escape_html_entities(it.key.to_display_string())), StyleType::String));
html_output.append(wrap_string_in_style(DeprecatedString::formatted("\"{}\"", escape_html_entities(it.key.to_display_string())), StyleType::String));
html_output.append(wrap_string_in_style(": ", StyleType::Punctuation));
value_to_html(object.get_direct(it.value.offset), html_output, seen_objects);
if (index != object.shape().property_count() - 1)
@ -151,7 +151,7 @@ void MarkupGenerator::trace_to_html(TracebackFrame const& traceback_frame, Strin
return last_slash_index.has_value() ? filename.substring_view(*last_slash_index + 1) : filename;
};
auto filename = escape_html_entities(get_filename_from_path(traceback_frame.source_range.filename()));
auto trace = String::formatted("at {} ({}:{}:{})", function_name, filename, line, column);
auto trace = DeprecatedString::formatted("at {} ({}:{}:{})", function_name, filename, line, column);
html_output.appendff("&nbsp;&nbsp;{}<br>", trace);
}
@ -163,7 +163,7 @@ void MarkupGenerator::error_to_html(Error const& error, StringBuilder& html_outp
auto message = error.get_without_side_effects(vm.names.message).value_or(js_undefined());
auto name_string = name.to_string_without_side_effects();
auto message_string = message.to_string_without_side_effects();
auto uncaught_message = String::formatted("Uncaught {}[{}]: ", in_promise ? "(in promise) " : "", name_string);
auto uncaught_message = DeprecatedString::formatted("Uncaught {}[{}]: ", in_promise ? "(in promise) " : "", name_string);
html_output.append(wrap_string_in_style(uncaught_message, StyleType::Invalid));
html_output.appendff("{}<br>", message_string.is_empty() ? "\"\"" : escape_html_entities(message_string));
@ -174,7 +174,7 @@ void MarkupGenerator::error_to_html(Error const& error, StringBuilder& html_outp
}
}
String MarkupGenerator::style_from_style_type(StyleType type)
DeprecatedString MarkupGenerator::style_from_style_type(StyleType type)
{
switch (type) {
case StyleType::Invalid:
@ -233,14 +233,14 @@ MarkupGenerator::StyleType MarkupGenerator::style_type_for_token(Token token)
}
}
String MarkupGenerator::open_style_type(StyleType type)
DeprecatedString MarkupGenerator::open_style_type(StyleType type)
{
return String::formatted("<span style=\"{}\">", style_from_style_type(type));
return DeprecatedString::formatted("<span style=\"{}\">", style_from_style_type(type));
}
String MarkupGenerator::wrap_string_in_style(String source, StyleType type)
DeprecatedString MarkupGenerator::wrap_string_in_style(DeprecatedString source, StyleType type)
{
return String::formatted("<span style=\"{}\">{}</span>", style_from_style_type(type), escape_html_entities(source));
return DeprecatedString::formatted("<span style=\"{}\">{}</span>", style_from_style_type(type), escape_html_entities(source));
}
}

View file

@ -6,8 +6,8 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/HashTable.h>
#include <AK/String.h>
#include <LibJS/Forward.h>
#include <LibJS/Runtime/Error.h>
@ -15,9 +15,9 @@ namespace JS {
class MarkupGenerator {
public:
static String html_from_source(StringView);
static String html_from_value(Value);
static String html_from_error(Error const&, bool);
static DeprecatedString html_from_source(StringView);
static DeprecatedString html_from_value(Value);
static DeprecatedString html_from_error(Error const&, bool);
private:
enum class StyleType {
@ -41,10 +41,10 @@ private:
static void error_to_html(Error const&, StringBuilder& output_html, bool in_promise);
static void trace_to_html(TracebackFrame const&, StringBuilder& output_html);
static String style_from_style_type(StyleType);
static DeprecatedString style_from_style_type(StyleType);
static StyleType style_type_for_token(Token);
static String open_style_type(StyleType type);
static String wrap_string_in_style(String source, StyleType type);
static DeprecatedString open_style_type(StyleType type);
static DeprecatedString wrap_string_in_style(DeprecatedString source, StyleType type);
};
}

View file

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

View file

@ -83,7 +83,7 @@ public:
virtual ThrowCompletionOr<u32> inner_module_evaluation(VM& vm, Vector<Module*>& stack, u32 index);
protected:
Module(Realm&, String filename, Script::HostDefined* host_defined = nullptr);
Module(Realm&, DeprecatedString filename, Script::HostDefined* host_defined = nullptr);
virtual void visit_edges(Cell::Visitor&) override;
@ -106,7 +106,7 @@ private:
Script::HostDefined* m_host_defined { nullptr }; // [[HostDefined]]
// Needed for potential lookups of modules.
String m_filename;
DeprecatedString m_filename;
};
}

View file

@ -256,7 +256,7 @@ public:
private:
void throw_identifier_declared(FlyString const& name, NonnullRefPtr<Declaration> const& declaration)
{
m_parser.syntax_error(String::formatted("Identifier '{}' already declared", name), declaration->source_range().start);
m_parser.syntax_error(DeprecatedString::formatted("Identifier '{}' already declared", name), declaration->source_range().start);
}
Parser& m_parser;
@ -579,7 +579,7 @@ void Parser::parse_module(Program& program)
}
if (!found)
syntax_error(String::formatted("'{}' in export is not declared", exported_name), export_statement.source_range().start);
syntax_error(DeprecatedString::formatted("'{}' in export is not declared", exported_name), export_statement.source_range().start);
}
}
}
@ -664,9 +664,9 @@ NonnullRefPtr<Statement> Parser::parse_statement(AllowLabelledFunction allow_lab
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(String::formatted("{} declaration not allowed in single-statement context", m_state.current_token.name()));
syntax_error(DeprecatedString::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(String::formatted("let followed by [ is not allowed in single-statement context"));
syntax_error(DeprecatedString::formatted("let followed by [ is not allowed in single-statement context"));
}
auto expr = parse_expression(0);
@ -853,7 +853,7 @@ RefPtr<FunctionExpression> Parser::try_parse_arrow_function_expression(bool expe
auto function_start_offset = rule_start.position().offset;
auto function_end_offset = position().offset - m_state.current_token.trivia().length();
auto source_text = String { m_state.lexer.source().substring_view(function_start_offset, function_end_offset - function_start_offset) };
auto source_text = DeprecatedString { 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() }, "", move(source_text),
move(body), move(parameters), function_length, function_kind, body->in_strict_mode(),
@ -909,7 +909,7 @@ RefPtr<LabelledStatement> Parser::try_parse_labelled_statement(AllowLabelledFunc
}
if (m_state.labels_in_scope.contains(identifier))
syntax_error(String::formatted("Label '{}' has already been declared", identifier));
syntax_error(DeprecatedString::formatted("Label '{}' has already been declared", identifier));
RefPtr<Statement> labelled_item;
@ -1172,7 +1172,7 @@ NonnullRefPtr<ClassExpression> Parser::parse_class_expression(bool expect_class_
if (element.class_element_kind() != ClassElement::ElementKind::Method
|| element.is_static() != is_static) {
syntax_error(String::formatted("Duplicate private field or method named '{}'", name));
syntax_error(DeprecatedString::formatted("Duplicate private field or method named '{}'", name));
break;
}
@ -1180,14 +1180,14 @@ NonnullRefPtr<ClassExpression> Parser::parse_class_expression(bool expect_class_
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(String::formatted("Duplicate private field or method named '{}'", name));
syntax_error(DeprecatedString::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(String::formatted("Duplicate private field or method named '{}'", name));
syntax_error(DeprecatedString::formatted("Duplicate private field or method named '{}'", name));
}
property_key = create_ast_node<PrivateIdentifier>({ m_source_code, rule_start.position(), position() }, name);
@ -1360,12 +1360,12 @@ NonnullRefPtr<ClassExpression> Parser::parse_class_expression(bool expect_class_
if (outer_referenced_private_names)
outer_referenced_private_names->set(private_name);
else // FIXME: Make these error appear in the appropriate places.
syntax_error(String::formatted("Reference to undeclared private field or method '{}'", private_name));
syntax_error(DeprecatedString::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 = String { m_state.lexer.source().substring_view(function_start_offset, function_end_offset - function_start_offset) };
auto source_text = DeprecatedString { 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));
}
@ -1428,7 +1428,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(String::formatted("Identifier must not be a reserved word in strict mode ('{}')", string));
syntax_error(DeprecatedString::formatted("Identifier must not be a reserved word in strict mode ('{}')", string));
return { parse_identifier() };
}
case TokenType::NumericLiteral:
@ -1507,7 +1507,7 @@ Parser::PrimaryExpressionParseResult Parser::parse_primary_expression()
return { parse_await_expression() };
case TokenType::PrivateIdentifier:
if (!is_private_identifier_valid())
syntax_error(String::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
syntax_error(DeprecatedString::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()) };
@ -1528,7 +1528,7 @@ NonnullRefPtr<RegExpLiteral> Parser::parse_regexp_literal()
// Remove leading and trailing slash.
pattern = pattern.substring_view(1, pattern.length() - 2);
auto flags = String::empty();
auto flags = DeprecatedString::empty();
auto parsed_flags = RegExpObject::default_flags;
if (match(TokenType::RegexFlags)) {
@ -1542,18 +1542,18 @@ NonnullRefPtr<RegExpLiteral> Parser::parse_regexp_literal()
parsed_flags = parsed_flags_or_error.release_value();
}
String parsed_pattern;
DeprecatedString 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 = String::empty();
parsed_pattern = DeprecatedString::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(String::formatted("RegExp compile error: {}", Regex<ECMA262>(parsed_regex, parsed_pattern, parsed_flags).error_string()), rule_start.position());
syntax_error(DeprecatedString::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_string(), move(flags));
@ -1575,7 +1575,7 @@ NonnullRefPtr<Expression> Parser::parse_unary_prefixed_expression()
auto rhs_start = position();
auto rhs = parse_expression(precedence, associativity);
if (!is_simple_assignment_target(*rhs))
syntax_error(String::formatted("Right-hand side of prefix increment operator must be identifier or member expression, got {}", rhs->class_name()), rhs_start);
syntax_error(DeprecatedString::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&>(*rhs);
@ -1590,7 +1590,7 @@ NonnullRefPtr<Expression> Parser::parse_unary_prefixed_expression()
auto rhs_start = position();
auto rhs = parse_expression(precedence, associativity);
if (!is_simple_assignment_target(*rhs))
syntax_error(String::formatted("Right-hand side of prefix decrement operator must be identifier or member expression, got {}", rhs->class_name()), rhs_start);
syntax_error(DeprecatedString::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&>(*rhs);
@ -1784,7 +1784,7 @@ NonnullRefPtr<ObjectExpression> 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(String::formatted("'{}' is a reserved keyword", string_literal.value()));
syntax_error(DeprecatedString::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));
@ -1845,7 +1845,7 @@ NonnullRefPtr<StringLiteral> Parser::parse_string_literal(Token const& token, St
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) {
String message;
DeprecatedString 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.
@ -1855,7 +1855,7 @@ NonnullRefPtr<StringLiteral> Parser::parse_string_literal(Token const& token, St
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 = String::formatted("Malformed {} escape sequence", type);
message = DeprecatedString::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 {
@ -2129,9 +2129,9 @@ Parser::ExpressionResult Parser::parse_secondary_expression(NonnullRefPtr<Expres
consume();
if (match(TokenType::PrivateIdentifier)) {
if (!is_private_identifier_valid())
syntax_error(String::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
syntax_error(DeprecatedString::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
else if (is<SuperExpression>(*lhs))
syntax_error(String::formatted("Cannot access private field or method '{}' on super", m_state.current_token.value()));
syntax_error(DeprecatedString::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()) {
@ -2147,7 +2147,7 @@ Parser::ExpressionResult Parser::parse_secondary_expression(NonnullRefPtr<Expres
}
case TokenType::PlusPlus:
if (!is_simple_assignment_target(*lhs))
syntax_error(String::formatted("Left-hand side of postfix increment operator must be identifier or member expression, got {}", lhs->class_name()));
syntax_error(DeprecatedString::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&>(*lhs);
@ -2159,7 +2159,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(String::formatted("Left-hand side of postfix increment operator must be identifier or member expression, got {}", lhs->class_name()));
syntax_error(DeprecatedString::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&>(*lhs);
@ -2502,7 +2502,7 @@ NonnullRefPtr<FunctionBody> Parser::parse_function_body(Vector<FunctionParameter
for (auto& previous_name : parameter_names) {
if (previous_name == parameter_name) {
syntax_error(String::formatted("Duplicate parameter '{}' not allowed in strict mode", parameter_name));
syntax_error(DeprecatedString::formatted("Duplicate parameter '{}' not allowed in strict mode", parameter_name));
}
}
@ -2518,7 +2518,7 @@ NonnullRefPtr<FunctionBody> Parser::parse_function_body(Vector<FunctionParameter
for (auto& previous_name : parameter_names) {
if (previous_name == bound_name) {
syntax_error(String::formatted("Duplicate parameter '{}' not allowed in strict mode", bound_name));
syntax_error(DeprecatedString::formatted("Duplicate parameter '{}' not allowed in strict mode", bound_name));
break;
}
}
@ -2594,7 +2594,7 @@ NonnullRefPtr<FunctionNodeType> Parser::parse_function_node(u16 parse_options, O
check_identifier_name_for_assignment_validity(name);
if (function_kind == FunctionKind::AsyncGenerator && (name == "await"sv || name == "yield"sv))
syntax_error(String::formatted("async generator function is not allowed to be called '{}'", name));
syntax_error(DeprecatedString::formatted("async generator function is not allowed to be called '{}'", name));
if (m_state.in_class_static_init_block && name == "await"sv)
syntax_error("'await' is a reserved word");
@ -2630,7 +2630,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 = String { m_state.lexer.source().substring_view(function_start_offset, function_end_offset - function_start_offset) };
auto source_text = DeprecatedString { 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,
@ -2673,15 +2673,15 @@ Vector<FunctionParameter> Parser::parse_formal_parameters(int& function_length,
if (!has_same_name)
continue;
String message;
DeprecatedString message;
if (parse_options & FunctionNodeParseOptions::IsArrowFunction)
message = String::formatted("Duplicate parameter '{}' not allowed in arrow function", parameter_name);
message = DeprecatedString::formatted("Duplicate parameter '{}' not allowed in arrow function", parameter_name);
else if (m_state.strict_mode)
message = String::formatted("Duplicate parameter '{}' not allowed in strict mode", parameter_name);
message = DeprecatedString::formatted("Duplicate parameter '{}' not allowed in strict mode", parameter_name);
else if (has_default_parameter || match(TokenType::Equals))
message = String::formatted("Duplicate parameter '{}' not allowed in function with default parameter", parameter_name);
message = DeprecatedString::formatted("Duplicate parameter '{}' not allowed in function with default parameter", parameter_name);
else if (has_rest_parameter)
message = String::formatted("Duplicate parameter '{}' not allowed in function with rest parameter", parameter_name);
message = DeprecatedString::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;
@ -3066,7 +3066,7 @@ NonnullRefPtr<BreakStatement> Parser::parse_break_statement()
auto label = m_state.labels_in_scope.find(target_label);
if (label == m_state.labels_in_scope.end())
syntax_error(String::formatted("Label '{}' not found", target_label));
syntax_error(DeprecatedString::formatted("Label '{}' not found", target_label));
}
consume_or_insert_semicolon();
}
@ -3095,7 +3095,7 @@ NonnullRefPtr<ContinueStatement> Parser::parse_continue_statement()
auto label = m_state.labels_in_scope.find(target_label);
if (label == m_state.labels_in_scope.end())
syntax_error(String::formatted("Label '{}' not found or invalid", target_label));
syntax_error(DeprecatedString::formatted("Label '{}' not found or invalid", target_label));
else
label->value = label_position;
}
@ -3131,7 +3131,7 @@ NonnullRefPtr<OptionalChain> Parser::parse_optional_chain(NonnullRefPtr<Expressi
break;
case TokenType::PrivateIdentifier: {
if (!is_private_identifier_valid())
syntax_error(String::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
syntax_error(DeprecatedString::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
auto start = position();
auto private_identifier = consume();
@ -3167,7 +3167,7 @@ NonnullRefPtr<OptionalChain> Parser::parse_optional_chain(NonnullRefPtr<Expressi
consume();
if (match(TokenType::PrivateIdentifier)) {
if (!is_private_identifier_valid())
syntax_error(String::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
syntax_error(DeprecatedString::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
auto start = position();
auto private_identifier = consume();
@ -3382,7 +3382,7 @@ NonnullRefPtr<CatchClause> Parser::parse_catch_clause()
body->for_each_lexically_declared_name([&](auto const& name) {
if (bound_names.contains(name))
syntax_error(String::formatted("Identifier '{}' already declared as catch parameter", name));
syntax_error(DeprecatedString::formatted("Identifier '{}' already declared as catch parameter", name));
});
if (pattern_parameter) {
@ -3494,7 +3494,7 @@ NonnullRefPtr<Statement> Parser::parse_for_statement()
HashTable<FlyString> bound_names;
declaration->for_each_bound_name([&](auto const& name) {
if (bound_names.set(name) != AK::HashSetResult::InsertedNewEntry)
syntax_error(String::formatted("Identifier '{}' already declared in for loop initializer", name), declaration->source_range().start);
syntax_error(DeprecatedString::formatted("Identifier '{}' already declared in for loop initializer", name), declaration->source_range().start);
});
}
@ -3577,7 +3577,7 @@ NonnullRefPtr<Statement> Parser::parse_for_in_of_statement(NonnullRefPtr<ASTNode
}
}
if (!valid)
syntax_error(String::formatted("Invalid left-hand side in for-loop ('{}')", lhs->class_name()));
syntax_error(DeprecatedString::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;
@ -3928,7 +3928,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(String::formatted("'{}' is not allowed as an identifier in strict mode", name));
syntax_error(DeprecatedString::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");
@ -3969,7 +3969,7 @@ Token Parser::consume(TokenType expected_type)
auto token = consume();
if (expected_type == TokenType::Identifier) {
if (m_state.strict_mode && is_strict_reserved_word(token.value()))
syntax_error(String::formatted("Identifier must not be a reserved word in strict mode ('{}')", token.value()));
syntax_error(DeprecatedString::formatted("Identifier must not be a reserved word in strict mode ('{}')", token.value()));
}
return token;
}
@ -3992,7 +3992,7 @@ void Parser::expected(char const* what)
{
auto message = m_state.current_token.message();
if (message.is_empty())
message = String::formatted("Unexpected token {}. Expected {}", m_state.current_token.name(), what);
message = DeprecatedString::formatted("Unexpected token {}. Expected {}", m_state.current_token.name(), what);
syntax_error(message);
}
@ -4019,7 +4019,7 @@ void Parser::set_try_parse_arrow_function_expression_failed_at_position(Position
m_token_memoizations.set(position, { failed });
}
void Parser::syntax_error(String const& message, Optional<Position> position)
void Parser::syntax_error(DeprecatedString const& message, Optional<Position> position)
{
if (!position.has_value())
position = this->position();
@ -4051,7 +4051,7 @@ void Parser::check_identifier_name_for_assignment_validity(FlyString const& name
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(String::formatted("Binding pattern target may not be called '{}' in strict mode", name));
syntax_error(DeprecatedString::formatted("Binding pattern target may not be called '{}' in strict mode", name));
}
}
@ -4102,7 +4102,7 @@ ModuleRequest Parser::parse_module_request()
consume(TokenType::CurlyOpen);
while (!done() && !match(TokenType::CurlyClose)) {
String key;
DeprecatedString key;
if (match(TokenType::StringLiteral)) {
key = parse_string_literal(m_state.current_token)->value().to_string();
consume();
@ -4118,7 +4118,7 @@ ModuleRequest Parser::parse_module_request()
if (match(TokenType::StringLiteral)) {
for (auto& entries : request.assertions) {
if (entries.key == key)
syntax_error(String::formatted("Duplicate assertion clauses with name: {}", key));
syntax_error(DeprecatedString::formatted("Duplicate assertion clauses with name: {}", key));
}
request.add_assertion(move(key), parse_string_literal(m_state.current_token)->value().to_string());
}
@ -4202,7 +4202,7 @@ NonnullRefPtr<ImportStatement> Parser::parse_import_statement(Program& program)
consume(TokenType::Asterisk);
if (!match_as())
syntax_error(String::formatted("Unexpected token: {}", m_state.current_token.name()));
syntax_error(DeprecatedString::formatted("Unexpected token: {}", m_state.current_token.name()));
consume(TokenType::Identifier);
@ -4211,7 +4211,7 @@ NonnullRefPtr<ImportStatement> Parser::parse_import_statement(Program& program)
auto namespace_name = consume().value();
entries_with_location.append({ ImportEntry({}, namespace_name, true), namespace_position });
} else {
syntax_error(String::formatted("Unexpected token: {}", m_state.current_token.name()));
syntax_error(DeprecatedString::formatted("Unexpected token: {}", m_state.current_token.name()));
}
} else if (match(TokenType::CurlyOpen)) {
@ -4235,7 +4235,7 @@ NonnullRefPtr<ImportStatement> Parser::parse_import_statement(Program& program)
entries_with_location.append({ { name, alias }, alias_position });
} else if (require_as) {
syntax_error(String::formatted("Unexpected reserved word '{}'", name));
syntax_error(DeprecatedString::formatted("Unexpected reserved word '{}'", name));
} else {
check_identifier_name_for_assignment_validity(name);
@ -4273,7 +4273,7 @@ NonnullRefPtr<ImportStatement> Parser::parse_import_statement(Program& program)
auto from_statement = consume(TokenType::Identifier).original_value();
if (from_statement != "from"sv)
syntax_error(String::formatted("Expected 'from' got {}", from_statement));
syntax_error(DeprecatedString::formatted("Expected 'from' got {}", from_statement));
auto module_request = parse_module_request();
@ -4283,12 +4283,12 @@ NonnullRefPtr<ImportStatement> Parser::parse_import_statement(Program& program)
for (auto& entry : entries_with_location) {
for (auto& import_statement : program.imports()) {
if (import_statement.has_bound_name(entry.entry.local_name))
syntax_error(String::formatted("Identifier '{}' already declared", entry.entry.local_name), entry.position);
syntax_error(DeprecatedString::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(String::formatted("Identifier '{}' already declared", entry.entry.local_name), entry.position);
syntax_error(DeprecatedString::formatted("Identifier '{}' already declared", entry.entry.local_name), entry.position);
}
entries.append(move(entry.entry));
@ -4582,12 +4582,12 @@ NonnullRefPtr<ExportStatement> Parser::parse_export_statement(Program& program)
for (auto& entry : entries_with_location) {
for (auto& export_statement : program.exports()) {
if (export_statement.has_export(entry.entry.export_name))
syntax_error(String::formatted("Duplicate export with name: '{}'", entry.entry.export_name), entry.position);
syntax_error(DeprecatedString::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(String::formatted("Duplicate export with name: '{}'", entry.entry.export_name), entry.position);
syntax_error(DeprecatedString::formatted("Duplicate export with name: '{}'", entry.entry.export_name), entry.position);
}
entries.append(move(entry.entry));

View file

@ -218,7 +218,7 @@ private:
bool match(TokenType type) const;
bool done() const;
void expected(char const* what);
void syntax_error(String const& message, Optional<Position> = {});
void syntax_error(DeprecatedString const& message, Optional<Position> = {});
Token consume();
Token consume_identifier();
Token consume_identifier_reference();

View file

@ -12,20 +12,20 @@
namespace JS {
String ParserError::to_string() const
DeprecatedString ParserError::to_string() const
{
if (!position.has_value())
return message;
return String::formatted("{} (line: {}, column: {})", message, position.value().line, position.value().column);
return DeprecatedString::formatted("{} (line: {}, column: {})", message, position.value().line, position.value().column);
}
String ParserError::source_location_hint(StringView source, char const spacer, char const indicator) const
DeprecatedString 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.
String 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);
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);
StringBuilder builder;
builder.append(source_string.split_view('\n', SplitBehavior::KeepEmpty)[position.value().line - 1]);
builder.append('\n');

View file

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

View file

@ -6,7 +6,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <LibJS/Print.h>
#include <LibJS/Runtime/Array.h>
#include <LibJS/Runtime/ArrayBuffer.h>
@ -65,10 +65,10 @@
namespace {
ErrorOr<void> print_value(JS::PrintContext&, JS::Value value, HashTable<JS::Object*>& seen_objects);
String strip_ansi(StringView format_string)
DeprecatedString strip_ansi(StringView format_string)
{
if (format_string.is_empty())
return String::empty();
return DeprecatedString::empty();
StringBuilder builder;
size_t i;
@ -88,11 +88,11 @@ String strip_ansi(StringView format_string)
template<typename... Args>
ErrorOr<void> js_out(JS::PrintContext& print_context, CheckedFormatString<Args...> format_string, Args const&... args)
{
String formatted;
DeprecatedString formatted;
if (print_context.strip_ansi)
formatted = String::formatted(strip_ansi(format_string.view()), args...);
formatted = DeprecatedString::formatted(strip_ansi(format_string.view()), args...);
else
formatted = String::formatted(format_string.view(), args...);
formatted = DeprecatedString::formatted(format_string.view(), args...);
auto bytes = formatted.bytes();
while (!bytes.is_empty())

View file

@ -1209,7 +1209,7 @@ CanonicalIndex canonical_numeric_index_string(PropertyKey const& property_key, C
}
// 22.1.3.17.1 GetSubstitution ( matched, str, position, captures, namedCaptures, replacement ), https://tc39.es/ecma262/#sec-getsubstitution
ThrowCompletionOr<String> get_substitution(VM& vm, Utf16View const& matched, Utf16View const& str, size_t position, Span<Value> captures, Value named_captures, Value replacement)
ThrowCompletionOr<DeprecatedString> get_substitution(VM& vm, Utf16View const& matched, Utf16View const& str, size_t position, Span<Value> captures, Value named_captures, Value replacement)
{
auto replace_string = TRY(replacement.to_utf16_string(vm));
auto replace_view = replace_string.view();

View file

@ -46,7 +46,7 @@ enum class CanonicalIndexMode {
IgnoreNumericRoundtrip,
};
CanonicalIndex canonical_numeric_index_string(PropertyKey const&, CanonicalIndexMode needs_numeric);
ThrowCompletionOr<String> get_substitution(VM&, Utf16View const& matched, Utf16View const& str, size_t position, Span<Value> captures, Value named_captures, Value replacement);
ThrowCompletionOr<DeprecatedString> get_substitution(VM&, Utf16View const& matched, Utf16View const& str, size_t position, Span<Value> captures, Value named_captures, Value replacement);
enum class CallerMode {
Strict,

View file

@ -998,7 +998,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::join)
};
auto length = TRY(length_of_array_like(vm, *this_object));
String separator = ",";
DeprecatedString separator = ",";
if (!vm.argument(0).is_undefined())
separator = TRY(vm.argument(0).to_string(vm));
StringBuilder builder;

View file

@ -135,7 +135,7 @@ JS_DEFINE_NATIVE_FUNCTION(AsyncFromSyncIteratorPrototype::return_)
// 11. If Type(result) is not Object, then
if (!result.is_object()) {
auto* error = TypeError::create(realm, String::formatted(ErrorType::NotAnObject.message(), "SyncIteratorReturnResult"));
auto* error = TypeError::create(realm, DeprecatedString::formatted(ErrorType::NotAnObject.message(), "SyncIteratorReturnResult"));
// a. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
MUST(call(vm, *promise_capability->reject(), js_undefined(), error));
// b. Return promiseCapability.[[Promise]].
@ -183,7 +183,7 @@ JS_DEFINE_NATIVE_FUNCTION(AsyncFromSyncIteratorPrototype::throw_)
// 11. If Type(result) is not Object, then
if (!result.is_object()) {
auto* error = TypeError::create(realm, String::formatted(ErrorType::NotAnObject.message(), "SyncIteratorThrowResult"));
auto* error = TypeError::create(realm, DeprecatedString::formatted(ErrorType::NotAnObject.message(), "SyncIteratorThrowResult"));
// a. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
MUST(call(vm, *promise_capability->reject(), js_undefined(), error));

View file

@ -39,7 +39,7 @@ private:
Optional<State> m_async_generator_state; // [[AsyncGeneratorState]]
ExecutionContextVariant m_async_generator_context; // [[AsyncGeneratorContext]]
Vector<AsyncGeneratorRequest> m_async_generator_queue; // [[AsyncGeneratorQueue]]
Optional<String> m_generator_brand; // [[GeneratorBrand]]
Optional<DeprecatedString> m_generator_brand; // [[GeneratorBrand]]
};
}

View file

@ -19,7 +19,7 @@ public:
virtual ~BigInt() override = default;
Crypto::SignedBigInteger const& big_integer() const { return m_big_integer; }
const String to_string() const { return String::formatted("{}n", m_big_integer.to_base(10)); }
const DeprecatedString to_string() const { return DeprecatedString::formatted("{}n", m_big_integer.to_base(10)); }
private:
explicit BigInt(Crypto::SignedBigInteger);

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <LibJS/Runtime/AbstractOperations.h>
#include <LibJS/Runtime/BigInt.h>
#include <LibJS/Runtime/BigIntConstructor.h>

View file

@ -38,7 +38,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(String::formatted("bound {}", bound_target_function.name()))
, m_name(DeprecatedString::formatted("bound {}", bound_target_function.name()))
{
}

View file

@ -32,7 +32,7 @@ Date::Date(double date_value, Object& prototype)
{
}
String Date::iso_date_string() const
DeprecatedString Date::iso_date_string() const
{
int year = year_from_time(m_date_value);
@ -616,7 +616,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 = String::formatted("{}000000000", parsed_fraction);
auto fraction = DeprecatedString::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

@ -23,7 +23,7 @@ public:
double date_value() const { return m_date_value; }
void set_date_value(double value) { m_date_value = value; }
String iso_date_string() const;
DeprecatedString iso_date_string() const;
private:
Date(double date_value, Object& prototype);

View file

@ -23,7 +23,7 @@
namespace JS {
// 21.4.3.2 Date.parse ( string ), https://tc39.es/ecma262/#sec-date.parse
static double parse_simplified_iso8601(String const& iso_8601)
static double parse_simplified_iso8601(DeprecatedString const& iso_8601)
{
// 21.4.1.15 Date Time String Format, https://tc39.es/ecma262/#sec-date-time-string-format
GenericLexer lexer(iso_8601);
@ -152,7 +152,7 @@ static constexpr AK::Array<StringView, 2> extra_formats = {
"%m/%e/%Y"sv
};
static double parse_date_string(String const& date_string)
static double parse_date_string(DeprecatedString const& date_string)
{
auto value = parse_simplified_iso8601(date_string);
if (isfinite(value))

View file

@ -9,8 +9,8 @@
#include <AK/Array.h>
#include <AK/DateConstants.h>
#include <AK/DeprecatedString.h>
#include <AK/Function.h>
#include <AK/String.h>
#include <AK/TypeCasts.h>
#include <LibCore/DateTime.h>
#include <LibCrypto/BigInt/UnsignedBigInteger.h>
@ -1076,7 +1076,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_string)
}
// 21.4.4.41.1 TimeString ( tv ), https://tc39.es/ecma262/#sec-timestring
String time_string(double time)
DeprecatedString time_string(double time)
{
// 1. Let hour be ToZeroPaddedDecimalString((HourFromTime(tv)), 2).
auto hour = hour_from_time(time);
@ -1088,11 +1088,11 @@ String 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 String::formatted("{:02}:{:02}:{:02} GMT", hour, minute, second);
return DeprecatedString::formatted("{:02}:{:02}:{:02} GMT", hour, minute, second);
}
// 21.4.4.41.2 DateString ( tv ), https://tc39.es/ecma262/#sec-datestring
String date_string(double time)
DeprecatedString 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)];
@ -1111,11 +1111,11 @@ String 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 String::formatted("{} {} {:02} {}{:04}", weekday, month, day, year_sign, abs(year));
return DeprecatedString::formatted("{} {} {:02} {}{:04}", weekday, month, day, year_sign, abs(year));
}
// 21.4.4.41.3 TimeZoneString ( tv ), https://tc39.es/ecma262/#sec-timezoneestring
String time_zone_string(double time)
DeprecatedString time_zone_string(double time)
{
// 1. Let localTimeZone be DefaultTimeZone().
auto local_time_zone = default_time_zone();
@ -1169,11 +1169,11 @@ String time_zone_string(double time)
}
// 10. Return the string-concatenation of offsetSign, offsetHour, offsetMin, and tzName.
return String::formatted("{}{:02}{:02} ({})", offset_sign, offset_hour, offset_min, tz_name);
return DeprecatedString::formatted("{}{:02}{:02} ({})", offset_sign, offset_hour, offset_min, tz_name);
}
// 21.4.4.41.4 ToDateString ( tv ), https://tc39.es/ecma262/#sec-todatestring
String to_date_string(double time)
DeprecatedString to_date_string(double time)
{
// 1. If tv is NaN, return "Invalid Date".
if (Value(time).is_nan())
@ -1183,7 +1183,7 @@ String 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 String::formatted("{} {}{}", date_string(time), time_string(time), time_zone_string(time));
return DeprecatedString::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
@ -1213,7 +1213,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 = String::formatted("{}{}", time_string(local_time(time)), time_zone_string(time));
auto string = DeprecatedString::formatted("{}{}", time_string(local_time(time)), time_zone_string(time));
return js_string(vm, move(string));
}
@ -1245,7 +1245,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 = String::formatted("{}, {:02} {} {}{:04} {}", weekday, day, month, year_sign, abs(year), time_string(time));
auto string = DeprecatedString::formatted("{}, {:02} {} {}{:04} {}", weekday, day, month, year_sign, abs(year), time_string(time));
return js_string(vm, move(string));
}

View file

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

View file

@ -28,7 +28,7 @@
namespace JS {
ECMAScriptFunctionObject* ECMAScriptFunctionObject::create(Realm& realm, FlyString name, String source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, 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)
ECMAScriptFunctionObject* ECMAScriptFunctionObject::create(Realm& realm, FlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, 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) {
@ -48,12 +48,12 @@ ECMAScriptFunctionObject* ECMAScriptFunctionObject::create(Realm& realm, FlyStri
return realm.heap().allocate<ECMAScriptFunctionObject>(realm, move(name), move(source_text), ecmascript_code, move(parameters), m_function_length, 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::create(Realm& realm, FlyString name, Object& prototype, String source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, 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)
ECMAScriptFunctionObject* ECMAScriptFunctionObject::create(Realm& realm, FlyString name, Object& prototype, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, 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, 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(FlyString name, String source_text, Statement const& ecmascript_code, Vector<FunctionParameter> formal_parameters, i32 function_length, 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(FlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> formal_parameters, i32 function_length, 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)
@ -832,7 +832,7 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body()
for (auto& parameter : m_formal_parameters) {
if (!parameter.default_value)
continue;
auto executable = TRY(compile(*parameter.default_value, FunctionKind::Normal, String::formatted("default parameter #{} for {}", default_parameter_index, m_name)));
auto executable = TRY(compile(*parameter.default_value, FunctionKind::Normal, DeprecatedString::formatted("default parameter #{} for {}", default_parameter_index, m_name)));
m_default_parameter_bytecode_executables.append(move(executable));
}
}

View file

@ -32,8 +32,8 @@ public:
Global,
};
static ECMAScriptFunctionObject* create(Realm&, FlyString name, String source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, 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 ECMAScriptFunctionObject* create(Realm&, FlyString name, Object& prototype, String source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, 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 ECMAScriptFunctionObject* create(Realm&, FlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, 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 ECMAScriptFunctionObject* create(Realm&, FlyString name, Object& prototype, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, 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;
@ -64,8 +64,8 @@ public:
Object* home_object() const { return m_home_object; }
void set_home_object(Object* home_object) { m_home_object = home_object; }
String const& source_text() const { return m_source_text; }
void set_source_text(String source_text) { m_source_text = move(source_text); }
DeprecatedString const& source_text() const { return m_source_text; }
void set_source_text(DeprecatedString 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)); }
@ -93,7 +93,7 @@ protected:
virtual Completion ordinary_call_evaluate_body();
private:
ECMAScriptFunctionObject(FlyString name, String source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, 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(FlyString name, DeprecatedString source_text, Statement const& ecmascript_code, Vector<FunctionParameter> parameters, i32 m_function_length, 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;
@ -118,7 +118,7 @@ private:
Realm* m_realm { nullptr }; // [[Realm]]
ScriptOrModule m_script_or_module; // [[ScriptOrModule]]
Object* m_home_object { nullptr }; // [[HomeObject]]
String m_source_text; // [[SourceText]]
DeprecatedString 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

@ -19,7 +19,7 @@ Error* Error::create(Realm& realm)
return realm.heap().allocate<Error>(realm, *realm.intrinsics().error_prototype());
}
Error* Error::create(Realm& realm, String const& message)
Error* Error::create(Realm& realm, DeprecatedString const& message)
{
auto& vm = realm.vm();
auto* error = Error::create(realm);
@ -73,7 +73,7 @@ void Error::populate_stack()
}
}
String Error::stack_string() const
DeprecatedString Error::stack_string() const
{
StringBuilder stack_string_builder;
// Note: We roughly follow V8's formatting
@ -104,7 +104,7 @@ String Error::stack_string() const
return realm.heap().allocate<ClassName>(realm, *realm.intrinsics().snake_name##_prototype()); \
} \
\
ClassName* ClassName::create(Realm& realm, String const& message) \
ClassName* ClassName::create(Realm& realm, DeprecatedString const& message) \
{ \
auto& vm = realm.vm(); \
auto* error = ClassName::create(realm); \

View file

@ -24,11 +24,11 @@ class Error : public Object {
public:
static Error* create(Realm&);
static Error* create(Realm&, String const& message);
static Error* create(Realm&, DeprecatedString const& message);
virtual ~Error() override = default;
[[nodiscard]] String stack_string() const;
[[nodiscard]] DeprecatedString stack_string() const;
ThrowCompletionOr<void> install_error_cause(Value options);
@ -51,7 +51,7 @@ private:
\
public: \
static ClassName* create(Realm&); \
static ClassName* create(Realm&, String const& message); \
static ClassName* create(Realm&, DeprecatedString const& message); \
\
explicit ClassName(Object& prototype); \
virtual ~ClassName() override = default; \

View file

@ -45,7 +45,7 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string)
// 4. If name is undefined, set name to "Error"; otherwise set name to ? ToString(name).
auto name = name_property.is_undefined()
? String { "Error"sv }
? DeprecatedString { "Error"sv }
: TRY(name_property.to_string(vm));
// 5. Let msg be ? Get(O, "message").
@ -53,7 +53,7 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string)
// 6. If msg is undefined, set msg to the empty String; otherwise set msg to ? ToString(msg).
auto message = message_property.is_undefined()
? String::empty()
? DeprecatedString::empty()
: TRY(message_property.to_string(vm));
// 7. If name is the empty String, return msg.
@ -65,7 +65,7 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::to_string)
return js_string(vm, name);
// 9. Return the string-concatenation of name, the code unit 0x003A (COLON), the code unit 0x0020 (SPACE), and msg.
return js_string(vm, String::formatted("{}: {}", name, message));
return js_string(vm, DeprecatedString::formatted("{}: {}", name, message));
}
// B.1.1 get Error.prototype.stack ( ), https://tc39.es/proposal-error-stacks/#sec-get-error.prototype-stack
@ -84,21 +84,21 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::stack_getter)
// 4. Return ? GetStackString(error).
// NOTE: These steps are not implemented based on the proposal, but to roughly follow behavior of other browsers.
String name = "Error";
DeprecatedString name = "Error";
auto name_property = TRY(error.get(vm.names.name));
if (!name_property.is_undefined())
name = TRY(name_property.to_string(vm));
String message = "";
DeprecatedString message = "";
auto message_property = TRY(error.get(vm.names.message));
if (!message_property.is_undefined())
message = TRY(message_property.to_string(vm));
String header = name;
DeprecatedString header = name;
if (!message.is_empty())
header = String::formatted("{}: {}", name, message);
header = DeprecatedString::formatted("{}: {}", name, message);
return js_string(vm, String::formatted("{}\n{}", header, error.stack_string()));
return js_string(vm, DeprecatedString::formatted("{}\n{}", header, error.stack_string()));
}
// B.1.2 set Error.prototype.stack ( value ), https://tc39.es/proposal-error-stacks/#sec-set-error.prototype-stack

View file

@ -113,7 +113,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
auto arg_count = args.size();
// 9. Let P be the empty String.
String parameters_string = "";
DeprecatedString parameters_string = "";
Optional<Value> body_arg;
@ -138,7 +138,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
size_t k = 0;
// e. Repeat, while k < argCount - 1,
Vector<String> parameters;
Vector<DeprecatedString> parameters;
for (; k < arg_count - 1; ++k) {
// i. Let nextArg be args[k].
auto next_arg = args[k];
@ -149,18 +149,18 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
// iv. Set k to k + 1.
}
parameters_string = String::join(',', parameters);
parameters_string = DeprecatedString::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 = String::formatted("\n{}\n", body_arg.has_value() ? TRY(body_arg->to_string(vm)) : "");
auto body_string = DeprecatedString::formatted("\n{}\n", body_arg.has_value() ? TRY(body_arg->to_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 = String::formatted("{} anonymous({}\n) {{{}}}", prefix, parameters_string, body_string);
auto source_text = DeprecatedString::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));
String name;
DeprecatedString 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 = String::empty();
name = DeprecatedString::empty();
// c. Else, set name to the string-concatenation of "[", description, and "]".
else
name = String::formatted("[{}]", *description);
name = DeprecatedString::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 = String::formatted("{} {}", *prefix, name);
name = DeprecatedString::formatted("{} {}", *prefix, name);
// b. If F has an [[InitialName]] internal slot, then
if (is<NativeFunction>(this)) {

View file

@ -164,7 +164,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 js_string(vm, String::formatted("function {}() {{ [native code] }}", name));
return js_string(vm, DeprecatedString::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

@ -53,7 +53,7 @@ void GeneratorObject::visit_edges(Cell::Visitor& visitor)
}
// 27.5.3.2 GeneratorValidate ( generator, generatorBrand ), https://tc39.es/ecma262/#sec-generatorvalidate
ThrowCompletionOr<GeneratorObject::GeneratorState> GeneratorObject::validate(VM& vm, Optional<String> const& generator_brand)
ThrowCompletionOr<GeneratorObject::GeneratorState> GeneratorObject::validate(VM& vm, Optional<DeprecatedString> const& generator_brand)
{
// 1. Perform ? RequireInternalSlot(generator, [[GeneratorState]]).
// 2. Perform ? RequireInternalSlot(generator, [[GeneratorBrand]]).
@ -152,7 +152,7 @@ ThrowCompletionOr<Value> GeneratorObject::execute(VM& vm, Completion const& comp
}
// 27.5.3.3 GeneratorResume ( generator, value, generatorBrand ), https://tc39.es/ecma262/#sec-generatorresume
ThrowCompletionOr<Value> GeneratorObject::resume(VM& vm, Value value, Optional<String> generator_brand)
ThrowCompletionOr<Value> GeneratorObject::resume(VM& vm, Value value, Optional<DeprecatedString> generator_brand)
{
// 1. Let state be ? GeneratorValidate(generator, generatorBrand).
auto state = TRY(validate(vm, generator_brand));
@ -191,7 +191,7 @@ ThrowCompletionOr<Value> GeneratorObject::resume(VM& vm, Value value, Optional<S
}
// 27.5.3.4 GeneratorResumeAbrupt ( generator, abruptCompletion, generatorBrand ), https://tc39.es/ecma262/#sec-generatorresumeabrupt
ThrowCompletionOr<Value> GeneratorObject::resume_abrupt(JS::VM& vm, JS::Completion abrupt_completion, Optional<AK::String> generator_brand)
ThrowCompletionOr<Value> GeneratorObject::resume_abrupt(JS::VM& vm, JS::Completion abrupt_completion, Optional<AK::DeprecatedString> generator_brand)
{
// Not part of the spec, but the spec assumes abruptCompletion.[[Value]] is not empty.
VERIFY(abrupt_completion.value().has_value());

View file

@ -21,8 +21,8 @@ public:
virtual ~GeneratorObject() override = default;
void visit_edges(Cell::Visitor&) override;
ThrowCompletionOr<Value> resume(VM&, Value value, Optional<String> generator_brand);
ThrowCompletionOr<Value> resume_abrupt(VM&, JS::Completion abrupt_completion, Optional<String> generator_brand);
ThrowCompletionOr<Value> resume(VM&, Value value, Optional<DeprecatedString> generator_brand);
ThrowCompletionOr<Value> resume_abrupt(VM&, JS::Completion abrupt_completion, Optional<DeprecatedString> generator_brand);
private:
GeneratorObject(Realm&, Object& prototype, ExecutionContext);
@ -34,7 +34,7 @@ private:
Completed,
};
ThrowCompletionOr<GeneratorState> validate(VM&, Optional<String> const& generator_brand);
ThrowCompletionOr<GeneratorState> validate(VM&, Optional<DeprecatedString> const& generator_brand);
ThrowCompletionOr<Value> execute(VM&, JS::Completion const& completion);
ExecutionContext m_execution_context;
@ -42,7 +42,7 @@ private:
Value m_previous_value;
Optional<Bytecode::RegisterWindow> m_frame;
GeneratorState m_generator_state { GeneratorState::SuspendedStart };
Optional<String> m_generator_brand;
Optional<DeprecatedString> m_generator_brand;
};
}

View file

@ -341,7 +341,7 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::eval)
}
// 19.2.6.1.1 Encode ( string, unescapedSet ), https://tc39.es/ecma262/#sec-encode
static ThrowCompletionOr<String> encode(VM& vm, String const& string, StringView unescaped_set)
static ThrowCompletionOr<DeprecatedString> encode(VM& vm, DeprecatedString const& string, StringView unescaped_set)
{
auto utf16_string = Utf16String(string);
@ -396,7 +396,7 @@ static ThrowCompletionOr<String> encode(VM& vm, String const& string, StringView
}
// 19.2.6.1.2 Decode ( string, reservedSet ), https://tc39.es/ecma262/#sec-decode
static ThrowCompletionOr<String> decode(VM& vm, String const& string, StringView reserved_set)
static ThrowCompletionOr<DeprecatedString> decode(VM& vm, DeprecatedString const& string, StringView reserved_set)
{
StringBuilder decoded_builder;
auto code_point_start_offset = 0u;

View file

@ -80,7 +80,7 @@ Optional<::Locale::LocaleID> is_structurally_valid_language_tag(StringView local
}
// 6.2.3 CanonicalizeUnicodeLocaleId ( locale ), https://tc39.es/ecma402/#sec-canonicalizeunicodelocaleid
String canonicalize_unicode_locale_id(::Locale::LocaleID& locale)
DeprecatedString canonicalize_unicode_locale_id(::Locale::LocaleID& locale)
{
// Note: This implementation differs from the spec in how Step 3 is implemented. The spec assumes
// the input to this method is a string, and is written such that operations are performed on parts
@ -183,18 +183,18 @@ bool is_well_formed_unit_identifier(StringView unit_identifier)
}
// 9.2.1 CanonicalizeLocaleList ( locales ), https://tc39.es/ecma402/#sec-canonicalizelocalelist
ThrowCompletionOr<Vector<String>> canonicalize_locale_list(VM& vm, Value locales)
ThrowCompletionOr<Vector<DeprecatedString>> canonicalize_locale_list(VM& vm, Value locales)
{
auto& realm = *vm.current_realm();
// 1. If locales is undefined, then
if (locales.is_undefined()) {
// a. Return a new empty List.
return Vector<String> {};
return Vector<DeprecatedString> {};
}
// 2. Let seen be a new empty List.
Vector<String> seen;
Vector<DeprecatedString> seen;
Object* object = nullptr;
// 3. If Type(locales) is String or Type(locales) is Object and locales has an [[InitializedLocale]] internal slot, then
@ -230,7 +230,7 @@ ThrowCompletionOr<Vector<String>> canonicalize_locale_list(VM& vm, Value locales
if (!key_value.is_string() && !key_value.is_object())
return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOrString, key_value.to_string_without_side_effects());
String tag;
DeprecatedString tag;
// iii. If Type(kValue) is Object and kValue has an [[InitializedLocale]] internal slot, then
if (key_value.is_object() && is<Locale>(key_value.as_object())) {
@ -263,7 +263,7 @@ ThrowCompletionOr<Vector<String>> canonicalize_locale_list(VM& vm, Value locales
}
// 9.2.2 BestAvailableLocale ( availableLocales, locale ), https://tc39.es/ecma402/#sec-bestavailablelocale
Optional<String> best_available_locale(StringView locale)
Optional<DeprecatedString> best_available_locale(StringView locale)
{
// 1. Let candidate be locale.
StringView candidate = locale;
@ -289,12 +289,12 @@ Optional<String> best_available_locale(StringView locale)
}
struct MatcherResult {
String locale;
DeprecatedString locale;
Vector<::Locale::Extension> extensions {};
};
// 9.2.3 LookupMatcher ( availableLocales, requestedLocales ), https://tc39.es/ecma402/#sec-lookupmatcher
static MatcherResult lookup_matcher(Vector<String> const& requested_locales)
static MatcherResult lookup_matcher(Vector<DeprecatedString> const& requested_locales)
{
// 1. Let result be a new Record.
MatcherResult result {};
@ -337,7 +337,7 @@ static MatcherResult lookup_matcher(Vector<String> const& requested_locales)
}
// 9.2.4 BestFitMatcher ( availableLocales, requestedLocales ), https://tc39.es/ecma402/#sec-bestfitmatcher
static MatcherResult best_fit_matcher(Vector<String> const& requested_locales)
static MatcherResult best_fit_matcher(Vector<DeprecatedString> const& requested_locales)
{
// The algorithm is implementation dependent, but should produce results that a typical user of the requested locales would
// perceive as at least as good as those produced by the LookupMatcher abstract operation.
@ -345,7 +345,7 @@ static MatcherResult best_fit_matcher(Vector<String> const& requested_locales)
}
// 9.2.6 InsertUnicodeExtensionAndCanonicalize ( locale, extension ), https://tc39.es/ecma402/#sec-insert-unicode-extension-and-canonicalize
String insert_unicode_extension_and_canonicalize(::Locale::LocaleID locale, ::Locale::LocaleExtension extension)
DeprecatedString insert_unicode_extension_and_canonicalize(::Locale::LocaleID locale, ::Locale::LocaleExtension extension)
{
// Note: This implementation differs from the spec in how the extension is inserted. The spec assumes
// the input to this method is a string, and is written such that operations are performed on parts
@ -376,7 +376,7 @@ static auto& find_key_in_value(T& value, StringView key)
}
// 9.2.7 ResolveLocale ( availableLocales, requestedLocales, options, relevantExtensionKeys, localeData ), https://tc39.es/ecma402/#sec-resolvelocale
LocaleResult resolve_locale(Vector<String> const& requested_locales, LocaleOptions const& options, Span<StringView const> relevant_extension_keys)
LocaleResult resolve_locale(Vector<DeprecatedString> const& requested_locales, LocaleOptions const& options, Span<StringView const> relevant_extension_keys)
{
// 1. Let matcher be options.[[localeMatcher]].
auto const& matcher = options.locale_matcher;
@ -431,7 +431,7 @@ LocaleResult resolve_locale(Vector<String> const& requested_locales, LocaleOptio
// f. Assert: Type(value) is either String or Null.
// NOTE: ECMA-402 assumes keyLocaleData is sorted by locale preference. Our list is sorted
// alphabetically, so we get the locale's preferred value from LibUnicode.
Optional<String> value;
Optional<DeprecatedString> value;
if (auto preference = ::Locale::get_preferred_keyword_value_for_locale(found_locale, key); preference.has_value())
value = *preference;
@ -526,10 +526,10 @@ LocaleResult resolve_locale(Vector<String> const& requested_locales, LocaleOptio
}
// 9.2.8 LookupSupportedLocales ( availableLocales, requestedLocales ), https://tc39.es/ecma402/#sec-lookupsupportedlocales
Vector<String> lookup_supported_locales(Vector<String> const& requested_locales)
Vector<DeprecatedString> lookup_supported_locales(Vector<DeprecatedString> const& requested_locales)
{
// 1. Let subset be a new empty List.
Vector<String> subset;
Vector<DeprecatedString> subset;
// 2. For each element locale of requestedLocales, do
for (auto const& locale : requested_locales) {
@ -553,7 +553,7 @@ Vector<String> lookup_supported_locales(Vector<String> const& requested_locales)
}
// 9.2.9 BestFitSupportedLocales ( availableLocales, requestedLocales ), https://tc39.es/ecma402/#sec-bestfitsupportedlocales
Vector<String> best_fit_supported_locales(Vector<String> const& requested_locales)
Vector<DeprecatedString> best_fit_supported_locales(Vector<DeprecatedString> const& requested_locales)
{
// The BestFitSupportedLocales abstract operation returns the subset of the provided BCP 47
// language priority list requestedLocales for which availableLocales has a matching locale
@ -565,7 +565,7 @@ Vector<String> best_fit_supported_locales(Vector<String> const& requested_locale
}
// 9.2.10 SupportedLocales ( availableLocales, requestedLocales, options ), https://tc39.es/ecma402/#sec-supportedlocales
ThrowCompletionOr<Array*> supported_locales(VM& vm, Vector<String> const& requested_locales, Value options)
ThrowCompletionOr<Array*> supported_locales(VM& vm, Vector<DeprecatedString> const& requested_locales, Value options)
{
auto& realm = *vm.current_realm();
@ -575,7 +575,7 @@ ThrowCompletionOr<Array*> supported_locales(VM& vm, Vector<String> const& reques
// 2. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
auto matcher = TRY(get_option(vm, *options_object, vm.names.localeMatcher, OptionType::String, { "lookup"sv, "best fit"sv }, "best fit"sv));
Vector<String> supported_locales;
Vector<DeprecatedString> supported_locales;
// 3. If matcher is "best fit", then
if (matcher.as_string().string() == "best fit"sv) {
@ -589,7 +589,7 @@ ThrowCompletionOr<Array*> supported_locales(VM& vm, Vector<String> const& reques
}
// 5. Return CreateArrayFromList(supportedLocales).
return Array::create_from<String>(realm, supported_locales, [&vm](auto& locale) { return js_string(vm, locale); });
return Array::create_from<DeprecatedString>(realm, supported_locales, [&vm](auto& locale) { return js_string(vm, locale); });
}
// 9.2.12 CoerceOptionsToObject ( options ), https://tc39.es/ecma402/#sec-coerceoptionstoobject

View file

@ -6,8 +6,8 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/Span.h>
#include <AK/String.h>
#include <AK/Variant.h>
#include <AK/Vector.h>
#include <LibJS/Forward.h>
@ -21,36 +21,36 @@ namespace JS::Intl {
struct LocaleOptions {
Value locale_matcher;
Optional<String> ca; // [[Calendar]]
Optional<String> co; // [[Collation]]
Optional<String> hc; // [[HourCycle]]
Optional<String> kf; // [[CaseFirst]]
Optional<String> kn; // [[Numeric]]
Optional<String> nu; // [[NumberingSystem]]
Optional<DeprecatedString> ca; // [[Calendar]]
Optional<DeprecatedString> co; // [[Collation]]
Optional<DeprecatedString> hc; // [[HourCycle]]
Optional<DeprecatedString> kf; // [[CaseFirst]]
Optional<DeprecatedString> kn; // [[Numeric]]
Optional<DeprecatedString> nu; // [[NumberingSystem]]
};
struct LocaleResult {
String locale;
String data_locale;
Optional<String> ca; // [[Calendar]]
Optional<String> co; // [[Collation]]
Optional<String> hc; // [[HourCycle]]
Optional<String> kf; // [[CaseFirst]]
Optional<String> kn; // [[Numeric]]
Optional<String> nu; // [[NumberingSystem]]
DeprecatedString locale;
DeprecatedString data_locale;
Optional<DeprecatedString> ca; // [[Calendar]]
Optional<DeprecatedString> co; // [[Collation]]
Optional<DeprecatedString> hc; // [[HourCycle]]
Optional<DeprecatedString> kf; // [[CaseFirst]]
Optional<DeprecatedString> kn; // [[Numeric]]
Optional<DeprecatedString> nu; // [[NumberingSystem]]
};
struct PatternPartition {
PatternPartition() = default;
PatternPartition(StringView type_string, String value_string)
PatternPartition(StringView type_string, DeprecatedString value_string)
: type(type_string)
, value(move(value_string))
{
}
StringView type;
String value;
DeprecatedString value;
};
struct PatternPartitionWithSource : public PatternPartition {
@ -80,16 +80,16 @@ struct PatternPartitionWithSource : public PatternPartition {
using StringOrBoolean = Variant<StringView, bool>;
Optional<::Locale::LocaleID> is_structurally_valid_language_tag(StringView locale);
String canonicalize_unicode_locale_id(::Locale::LocaleID& locale);
DeprecatedString canonicalize_unicode_locale_id(::Locale::LocaleID& locale);
bool is_well_formed_currency_code(StringView currency);
bool is_well_formed_unit_identifier(StringView unit_identifier);
ThrowCompletionOr<Vector<String>> canonicalize_locale_list(VM&, Value locales);
Optional<String> best_available_locale(StringView locale);
String insert_unicode_extension_and_canonicalize(::Locale::LocaleID locale_id, ::Locale::LocaleExtension extension);
LocaleResult resolve_locale(Vector<String> const& requested_locales, LocaleOptions const& options, Span<StringView const> relevant_extension_keys);
Vector<String> lookup_supported_locales(Vector<String> const& requested_locales);
Vector<String> best_fit_supported_locales(Vector<String> const& requested_locales);
ThrowCompletionOr<Array*> supported_locales(VM&, Vector<String> const& requested_locales, Value options);
ThrowCompletionOr<Vector<DeprecatedString>> canonicalize_locale_list(VM&, Value locales);
Optional<DeprecatedString> best_available_locale(StringView locale);
DeprecatedString insert_unicode_extension_and_canonicalize(::Locale::LocaleID locale_id, ::Locale::LocaleExtension extension);
LocaleResult resolve_locale(Vector<DeprecatedString> const& requested_locales, LocaleOptions const& options, Span<StringView const> relevant_extension_keys);
Vector<DeprecatedString> lookup_supported_locales(Vector<DeprecatedString> const& requested_locales);
Vector<DeprecatedString> best_fit_supported_locales(Vector<DeprecatedString> const& requested_locales);
ThrowCompletionOr<Array*> supported_locales(VM&, Vector<DeprecatedString> const& requested_locales, Value options);
ThrowCompletionOr<Object*> coerce_options_to_object(VM&, Value options);
ThrowCompletionOr<StringOrBoolean> get_string_or_boolean_option(VM&, Object const& options, PropertyKey const& property, Span<StringView const> values, StringOrBoolean true_value, StringOrBoolean falsy_value, StringOrBoolean fallback);
ThrowCompletionOr<Optional<int>> default_number_option(VM&, Value value, int minimum, int maximum, Optional<int> fallback);

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/Array.h>
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/StringView.h>
#include <LibJS/Runtime/Intl/CollatorCompareFunction.h>
#include <LibJS/Runtime/Object.h>
@ -45,8 +45,8 @@ public:
virtual ~Collator() override = default;
String const& locale() const { return m_locale; }
void set_locale(String locale) { m_locale = move(locale); }
DeprecatedString const& locale() const { return m_locale; }
void set_locale(DeprecatedString locale) { m_locale = move(locale); }
Usage usage() const { return m_usage; }
void set_usage(StringView usage);
@ -60,8 +60,8 @@ public:
void set_case_first(StringView case_first);
StringView case_first_string() const;
String const& collation() const { return m_collation; }
void set_collation(String collation) { m_collation = move(collation); }
DeprecatedString const& collation() const { return m_collation; }
void set_collation(DeprecatedString collation) { m_collation = move(collation); }
bool ignore_punctuation() const { return m_ignore_punctuation; }
void set_ignore_punctuation(bool ignore_punctuation) { m_ignore_punctuation = ignore_punctuation; }
@ -77,11 +77,11 @@ private:
virtual void visit_edges(Visitor&) override;
String m_locale; // [[Locale]]
DeprecatedString m_locale; // [[Locale]]
Usage m_usage { Usage::Sort }; // [[Usage]]
Sensitivity m_sensitivity { Sensitivity::Variant }; // [[Sensitivity]]
CaseFirst m_case_first { CaseFirst::False }; // [[CaseFirst]]
String m_collation; // [[Collation]]
DeprecatedString m_collation; // [[Collation]]
bool m_ignore_punctuation { false }; // [[IgnorePunctuation]]
bool m_numeric { false }; // [[Numeric]]
CollatorCompareFunction* m_bound_compare { nullptr }; // [[BoundCompare]]

View file

@ -26,7 +26,7 @@ void CollatorCompareFunction::initialize(Realm&)
{
auto& vm = this->vm();
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable);
define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable);
}
// 10.3.3.2 CompareStrings ( collator, x, y ), https://tc39.es/ecma402/#sec-collator-comparestrings

View file

@ -629,7 +629,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
// d. Else if p is equal to "dayPeriod", then
else if (part == "dayPeriod"sv) {
String formatted_value;
DeprecatedString formatted_value;
// i. Let f be the value of dateTimeFormat's internal slot whose name is the Internal Slot column of the matching row.
auto style = date_time_format.day_period();
@ -662,7 +662,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
// f. Else if p matches a Property column of the row in Table 6, then
else if (auto style_and_value = find_calendar_field(part, date_time_format, range_format_options, local_time); style_and_value.has_value()) {
String formatted_value;
DeprecatedString formatted_value;
// i. If rangeFormatOptions is not undefined, let f be the value of rangeFormatOptions's field whose name matches p.
// ii. Else, let f be the value of dateTimeFormat's internal slot whose name is the Internal Slot column of the matching row.
@ -741,7 +741,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
else if (part == "weekday"sv)
symbol = ::Locale::get_calendar_weekday_symbol(data_locale, date_time_format.calendar(), style, static_cast<::Locale::Weekday>(value));
formatted_value = symbol.value_or(String::number(value));
formatted_value = symbol.value_or(DeprecatedString::number(value));
break;
}
@ -755,7 +755,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
// g. Else if p is equal to "ampm", then
else if (part == "ampm"sv) {
String formatted_value;
DeprecatedString formatted_value;
// i. Let v be tm.[[Hour]].
auto value = local_time.hour;
@ -830,7 +830,7 @@ ThrowCompletionOr<Vector<PatternPartition>> partition_date_time_pattern(VM& vm,
}
// 11.5.8 FormatDateTime ( dateTimeFormat, x ), https://tc39.es/ecma402/#sec-formatdatetime
ThrowCompletionOr<String> format_date_time(VM& vm, DateTimeFormat& date_time_format, double time)
ThrowCompletionOr<DeprecatedString> format_date_time(VM& vm, DateTimeFormat& date_time_format, double time)
{
// 1. Let parts be ? PartitionDateTimePattern(dateTimeFormat, x).
auto parts = TRY(partition_date_time_pattern(vm, date_time_format, time));
@ -1146,7 +1146,7 @@ ThrowCompletionOr<Vector<PatternPartitionWithSource>> partition_date_time_range_
}
// 11.5.11 FormatDateTimeRange ( dateTimeFormat, x, y ), https://tc39.es/ecma402/#sec-formatdatetimerange
ThrowCompletionOr<String> format_date_time_range(VM& vm, DateTimeFormat& date_time_format, double start, double end)
ThrowCompletionOr<DeprecatedString> format_date_time_range(VM& vm, DateTimeFormat& date_time_format, double start, double end)
{
// 1. Let parts be ? PartitionDateTimeRangePattern(dateTimeFormat, x, y).
auto parts = TRY(partition_date_time_range_pattern(vm, date_time_format, start, end));

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/Array.h>
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/StringView.h>
#include <AK/Time.h>
#include <AK/Types.h>
@ -43,17 +43,17 @@ public:
virtual ~DateTimeFormat() override = default;
String const& locale() const { return m_locale; }
void set_locale(String locale) { m_locale = move(locale); }
DeprecatedString const& locale() const { return m_locale; }
void set_locale(DeprecatedString locale) { m_locale = move(locale); }
String const& data_locale() const { return m_data_locale; }
void set_data_locale(String data_locale) { m_data_locale = move(data_locale); }
DeprecatedString const& data_locale() const { return m_data_locale; }
void set_data_locale(DeprecatedString data_locale) { m_data_locale = move(data_locale); }
String const& calendar() const { return m_calendar; }
void set_calendar(String calendar) { m_calendar = move(calendar); }
DeprecatedString const& calendar() const { return m_calendar; }
void set_calendar(DeprecatedString calendar) { m_calendar = move(calendar); }
String const& numbering_system() const { return m_numbering_system; }
void set_numbering_system(String numbering_system) { m_numbering_system = move(numbering_system); }
DeprecatedString const& numbering_system() const { return m_numbering_system; }
void set_numbering_system(DeprecatedString numbering_system) { m_numbering_system = move(numbering_system); }
bool has_hour_cycle() const { return m_hour_cycle.has_value(); }
::Locale::HourCycle hour_cycle() const { return *m_hour_cycle; }
@ -61,8 +61,8 @@ public:
void set_hour_cycle(::Locale::HourCycle hour_cycle) { m_hour_cycle = hour_cycle; }
void clear_hour_cycle() { m_hour_cycle.clear(); }
String const& time_zone() const { return m_time_zone; }
void set_time_zone(String time_zone) { m_time_zone = move(time_zone); }
DeprecatedString const& time_zone() const { return m_time_zone; }
void set_time_zone(DeprecatedString time_zone) { m_time_zone = move(time_zone); }
bool has_date_style() const { return m_date_style.has_value(); }
Style date_style() const { return *m_date_style; };
@ -74,8 +74,8 @@ public:
StringView time_style_string() const { return style_to_string(*m_time_style); };
void set_time_style(StringView style) { m_time_style = style_from_string(style); };
String const& pattern() const { return Patterns::pattern; };
void set_pattern(String pattern) { Patterns::pattern = move(pattern); }
DeprecatedString const& pattern() const { return Patterns::pattern; };
void set_pattern(DeprecatedString pattern) { Patterns::pattern = move(pattern); }
Span<::Locale::CalendarRangePattern const> range_patterns() const { return m_range_patterns.span(); };
void set_range_patterns(Vector<::Locale::CalendarRangePattern> range_patterns) { m_range_patterns = move(range_patterns); }
@ -134,17 +134,17 @@ private:
virtual void visit_edges(Visitor&) override;
String m_locale; // [[Locale]]
String m_calendar; // [[Calendar]]
String m_numbering_system; // [[NumberingSystem]]
DeprecatedString m_locale; // [[Locale]]
DeprecatedString m_calendar; // [[Calendar]]
DeprecatedString m_numbering_system; // [[NumberingSystem]]
Optional<::Locale::HourCycle> m_hour_cycle; // [[HourCycle]]
String m_time_zone; // [[TimeZone]]
DeprecatedString m_time_zone; // [[TimeZone]]
Optional<Style> m_date_style; // [[DateStyle]]
Optional<Style> m_time_style; // [[TimeStyle]]
Vector<::Locale::CalendarRangePattern> m_range_patterns; // [[RangePatterns]]
NativeFunction* m_bound_format { nullptr }; // [[BoundFormat]]
String m_data_locale;
DeprecatedString m_data_locale;
};
enum class OptionRequired {
@ -186,10 +186,10 @@ Optional<::Locale::CalendarPattern> basic_format_matcher(::Locale::CalendarPatte
Optional<::Locale::CalendarPattern> best_fit_format_matcher(::Locale::CalendarPattern const& options, Vector<::Locale::CalendarPattern> formats);
ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM&, DateTimeFormat&, Vector<PatternPartition> pattern_parts, double time, ::Locale::CalendarPattern const* range_format_options);
ThrowCompletionOr<Vector<PatternPartition>> partition_date_time_pattern(VM&, DateTimeFormat&, double time);
ThrowCompletionOr<String> format_date_time(VM&, DateTimeFormat&, double time);
ThrowCompletionOr<DeprecatedString> format_date_time(VM&, DateTimeFormat&, double time);
ThrowCompletionOr<Array*> format_date_time_to_parts(VM&, DateTimeFormat&, double time);
ThrowCompletionOr<Vector<PatternPartitionWithSource>> partition_date_time_range_pattern(VM&, DateTimeFormat&, double start, double end);
ThrowCompletionOr<String> format_date_time_range(VM&, DateTimeFormat&, double start, double end);
ThrowCompletionOr<DeprecatedString> format_date_time_range(VM&, DateTimeFormat&, double start, double end);
ThrowCompletionOr<Array*> format_date_time_range_to_parts(VM&, DateTimeFormat&, double start, double end);
ThrowCompletionOr<LocalTime> to_local_time(VM&, Crypto::SignedBigInteger const& epoch_ns, StringView calendar, StringView time_zone);

View file

@ -212,7 +212,7 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(VM& vm, DateTimeF
// 29. Let timeZone be ? Get(options, "timeZone").
auto time_zone_value = TRY(options->get(vm.names.timeZone));
String time_zone;
DeprecatedString time_zone;
// 30. If timeZone is undefined, then
if (time_zone_value.is_undefined()) {
@ -345,7 +345,7 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(VM& vm, DateTimeF
}
});
String pattern;
DeprecatedString pattern;
Vector<::Locale::CalendarRangePattern> range_patterns;
// 45. If dateTimeFormat.[[Hour]] is undefined, then

View file

@ -31,7 +31,7 @@ void DateTimeFormatFunction::initialize(Realm& realm)
Base::initialize(realm);
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable);
define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable);
}
ThrowCompletionOr<Value> DateTimeFormatFunction::call()

View file

@ -6,8 +6,8 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/StringView.h>
#include <LibJS/Runtime/Object.h>
#include <LibLocale/Locale.h>
@ -41,8 +41,8 @@ class DisplayNames final : public Object {
public:
virtual ~DisplayNames() override = default;
String const& locale() const { return m_locale; }
void set_locale(String locale) { m_locale = move(locale); }
DeprecatedString const& locale() const { return m_locale; }
void set_locale(DeprecatedString locale) { m_locale = move(locale); }
::Locale::Style style() const { return m_style; }
void set_style(StringView style) { m_style = ::Locale::style_from_string(style); }
@ -64,7 +64,7 @@ public:
private:
DisplayNames(Object& prototype);
String m_locale; // [[Locale]]
DeprecatedString m_locale; // [[Locale]]
::Locale::Style m_style { ::Locale::Style::Long }; // [[Style]]
Type m_type { Type::Invalid }; // [[Type]]
Fallback m_fallback { Fallback::Invalid }; // [[Fallback]]

View file

@ -52,7 +52,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of)
// 5. Let fields be displayNames.[[Fields]].
// 6. If fields has a field [[<code>]], return fields.[[<code>]].
Optional<StringView> result;
Optional<String> formatted_result;
Optional<DeprecatedString> formatted_result;
switch (display_names->type()) {
case DisplayNames::Type::Language:

View file

@ -232,7 +232,7 @@ bool is_valid_duration_record(Temporal::DurationRecord const& record)
}
// 1.1.6 GetDurationUnitOptions ( unit, options, baseStyle, stylesList, digitalBase, prevStyle ), https://tc39.es/proposal-intl-duration-format/#sec-getdurationunitoptions
ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, String const& unit, Object const& options, StringView base_style, Span<StringView const> styles_list, StringView digital_base, StringView previous_style)
ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, DeprecatedString const& unit, Object const& options, StringView base_style, Span<StringView const> 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, OptionType::String, styles_list, Empty {}));
@ -240,7 +240,7 @@ ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, String
// 2. Let displayDefault be "always".
auto display_default = "always"sv;
String style;
DeprecatedString style;
// 3. If style is undefined, then
if (style_value.is_undefined()) {
@ -276,7 +276,7 @@ ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM& vm, String
}
// 4. Let displayField be the string-concatenation of unit and "Display".
auto display_field = String::formatted("{}Display", unit);
auto display_field = DeprecatedString::formatted("{}Display", unit);
// 5. Let display be ? GetOption(options, displayField, "string", « "auto", "always" », displayDefault).
auto display = TRY(get_option(vm, options, display_field, OptionType::String, { "auto"sv, "always"sv }, display_default));
@ -510,17 +510,17 @@ Vector<PatternPartition> partition_duration_format_pattern(VM& vm, DurationForma
// FIXME: CreatePartsFromList expects a list of strings and creates a list of Pattern Partition records, but we already created a list of Pattern Partition records
// so we try to hack something together from it that looks mostly right
Vector<String> string_result;
Vector<DeprecatedString> string_result;
bool merge = false;
for (size_t i = 0; i < result.size(); ++i) {
auto const& part = result[i];
if (part.type == "literal") {
string_result.last() = String::formatted("{}{}", string_result.last(), part.value);
string_result.last() = DeprecatedString::formatted("{}{}", string_result.last(), part.value);
merge = true;
continue;
}
if (merge) {
string_result.last() = String::formatted("{}{}", string_result.last(), part.value);
string_result.last() = DeprecatedString::formatted("{}{}", string_result.last(), part.value);
merge = false;
continue;
}

View file

@ -8,7 +8,7 @@
#pragma once
#include <AK/Array.h>
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <LibJS/Runtime/Intl/AbstractOperations.h>
#include <LibJS/Runtime/Object.h>
#include <LibJS/Runtime/Temporal/Duration.h>
@ -51,18 +51,18 @@ public:
virtual ~DurationFormat() override = default;
void set_locale(String locale) { m_locale = move(locale); }
String const& locale() const { return m_locale; }
void set_locale(DeprecatedString locale) { m_locale = move(locale); }
DeprecatedString const& locale() const { return m_locale; }
void set_data_locale(String data_locale) { m_data_locale = move(data_locale); }
String const& data_locale() const { return m_data_locale; }
void set_data_locale(DeprecatedString data_locale) { m_data_locale = move(data_locale); }
DeprecatedString const& data_locale() const { return m_data_locale; }
void set_numbering_system(String numbering_system) { m_numbering_system = move(numbering_system); }
String const& numbering_system() const { return m_numbering_system; }
void set_numbering_system(DeprecatedString numbering_system) { m_numbering_system = move(numbering_system); }
DeprecatedString const& numbering_system() const { return m_numbering_system; }
void set_style(StringView style) { m_style = style_from_string(style); }
Style style() const { return m_style; }
String style_string() const { return style_to_string(m_style); }
DeprecatedString style_string() const { return style_to_string(m_style); }
void set_years_style(StringView years_style) { m_years_style = date_style_from_string(years_style); }
ValueStyle years_style() const { return m_years_style; }
@ -160,9 +160,9 @@ private:
static Display display_from_string(StringView display);
static StringView display_to_string(Display);
String m_locale; // [[Locale]]
String m_data_locale; // [[DataLocale]]
String m_numbering_system; // [[NumberingSystem]]
DeprecatedString m_locale; // [[Locale]]
DeprecatedString m_data_locale; // [[DataLocale]]
DeprecatedString m_numbering_system; // [[NumberingSystem]]
Style m_style; // [[Style]]
ValueStyle m_years_style { ValueStyle::Long }; // [[YearsStyle]]
Display m_years_display { Display::Auto }; // [[YearsDisplay]]
@ -217,14 +217,14 @@ static constexpr AK::Array<DurationInstanceComponent, 10> duration_instances_com
};
struct DurationUnitOptions {
String style;
String display;
DeprecatedString style;
DeprecatedString display;
};
ThrowCompletionOr<Temporal::DurationRecord> to_duration_record(VM&, Value input);
i8 duration_record_sign(Temporal::DurationRecord const&);
bool is_valid_duration_record(Temporal::DurationRecord const&);
ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM&, String const& unit, Object const& options, StringView base_style, Span<StringView const> styles_list, StringView digital_base, StringView previous_style);
ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(VM&, DeprecatedString const& unit, Object const& options, StringView base_style, Span<StringView const> styles_list, StringView digital_base, StringView previous_style);
Vector<PatternPartition> partition_duration_format_pattern(VM&, DurationFormat const&, Temporal::DurationRecord const& duration);
}

View file

@ -74,7 +74,7 @@ ThrowCompletionOr<Object*> DurationFormatConstructor::construct(FunctionObject&
// 8. Let opt be the Record { [[localeMatcher]]: matcher, [[nu]]: numberingSystem }.
LocaleOptions opt {};
opt.locale_matcher = matcher;
opt.nu = numbering_system.is_undefined() ? Optional<String>() : numbering_system.as_string().string();
opt.nu = numbering_system.is_undefined() ? Optional<DeprecatedString>() : numbering_system.as_string().string();
// 9. Let r be ResolveLocale(%DurationFormat%.[[AvailableLocales]], requestedLocales, opt, %DurationFormat%.[[RelevantExtensionKeys]], %DurationFormat%.[[LocaleData]]).
auto result = resolve_locale(requested_locales, opt, DurationFormat::relevant_extension_keys());
@ -99,7 +99,7 @@ ThrowCompletionOr<Object*> DurationFormatConstructor::construct(FunctionObject&
duration_format->set_data_locale(move(result.data_locale));
// 16. Let prevStyle be the empty String.
auto previous_style = String::empty();
auto previous_style = DeprecatedString::empty();
// 17. For each row of Table 1, except the header row, in table order, do
for (auto const& duration_instances_component : duration_instances_components) {

View file

@ -93,7 +93,7 @@ Vector<PatternPartition> deconstruct_pattern(StringView pattern, Placeables plac
}
// 13.5.2 CreatePartsFromList ( listFormat, list ), https://tc39.es/ecma402/#sec-createpartsfromlist
Vector<PatternPartition> create_parts_from_list(ListFormat const& list_format, Vector<String> const& list)
Vector<PatternPartition> create_parts_from_list(ListFormat const& list_format, Vector<DeprecatedString> const& list)
{
auto list_patterns = ::Locale::get_locale_list_patterns(list_format.locale(), list_format.type_string(), list_format.style());
if (!list_patterns.has_value())
@ -182,7 +182,7 @@ Vector<PatternPartition> create_parts_from_list(ListFormat const& list_format, V
}
// 13.5.3 FormatList ( listFormat, list ), https://tc39.es/ecma402/#sec-formatlist
String format_list(ListFormat const& list_format, Vector<String> const& list)
DeprecatedString format_list(ListFormat const& list_format, Vector<DeprecatedString> const& list)
{
// 1. Let parts be ! CreatePartsFromList(listFormat, list).
auto parts = create_parts_from_list(list_format, list);
@ -201,7 +201,7 @@ String format_list(ListFormat const& list_format, Vector<String> const& list)
}
// 13.5.4 FormatListToParts ( listFormat, list ), https://tc39.es/ecma402/#sec-formatlisttoparts
Array* format_list_to_parts(VM& vm, ListFormat const& list_format, Vector<String> const& list)
Array* format_list_to_parts(VM& vm, ListFormat const& list_format, Vector<DeprecatedString> const& list)
{
auto& realm = *vm.current_realm();
@ -237,19 +237,19 @@ Array* format_list_to_parts(VM& vm, ListFormat const& list_format, Vector<String
}
// 13.5.5 StringListFromIterable ( iterable ), https://tc39.es/ecma402/#sec-createstringlistfromiterable
ThrowCompletionOr<Vector<String>> string_list_from_iterable(VM& vm, Value iterable)
ThrowCompletionOr<Vector<DeprecatedString>> string_list_from_iterable(VM& vm, Value iterable)
{
// 1. If iterable is undefined, then
if (iterable.is_undefined()) {
// a. Return a new empty List.
return Vector<String> {};
return Vector<DeprecatedString> {};
}
// 2. Let iteratorRecord be ? GetIterator(iterable).
auto iterator_record = TRY(get_iterator(vm, iterable));
// 3. Let list be a new empty List.
Vector<String> list;
Vector<DeprecatedString> list;
// 4. Let next be true.
Object* next = nullptr;

View file

@ -6,8 +6,8 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/String.h>
#include <AK/StringView.h>
#include <AK/Variant.h>
#include <AK/Vector.h>
@ -30,8 +30,8 @@ public:
virtual ~ListFormat() override = default;
String const& locale() const { return m_locale; }
void set_locale(String locale) { m_locale = move(locale); }
DeprecatedString const& locale() const { return m_locale; }
void set_locale(DeprecatedString locale) { m_locale = move(locale); }
Type type() const { return m_type; }
void set_type(StringView type);
@ -44,7 +44,7 @@ public:
private:
explicit ListFormat(Object& prototype);
String m_locale; // [[Locale]]
DeprecatedString m_locale; // [[Locale]]
Type m_type { Type::Invalid }; // [[Type]]
::Locale::Style m_style { ::Locale::Style::Long }; // [[Style]]
};
@ -52,9 +52,9 @@ private:
using Placeables = HashMap<StringView, Variant<PatternPartition, Vector<PatternPartition>>>;
Vector<PatternPartition> deconstruct_pattern(StringView pattern, Placeables);
Vector<PatternPartition> create_parts_from_list(ListFormat const&, Vector<String> const& list);
String format_list(ListFormat const&, Vector<String> const& list);
Array* format_list_to_parts(VM&, ListFormat const&, Vector<String> const& list);
ThrowCompletionOr<Vector<String>> string_list_from_iterable(VM&, Value iterable);
Vector<PatternPartition> create_parts_from_list(ListFormat const&, Vector<DeprecatedString> const& list);
DeprecatedString format_list(ListFormat const&, Vector<DeprecatedString> const& list);
Array* format_list_to_parts(VM&, ListFormat const&, Vector<DeprecatedString> const& list);
ThrowCompletionOr<Vector<DeprecatedString>> string_list_from_iterable(VM&, Value iterable);
}

View file

@ -55,7 +55,7 @@ Locale::Locale(::Locale::LocaleID const& locale_id, Object& prototype)
}
// 1.1.1 CreateArrayFromListOrRestricted ( list , restricted )
static Array* create_array_from_list_or_restricted(VM& vm, Vector<StringView> list, Optional<String> restricted)
static Array* create_array_from_list_or_restricted(VM& vm, Vector<StringView> list, Optional<DeprecatedString> restricted)
{
auto& realm = *vm.current_realm();
@ -75,7 +75,7 @@ static Array* create_array_from_list_or_restricted(VM& vm, Vector<StringView> li
Array* calendars_of_locale(VM& vm, Locale const& locale_object)
{
// 1. Let restricted be loc.[[Calendar]].
Optional<String> restricted = locale_object.has_calendar() ? locale_object.calendar() : Optional<String> {};
Optional<DeprecatedString> restricted = locale_object.has_calendar() ? locale_object.calendar() : Optional<DeprecatedString> {};
// 2. Let locale be loc.[[Locale]].
auto const& locale = locale_object.locale();
@ -94,7 +94,7 @@ Array* calendars_of_locale(VM& vm, Locale const& locale_object)
Array* collations_of_locale(VM& vm, Locale const& locale_object)
{
// 1. Let restricted be loc.[[Collation]].
Optional<String> restricted = locale_object.has_collation() ? locale_object.collation() : Optional<String> {};
Optional<DeprecatedString> restricted = locale_object.has_collation() ? locale_object.collation() : Optional<DeprecatedString> {};
// 2. Let locale be loc.[[Locale]].
auto const& locale = locale_object.locale();
@ -113,7 +113,7 @@ Array* collations_of_locale(VM& vm, Locale const& locale_object)
Array* hour_cycles_of_locale(VM& vm, Locale const& locale_object)
{
// 1. Let restricted be loc.[[HourCycle]].
Optional<String> restricted = locale_object.has_hour_cycle() ? locale_object.hour_cycle() : Optional<String> {};
Optional<DeprecatedString> restricted = locale_object.has_hour_cycle() ? locale_object.hour_cycle() : Optional<DeprecatedString> {};
// 2. Let locale be loc.[[Locale]].
auto const& locale = locale_object.locale();
@ -132,7 +132,7 @@ Array* hour_cycles_of_locale(VM& vm, Locale const& locale_object)
Array* numbering_systems_of_locale(VM& vm, Locale const& locale_object)
{
// 1. Let restricted be loc.[[NumberingSystem]].
Optional<String> restricted = locale_object.has_numbering_system() ? locale_object.numbering_system() : Optional<String> {};
Optional<DeprecatedString> restricted = locale_object.has_numbering_system() ? locale_object.numbering_system() : Optional<DeprecatedString> {};
// 2. Let locale be loc.[[Locale]].
auto const& locale = locale_object.locale();

View file

@ -7,8 +7,8 @@
#pragma once
#include <AK/Array.h>
#include <AK/DeprecatedString.h>
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/Vector.h>
#include <LibJS/Runtime/Completion.h>
#include <LibJS/Runtime/Object.h>
@ -36,28 +36,28 @@ public:
virtual ~Locale() override = default;
String const& locale() const { return m_locale; }
void set_locale(String locale) { m_locale = move(locale); }
DeprecatedString const& locale() const { return m_locale; }
void set_locale(DeprecatedString locale) { m_locale = move(locale); }
bool has_calendar() const { return m_calendar.has_value(); }
String const& calendar() const { return m_calendar.value(); }
void set_calendar(String calendar) { m_calendar = move(calendar); }
DeprecatedString const& calendar() const { return m_calendar.value(); }
void set_calendar(DeprecatedString calendar) { m_calendar = move(calendar); }
bool has_case_first() const { return m_case_first.has_value(); }
String const& case_first() const { return m_case_first.value(); }
void set_case_first(String case_first) { m_case_first = move(case_first); }
DeprecatedString const& case_first() const { return m_case_first.value(); }
void set_case_first(DeprecatedString case_first) { m_case_first = move(case_first); }
bool has_collation() const { return m_collation.has_value(); }
String const& collation() const { return m_collation.value(); }
void set_collation(String collation) { m_collation = move(collation); }
DeprecatedString const& collation() const { return m_collation.value(); }
void set_collation(DeprecatedString collation) { m_collation = move(collation); }
bool has_hour_cycle() const { return m_hour_cycle.has_value(); }
String const& hour_cycle() const { return m_hour_cycle.value(); }
void set_hour_cycle(String hour_cycle) { m_hour_cycle = move(hour_cycle); }
DeprecatedString const& hour_cycle() const { return m_hour_cycle.value(); }
void set_hour_cycle(DeprecatedString hour_cycle) { m_hour_cycle = move(hour_cycle); }
bool has_numbering_system() const { return m_numbering_system.has_value(); }
String const& numbering_system() const { return m_numbering_system.value(); }
void set_numbering_system(String numbering_system) { m_numbering_system = move(numbering_system); }
DeprecatedString const& numbering_system() const { return m_numbering_system.value(); }
void set_numbering_system(DeprecatedString numbering_system) { m_numbering_system = move(numbering_system); }
bool numeric() const { return m_numeric; }
void set_numeric(bool numeric) { m_numeric = numeric; }
@ -66,13 +66,13 @@ private:
explicit Locale(Object& prototype);
Locale(::Locale::LocaleID const&, Object& prototype);
String m_locale; // [[Locale]]
Optional<String> m_calendar; // [[Calendar]]
Optional<String> m_case_first; // [[CaseFirst]]
Optional<String> m_collation; // [[Collation]]
Optional<String> m_hour_cycle; // [[HourCycle]]
Optional<String> m_numbering_system; // [[NumberingSystem]]
bool m_numeric { false }; // [[Numeric]]
DeprecatedString m_locale; // [[Locale]]
Optional<DeprecatedString> m_calendar; // [[Calendar]]
Optional<DeprecatedString> m_case_first; // [[CaseFirst]]
Optional<DeprecatedString> m_collation; // [[Collation]]
Optional<DeprecatedString> m_hour_cycle; // [[HourCycle]]
Optional<DeprecatedString> m_numbering_system; // [[NumberingSystem]]
bool m_numeric { false }; // [[Numeric]]
};
// Table 1: WeekInfo Record Fields, https://tc39.es/proposal-intl-locale-info/#table-locale-weekinfo-record

View file

@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/TypeCasts.h>
#include <LibJS/Runtime/AbstractOperations.h>
#include <LibJS/Runtime/GlobalObject.h>
@ -17,21 +17,21 @@
namespace JS::Intl {
struct LocaleAndKeys {
String locale;
Optional<String> ca;
Optional<String> co;
Optional<String> hc;
Optional<String> kf;
Optional<String> kn;
Optional<String> nu;
DeprecatedString locale;
Optional<DeprecatedString> ca;
Optional<DeprecatedString> co;
Optional<DeprecatedString> hc;
Optional<DeprecatedString> kf;
Optional<DeprecatedString> kn;
Optional<DeprecatedString> nu;
};
// Note: This is not an AO in the spec. This just serves to abstract very similar steps in ApplyOptionsToTag and the Intl.Locale constructor.
static ThrowCompletionOr<Optional<String>> get_string_option(VM& vm, Object const& options, PropertyKey const& property, Function<bool(StringView)> validator, Span<StringView const> values = {})
static ThrowCompletionOr<Optional<DeprecatedString>> get_string_option(VM& vm, Object const& options, PropertyKey const& property, Function<bool(StringView)> validator, Span<StringView const> values = {})
{
auto option = TRY(get_option(vm, options, property, OptionType::String, values, Empty {}));
if (option.is_undefined())
return Optional<String> {};
return Optional<DeprecatedString> {};
if (validator && !validator(option.as_string().string()))
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, option, property);
@ -40,7 +40,7 @@ static ThrowCompletionOr<Optional<String>> get_string_option(VM& vm, Object cons
}
// 14.1.2 ApplyOptionsToTag ( tag, options ), https://tc39.es/ecma402/#sec-apply-options-to-tag
static ThrowCompletionOr<String> apply_options_to_tag(VM& vm, StringView tag, Object const& options)
static ThrowCompletionOr<DeprecatedString> apply_options_to_tag(VM& vm, StringView tag, Object const& options)
{
// 1. Assert: Type(tag) is String.
// 2. Assert: Type(options) is Object.
@ -112,7 +112,7 @@ static LocaleAndKeys apply_unicode_extension_to_tag(StringView tag, LocaleAndKey
auto locale_id = ::Locale::parse_unicode_locale_id(tag);
VERIFY(locale_id.has_value());
Vector<String> attributes;
Vector<DeprecatedString> attributes;
Vector<::Locale::Keyword> keywords;
// 3. If tag contains a substring that is a Unicode locale extension sequence, then
@ -134,7 +134,7 @@ static LocaleAndKeys apply_unicode_extension_to_tag(StringView tag, LocaleAndKey
// a. Let attributes be a new empty List.
// b. Let keywords be a new empty List.
auto field_from_key = [](LocaleAndKeys& value, StringView key) -> Optional<String>& {
auto field_from_key = [](LocaleAndKeys& value, StringView key) -> Optional<DeprecatedString>& {
if (key == "ca"sv)
return value.ca;
if (key == "co"sv)
@ -156,7 +156,7 @@ static LocaleAndKeys apply_unicode_extension_to_tag(StringView tag, LocaleAndKey
// 6. For each element key of relevantExtensionKeys, do
for (auto const& key : relevant_extension_keys) {
// a. Let value be undefined.
Optional<String> value {};
Optional<DeprecatedString> value {};
::Locale::Keyword* entry = nullptr;
// b. If keywords contains an element whose [[Key]] is the same as key, then
@ -260,7 +260,7 @@ ThrowCompletionOr<Object*> LocaleConstructor::construct(FunctionObject& new_targ
// 6. Let locale be ? OrdinaryCreateFromConstructor(NewTarget, "%Locale.prototype%", internalSlotsList).
auto* locale = TRY(ordinary_create_from_constructor<Locale>(vm, new_target, &Intrinsics::intl_locale_prototype));
String tag;
DeprecatedString tag;
// 7. If Type(tag) is not String or Object, throw a TypeError exception.
if (!tag_value.is_string() && !tag_value.is_object())

View file

@ -293,12 +293,12 @@ bool MathematicalValue::is_zero() const
[](auto) { return false; });
}
String MathematicalValue::to_string() const
DeprecatedString MathematicalValue::to_string() const
{
return m_value.visit(
[](double value) { return number_to_string(value, NumberToStringMode::WithoutExponent); },
[](Crypto::SignedBigInteger const& value) { return value.to_base(10); },
[](auto) -> String { VERIFY_NOT_REACHED(); });
[](auto) -> DeprecatedString { VERIFY_NOT_REACHED(); });
}
Value MathematicalValue::to_value(VM& vm) const

View file

@ -87,7 +87,7 @@ public:
bool is_positive() const;
bool is_zero() const;
String to_string() const;
DeprecatedString to_string() const;
Value to_value(VM&) const;
private:

View file

@ -494,10 +494,10 @@ FormatResult format_numeric_to_string(NumberFormatBase const& intl_object, Mathe
// 14. If int < minInteger, then
if (digits < min_integer) {
// a. Let forwardZeros be the String consisting of minIntegerint occurrences of the character "0".
auto forward_zeros = String::repeated('0', min_integer - digits);
auto forward_zeros = DeprecatedString::repeated('0', min_integer - digits);
// b. Set string to the string-concatenation of forwardZeros and string.
string = String::formatted("{}{}", forward_zeros, string);
string = DeprecatedString::formatted("{}{}", forward_zeros, string);
}
// 15. If isNegative and x is 0, then
@ -522,7 +522,7 @@ Vector<PatternPartition> partition_number_pattern(VM& vm, NumberFormat& number_f
// 1. Let exponent be 0.
int exponent = 0;
String formatted_string;
DeprecatedString formatted_string;
// 2. If x is not-a-number, then
if (number.is_nan()) {
@ -714,7 +714,7 @@ static Vector<StringView> separate_integer_into_groups(::Locale::NumberGroupings
// 15.5.5 PartitionNotationSubPattern ( numberFormat, x, n, exponent ), https://tc39.es/ecma402/#sec-partitionnotationsubpattern
// 1.1.7 PartitionNotationSubPattern ( numberFormat, x, n, exponent ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-partitionnotationsubpattern
Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat& number_format, MathematicalValue const& number, String formatted_string, int exponent)
Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat& number_format, MathematicalValue const& number, DeprecatedString formatted_string, int exponent)
{
// 1. Let result be a new empty List.
Vector<PatternPartition> result;
@ -885,7 +885,7 @@ Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat& number_for
}
// 15.5.6 FormatNumeric ( numberFormat, x ), https://tc39.es/ecma402/#sec-formatnumber
String format_numeric(VM& vm, NumberFormat& number_format, MathematicalValue number)
DeprecatedString format_numeric(VM& vm, NumberFormat& number_format, MathematicalValue number)
{
// 1. Let parts be ? PartitionNumberPattern(numberFormat, x).
// Note: Our implementation of PartitionNumberPattern does not throw.
@ -941,7 +941,7 @@ Array* format_numeric_to_parts(VM& vm, NumberFormat& number_format, Mathematical
return result;
}
static String cut_trailing_zeroes(StringView string, int cut)
static DeprecatedString cut_trailing_zeroes(StringView string, int cut)
{
// These steps are exactly the same between ToRawPrecision and ToRawFixed.
@ -1022,7 +1022,7 @@ RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precis
// 2. If x = 0, then
if (number.is_zero()) {
// a. Let m be the String consisting of p occurrences of the character "0".
result.formatted_string = String::repeated('0', precision);
result.formatted_string = DeprecatedString::repeated('0', precision);
// b. Let e be 0.
exponent = 0;
@ -1073,10 +1073,10 @@ RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precis
// 4. If e ≥ p1, then
if (exponent >= (precision - 1)) {
// a. Let m be the string-concatenation of m and ep+1 occurrences of the character "0".
result.formatted_string = String::formatted(
result.formatted_string = DeprecatedString::formatted(
"{}{}",
result.formatted_string,
String::repeated('0', exponent - precision + 1));
DeprecatedString::repeated('0', exponent - precision + 1));
// b. Let int be e+1.
result.digits = exponent + 1;
@ -1084,7 +1084,7 @@ RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precis
// 5. Else if e ≥ 0, then
else if (exponent >= 0) {
// a. Let m be the string-concatenation of the first e+1 characters of m, the character ".", and the remaining p(e+1) characters of m.
result.formatted_string = String::formatted(
result.formatted_string = DeprecatedString::formatted(
"{}.{}",
result.formatted_string.substring_view(0, exponent + 1),
result.formatted_string.substring_view(exponent + 1));
@ -1096,9 +1096,9 @@ RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precis
else {
// a. Assert: e < 0.
// b. Let m be the string-concatenation of "0.", (e+1) occurrences of the character "0", and m.
result.formatted_string = String::formatted(
result.formatted_string = DeprecatedString::formatted(
"0.{}{}",
String::repeated('0', -1 * (exponent + 1)),
DeprecatedString::repeated('0', -1 * (exponent + 1)),
result.formatted_string);
// c. Let int be 1.
@ -1206,7 +1206,7 @@ RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction,
}
// 7. If n = 0, let m be "0". Otherwise, let m be the String consisting of the digits of the decimal representation of n (in order, with no leading zeroes).
result.formatted_string = n.is_zero() ? String("0"sv) : n.to_string();
result.formatted_string = n.is_zero() ? DeprecatedString("0"sv) : n.to_string();
// 8. If f ≠ 0, then
if (fraction != 0) {
@ -1216,10 +1216,10 @@ RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction,
// b. If k ≤ f, then
if (decimals <= static_cast<size_t>(fraction)) {
// i. Let z be the String value consisting of f+1k occurrences of the character "0".
auto zeroes = String::repeated('0', fraction + 1 - decimals);
auto zeroes = DeprecatedString::repeated('0', fraction + 1 - decimals);
// ii. Let m be the string-concatenation of z and m.
result.formatted_string = String::formatted("{}{}", zeroes, result.formatted_string);
result.formatted_string = DeprecatedString::formatted("{}{}", zeroes, result.formatted_string);
// iii. Let k be f+1.
decimals = fraction + 1;
@ -1230,7 +1230,7 @@ RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction,
auto b = result.formatted_string.substring_view(decimals - fraction, fraction);
// d. Let m be the string-concatenation of a, ".", and b.
result.formatted_string = String::formatted("{}.{}", a, b);
result.formatted_string = DeprecatedString::formatted("{}.{}", a, b);
// e. Let int be the number of characters in a.
result.digits = a.length();
@ -1253,7 +1253,7 @@ RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction,
// 15.5.11 GetNumberFormatPattern ( numberFormat, x ), https://tc39.es/ecma402/#sec-getnumberformatpattern
// 1.1.14 GetNumberFormatPattern ( numberFormat, x ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-getnumberformatpattern
Optional<Variant<StringView, String>> get_number_format_pattern(VM& vm, NumberFormat& number_format, MathematicalValue const& number, ::Locale::NumberFormat& found_pattern)
Optional<Variant<StringView, DeprecatedString>> get_number_format_pattern(VM& vm, NumberFormat& number_format, MathematicalValue const& number, ::Locale::NumberFormat& found_pattern)
{
// 1. Let localeData be %NumberFormat%.[[LocaleData]].
// 2. Let dataLocale be numberFormat.[[DataLocale]].
@ -1797,7 +1797,7 @@ Vector<PatternPartitionWithSource> collapse_number_range(Vector<PatternPartition
}
// 1.1.24 FormatNumericRange( numberFormat, x, y ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-formatnumericrange
ThrowCompletionOr<String> format_numeric_range(VM& vm, NumberFormat& number_format, MathematicalValue start, MathematicalValue end)
ThrowCompletionOr<DeprecatedString> format_numeric_range(VM& vm, NumberFormat& number_format, MathematicalValue start, MathematicalValue end)
{
// 1. Let parts be ? PartitionNumberRangePattern(numberFormat, x, y).
auto parts = TRY(partition_number_range_pattern(vm, number_format, move(start), move(end)));

View file

@ -7,8 +7,8 @@
#pragma once
#include <AK/Array.h>
#include <AK/DeprecatedString.h>
#include <AK/Optional.h>
#include <AK/String.h>
#include <LibJS/Runtime/Intl/AbstractOperations.h>
#include <LibJS/Runtime/Intl/MathematicalValue.h>
#include <LibJS/Runtime/Object.h>
@ -58,11 +58,11 @@ public:
virtual ~NumberFormatBase() override = default;
String const& locale() const { return m_locale; }
void set_locale(String locale) { m_locale = move(locale); }
DeprecatedString const& locale() const { return m_locale; }
void set_locale(DeprecatedString locale) { m_locale = move(locale); }
String const& data_locale() const { return m_data_locale; }
void set_data_locale(String data_locale) { m_data_locale = move(data_locale); }
DeprecatedString const& data_locale() const { return m_data_locale; }
void set_data_locale(DeprecatedString data_locale) { m_data_locale = move(data_locale); }
int min_integer_digits() const { return m_min_integer_digits; }
void set_min_integer_digits(int min_integer_digits) { m_min_integer_digits = min_integer_digits; }
@ -102,8 +102,8 @@ protected:
explicit NumberFormatBase(Object& prototype);
private:
String m_locale; // [[Locale]]
String m_data_locale; // [[DataLocale]]
DeprecatedString m_locale; // [[Locale]]
DeprecatedString m_data_locale; // [[DataLocale]]
int m_min_integer_digits { 0 }; // [[MinimumIntegerDigits]]
Optional<int> m_min_fraction_digits {}; // [[MinimumFractionDigits]]
Optional<int> m_max_fraction_digits {}; // [[MaximumFractionDigits]]
@ -178,16 +178,16 @@ public:
virtual ~NumberFormat() override = default;
String const& numbering_system() const { return m_numbering_system; }
void set_numbering_system(String numbering_system) { m_numbering_system = move(numbering_system); }
DeprecatedString const& numbering_system() const { return m_numbering_system; }
void set_numbering_system(DeprecatedString numbering_system) { m_numbering_system = move(numbering_system); }
Style style() const { return m_style; }
StringView style_string() const;
void set_style(StringView style);
bool has_currency() const { return m_currency.has_value(); }
String const& currency() const { return m_currency.value(); }
void set_currency(String currency) { m_currency = move(currency); }
DeprecatedString const& currency() const { return m_currency.value(); }
void set_currency(DeprecatedString currency) { m_currency = move(currency); }
bool has_currency_display() const { return m_currency_display.has_value(); }
CurrencyDisplay currency_display() const { return *m_currency_display; }
@ -201,8 +201,8 @@ public:
void set_currency_sign(StringView set_currency_sign);
bool has_unit() const { return m_unit.has_value(); }
String const& unit() const { return m_unit.value(); }
void set_unit(String unit) { m_unit = move(unit); }
DeprecatedString const& unit() const { return m_unit.value(); }
void set_unit(DeprecatedString unit) { m_unit = move(unit); }
bool has_unit_display() const { return m_unit_display.has_value(); }
::Locale::Style unit_display() const { return *m_unit_display; }
@ -238,14 +238,14 @@ private:
virtual void visit_edges(Visitor&) override;
String m_locale; // [[Locale]]
String m_data_locale; // [[DataLocale]]
String m_numbering_system; // [[NumberingSystem]]
DeprecatedString m_locale; // [[Locale]]
DeprecatedString m_data_locale; // [[DataLocale]]
DeprecatedString m_numbering_system; // [[NumberingSystem]]
Style m_style { Style::Invalid }; // [[Style]]
Optional<String> m_currency {}; // [[Currency]]
Optional<DeprecatedString> m_currency {}; // [[Currency]]
Optional<CurrencyDisplay> m_currency_display {}; // [[CurrencyDisplay]]
Optional<CurrencySign> m_currency_sign {}; // [[CurrencySign]]
Optional<String> m_unit {}; // [[Unit]]
Optional<DeprecatedString> m_unit {}; // [[Unit]]
Optional<::Locale::Style> m_unit_display {}; // [[UnitDisplay]]
UseGrouping m_use_grouping { false }; // [[UseGrouping]]
Notation m_notation { Notation::Invalid }; // [[Notation]]
@ -261,7 +261,7 @@ private:
};
struct FormatResult {
String formatted_string; // [[FormattedString]]
DeprecatedString formatted_string; // [[FormattedString]]
MathematicalValue rounded_number { 0.0 }; // [[RoundedNumber]]
};
@ -278,12 +278,12 @@ enum class RoundingDecision {
int currency_digits(StringView currency);
FormatResult format_numeric_to_string(NumberFormatBase const& intl_object, MathematicalValue number);
Vector<PatternPartition> partition_number_pattern(VM&, NumberFormat&, MathematicalValue number);
Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat&, MathematicalValue const& number, String formatted_string, int exponent);
String format_numeric(VM&, NumberFormat&, MathematicalValue number);
Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat&, MathematicalValue const& number, DeprecatedString formatted_string, int exponent);
DeprecatedString format_numeric(VM&, NumberFormat&, MathematicalValue number);
Array* format_numeric_to_parts(VM&, NumberFormat&, MathematicalValue number);
RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precision, int max_precision, Optional<NumberFormat::UnsignedRoundingMode> const& unsigned_rounding_mode);
RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction, int max_fraction, int rounding_increment, Optional<NumberFormat::UnsignedRoundingMode> const& unsigned_rounding_mode);
Optional<Variant<StringView, String>> get_number_format_pattern(VM&, NumberFormat&, MathematicalValue const& number, ::Locale::NumberFormat& found_pattern);
Optional<Variant<StringView, DeprecatedString>> get_number_format_pattern(VM&, NumberFormat&, MathematicalValue const& number, ::Locale::NumberFormat& found_pattern);
Optional<StringView> get_notation_sub_pattern(NumberFormat&, int exponent);
int compute_exponent(NumberFormat&, MathematicalValue number);
int compute_exponent_for_magnitude(NumberFormat&, int magnitude);
@ -293,7 +293,7 @@ RoundingDecision apply_unsigned_rounding_mode(MathematicalValue const& x, Mathem
ThrowCompletionOr<Vector<PatternPartitionWithSource>> partition_number_range_pattern(VM&, NumberFormat&, MathematicalValue start, MathematicalValue end);
Vector<PatternPartitionWithSource> format_approximately(NumberFormat&, Vector<PatternPartitionWithSource> result);
Vector<PatternPartitionWithSource> collapse_number_range(Vector<PatternPartitionWithSource> result);
ThrowCompletionOr<String> format_numeric_range(VM&, NumberFormat&, MathematicalValue start, MathematicalValue end);
ThrowCompletionOr<DeprecatedString> format_numeric_range(VM&, NumberFormat&, MathematicalValue start, MathematicalValue end);
ThrowCompletionOr<Array*> format_numeric_range_to_parts(VM&, NumberFormat&, MathematicalValue start, MathematicalValue end);
}

View file

@ -29,7 +29,7 @@ void NumberFormatFunction::initialize(Realm& realm)
Base::initialize(realm);
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable);
define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable);
}
ThrowCompletionOr<Value> NumberFormatFunction::call()

View file

@ -18,7 +18,7 @@ PluralRules::PluralRules(Object& prototype)
}
// 16.5.1 GetOperands ( s ), https://tc39.es/ecma402/#sec-getoperands
::Locale::PluralOperands get_operands(String const& string)
::Locale::PluralOperands get_operands(DeprecatedString const& string)
{
// 1.Let n be ! ToNumber(s).
auto number = string.to_double(AK::TrimWhitespace::Yes).release_value();

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/StringView.h>
#include <LibJS/Runtime/Completion.h>
#include <LibJS/Runtime/Intl/NumberFormat.h>
@ -31,7 +31,7 @@ private:
::Locale::PluralForm m_type { ::Locale::PluralForm::Cardinal }; // [[Type]]
};
::Locale::PluralOperands get_operands(String const& string);
::Locale::PluralOperands get_operands(DeprecatedString const& string);
::Locale::PluralCategory plural_rule_select(StringView locale, ::Locale::PluralForm type, Value number, ::Locale::PluralOperands operands);
::Locale::PluralCategory resolve_plural(PluralRules const&, Value number);
::Locale::PluralCategory resolve_plural(NumberFormatBase const& number_format, ::Locale::PluralForm type, Value number);

View file

@ -222,7 +222,7 @@ Vector<PatternPartitionWithUnit> make_parts_list(StringView pattern, StringView
}
// 17.5.4 FormatRelativeTime ( relativeTimeFormat, value, unit ), https://tc39.es/ecma402/#sec-FormatRelativeTime
ThrowCompletionOr<String> format_relative_time(VM& vm, RelativeTimeFormat& relative_time_format, double value, StringView unit)
ThrowCompletionOr<DeprecatedString> format_relative_time(VM& vm, RelativeTimeFormat& relative_time_format, double value, StringView unit)
{
// 1. Let parts be ? PartitionRelativeTimePattern(relativeTimeFormat, value, unit).
auto parts = TRY(partition_relative_time_pattern(vm, relative_time_format, value, unit));

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/Array.h>
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/StringView.h>
#include <LibJS/Runtime/Completion.h>
#include <LibJS/Runtime/Intl/AbstractOperations.h>
@ -35,14 +35,14 @@ public:
virtual ~RelativeTimeFormat() override = default;
String const& locale() const { return m_locale; }
void set_locale(String locale) { m_locale = move(locale); }
DeprecatedString const& locale() const { return m_locale; }
void set_locale(DeprecatedString locale) { m_locale = move(locale); }
String const& data_locale() const { return m_data_locale; }
void set_data_locale(String data_locale) { m_data_locale = move(data_locale); }
DeprecatedString const& data_locale() const { return m_data_locale; }
void set_data_locale(DeprecatedString data_locale) { m_data_locale = move(data_locale); }
String const& numbering_system() const { return m_numbering_system; }
void set_numbering_system(String numbering_system) { m_numbering_system = move(numbering_system); }
DeprecatedString const& numbering_system() const { return m_numbering_system; }
void set_numbering_system(DeprecatedString numbering_system) { m_numbering_system = move(numbering_system); }
::Locale::Style style() const { return m_style; }
void set_style(StringView style) { m_style = ::Locale::style_from_string(style); }
@ -63,9 +63,9 @@ private:
virtual void visit_edges(Cell::Visitor&) override;
String m_locale; // [[Locale]]
String m_data_locale; // [[DataLocale]]
String m_numbering_system; // [[NumberingSystem]]
DeprecatedString m_locale; // [[Locale]]
DeprecatedString m_data_locale; // [[DataLocale]]
DeprecatedString m_numbering_system; // [[NumberingSystem]]
::Locale::Style m_style { ::Locale::Style::Long }; // [[Style]]
Numeric m_numeric { Numeric::Always }; // [[Numeric]]
NumberFormat* m_number_format { nullptr }; // [[NumberFormat]]
@ -73,7 +73,7 @@ private:
};
struct PatternPartitionWithUnit : public PatternPartition {
PatternPartitionWithUnit(StringView type, String value, StringView unit_string = {})
PatternPartitionWithUnit(StringView type, DeprecatedString value, StringView unit_string = {})
: PatternPartition(type, move(value))
, unit(unit_string)
{
@ -85,7 +85,7 @@ struct PatternPartitionWithUnit : public PatternPartition {
ThrowCompletionOr<::Locale::TimeUnit> singular_relative_time_unit(VM&, StringView unit);
ThrowCompletionOr<Vector<PatternPartitionWithUnit>> partition_relative_time_pattern(VM&, RelativeTimeFormat&, double value, StringView unit);
Vector<PatternPartitionWithUnit> make_parts_list(StringView pattern, StringView unit, Vector<PatternPartition> parts);
ThrowCompletionOr<String> format_relative_time(VM&, RelativeTimeFormat&, double value, StringView unit);
ThrowCompletionOr<DeprecatedString> format_relative_time(VM&, RelativeTimeFormat&, double value, StringView unit);
ThrowCompletionOr<Array*> format_relative_time_to_parts(VM&, RelativeTimeFormat&, double value, StringView unit);
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <LibJS/Runtime/Object.h>
namespace JS::Intl {
@ -23,8 +23,8 @@ public:
virtual ~Segmenter() override = default;
String const& locale() const { return m_locale; }
void set_locale(String locale) { m_locale = move(locale); }
DeprecatedString const& locale() const { return m_locale; }
void set_locale(DeprecatedString locale) { m_locale = move(locale); }
SegmenterGranularity segmenter_granularity() const { return m_segmenter_granularity; }
void set_segmenter_granularity(StringView);
@ -33,7 +33,7 @@ public:
private:
explicit Segmenter(Object& prototype);
String m_locale; // [[Locale]]
DeprecatedString m_locale; // [[Locale]]
SegmenterGranularity m_segmenter_granularity { SegmenterGranularity::Grapheme }; // [[SegmenterGranularity]]
};

View file

@ -44,7 +44,7 @@ void JSONObject::initialize(Realm& realm)
}
// 25.5.2 JSON.stringify ( value [ , replacer [ , space ] ] ), https://tc39.es/ecma262/#sec-json.stringify
ThrowCompletionOr<String> JSONObject::stringify_impl(VM& vm, Value value, Value replacer, Value space)
ThrowCompletionOr<DeprecatedString> JSONObject::stringify_impl(VM& vm, Value value, Value replacer, Value space)
{
auto& realm = *vm.current_realm();
@ -58,10 +58,10 @@ ThrowCompletionOr<String> JSONObject::stringify_impl(VM& vm, Value value, Value
if (is_array) {
auto& replacer_object = replacer.as_object();
auto replacer_length = TRY(length_of_array_like(vm, replacer_object));
Vector<String> list;
Vector<DeprecatedString> list;
for (size_t i = 0; i < replacer_length; ++i) {
auto replacer_value = TRY(replacer_object.get(i));
String item;
DeprecatedString item;
if (replacer_value.is_string()) {
item = replacer_value.as_string().string();
} else if (replacer_value.is_number()) {
@ -91,7 +91,7 @@ ThrowCompletionOr<String> JSONObject::stringify_impl(VM& vm, Value value, Value
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 ? String::empty() : String::repeated(' ', space_mv);
state.gap = space_mv < 1 ? DeprecatedString::empty() : DeprecatedString::repeated(' ', space_mv);
} else if (space.is_string()) {
auto string = space.as_string().string();
if (string.length() <= 10)
@ -99,12 +99,12 @@ ThrowCompletionOr<String> JSONObject::stringify_impl(VM& vm, Value value, Value
else
state.gap = string.substring(0, 10);
} else {
state.gap = String::empty();
state.gap = DeprecatedString::empty();
}
auto* wrapper = Object::create(realm, realm.intrinsics().object_prototype());
MUST(wrapper->create_data_property_or_throw(String::empty(), value));
return serialize_json_property(vm, state, String::empty(), wrapper);
MUST(wrapper->create_data_property_or_throw(DeprecatedString::empty(), value));
return serialize_json_property(vm, state, DeprecatedString::empty(), wrapper);
}
// 25.5.2 JSON.stringify ( value [ , replacer [ , space ] ] ), https://tc39.es/ecma262/#sec-json.stringify
@ -125,7 +125,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::stringify)
}
// 25.5.2.1 SerializeJSONProperty ( state, key, holder ), https://tc39.es/ecma262/#sec-serializejsonproperty
ThrowCompletionOr<String> JSONObject::serialize_json_property(VM& vm, StringifyState& state, PropertyKey const& key, Object* holder)
ThrowCompletionOr<DeprecatedString> 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));
@ -215,26 +215,26 @@ ThrowCompletionOr<String> JSONObject::serialize_json_property(VM& vm, StringifyS
}
// 12. Return undefined.
return String {};
return DeprecatedString {};
}
// 25.5.2.4 SerializeJSONObject ( state, value ), https://tc39.es/ecma262/#sec-serializejsonobject
ThrowCompletionOr<String> JSONObject::serialize_json_object(VM& vm, StringifyState& state, Object& object)
ThrowCompletionOr<DeprecatedString> 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);
String previous_indent = state.indent;
state.indent = String::formatted("{}{}", state.indent, state.gap);
Vector<String> property_strings;
DeprecatedString previous_indent = state.indent;
state.indent = DeprecatedString::formatted("{}{}", state.indent, state.gap);
Vector<DeprecatedString> 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.is_null()) {
property_strings.append(String::formatted(
property_strings.append(DeprecatedString::formatted(
"{}:{}{}",
quote_json_string(key.to_string()),
state.gap.is_empty() ? "" : " ",
@ -268,7 +268,7 @@ ThrowCompletionOr<String> JSONObject::serialize_json_object(VM& vm, StringifySta
} else {
builder.append('\n');
builder.append(state.indent);
auto separator = String::formatted(",\n{}", state.indent);
auto separator = DeprecatedString::formatted(",\n{}", state.indent);
for (auto& property_string : property_strings) {
if (!first)
builder.append(separator);
@ -287,15 +287,15 @@ ThrowCompletionOr<String> JSONObject::serialize_json_object(VM& vm, StringifySta
}
// 25.5.2.5 SerializeJSONArray ( state, value ), https://tc39.es/ecma262/#sec-serializejsonarray
ThrowCompletionOr<String> JSONObject::serialize_json_array(VM& vm, StringifyState& state, Object& object)
ThrowCompletionOr<DeprecatedString> 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);
String previous_indent = state.indent;
state.indent = String::formatted("{}{}", state.indent, state.gap);
Vector<String> property_strings;
DeprecatedString previous_indent = state.indent;
state.indent = DeprecatedString::formatted("{}{}", state.indent, state.gap);
Vector<DeprecatedString> property_strings;
auto length = TRY(length_of_array_like(vm, object));
@ -328,7 +328,7 @@ ThrowCompletionOr<String> JSONObject::serialize_json_array(VM& vm, StringifyStat
} else {
builder.append("[\n"sv);
builder.append(state.indent);
auto separator = String::formatted(",\n{}", state.indent);
auto separator = DeprecatedString::formatted(",\n{}", state.indent);
bool first = true;
for (auto& property_string : property_strings) {
if (!first)
@ -348,7 +348,7 @@ ThrowCompletionOr<String> JSONObject::serialize_json_array(VM& vm, StringifyStat
}
// 25.5.2.2 QuoteJSONString ( value ), https://tc39.es/ecma262/#sec-quotejsonstring
String JSONObject::quote_json_string(String string)
DeprecatedString JSONObject::quote_json_string(DeprecatedString string)
{
StringBuilder builder;
builder.append('"');
@ -402,7 +402,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 = String::empty();
auto root_name = DeprecatedString::empty();
MUST(root->create_data_property_or_throw(root_name, unfiltered));
return internalize_json_property(vm, root, root_name, reviver.as_function());
}

View file

@ -19,7 +19,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<String> stringify_impl(VM&, Value value, Value replacer, Value space);
static ThrowCompletionOr<DeprecatedString> stringify_impl(VM&, Value value, Value replacer, Value space);
static Value parse_json_value(VM&, JsonValue const&);
@ -29,16 +29,16 @@ private:
struct StringifyState {
FunctionObject* replacer_function { nullptr };
HashTable<Object*> seen_objects;
String indent { String::empty() };
String gap;
Optional<Vector<String>> property_list;
DeprecatedString indent { DeprecatedString::empty() };
DeprecatedString gap;
Optional<Vector<DeprecatedString>> property_list;
};
// Stringify helpers
static ThrowCompletionOr<String> serialize_json_property(VM&, StringifyState&, PropertyKey const& key, Object* holder);
static ThrowCompletionOr<String> serialize_json_object(VM&, StringifyState&, Object&);
static ThrowCompletionOr<String> serialize_json_array(VM&, StringifyState&, Object&);
static String quote_json_string(String);
static ThrowCompletionOr<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);
// Parse helpers
static Object* parse_json_object(VM&, JsonObject const&);

View file

@ -54,7 +54,7 @@ ThrowCompletionOr<Object*> MapConstructor::construct(FunctionObject& new_target)
(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, String::formatted("Iterator value {}", iterator_value.to_string_without_side_effects()));
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, DeprecatedString::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,8 +14,8 @@ namespace JS {
// 2.9 ModuleRequest Records, https://tc39.es/proposal-import-assertions/#sec-modulerequest-record
struct ModuleRequest {
struct Assertion {
String key;
String value;
DeprecatedString key;
DeprecatedString value;
};
ModuleRequest() = default;
@ -27,7 +27,7 @@ struct ModuleRequest {
ModuleRequest(FlyString module_specifier, Vector<Assertion> assertions);
void add_assertion(String key, String value)
void add_assertion(DeprecatedString key, DeprecatedString value)
{
assertions.empend(move(key), move(value));
}

View file

@ -102,7 +102,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential)
// 7. Let s be the empty String.
auto sign = ""sv;
String number_string;
DeprecatedString number_string;
int exponent = 0;
// 8. If x < 0, then
@ -117,7 +117,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 = String::repeated('0', fraction_digits + 1);
number_string = DeprecatedString::repeated('0', fraction_digits + 1);
// b. Let e be 0.
exponent = 0;
@ -157,11 +157,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 = String::formatted("{}.{}", first, second);
number_string = DeprecatedString::formatted("{}.{}", first, second);
}
char exponent_sign = 0;
String exponent_string;
DeprecatedString exponent_string;
// 12. If e = 0, then
if (exponent == 0) {
@ -190,12 +190,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 = String::number(exponent);
exponent_string = DeprecatedString::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 js_string(vm, String::formatted("{}{}e{}{}", sign, number_string, exponent_sign, exponent_string));
return js_string(vm, DeprecatedString::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
@ -241,7 +241,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed)
auto n = round(pow(10.0f, fraction_digits) * number);
// b. If n = 0, let m be the String "0". Otherwise, let m be the String value consisting of the digits of the decimal representation of n (in order, with no leading zeroes).
auto m = (n == 0 ? "0" : String::formatted("{}", n));
auto m = (n == 0 ? "0" : DeprecatedString::formatted("{}", n));
// c. If f ≠ 0, then
if (fraction_digits != 0) {
@ -251,10 +251,10 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed)
// ii. If k ≤ f, then
if (k <= fraction_digits) {
// 1. Let z be the String value consisting of f + 1 - k occurrences of the code unit 0x0030 (DIGIT ZERO).
auto z = String::repeated('0', fraction_digits + 1 - k);
auto z = DeprecatedString::repeated('0', fraction_digits + 1 - k);
// 2. Set m to the string-concatenation of z and m.
m = String::formatted("{}{}", z, m);
m = DeprecatedString::formatted("{}{}", z, m);
// 3. Set k to f + 1.
k = fraction_digits + 1;
@ -263,13 +263,13 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed)
// iii. Let a be the first k - f code units of m.
// iv. Let b be the other f code units of m.
// v. Set m to the string-concatenation of a, ".", and b.
m = String::formatted("{}.{}",
m = DeprecatedString::formatted("{}.{}",
m.substring_view(0, k - fraction_digits),
m.substring_view(k - fraction_digits, fraction_digits));
}
// 12. Return the string-concatenation of s and m.
return js_string(vm, String::formatted("{}{}", s, m));
return js_string(vm, DeprecatedString::formatted("{}{}", s, m));
}
// 19.2.1 Number.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sup-number.prototype.tolocalestring
@ -321,7 +321,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision)
// 7. Let s be the empty String.
auto sign = ""sv;
String number_string;
DeprecatedString number_string;
int exponent = 0;
// 8. If x < 0, then
@ -336,7 +336,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 = String::repeated('0', precision);
number_string = DeprecatedString::repeated('0', precision);
// b. Let e be 0.
exponent = 0;
@ -365,7 +365,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 = String::formatted("{}.{}", first, second);
number_string = DeprecatedString::formatted("{}.{}", first, second);
}
char exponent_sign = 0;
@ -388,21 +388,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 = String::number(exponent);
auto exponent_string = DeprecatedString::number(exponent);
// vi. Return the string-concatenation of s, m, the code unit 0x0065 (LATIN SMALL LETTER E), c, and d.
return js_string(vm, String::formatted("{}{}e{}{}", sign, number_string, exponent_sign, exponent_string));
return js_string(vm, DeprecatedString::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 js_string(vm, String::formatted("{}{}", sign, number_string));
return js_string(vm, DeprecatedString::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 = String::formatted(
number_string = DeprecatedString::formatted(
"{}.{}",
number_string.substring_view(0, exponent + 1),
number_string.substring_view(exponent + 1));
@ -410,14 +410,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 = String::formatted(
number_string = DeprecatedString::formatted(
"0.{}{}",
String::repeated('0', -1 * (exponent + 1)),
DeprecatedString::repeated('0', -1 * (exponent + 1)),
number_string);
}
// 14. Return the string-concatenation of s and m.
return js_string(vm, String::formatted("{}{}", sign, number_string));
return js_string(vm, DeprecatedString::formatted("{}{}", sign, number_string));
}
// 21.1.3.6 Number.prototype.toString ( [ radix ] ), https://tc39.es/ecma262/#sec-number.prototype.tostring
@ -499,7 +499,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_string)
characters.take_last();
}
return js_string(vm, String(characters.data(), characters.size()));
return js_string(vm, DeprecatedString(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/String.h>
#include <AK/DeprecatedString.h>
#include <AK/TypeCasts.h>
#include <LibJS/Interpreter.h>
#include <LibJS/Runtime/AbstractOperations.h>
@ -940,7 +940,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(js_string(vm, String::number(entry.index())));
keys.append(js_string(vm, DeprecatedString::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

View file

@ -8,8 +8,8 @@
#pragma once
#include <AK/Badge.h>
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/String.h>
#include <AK/StringView.h>
#include <LibJS/Forward.h>
#include <LibJS/Heap/Cell.h>

View file

@ -227,7 +227,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::from_entries)
(void)TRY(get_iterator_values(vm, iterable, [&](Value iterator_value) -> Optional<Completion> {
if (!iterator_value.is_object())
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, String::formatted("Iterator value {}", iterator_value.to_string_without_side_effects()));
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, DeprecatedString::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,8 +5,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/Function.h>
#include <AK/String.h>
#include <LibJS/Runtime/AbstractOperations.h>
#include <LibJS/Runtime/Accessor.h>
#include <LibJS/Runtime/BooleanObject.h>
@ -82,7 +82,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::to_string)
// 4. Let isArray be ? IsArray(O).
auto is_array = TRY(Value(object).is_array(vm));
String builtin_tag;
DeprecatedString builtin_tag;
// 5. If isArray is true, let builtinTag be "Array".
if (is_array)
@ -119,7 +119,7 @@ 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.
String tag;
DeprecatedString tag;
// 16. If Type(tag) is not String, set tag to builtinTag.
if (!to_string_tag.is_string())
@ -128,7 +128,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::to_string)
tag = to_string_tag.as_string().string();
// 17. Return the string-concatenation of "[object ", tag, and "]".
return js_string(vm, String::formatted("[object {}]", tag));
return js_string(vm, DeprecatedString::formatted("[object {}]", tag));
}
// 20.1.3.5 Object.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-object.prototype.tolocalestring

View file

@ -23,7 +23,7 @@ PrimitiveString::PrimitiveString(PrimitiveString& lhs, PrimitiveString& rhs)
{
}
PrimitiveString::PrimitiveString(String string)
PrimitiveString::PrimitiveString(DeprecatedString string)
: m_has_utf8_string(true)
, m_utf8_string(move(string))
{
@ -63,7 +63,7 @@ bool PrimitiveString::is_empty() const
VERIFY_NOT_REACHED();
}
String const& PrimitiveString::string() const
DeprecatedString const& PrimitiveString::string() const
{
resolve_rope_if_needed();
if (!m_has_utf8_string) {
@ -137,7 +137,7 @@ PrimitiveString* js_string(VM& vm, Utf16String string)
return js_string(vm.heap(), move(string));
}
PrimitiveString* js_string(Heap& heap, String string)
PrimitiveString* js_string(Heap& heap, DeprecatedString string)
{
if (string.is_empty())
return &heap.vm().empty_string();
@ -158,7 +158,7 @@ PrimitiveString* js_string(Heap& heap, String string)
return it->value;
}
PrimitiveString* js_string(VM& vm, String string)
PrimitiveString* js_string(VM& vm, DeprecatedString string)
{
return js_string(vm.heap(), move(string));
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/StringView.h>
#include <LibJS/Forward.h>
#include <LibJS/Heap/Cell.h>
@ -26,7 +26,7 @@ public:
bool is_empty() const;
String const& string() const;
DeprecatedString const& string() const;
bool has_utf8_string() const { return m_has_utf8_string; }
Utf16String const& utf16_string() const;
@ -37,7 +37,7 @@ public:
private:
explicit PrimitiveString(PrimitiveString&, PrimitiveString&);
explicit PrimitiveString(String);
explicit PrimitiveString(DeprecatedString);
explicit PrimitiveString(Utf16String);
virtual void visit_edges(Cell::Visitor&) override;
@ -51,7 +51,7 @@ private:
mutable PrimitiveString* m_lhs { nullptr };
mutable PrimitiveString* m_rhs { nullptr };
mutable String m_utf8_string;
mutable DeprecatedString m_utf8_string;
mutable Utf16String m_utf16_string;
};
@ -62,8 +62,8 @@ PrimitiveString* js_string(VM&, Utf16View const&);
PrimitiveString* js_string(Heap&, Utf16String);
PrimitiveString* js_string(VM&, Utf16String);
PrimitiveString* js_string(Heap&, String);
PrimitiveString* js_string(VM&, String);
PrimitiveString* js_string(Heap&, DeprecatedString);
PrimitiveString* js_string(VM&, DeprecatedString);
PrimitiveString* js_rope_string(VM&, PrimitiveString&, PrimitiveString&);

View file

@ -157,7 +157,7 @@ Promise::ResolvingFunctions Promise::create_resolving_functions()
// 16. Return undefined.
return js_undefined();
});
resolve_function->define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable);
resolve_function->define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable);
// 7. Let stepsReject be the algorithm steps defined in Promise Reject Functions.
// 8. Let lengthReject be the number of non-optional parameters of the function definition in Promise Reject Functions.
@ -189,7 +189,7 @@ Promise::ResolvingFunctions Promise::create_resolving_functions()
// 8. Return undefined.
return js_undefined();
});
reject_function->define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable);
reject_function->define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable);
// 12. Return the Record { [[Resolve]]: resolve, [[Reject]]: reject }.
return { *resolve_function, *reject_function };

View file

@ -139,7 +139,7 @@ static ThrowCompletionOr<Value> perform_promise_all(VM& vm, Iterator& iterator_r
// p. Set onFulfilled.[[Capability]] to resultCapability.
// q. Set onFulfilled.[[RemainingElements]] to remainingElementsCount.
auto* on_fulfilled = PromiseAllResolveElementFunction::create(realm, index, values, result_capability, remaining_elements_count);
on_fulfilled->define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable);
on_fulfilled->define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable);
// s. Perform ? Invoke(nextPromise, "then", « onFulfilled, resultCapability.[[Reject]] »).
return next_promise.invoke(vm, vm.names.then, on_fulfilled, result_capability.reject());
@ -171,7 +171,7 @@ static ThrowCompletionOr<Value> perform_promise_all_settled(VM& vm, Iterator& it
// q. Set onFulfilled.[[Capability]] to resultCapability.
// r. Set onFulfilled.[[RemainingElements]] to remainingElementsCount.
auto* on_fulfilled = PromiseAllSettledResolveElementFunction::create(realm, index, values, result_capability, remaining_elements_count);
on_fulfilled->define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable);
on_fulfilled->define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable);
// s. Let stepsRejected be the algorithm steps defined in Promise.allSettled Reject Element Functions.
// t. Let lengthRejected be the number of non-optional parameters of the function definition in Promise.allSettled Reject Element Functions.
@ -182,7 +182,7 @@ static ThrowCompletionOr<Value> perform_promise_all_settled(VM& vm, Iterator& it
// y. Set onRejected.[[Capability]] to resultCapability.
// z. Set onRejected.[[RemainingElements]] to remainingElementsCount.
auto* on_rejected = PromiseAllSettledRejectElementFunction::create(realm, index, values, result_capability, remaining_elements_count);
on_rejected->define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable);
on_rejected->define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable);
// ab. Perform ? Invoke(nextPromise, "then", « onFulfilled, onRejected »).
return next_promise.invoke(vm, vm.names.then, on_fulfilled, on_rejected);
@ -217,7 +217,7 @@ static ThrowCompletionOr<Value> perform_promise_any(VM& vm, Iterator& iterator_r
// p. Set onRejected.[[Capability]] to resultCapability.
// q. Set onRejected.[[RemainingElements]] to remainingElementsCount.
auto* on_rejected = PromiseAnyRejectElementFunction::create(realm, index, errors, result_capability, remaining_elements_count);
on_rejected->define_direct_property(vm.names.name, js_string(vm, String::empty()), Attribute::Configurable);
on_rejected->define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable);
// s. Perform ? Invoke(nextPromise, "then", « resultCapability.[[Resolve]], onRejected »).
return next_promise.invoke(vm, vm.names.then, result_capability.resolve(), on_rejected);

View file

@ -7,8 +7,8 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/Format.h>
#include <AK/String.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<String> parts;
parts.append(String::formatted("[[Writable]]: {}", property_attributes.is_writable()));
parts.append(String::formatted("[[Enumerable]]: {}", property_attributes.is_enumerable()));
parts.append(String::formatted("[[Configurable]]: {}", property_attributes.is_configurable()));
return Formatter<StringView>::format(builder, String::formatted("PropertyAttributes {{ {} }}", String::join(", "sv, parts)));
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)));
}
};

View file

@ -49,20 +49,20 @@ template<>
struct Formatter<JS::PropertyDescriptor> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& builder, JS::PropertyDescriptor const& property_descriptor)
{
Vector<String> parts;
Vector<DeprecatedString> parts;
if (property_descriptor.value.has_value())
parts.append(String::formatted("[[Value]]: {}", property_descriptor.value->to_string_without_side_effects()));
parts.append(DeprecatedString::formatted("[[Value]]: {}", property_descriptor.value->to_string_without_side_effects()));
if (property_descriptor.get.has_value())
parts.append(String::formatted("[[Get]]: JS::Function* @ {:p}", *property_descriptor.get));
parts.append(DeprecatedString::formatted("[[Get]]: JS::Function* @ {:p}", *property_descriptor.get));
if (property_descriptor.set.has_value())
parts.append(String::formatted("[[Set]]: JS::Function* @ {:p}", *property_descriptor.set));
parts.append(DeprecatedString::formatted("[[Set]]: JS::Function* @ {:p}", *property_descriptor.set));
if (property_descriptor.writable.has_value())
parts.append(String::formatted("[[Writable]]: {}", *property_descriptor.writable));
parts.append(DeprecatedString::formatted("[[Writable]]: {}", *property_descriptor.writable));
if (property_descriptor.enumerable.has_value())
parts.append(String::formatted("[[Enumerable]]: {}", *property_descriptor.enumerable));
parts.append(DeprecatedString::formatted("[[Enumerable]]: {}", *property_descriptor.enumerable));
if (property_descriptor.configurable.has_value())
parts.append(String::formatted("[[Configurable]]: {}", *property_descriptor.configurable));
return Formatter<StringView>::format(builder, String::formatted("PropertyDescriptor {{ {} }}", String::join(", "sv, parts)));
parts.append(DeprecatedString::formatted("[[Configurable]]: {}", *property_descriptor.configurable));
return Formatter<StringView>::format(builder, DeprecatedString::formatted("PropertyDescriptor {{ {} }}", DeprecatedString::join(", "sv, parts)));
}
};

View file

@ -48,7 +48,7 @@ public:
VERIFY(index >= 0);
if constexpr (NumericLimits<T>::max() >= NumericLimits<u32>::max()) {
if (index >= NumericLimits<u32>::max()) {
m_string = String::number(index);
m_string = DeprecatedString::number(index);
m_type = Type::String;
m_string_may_be_number = false;
return;
@ -65,7 +65,7 @@ public:
{
}
PropertyKey(String const& string)
PropertyKey(DeprecatedString const& string)
: m_type(Type::String)
, m_string(FlyString(string))
{
@ -164,13 +164,13 @@ public:
return m_symbol;
}
String to_string() const
DeprecatedString to_string() const
{
VERIFY(is_valid());
VERIFY(!is_symbol());
if (is_string())
return as_string();
return String::number(as_number());
return DeprecatedString::number(as_number());
}
StringOrSymbol to_string_or_symbol() const

View file

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

Some files were not shown because too many files have changed in this diff Show more