User Guide
breakpoint_block.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/block.hpp"
24 
25 namespace nmodl::ast {
26 
27 /**
28  * \addtogroup ast_class
29  * \ingroup ast
30  * \{
31  */
32 
33 /**
34  * \brief Represents a `BREAKPOINT` block in NMODL
35  *
36  * The `BREAKPOINT` block is used to update current and conductance.
37  * at each time step. Here is an example of `BREAKPOINT` :
38  *
39  * \code{.mod}
40  * BREAKPOINT {
41  * SOLVE states METHOD cnexp
42  * gna = gnabar*m*m*m*h
43  * ina = gna*(v - ena)
44  * gk = gkbar*n*n*n*n
45  * ik = gk*(v - ek)
46  * il = gl*(v - el)
47  * }
48  * \endcode
49  *
50  * \sa ast::DerivativeBlock ast::InitialBlock
51  *
52 */
53 class BreakpointBlock : public Block {
54  private:
55  /// Block with statements vector
56  std::shared_ptr<StatementBlock> statement_block;
57  /// token with location information
58  std::shared_ptr<ModToken> token;
59  /// symbol table for a block
61 
62  public:
63  /// \name Ctor & dtor
64  /// \{
66  explicit BreakpointBlock(std::shared_ptr<StatementBlock> statement_block);
67  BreakpointBlock(const BreakpointBlock& obj);
68  virtual ~BreakpointBlock() = default;
69  /// \}
70 
71  /**
72  * \brief Check if the ast node is an instance of ast::BreakpointBlock
73  * \return true as object is of type ast::BreakpointBlock
74  */
75  bool is_breakpoint_block () const noexcept override {
76  return true;
77  }
78 
79  /**
80  * \brief Return a copy of the current node
81  *
82  * Recursively make a new copy/clone of the current node including
83  * all members and return a pointer to the node. This is used for
84  * passes like nmodl::visitor::InlineVisitor where nodes are cloned in the
85  * ast.
86  *
87  * \return pointer to the clone/copy of the current node
88  */
89  // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks)
90  BreakpointBlock* clone() const override {
91  return new BreakpointBlock(*this);
92  }
93  // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)
94 
95  /// \name Getters
96  /// \{
97 
98  /**
99  * \brief Return type (ast::AstNodeType) of ast node
100  *
101  * Every node in the ast has a type defined in ast::AstNodeType and this
102  * function is used to retrieve the same.
103  *
104  * \return ast node type i.e. ast::AstNodeType::BREAKPOINT_BLOCK
105  *
106  * \sa Ast::get_node_type_name
107  */
108  AstNodeType get_node_type() const noexcept override {
110  }
111 
112  /**
113  * \brief Return type (ast::AstNodeType) of ast node as std::string
114  *
115  * Every node in the ast has a type defined in ast::AstNodeType.
116  * This type name can be returned as a std::string for printing
117  * node to text/json form.
118  *
119  * \return name of the node type as a string i.e. "BreakpointBlock"
120  *
121  * \sa Ast::get_node_name
122  */
123  std::string get_node_type_name() const noexcept override {
124  return "BreakpointBlock";
125  }
126 
127  /**
128  * \brief Return NMODL statement of ast node as std::string
129  *
130  * Every node is related to a special statement in the NMODL. This
131  * statement can be returned as a std::string for printing to
132  * text/json form.
133  *
134  * \return name of the statement as a string i.e. "BREAKPOINT "
135  *
136  * \sa Ast::get_nmodl_name
137  */
138  std::string get_nmodl_name() const noexcept override {
139  return "BREAKPOINT ";
140  }
141 
142  /**
143  * \brief Get std::shared_ptr from `this` pointer of the current ast node
144  */
145  std::shared_ptr<Ast> get_shared_ptr() override {
146  return std::static_pointer_cast<BreakpointBlock>(shared_from_this());
147  }
148 
149  /**
150  * \brief Get std::shared_ptr from `this` pointer of the current ast node
151  */
152  std::shared_ptr<const Ast> get_shared_ptr() const override {
153  return std::static_pointer_cast<const BreakpointBlock>(shared_from_this());
154  }
155 
156  /**
157  * \brief Return associated token for the current ast node
158  *
159  * Not all ast nodes have token information. For example, nmodl::visitor::NeuronSolveVisitor
160  * can insert new nodes in the ast as a solution of ODEs. In this case, we return
161  * nullptr to store in the nmodl::symtab::SymbolTable.
162  *
163  * \return pointer to token if exist otherwise nullptr
164  */
165  const ModToken* get_token() const noexcept override {
166  return token.get();
167  }
168  /**
169  * \brief Return associated symbol table for the current ast node
170  *
171  * Only certain ast nodes (e.g. inherited from ast::Block) have associated
172  * symbol table. These nodes have nmodl::symtab::SymbolTable as member
173  * and it can be accessed using this method.
174  *
175  * \return pointer to the symbol table
176  *
177  * \sa nmodl::symtab::SymbolTable nmodl::visitor::SymtabVisitor
178  */
180  return symtab;
181  }
182 
183 
184 
185  /**
186  * \brief Getter for member variable \ref BreakpointBlock.statement_block
187  */
188  std::shared_ptr<StatementBlock> get_statement_block() const noexcept override {
189  return statement_block;
190  }
191  /// \}
192 
193  /// \name Setters
194  /// \{
195  /**
196  * \brief Set token for the current ast node
197  */
198  void set_token(const ModToken& tok) { token = std::make_shared<ModToken>(tok); }
199  /**
200  * \brief Set symbol table for the current ast node
201  *
202  * Top level, block scoped nodes store symbol table in the ast node.
203  * nmodl::visitor::SymtabVisitor then used this method to setup symbol table
204  * for every node in the ast.
205  *
206  * \sa nmodl::visitor::SymtabVisitor
207  */
208  void set_symbol_table(symtab::SymbolTable* newsymtab) override {
209  symtab = newsymtab;
210  }
211 
212  /**
213  * \brief Setter for member variable \ref BreakpointBlock.statement_block (rvalue reference)
214  */
215  void set_statement_block(std::shared_ptr<StatementBlock>&& statement_block);
216 
217  /**
218  * \brief Setter for member variable \ref BreakpointBlock.statement_block
219  */
220  void set_statement_block(const std::shared_ptr<StatementBlock>& statement_block);
221 
222  /// \}
223 
224  /// \name Visitor
225  /// \{
226  /**
227  * \brief visit children i.e. member variables of current node using provided visitor
228  *
229  * Different nodes in the AST have different members (i.e. children). This method
230  * recursively visits children using provided visitor.
231  *
232  * \param v Concrete visitor that will be used to recursively visit children
233  *
234  * \sa Ast::visit_children for example.
235  */
236  void visit_children(visitor::Visitor& v) override;
237 
238  /**
239  * \brief visit children i.e. member variables of current node using provided visitor
240  *
241  * Different nodes in the AST have different members (i.e. children). This method
242  * recursively visits children using provided visitor.
243  *
244  * \param v Concrete constant visitor that will be used to recursively visit children
245  *
246  * \sa Ast::visit_children for example.
247  */
248  void visit_children(visitor::ConstVisitor& v) const override;
249 
250  /**
251  * \brief accept (or visit) the current AST node using provided visitor
252  *
253  * Instead of visiting children of AST node, like Ast::visit_children,
254  * accept allows to visit the current node itself using provided concrete
255  * visitor.
256  *
257  * \param v Concrete visitor that will be used to recursively visit node
258  *
259  * \sa Ast::accept for example.
260  */
261  void accept(visitor::Visitor& v) override;
262 
263  /**
264  * \copydoc accept(visitor::Visitor&)
265  */
266  void accept(visitor::ConstVisitor& v) const override;
267  /// \}
268 
269  private:
270  /**
271  * \brief Set this object as parent for all the children
272  *
273  * This should be called in every object (with children) constructor
274  * to set parents. Since it is called only in the constructors it
275  * should not be virtual to avoid ambiguities (issue #295).
276  */
277  void set_parent_in_children();
278 };
279 
280 /** \} */ // end of ast_class
281 
282 
283 
284 } // namespace nmodl::ast
nmodl::visitor::ConstVisitor
Abstract base class for all constant visitors implementation.
Definition: visitor.hpp:298
nmodl::ast::BreakpointBlock::set_statement_block
void set_statement_block(std::shared_ptr< StatementBlock > &&statement_block)
Setter for member variable BreakpointBlock::statement_block (rvalue reference)
Definition: ast.cpp:4700
nmodl::ast::BreakpointBlock::symtab
symtab::SymbolTable * symtab
symbol table for a block
Definition: breakpoint_block.hpp:60
nmodl::ast::BreakpointBlock::get_nmodl_name
std::string get_nmodl_name() const noexcept override
Return NMODL statement of ast node as std::string.
Definition: breakpoint_block.hpp:138
ast_decl.hpp
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::ast::BreakpointBlock::~BreakpointBlock
virtual ~BreakpointBlock()=default
block.hpp
Auto generated AST classes declaration.
nmodl::ast
Abstract Syntax Tree (AST) related implementations.
Definition: ast_common.hpp:29
nmodl::ast::BreakpointBlock::accept
void accept(visitor::Visitor &v) override
accept (or visit) the current AST node using provided visitor
Definition: ast.cpp:4654
nmodl::ast::BreakpointBlock::token
std::shared_ptr< ModToken > token
token with location information
Definition: breakpoint_block.hpp:58
nmodl::ast::BreakpointBlock::get_statement_block
std::shared_ptr< StatementBlock > get_statement_block() const noexcept override
Getter for member variable BreakpointBlock::statement_block.
Definition: breakpoint_block.hpp:188
nmodl::ast::BreakpointBlock::get_symbol_table
symtab::SymbolTable * get_symbol_table() const override
Return associated symbol table for the current ast node.
Definition: breakpoint_block.hpp:179
nmodl::ast::AstNodeType
AstNodeType
Enum type for every AST node type.
Definition: ast_decl.hpp:164
nmodl::ast::BreakpointBlock::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: breakpoint_block.hpp:152
nmodl::ast::Block
Base class for all block scoped nodes.
Definition: block.hpp:41
nmodl::ast::BreakpointBlock::get_shared_ptr
std::shared_ptr< Ast > get_shared_ptr() override
Get std::shared_ptr from this pointer of the current ast node.
Definition: breakpoint_block.hpp:145
nmodl::ast::BreakpointBlock::statement_block
std::shared_ptr< StatementBlock > statement_block
Block with statements vector.
Definition: breakpoint_block.hpp:56
nmodl::ast::BreakpointBlock
Represents a BREAKPOINT block in NMODL.
Definition: breakpoint_block.hpp:53
nmodl::visitor::Visitor
Abstract base class for all visitors implementation.
Definition: visitor.hpp:39
nmodl::symtab::SymbolTable
Represent symbol table for a NMODL block.
Definition: symbol_table.hpp:57
nmodl::ast::BreakpointBlock::get_token
const ModToken * get_token() const noexcept override
Return associated token for the current ast node.
Definition: breakpoint_block.hpp:165
nmodl::ast::BreakpointBlock::set_token
void set_token(const ModToken &tok)
Set token for the current ast node.
Definition: breakpoint_block.hpp:198
nmodl::ast::StatementBlock
Represents block encapsulating list of statements.
Definition: statement_block.hpp:53
nmodl::ast::BreakpointBlock::visit_children
void visit_children(visitor::Visitor &v) override
visit children i.e.
Definition: ast.cpp:4642
nmodl::ast::BreakpointBlock::get_node_type
AstNodeType get_node_type() const noexcept override
Return type (ast::AstNodeType) of ast node.
Definition: breakpoint_block.hpp:108
nmodl::ast::BreakpointBlock::is_breakpoint_block
bool is_breakpoint_block() const noexcept override
Check if the ast node is an instance of ast::BreakpointBlock.
Definition: breakpoint_block.hpp:75
nmodl::ast::BreakpointBlock::BreakpointBlock
BreakpointBlock(StatementBlock *statement_block)
Definition: ast.cpp:4663
nmodl::ast::BreakpointBlock::clone
BreakpointBlock * clone() const override
Return a copy of the current node.
Definition: breakpoint_block.hpp:90
nmodl::ast::AstNodeType::BREAKPOINT_BLOCK
@ BREAKPOINT_BLOCK
type of ast::BreakpointBlock
nmodl::ModToken
Represent token returned by scanner.
Definition: modtoken.hpp:50
nmodl::ast::BreakpointBlock::set_parent_in_children
void set_parent_in_children()
Set this object as parent for all the children.
Definition: ast.cpp:4689
nmodl::ast::BreakpointBlock::set_symbol_table
void set_symbol_table(symtab::SymbolTable *newsymtab) override
Set symbol table for the current ast node.
Definition: breakpoint_block.hpp:208
nmodl::ast::BreakpointBlock::get_node_type_name
std::string get_node_type_name() const noexcept override
Return type (ast::AstNodeType) of ast node as std::string.
Definition: breakpoint_block.hpp:123