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