NEURON
matexp_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 #include "ast/conserve.hpp"
25 
26 namespace nmodl::ast {
27 
28 /**
29  * \addtogroup ast_class
30  * \ingroup ast
31  * \{
32  */
33 
34 /**
35  * \brief Represent matexp solver solution block based on Eigen
36  *
37  *
38 */
39 class MatexpBlock : public Block {
40  private:
41  /// If true then find steadystate solution, else advance by dt
42  std::shared_ptr<Boolean> steadystate;
43  /// Block of statements that assign to the Jacobian matrix
44  std::shared_ptr<StatementBlock> jacobian_block;
45  /// Conserve statements found in jacobian block
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 MatexpBlock(std::shared_ptr<Boolean> steadystate, std::shared_ptr<StatementBlock> jacobian_block, const ConserveVector& conserve);
57  MatexpBlock(const MatexpBlock& obj);
58  virtual ~MatexpBlock() = default;
59  /// \}
60 
61  /**
62  * \brief Check if the ast node is an instance of ast::MatexpBlock
63  * \return true as object is of type ast::MatexpBlock
64  */
65  bool is_matexp_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  MatexpBlock* clone() const override {
81  return new MatexpBlock(*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::MATEXP_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. "MatexpBlock"
110  *
111  * \sa Ast::get_node_name
112  */
113  std::string get_node_type_name() const noexcept override {
114  return "MatexpBlock";
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. "MATEXP_SOLVE"
125  *
126  * \sa Ast::get_nmodl_name
127  */
128  std::string get_nmodl_name() const noexcept override {
129  return "MATEXP_SOLVE";
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<MatexpBlock>(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 MatexpBlock>(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  /**
176  * \brief Getter for member variable \ref MatexpBlock.steadystate
177  */
178  std::shared_ptr<Boolean> get_steadystate() const noexcept {
179  return steadystate;
180  }
181 
182 
183 
184  /**
185  * \brief Getter for member variable \ref MatexpBlock.jacobian_block
186  */
187  std::shared_ptr<StatementBlock> get_jacobian_block() const noexcept {
188  return jacobian_block;
189  }
190 
191 
192 
193  /**
194  * \brief Getter for member variable \ref MatexpBlock.conserve
195  */
196  const ConserveVector& get_conserve() const noexcept {
197  return conserve;
198  }
199  /// \}
200 
201  /// \name Setters
202  /// \{
203  /**
204  * \brief Set token for the current ast node
205  */
206  void set_token(const ModToken& tok) { token = std::make_shared<ModToken>(tok); }
207  /**
208  * \brief Set symbol table for the current ast node
209  *
210  * Top level, block scoped nodes store symbol table in the ast node.
211  * nmodl::visitor::SymtabVisitor then used this method to setup symbol table
212  * for every node in the ast.
213  *
214  * \sa nmodl::visitor::SymtabVisitor
215  */
216  void set_symbol_table(symtab::SymbolTable* newsymtab) override {
217  symtab = newsymtab;
218  }
219 
220  /**
221  * \brief Setter for member variable \ref MatexpBlock.steadystate (rvalue reference)
222  */
223  void set_steadystate(std::shared_ptr<Boolean>&& steadystate);
224 
225  /**
226  * \brief Setter for member variable \ref MatexpBlock.steadystate
227  */
228  void set_steadystate(const std::shared_ptr<Boolean>& steadystate);
229 
230 
231  /**
232  * \brief Setter for member variable \ref MatexpBlock.jacobian_block (rvalue reference)
233  */
234  void set_jacobian_block(std::shared_ptr<StatementBlock>&& jacobian_block);
235 
236  /**
237  * \brief Setter for member variable \ref MatexpBlock.jacobian_block
238  */
239  void set_jacobian_block(const std::shared_ptr<StatementBlock>& jacobian_block);
240 
241 
242  /**
243  * \brief Setter for member variable \ref MatexpBlock.conserve (rvalue reference)
244  */
246 
247  /**
248  * \brief Setter for member variable \ref MatexpBlock.conserve
249  */
250  void set_conserve(const ConserveVector& conserve);
251 
252  /// \}
253 
254  /// \name Visitor
255  /// \{
256  /**
257  * \brief visit children i.e. member variables of current node using provided visitor
258  *
259  * Different nodes in the AST have different members (i.e. children). This method
260  * recursively visits children using provided visitor.
261  *
262  * \param v Concrete visitor that will be used to recursively visit children
263  *
264  * \sa Ast::visit_children for example.
265  */
266  void visit_children(visitor::Visitor& v) override;
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 constant visitor that will be used to recursively visit children
275  *
276  * \sa Ast::visit_children for example.
277  */
278  void visit_children(visitor::ConstVisitor& v) const override;
279 
280  /**
281  * \brief accept (or visit) the current AST node using provided visitor
282  *
283  * Instead of visiting children of AST node, like Ast::visit_children,
284  * accept allows to visit the current node itself using provided concrete
285  * visitor.
286  *
287  * \param v Concrete visitor that will be used to recursively visit node
288  *
289  * \sa Ast::accept for example.
290  */
291  void accept(visitor::Visitor& v) override;
292 
293  /**
294  * \copydoc accept(visitor::Visitor&)
295  */
296  void accept(visitor::ConstVisitor& v) const override;
297  /// \}
298 
299  private:
300  /**
301  * \brief Set this object as parent for all the children
302  *
303  * This should be called in every object (with children) constructor
304  * to set parents. Since it is called only in the constructors it
305  * should not be virtual to avoid ambiguities (issue #295).
306  */
307  void set_parent_in_children();
308 };
309 
310 /** \} */ // end of ast_class
311 
312 
313 
314 
315 
316 } // namespace nmodl::ast
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
Auto generated AST classes declaration.
Represent token returned by scanner.
Definition: modtoken.hpp:50
Base class for all block scoped nodes.
Definition: block.hpp:41
Represents a boolean variable.
Definition: boolean.hpp:42
Represent matexp solver solution block based on Eigen.
void set_conserve(ConserveVector &&conserve)
Setter for member variable MatexpBlock::conserve (rvalue reference)
Definition: ast.cpp:13753
std::shared_ptr< Ast > get_shared_ptr() override
Get std::shared_ptr from this pointer of the current ast node.
ConserveVector conserve
Conserve statements found in jacobian block.
AstNodeType get_node_type() const noexcept override
Return type (ast::AstNodeType) of ast node.
void accept(visitor::Visitor &v) override
accept (or visit) the current AST node using provided visitor
Definition: ast.cpp:13656
virtual ~MatexpBlock()=default
MatexpBlock * clone() const override
Return a copy of the current node.
const ConserveVector & get_conserve() const noexcept
Getter for member variable MatexpBlock::conserve.
MatexpBlock(Boolean *steadystate, StatementBlock *jacobian_block, const ConserveVector &conserve)
Definition: ast.cpp:13665
std::shared_ptr< const Ast > get_shared_ptr() const override
Get std::shared_ptr from this pointer of the current ast node.
void set_parent_in_children()
Set this object as parent for all the children.
Definition: ast.cpp:13699
void set_jacobian_block(std::shared_ptr< StatementBlock > &&jacobian_block)
Setter for member variable MatexpBlock::jacobian_block (rvalue reference)
Definition: ast.cpp:13736
std::shared_ptr< Boolean > steadystate
If true then find steadystate solution, else advance by dt.
std::shared_ptr< Boolean > get_steadystate() const noexcept
Getter for member variable MatexpBlock::steadystate.
std::shared_ptr< ModToken > token
token with location information
void set_symbol_table(symtab::SymbolTable *newsymtab) override
Set symbol table for the current ast node.
bool is_matexp_block() const noexcept override
Check if the ast node is an instance of ast::MatexpBlock.
std::shared_ptr< StatementBlock > get_jacobian_block() const noexcept
Getter for member variable MatexpBlock::jacobian_block.
const ModToken * get_token() const noexcept override
Return associated token for the current ast node.
void visit_children(visitor::Visitor &v) override
visit children i.e.
Definition: ast.cpp:13628
void set_token(const ModToken &tok)
Set token for the current ast node.
std::shared_ptr< StatementBlock > jacobian_block
Block of statements that assign to the Jacobian matrix.
void set_steadystate(std::shared_ptr< Boolean > &&steadystate)
Setter for member variable MatexpBlock::steadystate (rvalue reference)
Definition: ast.cpp:13719
symtab::SymbolTable * get_symbol_table() const override
Return associated symbol table for the current ast node.
std::string get_node_type_name() const noexcept override
Return type (ast::AstNodeType) of ast node as std::string.
std::string get_nmodl_name() const noexcept override
Return NMODL statement of ast node as std::string.
symtab::SymbolTable * symtab
symbol table for a block
Represents block encapsulating list of statements.
Represent symbol table for a NMODL block.
Abstract base class for all constant visitors implementation.
Definition: visitor.hpp:304
Abstract base class for all visitors implementation.
Definition: visitor.hpp:39
Auto generated AST classes declaration.
#define v
Definition: md1redef.h:11
AstNodeType
Enum type for every AST node type.
Definition: ast_decl.hpp:167
@ MATEXP_BLOCK
type of ast::MatexpBlock
std::vector< std::shared_ptr< Conserve > > ConserveVector
Definition: ast_decl.hpp:395
Abstract Syntax Tree (AST) related implementations.
Definition: ast_common.hpp:29