User Guide
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/expression.hpp"
24 
25 namespace nmodl::ast {
26 
27 /**
28  * \addtogroup ast_class
29  * \ingroup ast
30  * \{
31  */
32 
33 /**
34  * \brief Base class for all block scoped nodes
35  *
36  * NMODL has different local and globals block scoped nodes like
37  * ast::NeuronBlock, ast::ParamBlock, ast::IfStatement etc. Ast::Block
38  * is base class and defines common interface for these nodes.
39  *
40 */
41 class Block : public Expression {
42 
43  public:
44  /// \name Ctor & dtor
45  /// \{
46  virtual ~Block() = default;
47  /// \}
48  /// \name Not implemented
49  /// \{
50  virtual const ArgumentVector& get_parameters() const {
51  throw std::runtime_error("get_parameters not implemented");
52  }
53  /// \}
54  /**
55  * \brief Check if the ast node is an instance of ast::Block
56  * \return true as object is of type ast::Block
57  */
58  bool is_block () const noexcept override {
59  return true;
60  }
61 
62  /**
63  * \brief Return a copy of the current node
64  *
65  * Recursively make a new copy/clone of the current node including
66  * all members and return a pointer to the node. This is used for
67  * passes like nmodl::visitor::InlineVisitor where nodes are cloned in the
68  * ast.
69  *
70  * \return pointer to the clone/copy of the current node
71  */
72  // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks)
73  virtual Block* clone() const override {
74  return new Block(*this);
75  }
76  // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)
77 
78  /// \name Getters
79  /// \{
80 
81  /**
82  * \brief Return type (ast::AstNodeType) of ast node
83  *
84  * Every node in the ast has a type defined in ast::AstNodeType and this
85  * function is used to retrieve the same.
86  *
87  * \return ast node type i.e. ast::AstNodeType::BLOCK
88  *
89  * \sa Ast::get_node_type_name
90  */
91  virtual AstNodeType get_node_type() const noexcept override {
92  return AstNodeType::BLOCK;
93  }
94 
95  /**
96  * \brief Return type (ast::AstNodeType) of ast node as std::string
97  *
98  * Every node in the ast has a type defined in ast::AstNodeType.
99  * This type name can be returned as a std::string for printing
100  * node to text/json form.
101  *
102  * \return name of the node type as a string i.e. "Block"
103  *
104  * \sa Ast::get_node_name
105  */
106  virtual std::string get_node_type_name() const noexcept override {
107  return "Block";
108  }
109 
110 
111  /**
112  * \brief Get std::shared_ptr from `this` pointer of the current ast node
113  */
114  virtual std::shared_ptr<Ast> get_shared_ptr() override {
115  return std::static_pointer_cast<Block>(shared_from_this());
116  }
117 
118  /**
119  * \brief Get std::shared_ptr from `this` pointer of the current ast node
120  */
121  virtual std::shared_ptr<const Ast> get_shared_ptr() const override {
122  return std::static_pointer_cast<const Block>(shared_from_this());
123  }
124 
125  /// \}
126 
127 
128 
129  /// \name Visitor
130  /// \{
131  /**
132  * \brief visit children i.e. member variables of current node using provided visitor
133  *
134  * Different nodes in the AST have different members (i.e. children). This method
135  * recursively visits children using provided visitor.
136  *
137  * \param v Concrete visitor that will be used to recursively visit children
138  *
139  * \sa Ast::visit_children for example.
140  */
141  virtual void visit_children(visitor::Visitor& v) override;
142 
143  /**
144  * \brief visit children i.e. member variables of current node using provided visitor
145  *
146  * Different nodes in the AST have different members (i.e. children). This method
147  * recursively visits children using provided visitor.
148  *
149  * \param v Concrete constant visitor that will be used to recursively visit children
150  *
151  * \sa Ast::visit_children for example.
152  */
153  virtual void visit_children(visitor::ConstVisitor& v) const override;
154 
155  /**
156  * \brief accept (or visit) the current AST node using provided visitor
157  *
158  * Instead of visiting children of AST node, like Ast::visit_children,
159  * accept allows to visit the current node itself using provided concrete
160  * visitor.
161  *
162  * \param v Concrete visitor that will be used to recursively visit node
163  *
164  * \sa Ast::accept for example.
165  */
166  virtual void accept(visitor::Visitor& v) override;
167 
168  /**
169  * \copydoc accept(visitor::Visitor&)
170  */
171  virtual void accept(visitor::ConstVisitor& v) const override;
172  /// \}
173 
174 };
175 
176 /** \} */ // end of ast_class
177 
178 
179 } // namespace nmodl::ast
nmodl::visitor::ConstVisitor
Abstract base class for all constant visitors implementation.
Definition: visitor.hpp:298
ast_decl.hpp
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
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::Block
Base class for all block scoped nodes.
Definition: block.hpp:41
nmodl::ast::ArgumentVector
std::vector< std::shared_ptr< Argument > > ArgumentVector
Definition: ast_decl.hpp:312
nmodl::visitor::Visitor
Abstract base class for all visitors implementation.
Definition: visitor.hpp:39
nmodl::ast::Block::~Block
virtual ~Block()=default
nmodl::ast::Block::get_node_type_name
virtual std::string get_node_type_name() const noexcept override
Return type (ast::AstNodeType) of ast node as std::string.
Definition: block.hpp:106
nmodl::ast::Block::clone
virtual Block * clone() const override
Return a copy of the current node.
Definition: block.hpp:73
nmodl::ast::Block::is_block
bool is_block() const noexcept override
Check if the ast node is an instance of ast::Block.
Definition: block.hpp:58
nmodl::ast::Block::get_shared_ptr
virtual std::shared_ptr< Ast > get_shared_ptr() override
Get std::shared_ptr from this pointer of the current ast node.
Definition: block.hpp:114
nmodl::ast::Block::get_node_type
virtual AstNodeType get_node_type() const noexcept override
Return type (ast::AstNodeType) of ast node.
Definition: block.hpp:91
expression.hpp
Auto generated AST classes declaration.
nmodl::ast::Block::visit_children
virtual void visit_children(visitor::Visitor &v) override
visit children i.e.
Definition: ast.cpp:388
nmodl::ast::AstNodeType::BLOCK
@ BLOCK
type of ast::Block
nmodl::ast::Expression
Base class for all expressions in the NMODL.
Definition: expression.hpp:43
nmodl::ast::Block::get_shared_ptr
virtual std::shared_ptr< const Ast > get_shared_ptr() const override
Get std::shared_ptr from this pointer of the current ast node.
Definition: block.hpp:121
nmodl::ast::Block::get_parameters
virtual const ArgumentVector & get_parameters() const
Definition: block.hpp:50
nmodl::ast::Block::accept
virtual void accept(visitor::Visitor &v) override
accept (or visit) the current AST node using provided visitor
Definition: ast.cpp:394