mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:57:45 +00:00
Everywhere: Run clang-format
This commit is contained in:
parent
0376c127f6
commit
086969277e
1665 changed files with 8479 additions and 8479 deletions
|
@ -23,7 +23,7 @@ void ASTNode::dump(FILE* output, size_t indent) const
|
|||
void TranslationUnit::dump(FILE* output, size_t indent) const
|
||||
{
|
||||
ASTNode::dump(output, indent);
|
||||
for (const auto& child : m_declarations) {
|
||||
for (auto const& child : m_declarations) {
|
||||
child.dump(output, indent + 1);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ void FunctionDeclaration::dump(FILE* output, size_t indent) const
|
|||
}
|
||||
print_indent(output, indent + 1);
|
||||
outln(output, "(");
|
||||
for (const auto& arg : m_parameters) {
|
||||
for (auto const& arg : m_parameters) {
|
||||
arg.dump(output, indent + 1);
|
||||
}
|
||||
print_indent(output, indent + 1);
|
||||
|
@ -155,7 +155,7 @@ void FunctionDefinition::dump(FILE* output, size_t indent) const
|
|||
ASTNode::dump(output, indent);
|
||||
print_indent(output, indent);
|
||||
outln(output, "{{");
|
||||
for (const auto& statement : m_statements) {
|
||||
for (auto const& statement : m_statements) {
|
||||
statement.dump(output, indent + 1);
|
||||
}
|
||||
print_indent(output, indent);
|
||||
|
@ -200,7 +200,7 @@ void BinaryExpression::dump(FILE* output, size_t indent) const
|
|||
{
|
||||
ASTNode::dump(output, indent);
|
||||
|
||||
const char* op_string = nullptr;
|
||||
char const* op_string = nullptr;
|
||||
switch (m_op) {
|
||||
case BinaryOp::Addition:
|
||||
op_string = "+";
|
||||
|
@ -272,7 +272,7 @@ void AssignmentExpression::dump(FILE* output, size_t indent) const
|
|||
{
|
||||
ASTNode::dump(output, indent);
|
||||
|
||||
const char* op_string = nullptr;
|
||||
char const* op_string = nullptr;
|
||||
switch (m_op) {
|
||||
case AssignmentOp::Assignment:
|
||||
op_string = "=";
|
||||
|
@ -296,7 +296,7 @@ void FunctionCall::dump(FILE* output, size_t indent) const
|
|||
{
|
||||
ASTNode::dump(output, indent);
|
||||
m_callee->dump(output, indent + 1);
|
||||
for (const auto& arg : m_arguments) {
|
||||
for (auto const& arg : m_arguments) {
|
||||
arg.dump(output, indent + 1);
|
||||
}
|
||||
}
|
||||
|
@ -349,7 +349,7 @@ void UnaryExpression::dump(FILE* output, size_t indent) const
|
|||
{
|
||||
ASTNode::dump(output, indent);
|
||||
|
||||
const char* op_string = nullptr;
|
||||
char const* op_string = nullptr;
|
||||
switch (m_op) {
|
||||
case UnaryOp::BitwiseNot:
|
||||
op_string = "~";
|
||||
|
@ -449,7 +449,7 @@ NonnullRefPtrVector<Declaration> Statement::declarations() const
|
|||
{
|
||||
if (is_declaration()) {
|
||||
NonnullRefPtrVector<Declaration> vec;
|
||||
const auto& decl = static_cast<const Declaration&>(*this);
|
||||
auto const& decl = static_cast<Declaration const&>(*this);
|
||||
vec.empend(const_cast<Declaration&>(decl));
|
||||
return vec;
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ void Constructor::dump(FILE* output, size_t indent) const
|
|||
outln(output, "C'tor");
|
||||
print_indent(output, indent + 1);
|
||||
outln(output, "(");
|
||||
for (const auto& arg : parameters()) {
|
||||
for (auto const& arg : parameters()) {
|
||||
arg.dump(output, indent + 1);
|
||||
}
|
||||
print_indent(output, indent + 1);
|
||||
|
@ -623,7 +623,7 @@ void Destructor::dump(FILE* output, size_t indent) const
|
|||
outln(output, "D'tor");
|
||||
print_indent(output, indent + 1);
|
||||
outln(output, "(");
|
||||
for (const auto& arg : parameters()) {
|
||||
for (auto const& arg : parameters()) {
|
||||
arg.dump(output, indent + 1);
|
||||
}
|
||||
print_indent(output, indent + 1);
|
||||
|
|
|
@ -47,11 +47,11 @@ public:
|
|||
VERIFY(m_end.has_value());
|
||||
return m_end.value();
|
||||
}
|
||||
const FlyString& filename() const
|
||||
FlyString const& filename() const
|
||||
{
|
||||
return m_filename;
|
||||
}
|
||||
void set_end(const Position& end) { m_end = end; }
|
||||
void set_end(Position const& end) { m_end = end; }
|
||||
void set_parent(ASTNode& parent) { m_parent = &parent; }
|
||||
|
||||
virtual NonnullRefPtrVector<Declaration> declarations() const { return {}; }
|
||||
|
@ -66,7 +66,7 @@ public:
|
|||
virtual bool is_dummy_node() const { return false; }
|
||||
|
||||
protected:
|
||||
ASTNode(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
ASTNode(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: m_parent(parent)
|
||||
, m_start(start)
|
||||
, m_end(end)
|
||||
|
@ -89,7 +89,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual NonnullRefPtrVector<Declaration> declarations() const override { return m_declarations; }
|
||||
|
||||
TranslationUnit(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
TranslationUnit(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: ASTNode(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public:
|
|||
virtual NonnullRefPtrVector<Declaration> declarations() const override;
|
||||
|
||||
protected:
|
||||
Statement(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
Statement(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: ASTNode(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -127,12 +127,12 @@ public:
|
|||
virtual bool is_namespace() const { return false; }
|
||||
virtual bool is_enum() const { return false; }
|
||||
bool is_member() const { return parent() != nullptr && parent()->is_declaration() && verify_cast<Declaration>(parent())->is_struct_or_class(); }
|
||||
const Name* name() const { return m_name; }
|
||||
Name const* name() const { return m_name; }
|
||||
StringView full_name() const;
|
||||
void set_name(RefPtr<Name> name) { m_name = move(name); }
|
||||
|
||||
protected:
|
||||
Declaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
Declaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ class InvalidDeclaration : public Declaration {
|
|||
public:
|
||||
virtual ~InvalidDeclaration() override = default;
|
||||
virtual StringView class_name() const override { return "InvalidDeclaration"sv; }
|
||||
InvalidDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
InvalidDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -162,19 +162,19 @@ public:
|
|||
virtual bool is_destructor() const { return false; }
|
||||
RefPtr<FunctionDefinition> definition() { return m_definition; }
|
||||
|
||||
FunctionDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
FunctionDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
||||
virtual NonnullRefPtrVector<Declaration> declarations() const override;
|
||||
const Vector<StringView>& qualifiers() const { return m_qualifiers; }
|
||||
void set_qualifiers(const Vector<StringView>& qualifiers) { m_qualifiers = qualifiers; }
|
||||
const Type* return_type() const { return m_return_type.ptr(); }
|
||||
void set_return_type(const RefPtr<Type>& return_type) { m_return_type = return_type; }
|
||||
const NonnullRefPtrVector<Parameter>& parameters() const { return m_parameters; }
|
||||
void set_parameters(const NonnullRefPtrVector<Parameter>& parameters) { m_parameters = parameters; }
|
||||
const FunctionDefinition* definition() const { return m_definition.ptr(); }
|
||||
Vector<StringView> const& qualifiers() const { return m_qualifiers; }
|
||||
void set_qualifiers(Vector<StringView> const& qualifiers) { m_qualifiers = qualifiers; }
|
||||
Type const* return_type() const { return m_return_type.ptr(); }
|
||||
void set_return_type(RefPtr<Type> const& return_type) { m_return_type = return_type; }
|
||||
NonnullRefPtrVector<Parameter> const& parameters() const { return m_parameters; }
|
||||
void set_parameters(NonnullRefPtrVector<Parameter> const& parameters) { m_parameters = parameters; }
|
||||
FunctionDefinition const* definition() const { return m_definition.ptr(); }
|
||||
void set_definition(RefPtr<FunctionDefinition>&& definition) { m_definition = move(definition); }
|
||||
|
||||
private:
|
||||
|
@ -190,10 +190,10 @@ public:
|
|||
virtual bool is_variable_or_parameter_declaration() const override { return true; }
|
||||
|
||||
void set_type(RefPtr<Type>&& type) { m_type = move(type); }
|
||||
const Type* type() const { return m_type.ptr(); }
|
||||
Type const* type() const { return m_type.ptr(); }
|
||||
|
||||
protected:
|
||||
VariableOrParameterDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
VariableOrParameterDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_parameter() const override { return true; }
|
||||
|
||||
Parameter(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename, RefPtr<Name> name)
|
||||
Parameter(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename, RefPtr<Name> name)
|
||||
: VariableOrParameterDeclaration(parent, start, end, filename)
|
||||
{
|
||||
m_name = name;
|
||||
|
@ -237,7 +237,7 @@ public:
|
|||
void set_qualifiers(Vector<StringView>&& qualifiers) { m_qualifiers = move(qualifiers); }
|
||||
|
||||
protected:
|
||||
Type(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
Type(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: ASTNode(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -254,12 +254,12 @@ public:
|
|||
virtual String to_string() const override;
|
||||
virtual bool is_named_type() const override { return true; }
|
||||
|
||||
NamedType(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
NamedType(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Type(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
||||
const Name* name() const { return m_name.ptr(); }
|
||||
Name const* name() const { return m_name.ptr(); }
|
||||
void set_name(RefPtr<Name>&& name) { m_name = move(name); }
|
||||
|
||||
private:
|
||||
|
@ -273,12 +273,12 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual String to_string() const override;
|
||||
|
||||
Pointer(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
Pointer(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Type(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
||||
const Type* pointee() const { return m_pointee.ptr(); }
|
||||
Type const* pointee() const { return m_pointee.ptr(); }
|
||||
void set_pointee(RefPtr<Type>&& pointee) { m_pointee = move(pointee); }
|
||||
|
||||
private:
|
||||
|
@ -297,13 +297,13 @@ public:
|
|||
Rvalue,
|
||||
};
|
||||
|
||||
Reference(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename, Kind kind)
|
||||
Reference(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename, Kind kind)
|
||||
: Type(parent, start, end, filename)
|
||||
, m_kind(kind)
|
||||
{
|
||||
}
|
||||
|
||||
const Type* referenced_type() const { return m_referenced_type.ptr(); }
|
||||
Type const* referenced_type() const { return m_referenced_type.ptr(); }
|
||||
void set_referenced_type(RefPtr<Type>&& pointee) { m_referenced_type = move(pointee); }
|
||||
Kind kind() const { return m_kind; }
|
||||
|
||||
|
@ -319,7 +319,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual String to_string() const override;
|
||||
|
||||
FunctionType(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
FunctionType(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Type(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ public:
|
|||
virtual StringView class_name() const override { return "FunctionDefinition"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
FunctionDefinition(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
FunctionDefinition(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: ASTNode(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ class InvalidStatement : public Statement {
|
|||
public:
|
||||
virtual ~InvalidStatement() override = default;
|
||||
virtual StringView class_name() const override { return "InvalidStatement"sv; }
|
||||
InvalidStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
InvalidStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -367,7 +367,7 @@ public:
|
|||
virtual StringView class_name() const override { return "Expression"sv; }
|
||||
|
||||
protected:
|
||||
Expression(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
Expression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ class InvalidExpression : public Expression {
|
|||
public:
|
||||
virtual ~InvalidExpression() override = default;
|
||||
virtual StringView class_name() const override { return "InvalidExpression"sv; }
|
||||
InvalidExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
InvalidExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -389,14 +389,14 @@ public:
|
|||
virtual StringView class_name() const override { return "VariableDeclaration"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
VariableDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
VariableDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: VariableOrParameterDeclaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool is_variable_declaration() const override { return true; }
|
||||
|
||||
const Expression* initial_value() const { return m_initial_value; }
|
||||
Expression const* initial_value() const { return m_initial_value; }
|
||||
void set_initial_value(RefPtr<Expression>&& initial_value) { m_initial_value = move(initial_value); }
|
||||
|
||||
private:
|
||||
|
@ -409,12 +409,12 @@ public:
|
|||
virtual StringView class_name() const override { return "Identifier"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
Identifier(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename, StringView name)
|
||||
Identifier(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename, StringView name)
|
||||
: Expression(parent, start, end, filename)
|
||||
, m_name(name)
|
||||
{
|
||||
}
|
||||
Identifier(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
Identifier(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Identifier(parent, start, end, filename, {})
|
||||
{
|
||||
}
|
||||
|
@ -436,13 +436,13 @@ public:
|
|||
virtual bool is_name() const override { return true; }
|
||||
virtual bool is_templatized() const { return false; }
|
||||
|
||||
Name(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
Name(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
virtual StringView full_name() const;
|
||||
|
||||
const Identifier* name() const { return m_name.ptr(); }
|
||||
Identifier const* name() const { return m_name.ptr(); }
|
||||
void set_name(RefPtr<Identifier>&& name) { m_name = move(name); }
|
||||
NonnullRefPtrVector<Identifier> const& scope() const { return m_scope; }
|
||||
void set_scope(NonnullRefPtrVector<Identifier> scope) { m_scope = move(scope); }
|
||||
|
@ -461,7 +461,7 @@ public:
|
|||
virtual bool is_templatized() const override { return true; }
|
||||
virtual StringView full_name() const override;
|
||||
|
||||
TemplatizedName(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
TemplatizedName(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Name(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -479,7 +479,7 @@ public:
|
|||
virtual StringView class_name() const override { return "NumericLiteral"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
NumericLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename, StringView value)
|
||||
NumericLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename, StringView value)
|
||||
: Expression(parent, start, end, filename)
|
||||
, m_value(value)
|
||||
{
|
||||
|
@ -495,7 +495,7 @@ public:
|
|||
virtual StringView class_name() const override { return "NullPointerLiteral"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
NullPointerLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
NullPointerLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -507,7 +507,7 @@ public:
|
|||
virtual StringView class_name() const override { return "BooleanLiteral"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
BooleanLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename, bool value)
|
||||
BooleanLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename, bool value)
|
||||
: Expression(parent, start, end, filename)
|
||||
, m_value(value)
|
||||
{
|
||||
|
@ -541,7 +541,7 @@ enum class BinaryOp {
|
|||
|
||||
class BinaryExpression : public Expression {
|
||||
public:
|
||||
BinaryExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
BinaryExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -571,7 +571,7 @@ enum class AssignmentOp {
|
|||
|
||||
class AssignmentExpression : public Expression {
|
||||
public:
|
||||
AssignmentExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
AssignmentExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -582,9 +582,9 @@ public:
|
|||
|
||||
AssignmentOp op() const { return m_op; }
|
||||
void set_op(AssignmentOp op) { m_op = op; }
|
||||
const Expression* lhs() const { return m_lhs; }
|
||||
Expression const* lhs() const { return m_lhs; }
|
||||
void set_lhs(RefPtr<Expression>&& e) { m_lhs = move(e); }
|
||||
const Expression* rhs() const { return m_rhs; }
|
||||
Expression const* rhs() const { return m_rhs; }
|
||||
void set_rhs(RefPtr<Expression>&& e) { m_rhs = move(e); }
|
||||
|
||||
private:
|
||||
|
@ -595,7 +595,7 @@ private:
|
|||
|
||||
class FunctionCall : public Expression {
|
||||
public:
|
||||
FunctionCall(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
FunctionCall(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -605,7 +605,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_function_call() const override { return true; }
|
||||
|
||||
const Expression* callee() const { return m_callee.ptr(); }
|
||||
Expression const* callee() const { return m_callee.ptr(); }
|
||||
void set_callee(RefPtr<Expression>&& callee) { m_callee = move(callee); }
|
||||
|
||||
void add_argument(NonnullRefPtr<Expression>&& arg) { m_arguments.append(move(arg)); }
|
||||
|
@ -618,7 +618,7 @@ private:
|
|||
|
||||
class StringLiteral final : public Expression {
|
||||
public:
|
||||
StringLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
StringLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -639,13 +639,13 @@ public:
|
|||
virtual ~ReturnStatement() override = default;
|
||||
virtual StringView class_name() const override { return "ReturnStatement"sv; }
|
||||
|
||||
ReturnStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
ReturnStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
const Expression* value() const { return m_value.ptr(); }
|
||||
Expression const* value() const { return m_value.ptr(); }
|
||||
void set_value(RefPtr<Expression>&& value) { m_value = move(value); }
|
||||
|
||||
private:
|
||||
|
@ -659,7 +659,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_enum() const override { return true; }
|
||||
|
||||
EnumDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
EnumDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -696,7 +696,7 @@ public:
|
|||
Class
|
||||
};
|
||||
|
||||
StructOrClassDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename, StructOrClassDeclaration::Type type)
|
||||
StructOrClassDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename, StructOrClassDeclaration::Type type)
|
||||
: Declaration(parent, start, end, filename)
|
||||
, m_type(type)
|
||||
{
|
||||
|
@ -722,7 +722,7 @@ enum class UnaryOp {
|
|||
|
||||
class UnaryExpression : public Expression {
|
||||
public:
|
||||
UnaryExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
UnaryExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -741,7 +741,7 @@ private:
|
|||
|
||||
class MemberExpression : public Expression {
|
||||
public:
|
||||
MemberExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
MemberExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -751,9 +751,9 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_member_expression() const override { return true; }
|
||||
|
||||
const Expression* object() const { return m_object.ptr(); }
|
||||
Expression const* object() const { return m_object.ptr(); }
|
||||
void set_object(RefPtr<Expression>&& object) { m_object = move(object); }
|
||||
const Expression* property() const { return m_property.ptr(); }
|
||||
Expression const* property() const { return m_property.ptr(); }
|
||||
void set_property(RefPtr<Expression>&& property) { m_property = move(property); }
|
||||
|
||||
private:
|
||||
|
@ -763,7 +763,7 @@ private:
|
|||
|
||||
class ForStatement : public Statement {
|
||||
public:
|
||||
ForStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
ForStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -778,7 +778,7 @@ public:
|
|||
void set_test(RefPtr<Expression>&& test) { m_test = move(test); }
|
||||
void set_update(RefPtr<Expression>&& update) { m_update = move(update); }
|
||||
void set_body(RefPtr<Statement>&& body) { m_body = move(body); }
|
||||
const Statement* body() const { return m_body.ptr(); }
|
||||
Statement const* body() const { return m_body.ptr(); }
|
||||
|
||||
private:
|
||||
RefPtr<VariableDeclaration> m_init;
|
||||
|
@ -789,7 +789,7 @@ private:
|
|||
|
||||
class BlockStatement final : public Statement {
|
||||
public:
|
||||
BlockStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
BlockStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -808,7 +808,7 @@ private:
|
|||
|
||||
class Comment final : public Statement {
|
||||
public:
|
||||
Comment(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
Comment(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -819,7 +819,7 @@ public:
|
|||
|
||||
class IfStatement : public Statement {
|
||||
public:
|
||||
IfStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
IfStatement(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Statement(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -833,8 +833,8 @@ public:
|
|||
void set_then_statement(RefPtr<Statement>&& then) { m_then = move(then); }
|
||||
void set_else_statement(RefPtr<Statement>&& _else) { m_else = move(_else); }
|
||||
|
||||
const Statement* then_statement() const { return m_then.ptr(); }
|
||||
const Statement* else_statement() const { return m_else.ptr(); }
|
||||
Statement const* then_statement() const { return m_then.ptr(); }
|
||||
Statement const* else_statement() const { return m_else.ptr(); }
|
||||
|
||||
private:
|
||||
RefPtr<Expression> m_predicate;
|
||||
|
@ -849,7 +849,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_namespace() const override { return true; }
|
||||
|
||||
NamespaceDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
NamespaceDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Declaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -863,7 +863,7 @@ private:
|
|||
|
||||
class CppCastExpression : public Expression {
|
||||
public:
|
||||
CppCastExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
CppCastExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -884,7 +884,7 @@ private:
|
|||
|
||||
class CStyleCastExpression : public Expression {
|
||||
public:
|
||||
CStyleCastExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
CStyleCastExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -903,7 +903,7 @@ private:
|
|||
|
||||
class SizeofExpression : public Expression {
|
||||
public:
|
||||
SizeofExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
SizeofExpression(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -920,7 +920,7 @@ private:
|
|||
|
||||
class BracedInitList : public Expression {
|
||||
public:
|
||||
BracedInitList(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
BracedInitList(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: Expression(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -937,7 +937,7 @@ private:
|
|||
|
||||
class DummyAstNode : public ASTNode {
|
||||
public:
|
||||
DummyAstNode(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
DummyAstNode(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: ASTNode(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -953,7 +953,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_constructor() const override { return true; }
|
||||
|
||||
Constructor(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
Constructor(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: FunctionDeclaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
@ -966,7 +966,7 @@ public:
|
|||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual bool is_destructor() const override { return true; }
|
||||
|
||||
Destructor(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
|
||||
Destructor(ASTNode* parent, Optional<Position> start, Optional<Position> end, String const& filename)
|
||||
: FunctionDeclaration(parent, start, end, filename)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -864,12 +864,12 @@ void Parser::load_state()
|
|||
m_state = m_saved_states.take_last();
|
||||
}
|
||||
|
||||
StringView Parser::text_of_token(const Cpp::Token& token) const
|
||||
StringView Parser::text_of_token(Cpp::Token const& token) const
|
||||
{
|
||||
return token.text();
|
||||
}
|
||||
|
||||
String Parser::text_of_node(const ASTNode& node) const
|
||||
String Parser::text_of_node(ASTNode const& node) const
|
||||
{
|
||||
return text_in_range(node.start(), node.end());
|
||||
}
|
||||
|
@ -969,7 +969,7 @@ Optional<size_t> Parser::index_of_node_at(Position pos) const
|
|||
VERIFY(m_saved_states.is_empty());
|
||||
Optional<size_t> match_node_index;
|
||||
|
||||
auto node_span = [](const ASTNode& node) {
|
||||
auto node_span = [](ASTNode const& node) {
|
||||
VERIFY(node.end().line >= node.start().line);
|
||||
VERIFY((node.end().line > node.start().line) || (node.end().column >= node.start().column));
|
||||
return Position { node.end().line - node.start().line, node.start().line != node.end().line ? 0 : node.end().column - node.start().column };
|
||||
|
@ -1106,7 +1106,7 @@ NonnullRefPtr<EnumDeclaration> Parser::parse_enum_declaration(ASTNode& parent)
|
|||
return enum_decl;
|
||||
}
|
||||
|
||||
Token Parser::consume_keyword(const String& keyword)
|
||||
Token Parser::consume_keyword(String const& keyword)
|
||||
{
|
||||
auto token = consume();
|
||||
if (token.type() != Token::Type::Keyword) {
|
||||
|
@ -1120,7 +1120,7 @@ Token Parser::consume_keyword(const String& keyword)
|
|||
return token;
|
||||
}
|
||||
|
||||
bool Parser::match_keyword(const String& keyword)
|
||||
bool Parser::match_keyword(String const& keyword)
|
||||
{
|
||||
auto token = peek();
|
||||
if (token.type() != Token::Type::Keyword) {
|
||||
|
|
|
@ -29,11 +29,11 @@ public:
|
|||
Optional<Token> token_at(Position) const;
|
||||
Optional<size_t> index_of_token_at(Position) const;
|
||||
RefPtr<const TranslationUnit> root_node() const { return m_root_node; }
|
||||
String text_of_node(const ASTNode&) const;
|
||||
StringView text_of_token(const Cpp::Token& token) const;
|
||||
String text_of_node(ASTNode const&) const;
|
||||
StringView text_of_token(Cpp::Token const& token) const;
|
||||
void print_tokens() const;
|
||||
Vector<Token> const& tokens() const { return m_tokens; }
|
||||
const Vector<String>& errors() const { return m_errors; }
|
||||
Vector<String> const& errors() const { return m_errors; }
|
||||
|
||||
struct TodoEntry {
|
||||
String content;
|
||||
|
@ -71,7 +71,7 @@ private:
|
|||
bool match_literal();
|
||||
bool match_unary_expression();
|
||||
bool match_boolean_literal();
|
||||
bool match_keyword(const String&);
|
||||
bool match_keyword(String const&);
|
||||
bool match_block_statement();
|
||||
bool match_namespace_declaration();
|
||||
bool match_template_arguments();
|
||||
|
@ -130,7 +130,7 @@ private:
|
|||
bool match(Token::Type);
|
||||
Token consume(Token::Type);
|
||||
Token consume();
|
||||
Token consume_keyword(const String&);
|
||||
Token consume_keyword(String const&);
|
||||
Token peek(size_t offset = 0) const;
|
||||
Optional<Token> peek(Token::Type) const;
|
||||
Position position() const;
|
||||
|
@ -149,7 +149,7 @@ private:
|
|||
|
||||
template<class T, class... Args>
|
||||
NonnullRefPtr<T>
|
||||
create_ast_node(ASTNode& parent, const Position& start, Optional<Position> end, Args&&... args)
|
||||
create_ast_node(ASTNode& parent, Position const& start, Optional<Position> end, Args&&... args)
|
||||
{
|
||||
auto node = adopt_ref(*new T(&parent, start, end, m_filename, forward<Args>(args)...));
|
||||
|
||||
|
@ -163,7 +163,7 @@ private:
|
|||
}
|
||||
|
||||
NonnullRefPtr<TranslationUnit>
|
||||
create_root_ast_node(const Position& start, Position end)
|
||||
create_root_ast_node(Position const& start, Position end)
|
||||
{
|
||||
auto node = adopt_ref(*new TranslationUnit(nullptr, start, end, m_filename));
|
||||
m_nodes.append(node);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <ctype.h>
|
||||
|
||||
namespace Cpp {
|
||||
Preprocessor::Preprocessor(const String& filename, StringView program)
|
||||
Preprocessor::Preprocessor(String const& filename, StringView program)
|
||||
: m_filename(filename)
|
||||
, m_program(program)
|
||||
{
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Cpp {
|
|||
class Preprocessor {
|
||||
|
||||
public:
|
||||
explicit Preprocessor(const String& filename, StringView program);
|
||||
explicit Preprocessor(String const& filename, StringView program);
|
||||
Vector<Token> process_and_lex();
|
||||
Vector<StringView> included_paths() const { return m_included_paths; }
|
||||
|
||||
|
|
|
@ -9,19 +9,19 @@
|
|||
|
||||
namespace Cpp {
|
||||
|
||||
bool Position::operator<(const Position& other) const
|
||||
bool Position::operator<(Position const& other) const
|
||||
{
|
||||
return line < other.line || (line == other.line && column < other.column);
|
||||
}
|
||||
bool Position::operator>(const Position& other) const
|
||||
bool Position::operator>(Position const& other) const
|
||||
{
|
||||
return !(*this < other) && !(*this == other);
|
||||
}
|
||||
bool Position::operator==(const Position& other) const
|
||||
bool Position::operator==(Position const& other) const
|
||||
{
|
||||
return line == other.line && column == other.column;
|
||||
}
|
||||
bool Position::operator<=(const Position& other) const
|
||||
bool Position::operator<=(Position const& other) const
|
||||
{
|
||||
return !(*this > other);
|
||||
}
|
||||
|
|
|
@ -83,10 +83,10 @@ struct Position {
|
|||
size_t line { 0 };
|
||||
size_t column { 0 };
|
||||
|
||||
bool operator<(const Position&) const;
|
||||
bool operator<=(const Position&) const;
|
||||
bool operator>(const Position&) const;
|
||||
bool operator==(const Position&) const;
|
||||
bool operator<(Position const&) const;
|
||||
bool operator<=(Position const&) const;
|
||||
bool operator>(Position const&) const;
|
||||
bool operator==(Position const&) const;
|
||||
};
|
||||
|
||||
struct Token {
|
||||
|
@ -96,7 +96,7 @@ struct Token {
|
|||
#undef __TOKEN
|
||||
};
|
||||
|
||||
Token(Type type, const Position& start, const Position& end, StringView text)
|
||||
Token(Type type, Position const& start, Position const& end, StringView text)
|
||||
: m_type(type)
|
||||
, m_start(start)
|
||||
, m_end(end)
|
||||
|
@ -104,7 +104,7 @@ struct Token {
|
|||
{
|
||||
}
|
||||
|
||||
static const char* type_to_string(Type t)
|
||||
static char const* type_to_string(Type t)
|
||||
{
|
||||
switch (t) {
|
||||
#define __TOKEN(x) \
|
||||
|
@ -119,11 +119,11 @@ struct Token {
|
|||
String to_string() const;
|
||||
String type_as_string() const;
|
||||
|
||||
const Position& start() const { return m_start; }
|
||||
const Position& end() const { return m_end; }
|
||||
Position const& start() const { return m_start; }
|
||||
Position const& end() const { return m_end; }
|
||||
|
||||
void set_start(const Position& other) { m_start = other; }
|
||||
void set_end(const Position& other) { m_end = other; }
|
||||
void set_start(Position const& other) { m_start = other; }
|
||||
void set_end(Position const& other) { m_end = other; }
|
||||
Type type() const { return m_type; }
|
||||
StringView text() const { return m_text; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue