User Guide
function_table_block.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 FunctionTableBlock : public Block {
40  private:
41  /// Name of the function table block
42  std::shared_ptr<Name> name;
43  /// Vector of the parameters
45  /// Unit if specified
46  std::shared_ptr<Unit> unit;
47  /// token with location information
48  std::shared_ptr<ModToken> token;
49  /// symbol table for a block
51 
52  public:
53  /// \name Ctor & dtor
54  /// \{
56  explicit FunctionTableBlock(std::shared_ptr<Name> name, const ArgumentVector& parameters, std::shared_ptr<Unit> unit);
58  virtual ~FunctionTableBlock() = default;
59  /// \}
60 
61  /**
62  * \brief Check if the ast node is an instance of ast::FunctionTableBlock
63  * \return true as object is of type ast::FunctionTableBlock
64  */
65  bool is_function_table_block () const noexcept override {
66  return true;
67  }
68 
69  /**
70  * \brief Return a copy of the current node
71  *
72  * Recursively make a new copy/clone of the current node including
73  * all members and return a pointer to the node. This is used for
74  * passes like nmodl::visitor::InlineVisitor where nodes are cloned in the
75  * ast.
76  *
77  * \return pointer to the clone/copy of the current node
78  */
79  // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks)
80  FunctionTableBlock* clone() const override {
81  return new FunctionTableBlock(*this);
82  }
83  // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)
84 
85  /// \name Getters
86  /// \{
87 
88  /**
89  * \brief Return type (ast::AstNodeType) of ast node
90  *
91  * Every node in the ast has a type defined in ast::AstNodeType and this
92  * function is used to retrieve the same.
93  *
94  * \return ast node type i.e. ast::AstNodeType::FUNCTION_TABLE_BLOCK
95  *
96  * \sa Ast::get_node_type_name
97  */
98  AstNodeType get_node_type() const noexcept override {
100  }
101 
102  /**
103  * \brief Return type (ast::AstNodeType) of ast node as std::string
104  *
105  * Every node in the ast has a type defined in ast::AstNodeType.
106  * This type name can be returned as a std::string for printing
107  * node to text/json form.
108  *
109  * \return name of the node type as a string i.e. "FunctionTableBlock"
110  *
111  * \sa Ast::get_node_name
112  */
113  std::string get_node_type_name() const noexcept override {
114  return "FunctionTableBlock";
115  }
116 
117  /**
118  * \brief Return NMODL statement of ast node as std::string
119  *
120  * Every node is related to a special statement in the NMODL. This
121  * statement can be returned as a std::string for printing to
122  * text/json form.
123  *
124  * \return name of the statement as a string i.e. "FUNCTION_TABLE "
125  *
126  * \sa Ast::get_nmodl_name
127  */
128  std::string get_nmodl_name() const noexcept override {
129  return "FUNCTION_TABLE ";
130  }
131 
132  /**
133  * \brief Get std::shared_ptr from `this` pointer of the current ast node
134  */
135  std::shared_ptr<Ast> get_shared_ptr() override {
136  return std::static_pointer_cast<FunctionTableBlock>(shared_from_this());
137  }
138 
139  /**
140  * \brief Get std::shared_ptr from `this` pointer of the current ast node
141  */
142  std::shared_ptr<const Ast> get_shared_ptr() const override {
143  return std::static_pointer_cast<const FunctionTableBlock>(shared_from_this());
144  }
145 
146  /**
147  * \brief Return associated token for the current ast node
148  *
149  * Not all ast nodes have token information. For example, nmodl::visitor::NeuronSolveVisitor
150  * can insert new nodes in the ast as a solution of ODEs. In this case, we return
151  * nullptr to store in the nmodl::symtab::SymbolTable.
152  *
153  * \return pointer to token if exist otherwise nullptr
154  */
155  const ModToken* get_token() const noexcept override {
156  return token.get();
157  }
158  /**
159  * \brief Return associated symbol table for the current ast node
160  *
161  * Only certain ast nodes (e.g. inherited from ast::Block) have associated
162  * symbol table. These nodes have nmodl::symtab::SymbolTable as member
163  * and it can be accessed using this method.
164  *
165  * \return pointer to the symbol table
166  *
167  * \sa nmodl::symtab::SymbolTable nmodl::visitor::SymtabVisitor
168  */
170  return symtab;
171  }
172 
173 
174  /**
175  * \brief Return name of the node
176  *
177  * Some ast nodes have a member marked designated as node name. For example,
178  * in case of this ast::Name has name designated as a
179  * node name.
180  *
181  * \return name of the node as std::string
182  *
183  * \sa Ast::get_node_type_name
184  */
185  std::string get_node_name() const override;
186 
187  /**
188  * \brief Getter for member variable \ref FunctionTableBlock.name
189  */
190  std::shared_ptr<Name> get_name() const noexcept {
191  return name;
192  }
193 
194 
195 
196  /**
197  * \brief Getter for member variable \ref FunctionTableBlock.parameters
198  */
199  const ArgumentVector& get_parameters() const noexcept override {
200  return parameters;
201  }
202 
203 
204 
205  /**
206  * \brief Getter for member variable \ref FunctionTableBlock.unit
207  */
208  std::shared_ptr<Unit> get_unit() const noexcept {
209  return unit;
210  }
211  /// \}
212 
213  /// \name Setters
214  /// \{
215  /**
216  * \brief Set token for the current ast node
217  */
218  void set_token(const ModToken& tok) { token = std::make_shared<ModToken>(tok); }
219  /**
220  * \brief Set symbol table for the current ast node
221  *
222  * Top level, block scoped nodes store symbol table in the ast node.
223  * nmodl::visitor::SymtabVisitor then used this method to setup symbol table
224  * for every node in the ast.
225  *
226  * \sa nmodl::visitor::SymtabVisitor
227  */
228  void set_symbol_table(symtab::SymbolTable* newsymtab) override {
229  symtab = newsymtab;
230  }
231 
232  /**
233  * \brief Setter for member variable \ref FunctionTableBlock.name (rvalue reference)
234  */
235  void set_name(std::shared_ptr<Name>&& name);
236 
237  /**
238  * \brief Setter for member variable \ref FunctionTableBlock.name
239  */
240  void set_name(const std::shared_ptr<Name>& name);
241 
242 
243  /**
244  * \brief Setter for member variable \ref FunctionTableBlock.parameters (rvalue reference)
245  */
247 
248  /**
249  * \brief Setter for member variable \ref FunctionTableBlock.parameters
250  */
252 
253 
254  /**
255  * \brief Setter for member variable \ref FunctionTableBlock.unit (rvalue reference)
256  */
257  void set_unit(std::shared_ptr<Unit>&& unit);
258 
259  /**
260  * \brief Setter for member variable \ref FunctionTableBlock.unit
261  */
262  void set_unit(const std::shared_ptr<Unit>& unit);
263 
264  /// \}
265 
266  /// \name Visitor
267  /// \{
268  /**
269  * \brief visit children i.e. member variables of current node using provided visitor
270  *
271  * Different nodes in the AST have different members (i.e. children). This method
272  * recursively visits children using provided visitor.
273  *
274  * \param v Concrete visitor that will be used to recursively visit children
275  *
276  * \sa Ast::visit_children for example.
277  */
278  void visit_children(visitor::Visitor& v) override;
279 
280  /**
281  * \brief visit children i.e. member variables of current node using provided visitor
282  *
283  * Different nodes in the AST have different members (i.e. children). This method
284  * recursively visits children using provided visitor.
285  *
286  * \param v Concrete constant visitor that will be used to recursively visit children
287  *
288  * \sa Ast::visit_children for example.
289  */
290  void visit_children(visitor::ConstVisitor& v) const override;
291 
292  /**
293  * \brief accept (or visit) the current AST node using provided visitor
294  *
295  * Instead of visiting children of AST node, like Ast::visit_children,
296  * accept allows to visit the current node itself using provided concrete
297  * visitor.
298  *
299  * \param v Concrete visitor that will be used to recursively visit node
300  *
301  * \sa Ast::accept for example.
302  */
303  void accept(visitor::Visitor& v) override;
304 
305  /**
306  * \copydoc accept(visitor::Visitor&)
307  */
308  void accept(visitor::ConstVisitor& v) const override;
309  /// \}
310 
311  private:
312  /**
313  * \brief Set this object as parent for all the children
314  *
315  * This should be called in every object (with children) constructor
316  * to set parents. Since it is called only in the constructors it
317  * should not be virtual to avoid ambiguities (issue #295).
318  */
319  void set_parent_in_children();
320 };
321 
322 /** \} */ // end of ast_class
323 
324 
325 
326 
327 
328 } // namespace nmodl::ast
nmodl::visitor::ConstVisitor
Abstract base class for all constant visitors implementation.
Definition: visitor.hpp:298
nmodl::ast::FunctionTableBlock::visit_children
void visit_children(visitor::Visitor &v) override
visit children i.e.
Definition: ast.cpp:3810
nmodl::ast::Unit
TODO.
Definition: unit.hpp:38
nmodl::ast::FunctionTableBlock::accept
void accept(visitor::Visitor &v) override
accept (or visit) the current AST node using provided visitor
Definition: ast.cpp:3842
nmodl::ast::FunctionTableBlock::set_unit
void set_unit(std::shared_ptr< Unit > &&unit)
Setter for member variable FunctionTableBlock::unit (rvalue reference)
Definition: ast.cpp:3939
nmodl::ast::FunctionTableBlock::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: function_table_block.hpp:142
nmodl::ast::FunctionTableBlock::token
std::shared_ptr< ModToken > token
token with location information
Definition: function_table_block.hpp:48
nmodl::ast::FunctionTableBlock::get_parameters
const ArgumentVector & get_parameters() const noexcept override
Getter for member variable FunctionTableBlock::parameters.
Definition: function_table_block.hpp:199
nmodl::ast::FunctionTableBlock::get_token
const ModToken * get_token() const noexcept override
Return associated token for the current ast node.
Definition: function_table_block.hpp:155
nmodl::ast::FunctionTableBlock
TODO.
Definition: function_table_block.hpp:39
nmodl::ast::FunctionTableBlock::set_symbol_table
void set_symbol_table(symtab::SymbolTable *newsymtab) override
Set symbol table for the current ast node.
Definition: function_table_block.hpp:228
ast_decl.hpp
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::ast::AstNodeType::FUNCTION_TABLE_BLOCK
@ FUNCTION_TABLE_BLOCK
type of ast::FunctionTableBlock
nmodl::ast::FunctionTableBlock::unit
std::shared_ptr< Unit > unit
Unit if specified.
Definition: function_table_block.hpp:46
nmodl::ast::FunctionTableBlock::set_name
void set_name(std::shared_ptr< Name > &&name)
Setter for member variable FunctionTableBlock::name (rvalue reference)
Definition: ast.cpp:3905
block.hpp
Auto generated AST classes declaration.
nmodl::ast
Abstract Syntax Tree (AST) related implementations.
Definition: ast_common.hpp:29
nmodl::ast::FunctionTableBlock::clone
FunctionTableBlock * clone() const override
Return a copy of the current node.
Definition: function_table_block.hpp:80
nmodl::ast::AstNodeType
AstNodeType
Enum type for every AST node type.
Definition: ast_decl.hpp:164
nmodl::ast::FunctionTableBlock::get_node_name
std::string get_node_name() const override
Return name of the node.
Definition: ast.cpp:3800
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::FunctionTableBlock::get_node_type_name
std::string get_node_type_name() const noexcept override
Return type (ast::AstNodeType) of ast node as std::string.
Definition: function_table_block.hpp:113
nmodl::ast::FunctionTableBlock::get_name
std::shared_ptr< Name > get_name() const noexcept
Getter for member variable FunctionTableBlock::name.
Definition: function_table_block.hpp:190
nmodl::ast::FunctionTableBlock::get_node_type
AstNodeType get_node_type() const noexcept override
Return type (ast::AstNodeType) of ast node.
Definition: function_table_block.hpp:98
nmodl::symtab::SymbolTable
Represent symbol table for a NMODL block.
Definition: symbol_table.hpp:57
nmodl::ast::FunctionTableBlock::symtab
symtab::SymbolTable * symtab
symbol table for a block
Definition: function_table_block.hpp:50
nmodl::ast::FunctionTableBlock::~FunctionTableBlock
virtual ~FunctionTableBlock()=default
nmodl::ast::FunctionTableBlock::FunctionTableBlock
FunctionTableBlock(Name *name, const ArgumentVector &parameters, Unit *unit)
Definition: ast.cpp:3851
nmodl::ast::FunctionTableBlock::name
std::shared_ptr< Name > name
Name of the function table block.
Definition: function_table_block.hpp:42
nmodl::ast::FunctionTableBlock::get_nmodl_name
std::string get_nmodl_name() const noexcept override
Return NMODL statement of ast node as std::string.
Definition: function_table_block.hpp:128
nmodl::ast::FunctionTableBlock::parameters
ArgumentVector parameters
Vector of the parameters.
Definition: function_table_block.hpp:44
nmodl::ast::FunctionTableBlock::get_shared_ptr
std::shared_ptr< Ast > get_shared_ptr() override
Get std::shared_ptr from this pointer of the current ast node.
Definition: function_table_block.hpp:135
nmodl::ast::FunctionTableBlock::set_token
void set_token(const ModToken &tok)
Set token for the current ast node.
Definition: function_table_block.hpp:218
nmodl::ast::FunctionTableBlock::get_symbol_table
symtab::SymbolTable * get_symbol_table() const override
Return associated symbol table for the current ast node.
Definition: function_table_block.hpp:169
nmodl::ast::FunctionTableBlock::get_unit
std::shared_ptr< Unit > get_unit() const noexcept
Getter for member variable FunctionTableBlock::unit.
Definition: function_table_block.hpp:208
nmodl::ast::Name
Represents a name.
Definition: name.hpp:44
argument.hpp
Auto generated AST classes declaration.
nmodl::ast::FunctionTableBlock::is_function_table_block
bool is_function_table_block() const noexcept override
Check if the ast node is an instance of ast::FunctionTableBlock.
Definition: function_table_block.hpp:65
nmodl::ast::FunctionTableBlock::set_parameters
void set_parameters(ArgumentVector &&parameters)
Setter for member variable FunctionTableBlock::parameters (rvalue reference)
Definition: ast.cpp:3922
nmodl::ast::FunctionTableBlock::set_parent_in_children
void set_parent_in_children()
Set this object as parent for all the children.
Definition: ast.cpp:3885
nmodl::ModToken
Represent token returned by scanner.
Definition: modtoken.hpp:50