From 3226ce3d8354b918d0c6803fd4c24a612852660b Mon Sep 17 00:00:00 2001 From: Evan Smal Date: Thu, 26 Jan 2023 08:40:21 -0500 Subject: LibJS: Remove some usage of DeprecatedString usage from Lexer This changes the filename member from DeprecatedString to String. Parser has also been updated to meet the updated Lexer interface. --- Userland/Libraries/LibJS/Lexer.cpp | 2 +- Userland/Libraries/LibJS/Lexer.h | 5 +++-- Userland/Libraries/LibJS/Parser.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'Userland') diff --git a/Userland/Libraries/LibJS/Lexer.cpp b/Userland/Libraries/LibJS/Lexer.cpp index 366fe8948c..141c0db911 100644 --- a/Userland/Libraries/LibJS/Lexer.cpp +++ b/Userland/Libraries/LibJS/Lexer.cpp @@ -24,7 +24,7 @@ HashMap Lexer::s_single_char_tokens; Lexer::Lexer(StringView source, StringView filename, size_t line_number, size_t line_column) : m_source(source) , m_current_token(TokenType::Eof, {}, {}, {}, filename, 0, 0, 0) - , m_filename(filename) + , m_filename(String::from_utf8(filename).release_value_but_fixme_should_propagate_errors()) , m_line_number(line_number) , m_line_column(line_column) , m_parsed_identifiers(adopt_ref(*new ParsedIdentifiers)) diff --git a/Userland/Libraries/LibJS/Lexer.h b/Userland/Libraries/LibJS/Lexer.h index 889c78a5ff..dfce81c795 100644 --- a/Userland/Libraries/LibJS/Lexer.h +++ b/Userland/Libraries/LibJS/Lexer.h @@ -10,6 +10,7 @@ #include #include +#include #include namespace JS { @@ -21,7 +22,7 @@ public: Token next(); DeprecatedString const& source() const { return m_source; }; - DeprecatedString const& filename() const { return m_filename; }; + String const& filename() const { return m_filename; }; void disallow_html_comments() { m_allow_html_comments = false; }; @@ -63,7 +64,7 @@ private: char m_current_char { 0 }; bool m_eof { false }; - DeprecatedString m_filename; + String m_filename; size_t m_line_number { 1 }; size_t m_line_column { 0 }; diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp index 25ceaf4f1f..2a9c0c4b75 100644 --- a/Userland/Libraries/LibJS/Parser.cpp +++ b/Userland/Libraries/LibJS/Parser.cpp @@ -409,7 +409,7 @@ Parser::ParserState::ParserState(Lexer l, Program::Type program_type) } Parser::Parser(Lexer lexer, Program::Type program_type, Optional initial_state_for_eval) - : m_source_code(SourceCode::create(String::from_deprecated_string(lexer.filename()).release_value_but_fixme_should_propagate_errors(), String::from_deprecated_string(lexer.source()).release_value_but_fixme_should_propagate_errors())) + : m_source_code(SourceCode::create(lexer.filename(), String::from_deprecated_string(lexer.source()).release_value_but_fixme_should_propagate_errors())) , m_state(move(lexer), program_type) , m_program_type(program_type) { -- cgit v1.2.3