LCOV - code coverage report
Current view: top level - src/parsingAnalysis - checkPosition.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 65 0
Test Date: 2025-04-18 15:53:49 Functions: 0.0 % 7 0

            Line data    Source code
       1              : #include "../../inc/parsingAnalysis/checkPosition.h"
       2              : #include <cstddef>
       3              : 
       4              : namespace nicole {
       5              : 
       6              : bool CheckPosition::hasAnyAncestorOf(
       7            0 :     const AST *node, const std::unordered_set<AST_TYPE> &possibles) noexcept {
       8            0 :   auto auxiliar{node};
       9            0 :   while (auxiliar->father()) {
      10            0 :     auxiliar = auxiliar->father().get();
      11            0 :     if (possibles.count(auxiliar->type())) {
      12            0 :       return true;
      13            0 :     }
      14            0 :   }
      15            0 :   return false;
      16            0 : }
      17              : 
      18              : bool CheckPosition::hasEveryAncestorInOrder(
      19            0 :     const AST *node, const std::vector<AST_TYPE> &possibles) noexcept {
      20            0 :   auto auxiliar{node};
      21            0 :   size_t index{0};
      22            0 :   while (auxiliar->father() and index < possibles.size()) {
      23            0 :     auxiliar = auxiliar->father().get();
      24            0 :     if (auxiliar->type() != possibles[index]) {
      25            0 :       return false;
      26            0 :     }
      27            0 :     ++index;
      28            0 :   }
      29            0 :   return true;
      30            0 : }
      31              : 
      32            0 : bool CheckPosition::itsBodyAncestorHasParent(const AST *node) noexcept {
      33            0 :   std::shared_ptr<AST> father{nullptr};
      34            0 :   if (!node->father()) {
      35            0 :     return false;
      36            0 :   }
      37            0 :   father = node->father();
      38            0 :   if (father->type() != AST_TYPE::STATEMENT) {
      39            0 :     return false;
      40            0 :   }
      41            0 :   if (!father->father()) {
      42            0 :     return false;
      43            0 :   }
      44            0 :   father = father->father();
      45            0 :   if (father->type() != AST_TYPE::BODY) {
      46            0 :     return false;
      47            0 :   }
      48            0 :   if (!father->father()) {
      49            0 :     return false;
      50            0 :   }
      51            0 :   return true;
      52            0 : }
      53              : 
      54            0 : bool CheckPosition::isInsideForHeader(const AST *node) noexcept {
      55            0 :   return (node->father() and node->father()->type() == AST_TYPE::FOR) ? true
      56            0 :                                                                       : false;
      57            0 : }
      58              : 
      59            0 : bool CheckPosition::hasLoopAncestor(const AST *node) noexcept {
      60            0 :   return hasAnyAncestorOf(node,
      61            0 :                           {AST_TYPE::WHILE, AST_TYPE::FOR, AST_TYPE::DO_WHILE});
      62            0 : }
      63              : 
      64            0 : bool CheckPosition::hasAssigmentOrDeclAncestor(const AST *node) noexcept {
      65            0 :   return hasAnyAncestorOf(node, {AST_TYPE::AUTO_DECL, AST_TYPE::VAR_TYPED_DECL,
      66            0 :                                  AST_TYPE::ASSIGNMENT});
      67            0 : }
      68              : 
      69            0 : bool CheckPosition::isOutOfScope(const AST *node) noexcept {
      70            0 :   auto auxiliar{node};
      71            0 :   while (auxiliar->father()) {
      72            0 :     auxiliar = auxiliar->father().get();
      73            0 :     if (auxiliar->type() == AST_TYPE::BODY and auxiliar->father()) {
      74            0 :       return false;
      75            0 :     }
      76            0 :   }
      77            0 :   return true;
      78            0 : }
      79              : 
      80              : } // namespace nicole
        

Generated by: LCOV version 2.0-1