LCOV - code coverage report
Current view: top level - inc/tables/scope - scope.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 4 0
Test Date: 2025-04-18 15:53:49 Functions: 0.0 % 2 0

            Line data    Source code
       1              : #ifndef SCOPE_H
       2              : #define SCOPE_H
       3              : 
       4              : #include "../../errors.h"
       5              : #include "variable.h"
       6              : #include <expected>
       7              : #include <iostream>
       8              : #include <memory>
       9              : #include <ostream>
      10              : #include <string>
      11              : #include <unordered_map>
      12              : 
      13              : namespace nicole {
      14              : 
      15              : class Scope final {
      16              : private:
      17              :   mutable std::unordered_map<std::string, Variable> table_;
      18              :   std::shared_ptr<Scope> father_;
      19              : 
      20              : public:
      21              :   explicit Scope(const std::shared_ptr<Scope> &father) noexcept
      22            0 :       : father_{father} {}
      23              : 
      24            0 :   [[nodiscard]] const std::shared_ptr<Scope> &father() const noexcept {
      25            0 :     return father_;
      26            0 :   }
      27              : 
      28              :   [[nodiscard]] bool has(const std::string &id) const noexcept;
      29              : 
      30              :   [[nodiscard]] const std::expected<Variable, Error>
      31              :   getVariable(const std::string &id) const noexcept;
      32              : 
      33              :   [[nodiscard]] std::expected<std::monostate, Error>
      34              :   insert(const Variable &variable) noexcept;
      35              : 
      36              :   std::expected<std::monostate, Error>
      37              :   setVariableType(const std::string &id,
      38              :                   const std::shared_ptr<Type> &type) const noexcept;
      39              : 
      40              :   friend std::ostream &operator<<(std::ostream &os,
      41              :                                   const Scope &scope) noexcept;
      42              : 
      43              : }; // namespace nicole
      44              : 
      45              : } // namespace nicole
      46              : 
      47              : #endif
        

Generated by: LCOV version 2.0-1