summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorEvan Smal <evan.smal@hotmail.com>2023-01-26 08:40:21 -0500
committerLinus Groh <mail@linusgroh.de>2023-01-26 20:25:25 +0000
commit3226ce3d8354b918d0c6803fd4c24a612852660b (patch)
tree12c57d90d840552b35c9fcc6bb998530f66a5a92 /Userland
parentcfa6b4d81547b7c109186e2db973344499e7f80a (diff)
downloadserenity-3226ce3d8354b918d0c6803fd4c24a612852660b.zip
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.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Lexer.cpp2
-rw-r--r--Userland/Libraries/LibJS/Lexer.h5
-rw-r--r--Userland/Libraries/LibJS/Parser.cpp2
3 files changed, 5 insertions, 4 deletions
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<char, TokenType> 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 <AK/DeprecatedString.h>
#include <AK/HashMap.h>
+#include <AK/String.h>
#include <AK/StringView.h>
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<EvalInitialState> 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)
{