User Guide
eigen_linear_solver_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 Represent linear solver solution block based on Eigen
35  *
36  *
37 */
38 class EigenLinearSolverBlock : public Block {
39  private:
40  /// number of state vars used in solve
41  std::shared_ptr<Integer> n_state_vars;
42  /// Statements to be declared in the functor
43  std::shared_ptr<StatementBlock> variable_block;
44  /// Statement block to be executed before calling linear solver
45  std::shared_ptr<StatementBlock> initialize_block;
46  /// update X from states
47  std::shared_ptr<StatementBlock> setup_x_block;
48  /// update back states from X
49  std::shared_ptr<StatementBlock> update_states_block;
50  /// Statement block to be executed after calling linear solver
51  std::shared_ptr<StatementBlock> finalize_block;
52  /// token with location information
53  std::shared_ptr<ModToken> token;
54  /// symbol table for a block
56 
57  public:
58  /// \name Ctor & dtor
59  /// \{
61  explicit EigenLinearSolverBlock(std::shared_ptr<Integer> n_state_vars, std::shared_ptr<StatementBlock> variable_block, std::shared_ptr<StatementBlock> initialize_block, std::shared_ptr<StatementBlock> setup_x_block, std::shared_ptr<StatementBlock> update_states_block, std::shared_ptr<StatementBlock> finalize_block);
63  virtual ~EigenLinearSolverBlock() = default;
64  /// \}
65 
66  /**
67  * \brief Check if the ast node is an instance of ast::EigenLinearSolverBlock
68  * \return true as object is of type ast::EigenLinearSolverBlock
69  */
70  bool is_eigen_linear_solver_block () const noexcept override {
71  return true;
72  }
73 
74  /**
75  * \brief Return a copy of the current node
76  *
77  * Recursively make a new copy/clone of the current node including
78  * all members and return a pointer to the node. This is used for
79  * passes like nmodl::visitor::InlineVisitor where nodes are cloned in the
80  * ast.
81  *
82  * \return pointer to the clone/copy of the current node
83  */
84  // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks)
85  EigenLinearSolverBlock* clone() const override {
86  return new EigenLinearSolverBlock(*this);
87  }
88  // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)
89 
90  /// \name Getters
91  /// \{
92 
93  /**
94  * \brief Return type (ast::AstNodeType) of ast node
95  *
96  * Every node in the ast has a type defined in ast::AstNodeType and this
97  * function is used to retrieve the same.
98  *
99  * \return ast node type i.e. ast::AstNodeType::EIGEN_LINEAR_SOLVER_BLOCK
100  *
101  * \sa Ast::get_node_type_name
102  */
103  AstNodeType get_node_type() const noexcept override {
105  }
106 
107  /**
108  * \brief Return type (ast::AstNodeType) of ast node as std::string
109  *
110  * Every node in the ast has a type defined in ast::AstNodeType.
111  * This type name can be returned as a std::string for printing
112  * node to text/json form.
113  *
114  * \return name of the node type as a string i.e. "EigenLinearSolverBlock"
115  *
116  * \sa Ast::get_node_name
117  */
118  std::string get_node_type_name() const noexcept override {
119  return "EigenLinearSolverBlock";
120  }
121 
122  /**
123  * \brief Return NMODL statement of ast node as std::string
124  *
125  * Every node is related to a special statement in the NMODL. This
126  * statement can be returned as a std::string for printing to
127  * text/json form.
128  *
129  * \return name of the statement as a string i.e. "EIGEN_LINEAR_SOLVE"
130  *
131  * \sa Ast::get_nmodl_name
132  */
133  std::string get_nmodl_name() const noexcept override {
134  return "EIGEN_LINEAR_SOLVE";
135  }
136 
137  /**
138  * \brief Get std::shared_ptr from `this` pointer of the current ast node
139  */
140  std::shared_ptr<Ast> get_shared_ptr() override {
141  return std::static_pointer_cast<EigenLinearSolverBlock>(shared_from_this());
142  }
143 
144  /**
145  * \brief Get std::shared_ptr from `this` pointer of the current ast node
146  */
147  std::shared_ptr<const Ast> get_shared_ptr() const override {
148  return std::static_pointer_cast<const EigenLinearSolverBlock>(shared_from_this());
149  }
150 
151  /**
152  * \brief Return associated token for the current ast node
153  *
154  * Not all ast nodes have token information. For example, nmodl::visitor::NeuronSolveVisitor
155  * can insert new nodes in the ast as a solution of ODEs. In this case, we return
156  * nullptr to store in the nmodl::symtab::SymbolTable.
157  *
158  * \return pointer to token if exist otherwise nullptr
159  */
160  const ModToken* get_token() const noexcept override {
161  return token.get();
162  }
163  /**
164  * \brief Return associated symbol table for the current ast node
165  *
166  * Only certain ast nodes (e.g. inherited from ast::Block) have associated
167  * symbol table. These nodes have nmodl::symtab::SymbolTable as member
168  * and it can be accessed using this method.
169  *
170  * \return pointer to the symbol table
171  *
172  * \sa nmodl::symtab::SymbolTable nmodl::visitor::SymtabVisitor
173  */
175  return symtab;
176  }
177 
178 
179 
180  /**
181  * \brief Getter for member variable \ref EigenLinearSolverBlock.n_state_vars
182  */
183  std::shared_ptr<Integer> get_n_state_vars() const noexcept {
184  return n_state_vars;
185  }
186 
187 
188 
189  /**
190  * \brief Getter for member variable \ref EigenLinearSolverBlock.variable_block
191  */
192  std::shared_ptr<StatementBlock> get_variable_block() const noexcept {
193  return variable_block;
194  }
195 
196 
197 
198  /**
199  * \brief Getter for member variable \ref EigenLinearSolverBlock.initialize_block
200  */
201  std::shared_ptr<StatementBlock> get_initialize_block() const noexcept {
202  return initialize_block;
203  }
204 
205 
206 
207  /**
208  * \brief Getter for member variable \ref EigenLinearSolverBlock.setup_x_block
209  */
210  std::shared_ptr<StatementBlock> get_setup_x_block() const noexcept {
211  return setup_x_block;
212  }
213 
214 
215 
216  /**
217  * \brief Getter for member variable \ref EigenLinearSolverBlock.update_states_block
218  */
219  std::shared_ptr<StatementBlock> get_update_states_block() const noexcept {
220  return update_states_block;
221  }
222 
223 
224 
225  /**
226  * \brief Getter for member variable \ref EigenLinearSolverBlock.finalize_block
227  */
228  std::shared_ptr<StatementBlock> get_finalize_block() const noexcept {
229  return finalize_block;
230  }
231  /// \}
232 
233  /// \name Setters
234  /// \{
235  /**
236  * \brief Set token for the current ast node
237  */
238  void set_token(const ModToken& tok) { token = std::make_shared<ModToken>(tok); }
239  /**
240  * \brief Set symbol table for the current ast node
241  *
242  * Top level, block scoped nodes store symbol table in the ast node.
243  * nmodl::visitor::SymtabVisitor then used this method to setup symbol table
244  * for every node in the ast.
245  *
246  * \sa nmodl::visitor::SymtabVisitor
247  */
248  void set_symbol_table(symtab::SymbolTable* newsymtab) override {
249  symtab = newsymtab;
250  }
251 
252  /**
253  * \brief Setter for member variable \ref EigenLinearSolverBlock.n_state_vars (rvalue reference)
254  */
255  void set_n_state_vars(std::shared_ptr<Integer>&& n_state_vars);
256 
257  /**
258  * \brief Setter for member variable \ref EigenLinearSolverBlock.n_state_vars
259  */
260  void set_n_state_vars(const std::shared_ptr<Integer>& n_state_vars);
261 
262 
263  /**
264  * \brief Setter for member variable \ref EigenLinearSolverBlock.variable_block (rvalue reference)
265  */
266  void set_variable_block(std::shared_ptr<StatementBlock>&& variable_block);
267 
268  /**
269  * \brief Setter for member variable \ref EigenLinearSolverBlock.variable_block
270  */
271  void set_variable_block(const std::shared_ptr<StatementBlock>& variable_block);
272 
273 
274  /**
275  * \brief Setter for member variable \ref EigenLinearSolverBlock.initialize_block (rvalue reference)
276  */
277  void set_initialize_block(std::shared_ptr<StatementBlock>&& initialize_block);
278 
279  /**
280  * \brief Setter for member variable \ref EigenLinearSolverBlock.initialize_block
281  */
282  void set_initialize_block(const std::shared_ptr<StatementBlock>& initialize_block);
283 
284 
285  /**
286  * \brief Setter for member variable \ref EigenLinearSolverBlock.setup_x_block (rvalue reference)
287  */
288  void set_setup_x_block(std::shared_ptr<StatementBlock>&& setup_x_block);
289 
290  /**
291  * \brief Setter for member variable \ref EigenLinearSolverBlock.setup_x_block
292  */
293  void set_setup_x_block(const std::shared_ptr<StatementBlock>& setup_x_block);
294 
295 
296  /**
297  * \brief Setter for member variable \ref EigenLinearSolverBlock.update_states_block (rvalue reference)
298  */
299  void set_update_states_block(std::shared_ptr<StatementBlock>&& update_states_block);
300 
301  /**
302  * \brief Setter for member variable \ref EigenLinearSolverBlock.update_states_block
303  */
304  void set_update_states_block(const std::shared_ptr<StatementBlock>& update_states_block);
305 
306 
307  /**
308  * \brief Setter for member variable \ref EigenLinearSolverBlock.finalize_block (rvalue reference)
309  */
310  void set_finalize_block(std::shared_ptr<StatementBlock>&& finalize_block);
311 
312  /**
313  * \brief Setter for member variable \ref EigenLinearSolverBlock.finalize_block
314  */
315  void set_finalize_block(const std::shared_ptr<StatementBlock>& finalize_block);
316 
317  /// \}
318 
319  /// \name Visitor
320  /// \{
321  /**
322  * \brief visit children i.e. member variables of current node using provided visitor
323  *
324  * Different nodes in the AST have different members (i.e. children). This method
325  * recursively visits children using provided visitor.
326  *
327  * \param v Concrete visitor that will be used to recursively visit children
328  *
329  * \sa Ast::visit_children for example.
330  */
331  void visit_children(visitor::Visitor& v) override;
332 
333  /**
334  * \brief visit children i.e. member variables of current node using provided visitor
335  *
336  * Different nodes in the AST have different members (i.e. children). This method
337  * recursively visits children using provided visitor.
338  *
339  * \param v Concrete constant visitor that will be used to recursively visit children
340  *
341  * \sa Ast::visit_children for example.
342  */
343  void visit_children(visitor::ConstVisitor& v) const override;
344 
345  /**
346  * \brief accept (or visit) the current AST node using provided visitor
347  *
348  * Instead of visiting children of AST node, like Ast::visit_children,
349  * accept allows to visit the current node itself using provided concrete
350  * visitor.
351  *
352  * \param v Concrete visitor that will be used to recursively visit node
353  *
354  * \sa Ast::accept for example.
355  */
356  void accept(visitor::Visitor& v) override;
357 
358  /**
359  * \copydoc accept(visitor::Visitor&)
360  */
361  void accept(visitor::ConstVisitor& v) const override;
362  /// \}
363 
364  private:
365  /**
366  * \brief Set this object as parent for all the children
367  *
368  * This should be called in every object (with children) constructor
369  * to set parents. Since it is called only in the constructors it
370  * should not be virtual to avoid ambiguities (issue #295).
371  */
372  void set_parent_in_children();
373 };
374 
375 /** \} */ // end of ast_class
376 
377 
378 
379 
380 
381 
382 
383 
384 } // namespace nmodl::ast
nmodl::visitor::ConstVisitor
Abstract base class for all constant visitors implementation.
Definition: visitor.hpp:298
nmodl::ast::EigenLinearSolverBlock::is_eigen_linear_solver_block
bool is_eigen_linear_solver_block() const noexcept override
Check if the ast node is an instance of ast::EigenLinearSolverBlock.
Definition: eigen_linear_solver_block.hpp:70
nmodl::ast::EigenLinearSolverBlock::set_finalize_block
void set_finalize_block(std::shared_ptr< StatementBlock > &&finalize_block)
Setter for member variable EigenLinearSolverBlock::finalize_block (rvalue reference)
Definition: ast.cpp:13590
nmodl::ast::EigenLinearSolverBlock::get_shared_ptr
std::shared_ptr< Ast > get_shared_ptr() override
Get std::shared_ptr from this pointer of the current ast node.
Definition: eigen_linear_solver_block.hpp:140
nmodl::ast::EigenLinearSolverBlock::set_update_states_block
void set_update_states_block(std::shared_ptr< StatementBlock > &&update_states_block)
Setter for member variable EigenLinearSolverBlock::update_states_block (rvalue reference)
Definition: ast.cpp:13573
nmodl::ast::EigenLinearSolverBlock::get_node_type_name
std::string get_node_type_name() const noexcept override
Return type (ast::AstNodeType) of ast node as std::string.
Definition: eigen_linear_solver_block.hpp:118
nmodl::ast::EigenLinearSolverBlock::set_n_state_vars
void set_n_state_vars(std::shared_ptr< Integer > &&n_state_vars)
Setter for member variable EigenLinearSolverBlock::n_state_vars (rvalue reference)
Definition: ast.cpp:13505
nmodl::ast::EigenLinearSolverBlock::get_node_type
AstNodeType get_node_type() const noexcept override
Return type (ast::AstNodeType) of ast node.
Definition: eigen_linear_solver_block.hpp:103
ast_decl.hpp
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::ast::EigenLinearSolverBlock::get_setup_x_block
std::shared_ptr< StatementBlock > get_setup_x_block() const noexcept
Getter for member variable EigenLinearSolverBlock::setup_x_block.
Definition: eigen_linear_solver_block.hpp:210
block.hpp
Auto generated AST classes declaration.
nmodl::ast::EigenLinearSolverBlock::get_variable_block
std::shared_ptr< StatementBlock > get_variable_block() const noexcept
Getter for member variable EigenLinearSolverBlock::variable_block.
Definition: eigen_linear_solver_block.hpp:192
nmodl::ast::EigenLinearSolverBlock::set_symbol_table
void set_symbol_table(symtab::SymbolTable *newsymtab) override
Set symbol table for the current ast node.
Definition: eigen_linear_solver_block.hpp:248
nmodl::ast::Integer
Represents an integer variable.
Definition: integer.hpp:49
nmodl::ast
Abstract Syntax Tree (AST) related implementations.
Definition: ast_common.hpp:29
nmodl::ast::EigenLinearSolverBlock::initialize_block
std::shared_ptr< StatementBlock > initialize_block
Statement block to be executed before calling linear solver.
Definition: eigen_linear_solver_block.hpp:45
nmodl::ast::EigenLinearSolverBlock::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: eigen_linear_solver_block.hpp:147
nmodl::ast::AstNodeType
AstNodeType
Enum type for every AST node type.
Definition: ast_decl.hpp:164
nmodl::ast::EigenLinearSolverBlock::get_initialize_block
std::shared_ptr< StatementBlock > get_initialize_block() const noexcept
Getter for member variable EigenLinearSolverBlock::initialize_block.
Definition: eigen_linear_solver_block.hpp:201
nmodl::ast::EigenLinearSolverBlock::get_update_states_block
std::shared_ptr< StatementBlock > get_update_states_block() const noexcept
Getter for member variable EigenLinearSolverBlock::update_states_block.
Definition: eigen_linear_solver_block.hpp:219
nmodl::ast::Block
Base class for all block scoped nodes.
Definition: block.hpp:41
nmodl::ast::EigenLinearSolverBlock::finalize_block
std::shared_ptr< StatementBlock > finalize_block
Statement block to be executed after calling linear solver.
Definition: eigen_linear_solver_block.hpp:51
nmodl::ast::EigenLinearSolverBlock::accept
void accept(visitor::Visitor &v) override
accept (or visit) the current AST node using provided visitor
Definition: ast.cpp:13419
nmodl::ast::EigenLinearSolverBlock::get_finalize_block
std::shared_ptr< StatementBlock > get_finalize_block() const noexcept
Getter for member variable EigenLinearSolverBlock::finalize_block.
Definition: eigen_linear_solver_block.hpp:228
nmodl::visitor::Visitor
Abstract base class for all visitors implementation.
Definition: visitor.hpp:39
nmodl::ast::EigenLinearSolverBlock::get_symbol_table
symtab::SymbolTable * get_symbol_table() const override
Return associated symbol table for the current ast node.
Definition: eigen_linear_solver_block.hpp:174
nmodl::ast::EigenLinearSolverBlock::get_token
const ModToken * get_token() const noexcept override
Return associated token for the current ast node.
Definition: eigen_linear_solver_block.hpp:160
nmodl::ast::EigenLinearSolverBlock::variable_block
std::shared_ptr< StatementBlock > variable_block
Statements to be declared in the functor.
Definition: eigen_linear_solver_block.hpp:43
nmodl::ast::EigenLinearSolverBlock::visit_children
void visit_children(visitor::Visitor &v) override
visit children i.e.
Definition: ast.cpp:13377
nmodl::ast::EigenLinearSolverBlock::EigenLinearSolverBlock
EigenLinearSolverBlock(Integer *n_state_vars, StatementBlock *variable_block, StatementBlock *initialize_block, StatementBlock *setup_x_block, StatementBlock *update_states_block, StatementBlock *finalize_block)
Definition: ast.cpp:13428
nmodl::ast::EigenLinearSolverBlock::set_token
void set_token(const ModToken &tok)
Set token for the current ast node.
Definition: eigen_linear_solver_block.hpp:238
nmodl::ast::EigenLinearSolverBlock::set_variable_block
void set_variable_block(std::shared_ptr< StatementBlock > &&variable_block)
Setter for member variable EigenLinearSolverBlock::variable_block (rvalue reference)
Definition: ast.cpp:13522
nmodl::ast::EigenLinearSolverBlock::get_n_state_vars
std::shared_ptr< Integer > get_n_state_vars() const noexcept
Getter for member variable EigenLinearSolverBlock::n_state_vars.
Definition: eigen_linear_solver_block.hpp:183
nmodl::ast::EigenLinearSolverBlock::set_setup_x_block
void set_setup_x_block(std::shared_ptr< StatementBlock > &&setup_x_block)
Setter for member variable EigenLinearSolverBlock::setup_x_block (rvalue reference)
Definition: ast.cpp:13556
nmodl::symtab::SymbolTable
Represent symbol table for a NMODL block.
Definition: symbol_table.hpp:57
nmodl::ast::EigenLinearSolverBlock
Represent linear solver solution block based on Eigen.
Definition: eigen_linear_solver_block.hpp:38
nmodl::ast::AstNodeType::EIGEN_LINEAR_SOLVER_BLOCK
@ EIGEN_LINEAR_SOLVER_BLOCK
type of ast::EigenLinearSolverBlock
nmodl::ast::EigenLinearSolverBlock::clone
EigenLinearSolverBlock * clone() const override
Return a copy of the current node.
Definition: eigen_linear_solver_block.hpp:85
nmodl::ast::StatementBlock
Represents block encapsulating list of statements.
Definition: statement_block.hpp:53
nmodl::ast::EigenLinearSolverBlock::symtab
symtab::SymbolTable * symtab
symbol table for a block
Definition: eigen_linear_solver_block.hpp:55
nmodl::ast::EigenLinearSolverBlock::set_initialize_block
void set_initialize_block(std::shared_ptr< StatementBlock > &&initialize_block)
Setter for member variable EigenLinearSolverBlock::initialize_block (rvalue reference)
Definition: ast.cpp:13539
nmodl::ast::EigenLinearSolverBlock::~EigenLinearSolverBlock
virtual ~EigenLinearSolverBlock()=default
nmodl::ast::EigenLinearSolverBlock::get_nmodl_name
std::string get_nmodl_name() const noexcept override
Return NMODL statement of ast node as std::string.
Definition: eigen_linear_solver_block.hpp:133
nmodl::ast::EigenLinearSolverBlock::token
std::shared_ptr< ModToken > token
token with location information
Definition: eigen_linear_solver_block.hpp:53
nmodl::ast::EigenLinearSolverBlock::set_parent_in_children
void set_parent_in_children()
Set this object as parent for all the children.
Definition: ast.cpp:13474
nmodl::ast::EigenLinearSolverBlock::update_states_block
std::shared_ptr< StatementBlock > update_states_block
update back states from X
Definition: eigen_linear_solver_block.hpp:49
nmodl::ast::EigenLinearSolverBlock::setup_x_block
std::shared_ptr< StatementBlock > setup_x_block
update X from states
Definition: eigen_linear_solver_block.hpp:47
nmodl::ast::EigenLinearSolverBlock::n_state_vars
std::shared_ptr< Integer > n_state_vars
number of state vars used in solve
Definition: eigen_linear_solver_block.hpp:41
nmodl::ModToken
Represent token returned by scanner.
Definition: modtoken.hpp:50