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