<commit_before>//! \file
/*
**  Copyright (C) - Triton
**
**  This program is under the terms of the LGPLv3 License.
*/

#ifndef TRITON_ASTGARBAGECOLLECTOR_H
#define TRITON_ASTGARBAGECOLLECTOR_H

#include <set>
#include <string>

#include "ast.hpp"
#include "symbolicEnums.hpp"
#include "tritonTypes.hpp"



//! \module The Triton namespace
namespace triton {
/*!
 *  \addtogroup triton
 *  @{
 */

  //! \module The AST namespace
  namespace ast {
  /*!
   *  \ingroup triton
   *  \addtogroup ast
   *  @{
   */

    //! \class AstGarbageCollector
    /*! \brief The AST garbage collector class */
    class AstGarbageCollector {
      protected:
        /* This container contains all allocated nodes. */
        std::set<triton::ast::AbstractNode*> allocatedNodes;

        /* This map maintains a link between symbolic variables and their nodes. */
        std::map<std::string, triton::ast::AbstractNode*> variableNodes;


      public:
        //! Constructor.
        AstGarbageCollector();

        //! Destructor.
        ~AstGarbageCollector();

        //! Go through every allocated nodes and free them.
        void freeAllAstNodes(void);

        //! Frees a set of nodes and removes them from the global container.
        void freeAstNodes(std::set<triton::ast::AbstractNode*>& nodes);

        //! Extracts all unique nodes from a partial AST into the uniqueNodes set.
        void extractUniqueAstNodes(std::set<triton::ast::AbstractNode*>& uniqueNodes, triton::ast::AbstractNode* root);

        //! Records the allocated node or returns the same node if it already exists inside the dictionaries.
        triton::ast::AbstractNode* recordAstNode(triton::ast::AbstractNode* node);

        //! Records a variable AST node.
        void recordVariableAstNode(std::string& name, triton::ast::AbstractNode* node);

        //! Returns all allocated nodes.
        std::set<triton::ast::AbstractNode*> getAllocatedAstNodes(void);

        //! Returns all variable nodes recorded.
        std::map<std::string, triton::ast::AbstractNode*> getAstVariableNodes(void);

        //! Returns the node of a recorded variable.
        triton::ast::AbstractNode* getAstVariableNode(std::string& name);

        //! Sets all allocated nodes.
        void setAllocatedAstNodes(std::set<triton::ast::AbstractNode*> nodes);

        //! Sets all variable nodes recorded.
        void setAstVariableNodes(std::map<std::string, triton::ast::AbstractNode*> nodes);
    };

  /*! @} End of ast namespace */
  };
/*! @} End of triton namespace */
};

#endif /* TRITON_ASTGARBAGECOLLECTOR_H */

<commit_msg>Update doxygen comment<commit_after>//! \file
/*
**  Copyright (C) - Triton
**
**  This program is under the terms of the LGPLv3 License.
*/

#ifndef TRITON_ASTGARBAGECOLLECTOR_H
#define TRITON_ASTGARBAGECOLLECTOR_H

#include <set>
#include <string>

#include "ast.hpp"
#include "symbolicEnums.hpp"
#include "tritonTypes.hpp"



//! \module The Triton namespace
namespace triton {
/*!
 *  \addtogroup triton
 *  @{
 */

  //! \module The AST namespace
  namespace ast {
  /*!
   *  \ingroup triton
   *  \addtogroup ast
   *  @{
   */

    //! \class AstGarbageCollector
    /*! \brief The AST garbage collector class */
    class AstGarbageCollector {
      protected:
        //! This container contains all allocated nodes.
        std::set<triton::ast::AbstractNode*> allocatedNodes;

        //! This map maintains a link between symbolic variables and their nodes.
        std::map<std::string, triton::ast::AbstractNode*> variableNodes;


      public:
        //! Constructor.
        AstGarbageCollector();

        //! Destructor.
        ~AstGarbageCollector();

        //! Go through every allocated nodes and free them.
        void freeAllAstNodes(void);

        //! Frees a set of nodes and removes them from the global container.
        void freeAstNodes(std::set<triton::ast::AbstractNode*>& nodes);

        //! Extracts all unique nodes from a partial AST into the uniqueNodes set.
        void extractUniqueAstNodes(std::set<triton::ast::AbstractNode*>& uniqueNodes, triton::ast::AbstractNode* root);

        //! Records the allocated node or returns the same node if it already exists inside the dictionaries.
        triton::ast::AbstractNode* recordAstNode(triton::ast::AbstractNode* node);

        //! Records a variable AST node.
        void recordVariableAstNode(std::string& name, triton::ast::AbstractNode* node);

        //! Returns all allocated nodes.
        std::set<triton::ast::AbstractNode*> getAllocatedAstNodes(void);

        //! Returns all variable nodes recorded.
        std::map<std::string, triton::ast::AbstractNode*> getAstVariableNodes(void);

        //! Returns the node of a recorded variable.
        triton::ast::AbstractNode* getAstVariableNode(std::string& name);

        //! Sets all allocated nodes.
        void setAllocatedAstNodes(std::set<triton::ast::AbstractNode*> nodes);

        //! Sets all variable nodes recorded.
        void setAstVariableNodes(std::map<std::string, triton::ast::AbstractNode*> nodes);
    };

  /*! @} End of ast namespace */
  };
/*! @} End of triton namespace */
};

#endif /* TRITON_ASTGARBAGECOLLECTOR_H */


{'fraction_non_alphanumeric': 0.12392096681373489, 'fraction_numerical': 0.0003836562440053712, 'mean_word_length': 3.0449961210240497, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5208790', 'n_tokens_mistral': 1598, 'n_tokens_neox': 1470, 'n_words': 414}