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