LibCpp: Generalize ASTNode::dump() to support redirecting its output

Previously, ASTNode::dump() used outln() for output, which meant it
always wrote its output to stdout.

After this commit, ASTNode::dump() receives an 'output' argument (which
is stdout by default). This enables writing the output to somewhere
else.

This will be useful for testing the LibCpp Parser with the output of
ASTNode::dump.
This commit is contained in:
Itamar 2021-05-17 13:04:15 +03:00 committed by Andreas Kling
parent 463a91c4a2
commit 402483ec1f
Notes: sideshowbarker 2024-07-18 17:44:58 +09:00
4 changed files with 194 additions and 194 deletions

View file

@ -559,7 +559,7 @@ OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_docu
auto root = document_data->parser().parse();
if constexpr (CPP_LANGUAGE_SERVER_DEBUG)
root->dump(0);
root->dump();
update_declared_symbols(*document_data);

View file

@ -8,50 +8,50 @@
namespace Cpp {
static void print_indent(int indent)
static void print_indent(FILE* output, int indent)
{
for (int i = 0; i < indent * 2; ++i)
out(" ");
out(output, " ");
}
void ASTNode::dump(size_t indent) const
void ASTNode::dump(FILE* output, size_t indent) const
{
print_indent(indent);
outln("{}[{}:{}->{}:{}]", class_name(), start().line, start().column, end().line, end().column);
print_indent(output, indent);
outln(output, "{}[{}:{}->{}:{}]", class_name(), start().line, start().column, end().line, end().column);
}
void TranslationUnit::dump(size_t indent) const
void TranslationUnit::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
ASTNode::dump(output, indent);
for (const auto& child : m_declarations) {
child.dump(indent + 1);
child.dump(output, indent + 1);
}
}
void FunctionDeclaration::dump(size_t indent) const
void FunctionDeclaration::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
ASTNode::dump(output, indent);
String qualifiers_string;
if (!m_qualifiers.is_empty()) {
print_indent(indent + 1);
outln("[{}]", String::join(" ", m_qualifiers));
print_indent(output, indent + 1);
outln(output, "[{}]", String::join(" ", m_qualifiers));
}
m_return_type->dump(indent + 1);
m_return_type->dump(output, indent + 1);
if (!m_name.is_null()) {
print_indent(indent + 1);
outln("{}", m_name);
print_indent(output, indent + 1);
outln(output, "{}", m_name);
}
print_indent(indent + 1);
outln("(");
print_indent(output, indent + 1);
outln(output, "(");
for (const auto& arg : m_parameters) {
arg.dump(indent + 1);
arg.dump(output, indent + 1);
}
print_indent(indent + 1);
outln(")");
print_indent(output, indent + 1);
outln(output, ")");
if (!m_definition.is_null()) {
m_definition->dump(indent + 1);
m_definition->dump(output, indent + 1);
}
}
@ -64,11 +64,11 @@ NonnullRefPtrVector<Declaration> FunctionDeclaration::declarations() const
return declarations;
}
void Type::dump(size_t indent) const
void Type::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
print_indent(indent + 1);
outln("{}", to_string());
ASTNode::dump(output, indent);
print_indent(output, indent + 1);
outln(output, "{}", to_string());
}
String Type::to_string() const
@ -96,31 +96,31 @@ String Pointer::to_string() const
return builder.to_string();
}
void Parameter::dump(size_t indent) const
void Parameter::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
ASTNode::dump(output, indent);
if (m_is_ellipsis) {
print_indent(indent + 1);
outln("...");
print_indent(output, indent + 1);
outln(output, "...");
}
if (!m_name.is_null()) {
print_indent(indent);
outln("{}", m_name);
print_indent(output, indent);
outln(output, "{}", m_name);
}
if (m_type)
m_type->dump(indent + 1);
m_type->dump(output, indent + 1);
}
void FunctionDefinition::dump(size_t indent) const
void FunctionDefinition::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
print_indent(indent);
outln("{{");
ASTNode::dump(output, indent);
print_indent(output, indent);
outln(output, "{{");
for (const auto& statement : m_statements) {
statement.dump(indent + 1);
statement.dump(output, indent + 1);
}
print_indent(indent);
outln("}}");
print_indent(output, indent);
outln(output, "}}");
}
NonnullRefPtrVector<Declaration> FunctionDefinition::declarations() const
@ -132,34 +132,34 @@ NonnullRefPtrVector<Declaration> FunctionDefinition::declarations() const
return declarations;
}
void VariableDeclaration::dump(size_t indent) const
void VariableDeclaration::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
ASTNode::dump(output, indent);
if (m_type)
m_type->dump(indent + 1);
print_indent(indent + 1);
outln("{}", m_name);
m_type->dump(output, indent + 1);
print_indent(output, indent + 1);
outln(output, "{}", m_name);
if (m_initial_value)
m_initial_value->dump(indent + 1);
m_initial_value->dump(output, indent + 1);
}
void Identifier::dump(size_t indent) const
void Identifier::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
print_indent(indent);
outln("{}", m_name);
ASTNode::dump(output, indent);
print_indent(output, indent);
outln(output, "{}", m_name);
}
void NumericLiteral::dump(size_t indent) const
void NumericLiteral::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
print_indent(indent);
outln("{}", m_value);
ASTNode::dump(output, indent);
print_indent(output, indent);
outln(output, "{}", m_value);
}
void BinaryExpression::dump(size_t indent) const
void BinaryExpression::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
ASTNode::dump(output, indent);
const char* op_string = nullptr;
switch (m_op) {
@ -222,16 +222,16 @@ void BinaryExpression::dump(size_t indent) const
break;
}
m_lhs->dump(indent + 1);
print_indent(indent + 1);
m_lhs->dump(output, indent + 1);
print_indent(output, indent + 1);
VERIFY(op_string);
outln("{}", op_string);
m_rhs->dump(indent + 1);
outln(output, "{}", op_string);
m_rhs->dump(output, indent + 1);
}
void AssignmentExpression::dump(size_t indent) const
void AssignmentExpression::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
ASTNode::dump(output, indent);
const char* op_string = nullptr;
switch (m_op) {
@ -246,54 +246,54 @@ void AssignmentExpression::dump(size_t indent) const
break;
}
m_lhs->dump(indent + 1);
print_indent(indent + 1);
m_lhs->dump(output, indent + 1);
print_indent(output, indent + 1);
VERIFY(op_string);
outln("{}", op_string);
m_rhs->dump(indent + 1);
outln(output, "{}", op_string);
m_rhs->dump(output, indent + 1);
}
void FunctionCall::dump(size_t indent) const
void FunctionCall::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
m_callee->dump(indent + 1);
ASTNode::dump(output, indent);
m_callee->dump(output, indent + 1);
for (const auto& arg : m_arguments) {
arg.dump(indent + 1);
arg.dump(output, indent + 1);
}
}
void StringLiteral::dump(size_t indent) const
void StringLiteral::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
print_indent(indent + 1);
outln("{}", m_value);
ASTNode::dump(output, indent);
print_indent(output, indent + 1);
outln(output, "{}", m_value);
}
void ReturnStatement::dump(size_t indent) const
void ReturnStatement::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
ASTNode::dump(output, indent);
if (m_value)
m_value->dump(indent + 1);
m_value->dump(output, indent + 1);
}
void EnumDeclaration::dump(size_t indent) const
void EnumDeclaration::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
print_indent(indent);
outln("{}", m_name);
ASTNode::dump(output, indent);
print_indent(output, indent);
outln(output, "{}", m_name);
for (auto& entry : m_entries) {
print_indent(indent + 1);
outln("{}", entry);
print_indent(output, indent + 1);
outln(output, "{}", entry);
}
}
void StructOrClassDeclaration::dump(size_t indent) const
void StructOrClassDeclaration::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
print_indent(indent);
outln("{}", m_name);
ASTNode::dump(output, indent);
print_indent(output, indent);
outln(output, "{}", m_name);
for (auto& member : m_members) {
member.dump(indent + 1);
member.dump(output, indent + 1);
}
}
NonnullRefPtrVector<Declaration> StructOrClassDeclaration::declarations() const
@ -304,20 +304,20 @@ NonnullRefPtrVector<Declaration> StructOrClassDeclaration::declarations() const
return declarations;
}
void MemberDeclaration::dump(size_t indent) const
void MemberDeclaration::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
m_type->dump(indent + 1);
print_indent(indent + 1);
outln("{}", m_name);
ASTNode::dump(output, indent);
m_type->dump(output, indent + 1);
print_indent(output, indent + 1);
outln(output, "{}", m_name);
if (m_initial_value) {
m_initial_value->dump(indent + 2);
m_initial_value->dump(output, indent + 2);
}
}
void UnaryExpression::dump(size_t indent) const
void UnaryExpression::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
ASTNode::dump(output, indent);
const char* op_string = nullptr;
switch (m_op) {
@ -344,52 +344,52 @@ void UnaryExpression::dump(size_t indent) const
}
VERIFY(op_string);
print_indent(indent + 1);
outln("{}", op_string);
m_lhs->dump(indent + 1);
print_indent(output, indent + 1);
outln(output, "{}", op_string);
m_lhs->dump(output, indent + 1);
}
void BooleanLiteral::dump(size_t indent) const
void BooleanLiteral::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
print_indent(indent + 1);
outln("{}", m_value ? "true" : "false");
ASTNode::dump(output, indent);
print_indent(output, indent + 1);
outln(output, "{}", m_value ? "true" : "false");
}
void Pointer::dump(size_t indent) const
void Pointer::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
ASTNode::dump(output, indent);
if (!m_pointee.is_null()) {
m_pointee->dump(indent + 1);
m_pointee->dump(output, indent + 1);
}
}
void MemberExpression::dump(size_t indent) const
void MemberExpression::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
m_object->dump(indent + 1);
m_property->dump(indent + 1);
ASTNode::dump(output, indent);
m_object->dump(output, indent + 1);
m_property->dump(output, indent + 1);
}
void BlockStatement::dump(size_t indent) const
void BlockStatement::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
ASTNode::dump(output, indent);
for (auto& statement : m_statements) {
statement.dump(indent + 1);
statement.dump(output, indent + 1);
}
}
void ForStatement::dump(size_t indent) const
void ForStatement::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
ASTNode::dump(output, indent);
if (m_init)
m_init->dump(indent + 1);
m_init->dump(output, indent + 1);
if (m_test)
m_test->dump(indent + 1);
m_test->dump(output, indent + 1);
if (m_update)
m_update->dump(indent + 1);
m_update->dump(output, indent + 1);
if (m_body)
m_body->dump(indent + 1);
m_body->dump(output, indent + 1);
}
NonnullRefPtrVector<Declaration> Statement::declarations() const
@ -422,23 +422,23 @@ NonnullRefPtrVector<Declaration> BlockStatement::declarations() const
return declarations;
}
void IfStatement::dump(size_t indent) const
void IfStatement::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
ASTNode::dump(output, indent);
if (m_predicate) {
print_indent(indent + 1);
outln("Predicate:");
m_predicate->dump(indent + 1);
print_indent(output, indent + 1);
outln(output, "Predicate:");
m_predicate->dump(output, indent + 1);
}
if (m_then) {
print_indent(indent + 1);
outln("Then:");
m_then->dump(indent + 1);
print_indent(output, indent + 1);
outln(output, "Then:");
m_then->dump(output, indent + 1);
}
if (m_else) {
print_indent(indent + 1);
outln("Else:");
m_else->dump(indent + 1);
print_indent(output, indent + 1);
outln(output, "Else:");
m_else->dump(output, indent + 1);
}
}
@ -454,25 +454,25 @@ NonnullRefPtrVector<Declaration> IfStatement::declarations() const
return declarations;
}
void NamespaceDeclaration::dump(size_t indent) const
void NamespaceDeclaration::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
print_indent(indent + 1);
outln("{}", m_name);
ASTNode::dump(output, indent);
print_indent(output, indent + 1);
outln(output, "{}", m_name);
for (auto& decl : m_declarations)
decl.dump(indent + 1);
decl.dump(output, indent + 1);
}
void NullPointerLiteral::dump(size_t indent) const
void NullPointerLiteral::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
ASTNode::dump(output, indent);
}
void Name::dump(size_t indent) const
void Name::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
print_indent(indent);
outln("{}", full_name());
ASTNode::dump(output, indent);
print_indent(output, indent);
outln(output, "{}", full_name());
}
String Name::full_name() const
@ -498,46 +498,46 @@ String TemplatizedName::full_name() const
return name.to_string();
}
void CppCastExpression::dump(size_t indent) const
void CppCastExpression::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
ASTNode::dump(output, indent);
print_indent(indent);
outln("{}", m_cast_type);
print_indent(output, indent);
outln(output, "{}", m_cast_type);
print_indent(indent + 1);
outln("<");
print_indent(output, indent + 1);
outln(output, "<");
if (m_type)
m_type->dump(indent + 1);
print_indent(indent + 1);
outln(">");
m_type->dump(output, indent + 1);
print_indent(output, indent + 1);
outln(output, ">");
if (m_expression)
m_expression->dump(indent + 1);
m_expression->dump(output, indent + 1);
}
void SizeofExpression::dump(size_t indent) const
void SizeofExpression::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
ASTNode::dump(output, indent);
if (m_type)
m_type->dump(indent + 1);
m_type->dump(output, indent + 1);
}
void BracedInitList::dump(size_t indent) const
void BracedInitList::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
ASTNode::dump(output, indent);
for (auto& exp : m_expressions) {
exp.dump(indent + 1);
exp.dump(output, indent + 1);
}
}
void CStyleCastExpression::dump(size_t indent) const
void CStyleCastExpression::dump(FILE* output, size_t indent) const
{
ASTNode::dump(indent);
ASTNode::dump(output, indent);
if (m_type)
m_type->dump(indent + 1);
m_type->dump(output, indent + 1);
if (m_expression)
m_expression->dump(indent + 1);
m_expression->dump(output, indent + 1);
}
}

View file

@ -29,7 +29,7 @@ class ASTNode : public RefCounted<ASTNode> {
public:
virtual ~ASTNode() = default;
virtual const char* class_name() const = 0;
virtual void dump(size_t indent) const;
virtual void dump(FILE* = stdout, size_t indent = 0) const;
ASTNode* parent() const { return m_parent; }
Position start() const
@ -81,7 +81,7 @@ class TranslationUnit : public ASTNode {
public:
virtual ~TranslationUnit() override = default;
virtual const char* class_name() const override { return "TranslationUnit"; }
virtual void dump(size_t indent) const override;
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)
@ -144,7 +144,7 @@ class FunctionDeclaration : public Declaration {
public:
virtual ~FunctionDeclaration() override = default;
virtual const char* class_name() const override { return "FunctionDeclaration"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
virtual bool is_function() const override { return true; }
RefPtr<FunctionDefinition> definition() { return m_definition; }
@ -179,7 +179,7 @@ class Parameter : public VariableOrParameterDeclaration {
public:
virtual ~Parameter() override = default;
virtual const char* class_name() const override { return "Parameter"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
Parameter(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename, StringView name)
: VariableOrParameterDeclaration(parent, start, end, filename)
@ -196,7 +196,7 @@ class Type : public ASTNode {
public:
virtual ~Type() override = default;
virtual const char* class_name() const override { return "Type"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
virtual bool is_type() const override { return true; }
virtual bool is_templatized() const { return false; }
virtual String to_string() const;
@ -215,7 +215,7 @@ class Pointer : public Type {
public:
virtual ~Pointer() override = default;
virtual const char* class_name() const override { return "Pointer"; }
virtual void dump(size_t indent) const override;
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)
@ -231,7 +231,7 @@ public:
virtual ~FunctionDefinition() override = default;
virtual const char* class_name() const override { return "FunctionDefinition"; }
NonnullRefPtrVector<Statement>& statements() { return m_statements; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
FunctionDefinition(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
: ASTNode(parent, start, end, filename)
@ -279,7 +279,7 @@ class VariableDeclaration : public VariableOrParameterDeclaration {
public:
virtual ~VariableDeclaration() override = default;
virtual const char* class_name() const override { return "VariableDeclaration"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
VariableDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
: VariableOrParameterDeclaration(parent, start, end, filename)
@ -295,7 +295,7 @@ class Identifier : public Expression {
public:
virtual ~Identifier() override = default;
virtual const char* class_name() const override { return "Identifier"; }
virtual void dump(size_t indent) const override;
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)
: Expression(parent, start, end, filename)
@ -316,7 +316,7 @@ class Name : public Expression {
public:
virtual ~Name() override = default;
virtual const char* class_name() const override { return "Name"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
virtual bool is_name() const override { return true; }
virtual bool is_templatized() const { return false; }
@ -349,7 +349,7 @@ class NumericLiteral : public Expression {
public:
virtual ~NumericLiteral() override = default;
virtual const char* class_name() const override { return "NumricLiteral"; }
virtual void dump(size_t indent) const override;
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)
: Expression(parent, start, end, filename)
@ -364,7 +364,7 @@ class NullPointerLiteral : public Expression {
public:
virtual ~NullPointerLiteral() override = default;
virtual const char* class_name() const override { return "NullPointerLiteral"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
NullPointerLiteral(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
: Expression(parent, start, end, filename)
@ -376,7 +376,7 @@ class BooleanLiteral : public Expression {
public:
virtual ~BooleanLiteral() override = default;
virtual const char* class_name() const override { return "BooleanLiteral"; }
virtual void dump(size_t indent) const override;
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)
: Expression(parent, start, end, filename)
@ -418,7 +418,7 @@ public:
virtual ~BinaryExpression() override = default;
virtual const char* class_name() const override { return "BinaryExpression"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
BinaryOp m_op;
RefPtr<Expression> m_lhs;
@ -440,7 +440,7 @@ public:
virtual ~AssignmentExpression() override = default;
virtual const char* class_name() const override { return "AssignmentExpression"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
AssignmentOp m_op;
RefPtr<Expression> m_lhs;
@ -456,7 +456,7 @@ public:
virtual ~FunctionCall() override = default;
virtual const char* class_name() const override { return "FunctionCall"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
virtual bool is_function_call() const override { return true; }
virtual bool is_templatized() const { return false; }
@ -473,7 +473,7 @@ public:
~StringLiteral() override = default;
virtual const char* class_name() const override { return "StringLiteral"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
String m_value;
};
@ -487,7 +487,7 @@ public:
: Statement(parent, start, end, filename)
{
}
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
RefPtr<Expression> m_value;
};
@ -496,7 +496,7 @@ class EnumDeclaration : public Declaration {
public:
virtual ~EnumDeclaration() override = default;
virtual const char* class_name() const override { return "EnumDeclaration"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
EnumDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
: Declaration(parent, start, end, filename)
@ -510,7 +510,7 @@ class MemberDeclaration : public Declaration {
public:
virtual ~MemberDeclaration() override = default;
virtual const char* class_name() const override { return "MemberDeclaration"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
virtual bool is_member() const override { return true; }
MemberDeclaration(ASTNode* parent, Optional<Position> start, Optional<Position> end, const String& filename)
@ -526,7 +526,7 @@ class StructOrClassDeclaration : public Declaration {
public:
virtual ~StructOrClassDeclaration() override = default;
virtual const char* class_name() const override { return "StructOrClassDeclaration"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
virtual bool is_struct_or_class() const override { return true; }
virtual bool is_struct() const override { return m_type == Type::Struct; }
virtual bool is_class() const override { return m_type == Type::Class; }
@ -566,7 +566,7 @@ public:
virtual ~UnaryExpression() override = default;
virtual const char* class_name() const override { return "UnaryExpression"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
UnaryOp m_op;
RefPtr<Expression> m_lhs;
@ -581,7 +581,7 @@ public:
virtual ~MemberExpression() override = default;
virtual const char* class_name() const override { return "MemberExpression"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
virtual bool is_member_expression() const override { return true; }
RefPtr<Expression> m_object;
@ -597,7 +597,7 @@ public:
virtual ~ForStatement() override = default;
virtual const char* class_name() const override { return "ForStatement"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
virtual NonnullRefPtrVector<Declaration> declarations() const override;
@ -616,7 +616,7 @@ public:
virtual ~BlockStatement() override = default;
virtual const char* class_name() const override { return "BlockStatement"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
virtual NonnullRefPtrVector<Declaration> declarations() const override;
@ -643,7 +643,7 @@ public:
virtual ~IfStatement() override = default;
virtual const char* class_name() const override { return "IfStatement"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
virtual NonnullRefPtrVector<Declaration> declarations() const override;
RefPtr<Expression> m_predicate;
@ -655,7 +655,7 @@ class NamespaceDeclaration : public Declaration {
public:
virtual ~NamespaceDeclaration() override = default;
virtual const char* class_name() const override { return "NamespaceDeclaration"; }
virtual void dump(size_t indent) const override;
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)
@ -677,7 +677,7 @@ public:
virtual ~CppCastExpression() override = default;
virtual const char* class_name() const override { return "CppCastExpression"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
StringView m_cast_type;
RefPtr<Type> m_type;
@ -693,7 +693,7 @@ public:
virtual ~CStyleCastExpression() override = default;
virtual const char* class_name() const override { return "CStyleCastExpression"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
RefPtr<Type> m_type;
RefPtr<Expression> m_expression;
@ -708,7 +708,7 @@ public:
virtual ~SizeofExpression() override = default;
virtual const char* class_name() const override { return "SizeofExpression"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
RefPtr<Type> m_type;
};
@ -722,7 +722,7 @@ public:
virtual ~BracedInitList() override = default;
virtual const char* class_name() const override { return "BracedInitList"; }
virtual void dump(size_t indent) const override;
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
NonnullRefPtrVector<Expression> m_expressions;
};
@ -735,6 +735,6 @@ public:
}
virtual bool is_dummy_node() const override { return true; }
virtual const char* class_name() const override { return "DummyAstNode"; }
virtual void dump(size_t) const override { }
virtual void dump(FILE* = stdout, size_t = 0) const override { }
};
}

View file

@ -40,5 +40,5 @@ int main(int argc, char** argv)
dbgln("{}", error);
}
root->dump(0);
root->dump();
}