From cfa6b4d81547b7c109186e2db973344499e7f80a Mon Sep 17 00:00:00 2001 From: Evan Smal Date: Thu, 26 Jan 2023 08:38:09 -0500 Subject: LibJS: Remove DeprecatedString usage from Token --- Userland/Libraries/LibJS/Lexer.cpp | 6 +++--- Userland/Libraries/LibJS/Parser.cpp | 2 +- Userland/Libraries/LibJS/Token.h | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Userland/Libraries/LibJS/Lexer.cpp b/Userland/Libraries/LibJS/Lexer.cpp index ee3deb2517..366fe8948c 100644 --- a/Userland/Libraries/LibJS/Lexer.cpp +++ b/Userland/Libraries/LibJS/Lexer.cpp @@ -836,7 +836,7 @@ Token Lexer::next() if (m_hit_invalid_unicode.has_value()) { value_start = m_hit_invalid_unicode.value() - 1; - m_current_token = Token(TokenType::Invalid, "Invalid unicode codepoint in source", + m_current_token = Token(TokenType::Invalid, String::from_utf8("Invalid unicode codepoint in source"sv).release_value_but_fixme_should_propagate_errors(), ""sv, // Since the invalid unicode can occur anywhere in the current token the trivia is not correct m_source.substring_view(value_start + 1, min(4u, m_source.length() - value_start - 2)), m_filename, @@ -849,7 +849,7 @@ Token Lexer::next() } else { m_current_token = Token( token_type, - token_message, + String::from_deprecated_string(token_message).release_value_but_fixme_should_propagate_errors(), m_source.substring_view(trivia_start - 1, value_start - trivia_start), m_source.substring_view(value_start - 1, m_position - value_start), m_filename, @@ -893,7 +893,7 @@ Token Lexer::force_slash_as_regex() m_current_token = Token( token_type, - "", + String {}, m_current_token.trivia(), m_source.substring_view(value_start - 1, m_position - value_start), m_filename, diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp index 494514d6ec..25ceaf4f1f 100644 --- a/Userland/Libraries/LibJS/Parser.cpp +++ b/Userland/Libraries/LibJS/Parser.cpp @@ -4133,7 +4133,7 @@ Token Parser::consume_and_validate_numeric_literal() void Parser::expected(char const* what) { - auto message = m_state.current_token.message(); + auto message = m_state.current_token.message().to_deprecated_string(); if (message.is_empty()) message = DeprecatedString::formatted("Unexpected token {}. Expected {}", m_state.current_token.name(), what); syntax_error(message); diff --git a/Userland/Libraries/LibJS/Token.h b/Userland/Libraries/LibJS/Token.h index 9ebc6c2f23..9f2d2d3821 100644 --- a/Userland/Libraries/LibJS/Token.h +++ b/Userland/Libraries/LibJS/Token.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include #include @@ -181,9 +181,9 @@ class Token { public: Token() = default; - Token(TokenType type, DeprecatedString message, StringView trivia, StringView value, StringView filename, size_t line_number, size_t line_column, size_t offset) + Token(TokenType type, String message, StringView trivia, StringView value, StringView filename, size_t line_number, size_t line_column, size_t offset) : m_type(type) - , m_message(message) + , m_message(move(message)) , m_trivia(trivia) , m_original_value(value) , m_value(value) @@ -200,7 +200,7 @@ public: char const* name() const; static char const* name(TokenType); - DeprecatedString const& message() const { return m_message; } + String const& message() const { return m_message; } StringView trivia() const { return m_trivia; } StringView original_value() const { return m_original_value; } StringView value() const @@ -246,7 +246,7 @@ public: private: TokenType m_type { TokenType::Invalid }; - DeprecatedString m_message; + String m_message; StringView m_trivia; StringView m_original_value; Variant m_value {}; -- cgit v1.2.3