User Guide
function_callpath_visitor.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2024 Blue Brain Project, EPFL.
3  * See the top-level LICENSE file for details.
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #pragma once
9 
10 /**
11  * \file
12  * \brief \copybrief nmodl::visitor::FunctionCallpathVisitor
13  */
14 
15 #include "ast/all.hpp"
16 #include "symtab/decl.hpp"
17 #include "visitors/ast_visitor.hpp"
18 
19 namespace nmodl {
20 namespace visitor {
21 
22 /**
23  * \addtogroup visitor_classes
24  * \{
25  */
26 
27 /**
28  * \class FunctionCallpathVisitor
29  * \brief %Visitor for traversing \c FunctionBlock s and \c ProcedureBlocks through
30  * their \c FunctionCall s
31  *
32  * This visitor is used to traverse the \c FUNCTION s and \c PROCEDURE s in the NMODL files.
33  * It visits the \c FunctionBlock s and \c ProcedureBlock s and if there is a \c FunctionCall
34  * in those, it visits the \c FunctionBlock or \c ProcedureBlock of the \c FunctionCall.
35  * Currently it only checks whether in this path of function calls there is any use of \c RANGE ,
36  * \c POINTER or \c BBCOREPOINTER variable. In case there is it adds the \c use_range_ptr_var
37  * property in the \c Symbol of the function or procedure in the program \c SymbolTable and does the
38  * same recursively for all the caller functions. The \c use_range_ptr_var property is used later in
39  * the \c CodegenNeuronCppVisitor .
40  *
41  */
43  private:
44  /// Vector of currently visited functions or procedures (used as a searchable stack)
45  std::vector<const ast::Block*> visited_functions_or_procedures;
46 
47  /// symbol table for the program
49 
50  public:
51  void visit_var_name(const ast::VarName& node) override;
52 
53  void visit_function_call(const ast::FunctionCall& node) override;
54 
55  void visit_function_block(const ast::FunctionBlock& node) override;
56 
57  void visit_procedure_block(const ast::ProcedureBlock& node) override;
58 
59  void visit_program(const ast::Program& node) override;
60 };
61 
62 /** \} */ // end of visitor_classes
63 
64 } // namespace visitor
65 } // namespace nmodl
nmodl::visitor::ConstAstVisitor
Concrete constant visitor for all AST classes.
Definition: ast_visitor.hpp:168
nmodl::ast::FunctionBlock
TODO.
Definition: function_block.hpp:39
nmodl::visitor::FunctionCallpathVisitor::visit_function_block
void visit_function_block(const ast::FunctionBlock &node) override
visit node of type ast::FunctionBlock
Definition: function_callpath_visitor.cpp:77
nmodl::visitor::FunctionCallpathVisitor::visit_program
void visit_program(const ast::Program &node) override
visit node of type ast::Program
Definition: function_callpath_visitor.cpp:89
nmodl
encapsulates code generation backend implementations
Definition: ast_common.hpp:26
nmodl::ast::VarName
Represents a variable.
Definition: var_name.hpp:43
nmodl::visitor::FunctionCallpathVisitor::visited_functions_or_procedures
std::vector< const ast::Block * > visited_functions_or_procedures
Vector of currently visited functions or procedures (used as a searchable stack)
Definition: function_callpath_visitor.hpp:45
nmodl::ast::FunctionCall
TODO.
Definition: function_call.hpp:38
nmodl::visitor::FunctionCallpathVisitor
Visitor for traversing FunctionBlock s and ProcedureBlocks through their FunctionCall s
Definition: function_callpath_visitor.hpp:42
nmodl::symtab::SymbolTable
Represent symbol table for a NMODL block.
Definition: symbol_table.hpp:57
nmodl::visitor::FunctionCallpathVisitor::psymtab
symtab::SymbolTable * psymtab
symbol table for the program
Definition: function_callpath_visitor.hpp:48
nmodl::ast::ProcedureBlock
TODO.
Definition: procedure_block.hpp:39
nmodl::visitor::FunctionCallpathVisitor::visit_var_name
void visit_var_name(const ast::VarName &node) override
visit node of type ast::VarName
Definition: function_callpath_visitor.cpp:17
nmodl::visitor::FunctionCallpathVisitor::visit_function_call
void visit_function_call(const ast::FunctionCall &node) override
visit node of type ast::FunctionCall
Definition: function_callpath_visitor.cpp:38
nmodl::ast::Program
Represents top level AST node for whole NMODL input.
Definition: program.hpp:39
decl.hpp
Forward declarations of symbols in namespace nmodl::symtab.
nmodl::visitor::FunctionCallpathVisitor::visit_procedure_block
void visit_procedure_block(const ast::ProcedureBlock &node) override
visit node of type ast::ProcedureBlock
Definition: function_callpath_visitor.cpp:65
all.hpp
Auto generated AST classes declaration.
ast_visitor.hpp
Concrete visitor for all AST classes.