mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibJS: Rename RegExpLiteral m_content to m_pattern
This is what we call it elsewhere, let's be consistent.
This commit is contained in:
parent
d1a72dc6eb
commit
c93c2dc72c
Notes:
sideshowbarker
2024-07-18 18:22:37 +09:00
3 changed files with 12 additions and 10 deletions
|
@ -1791,13 +1791,13 @@ Value NullLiteral::execute(Interpreter& interpreter, GlobalObject&) const
|
|||
void RegExpLiteral::dump(int indent) const
|
||||
{
|
||||
print_indent(indent);
|
||||
outln("{} (/{}/{})", class_name(), content(), flags());
|
||||
outln("{} (/{}/{})", class_name(), pattern(), flags());
|
||||
}
|
||||
|
||||
Value RegExpLiteral::execute(Interpreter& interpreter, GlobalObject& global_object) const
|
||||
{
|
||||
InterpreterNodeScope node_scope { interpreter, *this };
|
||||
return RegExpObject::create(global_object, content(), flags());
|
||||
return RegExpObject::create(global_object, pattern(), flags());
|
||||
}
|
||||
|
||||
void ArrayExpression::dump(int indent) const
|
||||
|
|
|
@ -658,21 +658,21 @@ public:
|
|||
|
||||
class RegExpLiteral final : public Literal {
|
||||
public:
|
||||
explicit RegExpLiteral(SourceRange source_range, String content, String flags)
|
||||
explicit RegExpLiteral(SourceRange source_range, String pattern, String flags)
|
||||
: Literal(move(source_range))
|
||||
, m_content(content)
|
||||
, m_flags(flags)
|
||||
, m_pattern(move(pattern))
|
||||
, m_flags(move(flags))
|
||||
{
|
||||
}
|
||||
|
||||
virtual Value execute(Interpreter&, GlobalObject&) const override;
|
||||
virtual void dump(int indent) const override;
|
||||
|
||||
const String& content() const { return m_content; }
|
||||
const String& pattern() const { return m_pattern; }
|
||||
const String& flags() const { return m_flags; }
|
||||
|
||||
private:
|
||||
String m_content;
|
||||
String m_pattern;
|
||||
String m_flags;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Stephan Unverwerth <s.unverwerth@gmx.de>
|
||||
* Copyright (c) 2020, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -683,9 +683,11 @@ NonnullRefPtr<Expression> Parser::parse_primary_expression()
|
|||
NonnullRefPtr<RegExpLiteral> Parser::parse_regexp_literal()
|
||||
{
|
||||
auto rule_start = push_start();
|
||||
auto content = consume().value();
|
||||
auto pattern = consume().value();
|
||||
// Remove leading and trailing slash.
|
||||
pattern = pattern.substring_view(1, pattern.length() - 2);
|
||||
auto flags = match(TokenType::RegexFlags) ? consume().value() : "";
|
||||
return create_ast_node<RegExpLiteral>({ m_parser_state.m_current_token.filename(), rule_start.position(), position() }, content.substring_view(1, content.length() - 2), flags);
|
||||
return create_ast_node<RegExpLiteral>({ m_parser_state.m_current_token.filename(), rule_start.position(), position() }, pattern, flags);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Expression> Parser::parse_unary_prefixed_expression()
|
||||
|
|
Loading…
Reference in a new issue