LCOV - code coverage report
Current view: top level - src/visitors/printTree - printTreeVarDecl.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 48 0
Test Date: 2025-04-18 15:53:49 Functions: 0.0 % 3 0

            Line data    Source code
       1              : #include "../../../inc/visitors/printTree/printTree.h"
       2              : #include "../../../inc/parsingAnalysis/ast/variables/ast_autoDecl.h"
       3              : #include "../../../inc/parsingAnalysis/ast/variables/ast_typedDecl.h"
       4              : #include "../../../inc/parsingAnalysis/ast/variables/ast_varCall.h"
       5              : #include <ostream>
       6              : 
       7              : namespace nicole {
       8              : 
       9              : std::expected<std::string, Error>
      10            0 : PrintTree::visit(const AST_AUTO_DECL *node) const noexcept {
      11            0 :   if (!node) {
      12            0 :     return createError(ERROR_TYPE::NULL_NODE, "invalid AST_AUTO_DECL");
      13            0 :   }
      14            0 :   std::ostringstream result;
      15            0 :   result << indent_ << "auto decl\n";
      16            0 :   increaseIndent();
      17            0 :   result << indent_ << "id: " << node->id() << "\n";
      18            0 :   result << indent_ << "const: " << ((node->isConst()) ? "true" : "false")
      19            0 :          << "\n";
      20            0 :   result << indent_ << "value:\n";
      21            0 :   const auto val{node->value()->accept(*this)};
      22            0 :   if (!val) {
      23            0 :     return createError(val.error());
      24            0 :   }
      25            0 :   result << *val << "\n";
      26            0 :   decreaseIndent();
      27            0 :   return result.str();
      28            0 : }
      29              : 
      30              : std::expected<std::string, Error>
      31            0 : PrintTree::visit(const AST_VAR_TYPED_DECL *node) const noexcept {
      32            0 :   if (!node) {
      33            0 :     return createError(ERROR_TYPE::NULL_NODE, "invalid AST_VAR_TYPED_DECL");
      34            0 :   }
      35            0 :   std::ostringstream result;
      36            0 :   result << indent_ << "var typed decl\n";
      37            0 :   increaseIndent();
      38            0 :   result << indent_ << "id: " << node->id() << "\n";
      39            0 :   result << indent_ << "type: " << node->varType()->toString() << "\n";
      40            0 :   result << indent_ << "value:\n";
      41            0 :   const auto val{node->value()->accept(*this)};
      42            0 :   if (!val) {
      43            0 :     return createError(val.error());
      44            0 :   }
      45            0 :   result << *val << "\n";
      46            0 :   decreaseIndent();
      47            0 :   return result.str();
      48            0 : }
      49              : 
      50              : std::expected<std::string, Error>
      51            0 : PrintTree::visit(const AST_VAR_CALL *node) const noexcept {
      52            0 :   if (!node) {
      53            0 :     return createError(ERROR_TYPE::NULL_NODE, "invalid AST_VAR_CALL");
      54            0 :   }
      55            0 :   std::ostringstream result;
      56            0 :   result << indent_ << "Var call\n";
      57            0 :   increaseIndent();
      58            0 :   result << indent_ << "id: " << node->id() << "\n";
      59            0 :   decreaseIndent();
      60            0 :   return result.str();
      61            0 : }
      62              : 
      63              : }
        

Generated by: LCOV version 2.0-1