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