diff options
Diffstat (limited to 'Userland/Libraries/LibCpp/AST.cpp')
-rw-r--r-- | Userland/Libraries/LibCpp/AST.cpp | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/Userland/Libraries/LibCpp/AST.cpp b/Userland/Libraries/LibCpp/AST.cpp index b19689baab..68f24da944 100644 --- a/Userland/Libraries/LibCpp/AST.cpp +++ b/Userland/Libraries/LibCpp/AST.cpp @@ -32,13 +32,13 @@ namespace Cpp { static void print_indent(int indent) { for (int i = 0; i < indent * 2; ++i) - dbgprintf(" "); + out(" "); } void ASTNode::dump(size_t indent) const { print_indent(indent); - dbgprintf("%s[%lu:%lu->%lu:%lu]\n", class_name(), start().line, start().column, end().line, end().column); + outln("{}[{}:{}->{}:{}]", class_name(), start().line, start().column, end().line, end().column); } void TranslationUnit::dump(size_t indent) const @@ -55,15 +55,15 @@ void FunctionDeclaration::dump(size_t indent) const m_return_type->dump(indent + 1); if (!m_name.is_null()) { print_indent(indent + 1); - dbgprintf("%s\n", m_name.to_string().characters()); + outln("{}", m_name); } print_indent(indent + 1); - dbgprintf("(\n"); + outln("("); for (const auto& arg : m_parameters) { arg.dump(indent + 1); } print_indent(indent + 1); - dbgprintf(")\n"); + outln(")"); if (!m_definition.is_null()) { m_definition->dump(indent + 1); } @@ -82,7 +82,7 @@ void Type::dump(size_t indent) const { ASTNode::dump(indent); print_indent(indent + 1); - dbgprintf("%s\n", m_name.to_string().characters()); + outln("{}", m_name); } void Parameter::dump(size_t indent) const @@ -90,23 +90,21 @@ void Parameter::dump(size_t indent) const ASTNode::dump(indent); if (!m_name.is_null()) { print_indent(indent); - dbgprintf("%s\n", m_name.to_string().characters()); + outln("{}", m_name); } m_type->dump(indent + 1); - // print_indent(indent); - // dbgprintf("%s [%s]\n", m_name.is_null() ? "" : m_name.to_string().characters(), m_type->name().to_string().characters()); } void FunctionDefinition::dump(size_t indent) const { ASTNode::dump(indent); print_indent(indent); - dbgprintf("{\n"); + outln("{"); for (const auto& statement : m_statements) { statement.dump(indent + 1); } print_indent(indent); - dbgprintf("}\n"); + outln("}"); } NonnullRefPtrVector<Declaration> FunctionDefinition::declarations() const @@ -123,7 +121,7 @@ void VariableDeclaration::dump(size_t indent) const ASTNode::dump(indent); m_type->dump(indent + 1); print_indent(indent + 1); - dbgprintf("%s\n", m_name.to_string().characters()); + outln("{}", m_name); if (m_initial_value) m_initial_value->dump(indent + 1); } @@ -132,14 +130,14 @@ void Identifier::dump(size_t indent) const { ASTNode::dump(indent); print_indent(indent); - dbgprintf("%s\n", m_name.to_string().characters()); + outln("{}", m_name); } void NumericLiteral::dump(size_t indent) const { ASTNode::dump(indent); print_indent(indent); - dbgprintf("%s\n", m_value.to_string().characters()); + outln("{}", m_value); } void BinaryExpression::dump(size_t indent) const @@ -195,7 +193,7 @@ void BinaryExpression::dump(size_t indent) const m_lhs->dump(indent + 1); print_indent(indent + 1); ASSERT(op_string); - dbgprintf("%s\n", op_string); + outln("{}", op_string); m_rhs->dump(indent + 1); } @@ -219,7 +217,7 @@ void AssignmentExpression::dump(size_t indent) const m_lhs->dump(indent + 1); print_indent(indent + 1); ASSERT(op_string); - dbgprintf("%s\n", op_string); + outln("{}"); m_rhs->dump(indent + 1); } @@ -227,7 +225,7 @@ void FunctionCall::dump(size_t indent) const { ASTNode::dump(indent); print_indent(indent); - dbgprintf("%s\n", m_name.to_string().characters()); + outln("{}", m_name); for (const auto& arg : m_arguments) { arg.dump(indent + 1); } @@ -237,7 +235,7 @@ void StringLiteral::dump(size_t indent) const { ASTNode::dump(indent); print_indent(indent + 1); - dbgprintf("%s\n", m_value.to_string().characters()); + outln("{}", m_value); } void ReturnStatement::dump(size_t indent) const @@ -250,10 +248,10 @@ void EnumDeclaration::dump(size_t indent) const { ASTNode::dump(indent); print_indent(indent); - dbgprintf("%s\n", m_name.to_string().characters()); + outln("{}", m_name); for (auto& entry : m_entries) { print_indent(indent + 1); - dbgprintf("%s\n", entry.to_string().characters()); + outln("{}", entry); } } @@ -261,7 +259,7 @@ void StructOrClassDeclaration::dump(size_t indent) const { ASTNode::dump(indent); print_indent(indent); - dbgprintf("%s\n", m_name.to_string().characters()); + outln("{}", m_name); for (auto& member : m_members) { member.dump(indent + 1); } @@ -272,7 +270,7 @@ void MemberDeclaration::dump(size_t indent) const ASTNode::dump(indent); m_type->dump(indent + 1); print_indent(indent + 1); - dbgprintf("%s\n", m_name.to_string().characters()); + outln("{}", m_name); if (m_initial_value) { m_initial_value->dump(indent + 2); } @@ -305,7 +303,7 @@ void UnaryExpression::dump(size_t indent) const ASSERT(op_string); print_indent(indent + 1); - dbgprintf("%s\n", op_string); + outln("{}", op_string); m_lhs->dump(indent + 1); } @@ -313,7 +311,7 @@ void BooleanLiteral::dump(size_t indent) const { ASTNode::dump(indent); print_indent(indent + 1); - dbgprintf("%s\n", m_value ? "true" : "false"); + outln("{}", m_value ? "true" : "false"); } void Pointer::dump(size_t indent) const @@ -384,17 +382,17 @@ void IfStatement::dump(size_t indent) const ASTNode::dump(indent); if (m_predicate) { print_indent(indent + 1); - dbgprintf("Predicate:\n"); + outln("Predicate:"); m_predicate->dump(indent + 1); } if (m_then) { print_indent(indent + 1); - dbgprintf("Then:\n"); + outln("Then:"); m_then->dump(indent + 1); } if (m_else) { print_indent(indent + 1); - dbgprintf("Else:\n"); + outln("Else:"); m_else->dump(indent + 1); } } |