User Guide
derivimplicit_callback.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/expression.hpp"
24 
25 namespace nmodl::ast {
26 
27 /**
28  * \addtogroup ast_class
29  * \ingroup ast
30  * \{
31  */
32 
33 /**
34  * \brief Represent a callback to NEURON's derivimplicit solver
35  *
36  *
37 */
39  private:
40  /// Block to be solved (typically derivative)
41  std::shared_ptr<Block> node_to_solve;
42  /// token with location information
43  std::shared_ptr<ModToken> token;
44 
45  public:
46  /// \name Ctor & dtor
47  /// \{
49  explicit DerivimplicitCallback(std::shared_ptr<Block> node_to_solve);
51  virtual ~DerivimplicitCallback() = default;
52  /// \}
53 
54  /**
55  * \brief Check if the ast node is an instance of ast::DerivimplicitCallback
56  * \return true as object is of type ast::DerivimplicitCallback
57  */
58  bool is_derivimplicit_callback () const noexcept override {
59  return true;
60  }
61 
62  /**
63  * \brief Return a copy of the current node
64  *
65  * Recursively make a new copy/clone of the current node including
66  * all members and return a pointer to the node. This is used for
67  * passes like nmodl::visitor::InlineVisitor where nodes are cloned in the
68  * ast.
69  *
70  * \return pointer to the clone/copy of the current node
71  */
72  // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks)
73  DerivimplicitCallback* clone() const override {
74  return new DerivimplicitCallback(*this);
75  }
76  // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)
77 
78  /// \name Getters
79  /// \{
80 
81  /**
82  * \brief Return type (ast::AstNodeType) of ast node
83  *
84  * Every node in the ast has a type defined in ast::AstNodeType and this
85  * function is used to retrieve the same.
86  *
87  * \return ast node type i.e. ast::AstNodeType::DERIVIMPLICIT_CALLBACK
88  *
89  * \sa Ast::get_node_type_name
90  */
91  AstNodeType get_node_type() const noexcept override {
93  }
94 
95  /**
96  * \brief Return type (ast::AstNodeType) of ast node as std::string
97  *
98  * Every node in the ast has a type defined in ast::AstNodeType.
99  * This type name can be returned as a std::string for printing
100  * node to text/json form.
101  *
102  * \return name of the node type as a string i.e. "DerivimplicitCallback"
103  *
104  * \sa Ast::get_node_name
105  */
106  std::string get_node_type_name() const noexcept override {
107  return "DerivimplicitCallback";
108  }
109 
110 
111  /**
112  * \brief Get std::shared_ptr from `this` pointer of the current ast node
113  */
114  std::shared_ptr<Ast> get_shared_ptr() override {
115  return std::static_pointer_cast<DerivimplicitCallback>(shared_from_this());
116  }
117 
118  /**
119  * \brief Get std::shared_ptr from `this` pointer of the current ast node
120  */
121  std::shared_ptr<const Ast> get_shared_ptr() const override {
122  return std::static_pointer_cast<const DerivimplicitCallback>(shared_from_this());
123  }
124 
125  /**
126  * \brief Return associated token for the current ast node
127  *
128  * Not all ast nodes have token information. For example, nmodl::visitor::NeuronSolveVisitor
129  * can insert new nodes in the ast as a solution of ODEs. In this case, we return
130  * nullptr to store in the nmodl::symtab::SymbolTable.
131  *
132  * \return pointer to token if exist otherwise nullptr
133  */
134  const ModToken* get_token() const noexcept override {
135  return token.get();
136  }
137 
138 
139 
140  /**
141  * \brief Getter for member variable \ref DerivimplicitCallback.node_to_solve
142  */
143  std::shared_ptr<Block> get_node_to_solve() const noexcept {
144  return node_to_solve;
145  }
146  /// \}
147 
148  /// \name Setters
149  /// \{
150  /**
151  * \brief Set token for the current ast node
152  */
153  void set_token(const ModToken& tok) { token = std::make_shared<ModToken>(tok); }
154 
155  /**
156  * \brief Setter for member variable \ref DerivimplicitCallback.node_to_solve (rvalue reference)
157  */
158  void set_node_to_solve(std::shared_ptr<Block>&& node_to_solve);
159 
160  /**
161  * \brief Setter for member variable \ref DerivimplicitCallback.node_to_solve
162  */
163  void set_node_to_solve(const std::shared_ptr<Block>& node_to_solve);
164 
165  /// \}
166 
167  /// \name Visitor
168  /// \{
169  /**
170  * \brief visit children i.e. member variables of current node using provided visitor
171  *
172  * Different nodes in the AST have different members (i.e. children). This method
173  * recursively visits children using provided visitor.
174  *
175  * \param v Concrete visitor that will be used to recursively visit children
176  *
177  * \sa Ast::visit_children for example.
178  */
179  void visit_children(visitor::Visitor& v) override;
180 
181  /**
182  * \brief visit children i.e. member variables of current node using provided visitor
183  *
184  * Different nodes in the AST have different members (i.e. children). This method
185  * recursively visits children using provided visitor.
186  *
187  * \param v Concrete constant visitor that will be used to recursively visit children
188  *
189  * \sa Ast::visit_children for example.
190  */
191  void visit_children(visitor::ConstVisitor& v) const override;
192 
193  /**
194  * \brief accept (or visit) the current AST node using provided visitor
195  *
196  * Instead of visiting children of AST node, like Ast::visit_children,
197  * accept allows to visit the current node itself using provided concrete
198  * visitor.
199  *
200  * \param v Concrete visitor that will be used to recursively visit node
201  *
202  * \sa Ast::accept for example.
203  */
204  void accept(visitor::Visitor& v) override;
205 
206  /**
207  * \copydoc accept(visitor::Visitor&)
208  */
209  void accept(visitor::ConstVisitor& v) const override;
210  /// \}
211 
212  private:
213  /**
214  * \brief Set this object as parent for all the children
215  *
216  * This should be called in every object (with children) constructor
217  * to set parents. Since it is called only in the constructors it
218  * should not be virtual to avoid ambiguities (issue #295).
219  */
220  void set_parent_in_children();
221 };
222 
223 /** \} */ // end of ast_class
224 
225 
226 
227 } // namespace nmodl::ast
nmodl::visitor::ConstVisitor
Abstract base class for all constant visitors implementation.
Definition: visitor.hpp:298
nmodl::ast::DerivimplicitCallback::get_node_to_solve
std::shared_ptr< Block > get_node_to_solve() const noexcept
Getter for member variable DerivimplicitCallback::node_to_solve.
Definition: derivimplicit_callback.hpp:143
nmodl::ast::DerivimplicitCallback::get_node_type
AstNodeType get_node_type() const noexcept override
Return type (ast::AstNodeType) of ast node.
Definition: derivimplicit_callback.hpp:91
nmodl::ast::AstNodeType::DERIVIMPLICIT_CALLBACK
@ DERIVIMPLICIT_CALLBACK
type of ast::DerivimplicitCallback
nmodl::ast::DerivimplicitCallback::set_node_to_solve
void set_node_to_solve(std::shared_ptr< Block > &&node_to_solve)
Setter for member variable DerivimplicitCallback::node_to_solve (rvalue reference)
Definition: ast.cpp:13758
nmodl::ast::DerivimplicitCallback::set_parent_in_children
void set_parent_in_children()
Set this object as parent for all the children.
Definition: ast.cpp:13747
nmodl::ast::DerivimplicitCallback::~DerivimplicitCallback
virtual ~DerivimplicitCallback()=default
ast_decl.hpp
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::ast
Abstract Syntax Tree (AST) related implementations.
Definition: ast_common.hpp:29
nmodl::ast::DerivimplicitCallback::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: derivimplicit_callback.hpp:121
nmodl::ast::AstNodeType
AstNodeType
Enum type for every AST node type.
Definition: ast_decl.hpp:164
nmodl::ast::Block
Base class for all block scoped nodes.
Definition: block.hpp:41
nmodl::ast::DerivimplicitCallback::get_token
const ModToken * get_token() const noexcept override
Return associated token for the current ast node.
Definition: derivimplicit_callback.hpp:134
nmodl::ast::DerivimplicitCallback::DerivimplicitCallback
DerivimplicitCallback(Block *node_to_solve)
Definition: ast.cpp:13721
nmodl::visitor::Visitor
Abstract base class for all visitors implementation.
Definition: visitor.hpp:39
nmodl::ast::DerivimplicitCallback::visit_children
void visit_children(visitor::Visitor &v) override
visit children i.e.
Definition: ast.cpp:13700
nmodl::ast::DerivimplicitCallback::set_token
void set_token(const ModToken &tok)
Set token for the current ast node.
Definition: derivimplicit_callback.hpp:153
nmodl::ast::DerivimplicitCallback::is_derivimplicit_callback
bool is_derivimplicit_callback() const noexcept override
Check if the ast node is an instance of ast::DerivimplicitCallback.
Definition: derivimplicit_callback.hpp:58
nmodl::ast::DerivimplicitCallback::node_to_solve
std::shared_ptr< Block > node_to_solve
Block to be solved (typically derivative)
Definition: derivimplicit_callback.hpp:41
nmodl::ast::DerivimplicitCallback
Represent a callback to NEURON's derivimplicit solver.
Definition: derivimplicit_callback.hpp:38
nmodl::ast::DerivimplicitCallback::get_node_type_name
std::string get_node_type_name() const noexcept override
Return type (ast::AstNodeType) of ast node as std::string.
Definition: derivimplicit_callback.hpp:106
nmodl::ast::DerivimplicitCallback::clone
DerivimplicitCallback * clone() const override
Return a copy of the current node.
Definition: derivimplicit_callback.hpp:73
nmodl::ast::DerivimplicitCallback::token
std::shared_ptr< ModToken > token
token with location information
Definition: derivimplicit_callback.hpp:43
nmodl::ast::DerivimplicitCallback::accept
void accept(visitor::Visitor &v) override
accept (or visit) the current AST node using provided visitor
Definition: ast.cpp:13712
nmodl::ast::DerivimplicitCallback::get_shared_ptr
std::shared_ptr< Ast > get_shared_ptr() override
Get std::shared_ptr from this pointer of the current ast node.
Definition: derivimplicit_callback.hpp:114
expression.hpp
Auto generated AST classes declaration.
nmodl::ast::Expression
Base class for all expressions in the NMODL.
Definition: expression.hpp:43
nmodl::ModToken
Represent token returned by scanner.
Definition: modtoken.hpp:50