User Guide
react_var_name.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/identifier.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 ReactVarName : public Identifier {
39  private:
40  /// TODO
41  std::shared_ptr<Integer> value;
42  /// TODO
43  std::shared_ptr<VarName> name;
44  /// token with location information
45  std::shared_ptr<ModToken> token;
46 
47  public:
48  /// \name Ctor & dtor
49  /// \{
50  explicit ReactVarName(Integer* value, VarName* name);
51  explicit ReactVarName(std::shared_ptr<Integer> value, std::shared_ptr<VarName> name);
52  ReactVarName(const ReactVarName& obj);
53  virtual ~ReactVarName() = default;
54  /// \}
55 
56  /**
57  * \brief Check if the ast node is an instance of ast::ReactVarName
58  * \return true as object is of type ast::ReactVarName
59  */
60  bool is_react_var_name () 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  ReactVarName* clone() const override {
76  return new ReactVarName(*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::REACT_VAR_NAME
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. "ReactVarName"
105  *
106  * \sa Ast::get_node_name
107  */
108  std::string get_node_type_name() const noexcept override {
109  return "ReactVarName";
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<ReactVarName>(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 ReactVarName>(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 ReactVarName.value
144  */
145  std::shared_ptr<Integer> get_value() const noexcept {
146  return value;
147  }
148 
149 
150  /**
151  * \brief Return name of the node
152  *
153  * Some ast nodes have a member marked designated as node name. For example,
154  * in case of this ast::VarName has name designated as a
155  * node name.
156  *
157  * \return name of the node as std::string
158  *
159  * \sa Ast::get_node_type_name
160  */
161  std::string get_node_name() const override;
162 
163  /**
164  * \brief Getter for member variable \ref ReactVarName.name
165  */
166  std::shared_ptr<VarName> get_name() const noexcept {
167  return name;
168  }
169  /// \}
170 
171  /// \name Setters
172  /// \{
173  /**
174  * \brief Set token for the current ast node
175  */
176  void set_token(const ModToken& tok) { token = std::make_shared<ModToken>(tok); }
177 
178  /**
179  * \brief Setter for member variable \ref ReactVarName.value (rvalue reference)
180  */
181  void set_value(std::shared_ptr<Integer>&& value);
182 
183  /**
184  * \brief Setter for member variable \ref ReactVarName.value
185  */
186  void set_value(const std::shared_ptr<Integer>& value);
187 
188 
189  /**
190  * \brief Setter for member variable \ref ReactVarName.name (rvalue reference)
191  */
192  void set_name(std::shared_ptr<VarName>&& name);
193 
194  /**
195  * \brief Setter for member variable \ref ReactVarName.name
196  */
197  void set_name(const std::shared_ptr<VarName>& name);
198 
199  /// \}
200 
201  /// \name Visitor
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 visitor that will be used to recursively visit children
210  *
211  * \sa Ast::visit_children for example.
212  */
213  void visit_children(visitor::Visitor& v) override;
214 
215  /**
216  * \brief visit children i.e. member variables of current node using provided visitor
217  *
218  * Different nodes in the AST have different members (i.e. children). This method
219  * recursively visits children using provided visitor.
220  *
221  * \param v Concrete constant visitor that will be used to recursively visit children
222  *
223  * \sa Ast::visit_children for example.
224  */
225  void visit_children(visitor::ConstVisitor& v) const override;
226 
227  /**
228  * \brief accept (or visit) the current AST node using provided visitor
229  *
230  * Instead of visiting children of AST node, like Ast::visit_children,
231  * accept allows to visit the current node itself using provided concrete
232  * visitor.
233  *
234  * \param v Concrete visitor that will be used to recursively visit node
235  *
236  * \sa Ast::accept for example.
237  */
238  void accept(visitor::Visitor& v) override;
239 
240  /**
241  * \copydoc accept(visitor::Visitor&)
242  */
243  void accept(visitor::ConstVisitor& v) const override;
244  /// \}
245 
246  private:
247  /**
248  * \brief Set this object as parent for all the children
249  *
250  * This should be called in every object (with children) constructor
251  * to set parents. Since it is called only in the constructors it
252  * should not be virtual to avoid ambiguities (issue #295).
253  */
254  void set_parent_in_children();
255 };
256 
257 /** \} */ // end of ast_class
258 
259 
260 
261 
262 } // namespace nmodl::ast
nmodl::ast::ReactVarName::clone
ReactVarName * clone() const override
Return a copy of the current node.
Definition: react_var_name.hpp:75
nmodl::visitor::ConstVisitor
Abstract base class for all constant visitors implementation.
Definition: visitor.hpp:302
nmodl::ast::ReactVarName::get_node_type_name
std::string get_node_type_name() const noexcept override
Return type (ast::AstNodeType) of ast node as std::string.
Definition: react_var_name.hpp:108
nmodl::ast::AstNodeType::REACT_VAR_NAME
@ REACT_VAR_NAME
type of ast::ReactVarName
nmodl::ast::Identifier
Base class for all identifiers.
Definition: identifier.hpp:41
nmodl::ast::ReactVarName::value
std::shared_ptr< Integer > value
TODO.
Definition: react_var_name.hpp:41
nmodl::ast::ReactVarName::accept
void accept(visitor::Visitor &v) override
accept (or visit) the current AST node using provided visitor
Definition: ast.cpp:1439
ast_decl.hpp
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::ast::ReactVarName::ReactVarName
ReactVarName(Integer *value, VarName *name)
Definition: ast.cpp:1448
nmodl::ast::ReactVarName
TODO.
Definition: react_var_name.hpp:38
nmodl::ast::ReactVarName::is_react_var_name
bool is_react_var_name() const noexcept override
Check if the ast node is an instance of ast::ReactVarName.
Definition: react_var_name.hpp:60
nmodl::ast::VarName
Represents a variable.
Definition: var_name.hpp:43
nmodl::ast::Integer
Represents an integer variable.
Definition: integer.hpp:49
nmodl::ast::ReactVarName::get_name
std::shared_ptr< VarName > get_name() const noexcept
Getter for member variable ReactVarName::name.
Definition: react_var_name.hpp:166
nmodl::ast
Abstract Syntax Tree (AST) related implementations.
Definition: ast_common.hpp:29
nmodl::ast::ReactVarName::get_node_type
AstNodeType get_node_type() const noexcept override
Return type (ast::AstNodeType) of ast node.
Definition: react_var_name.hpp:93
nmodl::ast::AstNodeType
AstNodeType
Enum type for every AST node type.
Definition: ast_decl.hpp:166
nmodl::ast::ReactVarName::get_token
const ModToken * get_token() const noexcept override
Return associated token for the current ast node.
Definition: react_var_name.hpp:136
nmodl::visitor::Visitor
Abstract base class for all visitors implementation.
Definition: visitor.hpp:39
nmodl::ast::ReactVarName::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: react_var_name.hpp:123
nmodl::ast::ReactVarName::set_token
void set_token(const ModToken &tok)
Set token for the current ast node.
Definition: react_var_name.hpp:176
nmodl::ast::ReactVarName::get_shared_ptr
std::shared_ptr< Ast > get_shared_ptr() override
Get std::shared_ptr from this pointer of the current ast node.
Definition: react_var_name.hpp:116
nmodl::ast::ReactVarName::token
std::shared_ptr< ModToken > token
token with location information
Definition: react_var_name.hpp:45
nmodl::ast::ReactVarName::set_value
void set_value(std::shared_ptr< Integer > &&value)
Setter for member variable ReactVarName::value (rvalue reference)
Definition: ast.cpp:1493
nmodl::ast::ReactVarName::name
std::shared_ptr< VarName > name
TODO.
Definition: react_var_name.hpp:43
identifier.hpp
Auto generated AST classes declaration.
nmodl::ast::ReactVarName::set_parent_in_children
void set_parent_in_children()
Set this object as parent for all the children.
Definition: ast.cpp:1478
nmodl::ast::ReactVarName::set_name
void set_name(std::shared_ptr< VarName > &&name)
Setter for member variable ReactVarName::name (rvalue reference)
Definition: ast.cpp:1510
nmodl::ast::ReactVarName::get_node_name
std::string get_node_name() const override
Return name of the node.
Definition: ast.cpp:1413
nmodl::ast::ReactVarName::~ReactVarName
virtual ~ReactVarName()=default
nmodl::ast::ReactVarName::get_value
std::shared_ptr< Integer > get_value() const noexcept
Getter for member variable ReactVarName::value.
Definition: react_var_name.hpp:145
nmodl::ModToken
Represent token returned by scanner.
Definition: modtoken.hpp:50
nmodl::ast::ReactVarName::visit_children
void visit_children(visitor::Visitor &v) override
visit children i.e.
Definition: ast.cpp:1417