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

            Line data    Source code
       1              : #include "../../../inc/parsingAnalysis/ast/utils/ast_import.h"
       2              : #include "../../../inc/parsingAnalysis/ast/utils/ast_print.h"
       3              : #include "../../../inc/visitors/typeAnalysis/typeAnalysis.h"
       4              : #include <memory>
       5              : 
       6              : namespace nicole {
       7              : 
       8              : /*
       9              : - comprueba que los tipos de los argumentos no sean void ni NoPropagate,
      10              : BreakType
      11              : - si es un userType comprueba que exista el metodo toStr()
      12              : - retorna NoPropagate
      13              :  */
      14              : std::expected<std::shared_ptr<Type>, Error>
      15            0 : TypeAnalysis::visit(const AST_PRINT *node) const noexcept {
      16            0 :   if (!node) {
      17            0 :     return createError(ERROR_TYPE::NULL_NODE, "invalid AST_PRINT");
      18            0 :   }
      19            0 :   for (const auto &expr : node->values()) {
      20            0 :     const auto result{expr->accept(*this)};
      21            0 :     if (!result) {
      22            0 :       return createError(result.error());
      23            0 :     }
      24              : 
      25            0 :     auto exprType = result.value();
      26              : 
      27            0 :     if (insideDeclWithGenerics &&
      28            0 :         typeTable_->isGenericType(exprType, currentGenericList_))
      29            0 :       continue;
      30              : 
      31            0 :     if (auto userType = std::dynamic_pointer_cast<UserType>(exprType)) {
      32            0 :       const auto exists = typeTable_->getType(userType->name());
      33            0 :       if (!exists) {
      34            0 :         return createError(exists.error());
      35            0 :       }
      36            0 :       auto methodsExp = std::dynamic_pointer_cast<UserType>(*exists)
      37            0 :                             ->getMethods("toString");
      38            0 :       if (!methodsExp) {
      39            0 :         return createError(methodsExp.error());
      40            0 :       }
      41            0 :       if (methodsExp.value().empty())
      42            0 :         return createError(ERROR_TYPE::TYPE, "User type " + userType->name() +
      43            0 :                                                  " must implement toString()");
      44            0 :     }
      45            0 :   }
      46            0 :   node->setReturnedFromAnalysis(typeTable_->noPropagateType());
      47            0 :   return typeTable_->noPropagateType();
      48            0 : }
      49              : 
      50              : /*
      51              : - retorna NoPropagate
      52              : */
      53              : std::expected<std::shared_ptr<Type>, Error>
      54            0 : TypeAnalysis::visit(const AST_IMPORT *node) const noexcept {
      55            0 :   if (!node) {
      56            0 :     return createError(ERROR_TYPE::NULL_NODE, "invalid AST_IMPORT");
      57            0 :   }
      58            0 :   node->setReturnedFromAnalysis(typeTable_->noPropagateType());
      59            0 :   return typeTable_->noPropagateType();
      60            0 : }
      61              : 
      62              : } // namespace nicole
        

Generated by: LCOV version 2.0-1