1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09:00

LibJS: Remove is_use_strict_directive for all StringLiterals

This value was only used in the parser so no need to have this in every
string literal in the ast.
This commit is contained in:
davidot 2022-11-27 02:21:25 +01:00 committed by Linus Groh
parent 3c68a6684e
commit 3acbd96851
Notes: sideshowbarker 2024-07-17 04:00:30 +09:00
2 changed files with 4 additions and 9 deletions

View file

@ -462,6 +462,7 @@ bool Parser::parse_directive(ScopeNode& body)
{
bool found_use_strict = false;
while (!done() && match(TokenType::StringLiteral)) {
auto raw_value = m_state.current_token.original_value();
// It cannot be a labelled function since we hit a string literal.
auto statement = parse_statement(AllowLabelledFunction::No);
body.append(statement);
@ -472,8 +473,7 @@ bool Parser::parse_directive(ScopeNode& body)
if (!is<StringLiteral>(expression))
break;
auto& string_literal = static_cast<StringLiteral const&>(expression);
if (string_literal.is_use_strict_directive()) {
if (raw_value.is_one_of("'use strict'"sv, "\"use strict\"")) {
found_use_strict = true;
if (m_state.string_legacy_octal_escape_sequence_in_scope)
@ -1865,9 +1865,7 @@ NonnullRefPtr<StringLiteral> Parser::parse_string_literal(Token const& token, St
}
}
auto is_use_strict_directive = string_literal_type == StringLiteralType::Normal && (token.value() == "'use strict'" || token.value() == "\"use strict\"");
return create_ast_node<StringLiteral>({ m_source_code, rule_start.position(), position() }, string, is_use_strict_directive);
return create_ast_node<StringLiteral>({ m_source_code, rule_start.position(), position() }, string);
}
NonnullRefPtr<TemplateLiteral> Parser::parse_template_literal(bool is_tagged)