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