User Guide
for_netcon.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2023 Blue Brain Project, EPFL.
3  * See the top-level LICENSE file for details.
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 ///
9 /// THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
10 ///
11 
12 #pragma once
13 
14 /**
15  * \dir
16  * \brief Auto generated AST Implementations
17  *
18  * \file
19  * \brief Auto generated AST classes declaration
20  */
21 
22 #include "ast/ast_decl.hpp"
23 #include "ast/argument.hpp"
24 #include "ast/block.hpp"
25 
26 namespace nmodl::ast {
27 
28 /**
29  * \addtogroup ast_class
30  * \ingroup ast
31  * \{
32  */
33 
34 /**
35  * \brief TODO
36  *
37  *
38 */
39 class ForNetcon : public Block {
40  private:
41  /// Arguments to the for netcon block
43  /// Block with statements vector
44  std::shared_ptr<StatementBlock> statement_block;
45  /// token with location information
46  std::shared_ptr<ModToken> token;
47  /// symbol table for a block
49 
50  public:
51  /// \name Ctor & dtor
52  /// \{
54  explicit ForNetcon(const ArgumentVector& parameters, std::shared_ptr<StatementBlock> statement_block);
55  ForNetcon(const ForNetcon& obj);
56  virtual ~ForNetcon() = default;
57  /// \}
58 
59  /**
60  * \brief Check if the ast node is an instance of ast::ForNetcon
61  * \return true as object is of type ast::ForNetcon
62  */
63  bool is_for_netcon () const noexcept override {
64  return true;
65  }
66 
67  /**
68  * \brief Return a copy of the current node
69  *
70  * Recursively make a new copy/clone of the current node including
71  * all members and return a pointer to the node. This is used for
72  * passes like nmodl::visitor::InlineVisitor where nodes are cloned in the
73  * ast.
74  *
75  * \return pointer to the clone/copy of the current node
76  */
77  // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks)
78  ForNetcon* clone() const override {
79  return new ForNetcon(*this);
80  }
81  // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)
82 
83  /// \name Getters
84  /// \{
85 
86  /**
87  * \brief Return type (ast::AstNodeType) of ast node
88  *
89  * Every node in the ast has a type defined in ast::AstNodeType and this
90  * function is used to retrieve the same.
91  *
92  * \return ast node type i.e. ast::AstNodeType::FOR_NETCON
93  *
94  * \sa Ast::get_node_type_name
95  */
96  AstNodeType get_node_type() const noexcept override {
98  }
99 
100  /**
101  * \brief Return type (ast::AstNodeType) of ast node as std::string
102  *
103  * Every node in the ast has a type defined in ast::AstNodeType.
104  * This type name can be returned as a std::string for printing
105  * node to text/json form.
106  *
107  * \return name of the node type as a string i.e. "ForNetcon"
108  *
109  * \sa Ast::get_node_name
110  */
111  std::string get_node_type_name() const noexcept override {
112  return "ForNetcon";
113  }
114 
115  /**
116  * \brief Return NMODL statement of ast node as std::string
117  *
118  * Every node is related to a special statement in the NMODL. This
119  * statement can be returned as a std::string for printing to
120  * text/json form.
121  *
122  * \return name of the statement as a string i.e. "FOR_NETCONS "
123  *
124  * \sa Ast::get_nmodl_name
125  */
126  std::string get_nmodl_name() const noexcept override {
127  return "FOR_NETCONS ";
128  }
129 
130  /**
131  * \brief Get std::shared_ptr from `this` pointer of the current ast node
132  */
133  std::shared_ptr<Ast> get_shared_ptr() override {
134  return std::static_pointer_cast<ForNetcon>(shared_from_this());
135  }
136 
137  /**
138  * \brief Get std::shared_ptr from `this` pointer of the current ast node
139  */
140  std::shared_ptr<const Ast> get_shared_ptr() const override {
141  return std::static_pointer_cast<const ForNetcon>(shared_from_this());
142  }
143 
144  /**
145  * \brief Return associated token for the current ast node
146  *
147  * Not all ast nodes have token information. For example, nmodl::visitor::NeuronSolveVisitor
148  * can insert new nodes in the ast as a solution of ODEs. In this case, we return
149  * nullptr to store in the nmodl::symtab::SymbolTable.
150  *
151  * \return pointer to token if exist otherwise nullptr
152  */
153  const ModToken* get_token() const noexcept override {
154  return token.get();
155  }
156  /**
157  * \brief Return associated symbol table for the current ast node
158  *
159  * Only certain ast nodes (e.g. inherited from ast::Block) have associated
160  * symbol table. These nodes have nmodl::symtab::SymbolTable as member
161  * and it can be accessed using this method.
162  *
163  * \return pointer to the symbol table
164  *
165  * \sa nmodl::symtab::SymbolTable nmodl::visitor::SymtabVisitor
166  */
168  return symtab;
169  }
170 
171 
172 
173  /**
174  * \brief Getter for member variable \ref ForNetcon.parameters
175  */
176  const ArgumentVector& get_parameters() const noexcept override {
177  return parameters;
178  }
179 
180 
181 
182  /**
183  * \brief Getter for member variable \ref ForNetcon.statement_block
184  */
185  std::shared_ptr<StatementBlock> get_statement_block() const noexcept override {
186  return statement_block;
187  }
188  /// \}
189 
190  /// \name Setters
191  /// \{
192  /**
193  * \brief Set token for the current ast node
194  */
195  void set_token(const ModToken& tok) { token = std::make_shared<ModToken>(tok); }
196  /**
197  * \brief Set symbol table for the current ast node
198  *
199  * Top level, block scoped nodes store symbol table in the ast node.
200  * nmodl::visitor::SymtabVisitor then used this method to setup symbol table
201  * for every node in the ast.
202  *
203  * \sa nmodl::visitor::SymtabVisitor
204  */
205  void set_symbol_table(symtab::SymbolTable* newsymtab) override {
206  symtab = newsymtab;
207  }
208 
209  /**
210  * \brief Setter for member variable \ref ForNetcon.parameters (rvalue reference)
211  */
213 
214  /**
215  * \brief Setter for member variable \ref ForNetcon.parameters
216  */
218 
219 
220  /**
221  * \brief Setter for member variable \ref ForNetcon.statement_block (rvalue reference)
222  */
223  void set_statement_block(std::shared_ptr<StatementBlock>&& statement_block);
224 
225  /**
226  * \brief Setter for member variable \ref ForNetcon.statement_block
227  */
228  void set_statement_block(const std::shared_ptr<StatementBlock>& statement_block);
229 
230  /// \}
231 
232  /// \name Visitor
233  /// \{
234  /**
235  * \brief visit children i.e. member variables of current node using provided visitor
236  *
237  * Different nodes in the AST have different members (i.e. children). This method
238  * recursively visits children using provided visitor.
239  *
240  * \param v Concrete visitor that will be used to recursively visit children
241  *
242  * \sa Ast::visit_children for example.
243  */
244  void visit_children(visitor::Visitor& v) override;
245 
246  /**
247  * \brief visit children i.e. member variables of current node using provided visitor
248  *
249  * Different nodes in the AST have different members (i.e. children). This method
250  * recursively visits children using provided visitor.
251  *
252  * \param v Concrete constant visitor that will be used to recursively visit children
253  *
254  * \sa Ast::visit_children for example.
255  */
256  void visit_children(visitor::ConstVisitor& v) const override;
257 
258  /**
259  * \brief accept (or visit) the current AST node using provided visitor
260  *
261  * Instead of visiting children of AST node, like Ast::visit_children,
262  * accept allows to visit the current node itself using provided concrete
263  * visitor.
264  *
265  * \param v Concrete visitor that will be used to recursively visit node
266  *
267  * \sa Ast::accept for example.
268  */
269  void accept(visitor::Visitor& v) override;
270 
271  /**
272  * \copydoc accept(visitor::Visitor&)
273  */
274  void accept(visitor::ConstVisitor& v) const override;
275  /// \}
276 
277  private:
278  /**
279  * \brief Set this object as parent for all the children
280  *
281  * This should be called in every object (with children) constructor
282  * to set parents. Since it is called only in the constructors it
283  * should not be virtual to avoid ambiguities (issue #295).
284  */
285  void set_parent_in_children();
286 };
287 
288 /** \} */ // end of ast_class
289 
290 
291 
292 
293 } // namespace nmodl::ast
nmodl::visitor::ConstVisitor
Abstract base class for all constant visitors implementation.
Definition: visitor.hpp:298
nmodl::ast::ForNetcon::get_shared_ptr
std::shared_ptr< const Ast > get_shared_ptr() const override
Get std::shared_ptr from this pointer of the current ast node.
Definition: for_netcon.hpp:140
nmodl::ast::ForNetcon::set_parameters
void set_parameters(ArgumentVector &&parameters)
Setter for member variable ForNetcon::parameters (rvalue reference)
Definition: ast.cpp:5092
nmodl::ast::ForNetcon::is_for_netcon
bool is_for_netcon() const noexcept override
Check if the ast node is an instance of ast::ForNetcon.
Definition: for_netcon.hpp:63
nmodl::ast::ForNetcon::get_shared_ptr
std::shared_ptr< Ast > get_shared_ptr() override
Get std::shared_ptr from this pointer of the current ast node.
Definition: for_netcon.hpp:133
nmodl::ast::ForNetcon::get_node_type_name
std::string get_node_type_name() const noexcept override
Return type (ast::AstNodeType) of ast node as std::string.
Definition: for_netcon.hpp:111
nmodl::ast::ForNetcon::ForNetcon
ForNetcon(const ArgumentVector &parameters, StatementBlock *statement_block)
Definition: ast.cpp:5046
nmodl::ast::AstNodeType::FOR_NETCON
@ FOR_NETCON
type of ast::ForNetcon
nmodl::ast::ForNetcon::set_statement_block
void set_statement_block(std::shared_ptr< StatementBlock > &&statement_block)
Setter for member variable ForNetcon::statement_block (rvalue reference)
Definition: ast.cpp:5109
ast_decl.hpp
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::ast::ForNetcon::statement_block
std::shared_ptr< StatementBlock > statement_block
Block with statements vector.
Definition: for_netcon.hpp:44
block.hpp
Auto generated AST classes declaration.
nmodl::ast::ForNetcon::get_token
const ModToken * get_token() const noexcept override
Return associated token for the current ast node.
Definition: for_netcon.hpp:153
nmodl::ast
Abstract Syntax Tree (AST) related implementations.
Definition: ast_common.hpp:29
nmodl::ast::ForNetcon::parameters
ArgumentVector parameters
Arguments to the for netcon block.
Definition: for_netcon.hpp:42
nmodl::ast::ForNetcon::accept
void accept(visitor::Visitor &v) override
accept (or visit) the current AST node using provided visitor
Definition: ast.cpp:5037
nmodl::ast::AstNodeType
AstNodeType
Enum type for every AST node type.
Definition: ast_decl.hpp:164
nmodl::ast::ForNetcon::get_node_type
AstNodeType get_node_type() const noexcept override
Return type (ast::AstNodeType) of ast node.
Definition: for_netcon.hpp:96
nmodl::ast::Block
Base class for all block scoped nodes.
Definition: block.hpp:41
nmodl::ast::ArgumentVector
std::vector< std::shared_ptr< Argument > > ArgumentVector
Definition: ast_decl.hpp:312
nmodl::visitor::Visitor
Abstract base class for all visitors implementation.
Definition: visitor.hpp:39
nmodl::ast::ForNetcon::set_symbol_table
void set_symbol_table(symtab::SymbolTable *newsymtab) override
Set symbol table for the current ast node.
Definition: for_netcon.hpp:205
nmodl::ast::ForNetcon::get_symbol_table
symtab::SymbolTable * get_symbol_table() const override
Return associated symbol table for the current ast node.
Definition: for_netcon.hpp:167
nmodl::ast::ForNetcon::get_statement_block
std::shared_ptr< StatementBlock > get_statement_block() const noexcept override
Getter for member variable ForNetcon::statement_block.
Definition: for_netcon.hpp:185
nmodl::ast::ForNetcon::set_token
void set_token(const ModToken &tok)
Set token for the current ast node.
Definition: for_netcon.hpp:195
nmodl::ast::ForNetcon::set_parent_in_children
void set_parent_in_children()
Set this object as parent for all the children.
Definition: ast.cpp:5076
nmodl::symtab::SymbolTable
Represent symbol table for a NMODL block.
Definition: symbol_table.hpp:57
nmodl::ast::ForNetcon::token
std::shared_ptr< ModToken > token
token with location information
Definition: for_netcon.hpp:46
nmodl::ast::StatementBlock
Represents block encapsulating list of statements.
Definition: statement_block.hpp:53
nmodl::ast::ForNetcon
TODO.
Definition: for_netcon.hpp:39
nmodl::ast::ForNetcon::get_parameters
const ArgumentVector & get_parameters() const noexcept override
Getter for member variable ForNetcon::parameters.
Definition: for_netcon.hpp:176
nmodl::ast::ForNetcon::symtab
symtab::SymbolTable * symtab
symbol table for a block
Definition: for_netcon.hpp:48
nmodl::ast::ForNetcon::get_nmodl_name
std::string get_nmodl_name() const noexcept override
Return NMODL statement of ast node as std::string.
Definition: for_netcon.hpp:126
nmodl::ast::ForNetcon::clone
ForNetcon * clone() const override
Return a copy of the current node.
Definition: for_netcon.hpp:78
argument.hpp
Auto generated AST classes declaration.
nmodl::ast::ForNetcon::~ForNetcon
virtual ~ForNetcon()=default
nmodl::ModToken
Represent token returned by scanner.
Definition: modtoken.hpp:50
nmodl::ast::ForNetcon::visit_children
void visit_children(visitor::Visitor &v) override
visit children i.e.
Definition: ast.cpp:5015