Spicy
for.h
1 // Copyright (c) 2020-2021 by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 #include <memory>
6 #include <utility>
7 
8 #include <hilti/ast/declarations/local-variable.h>
9 #include <hilti/ast/expression.h>
10 #include <hilti/ast/statement.h>
11 
12 namespace hilti {
13 namespace statement {
14 
16 class For : public NodeBase, public hilti::trait::isStatement {
17 public:
18  For(hilti::ID id, hilti::Expression seq, Statement body, Meta m = Meta())
19  : NodeBase(nodes(std::move(id), std::move(seq), std::move(body)), std::move(m)) {}
20 
21  const auto& id() const { return child<ID>(0); }
22  const auto& sequence() const { return child<hilti::Expression>(1); }
23  const auto& body() const { return child<hilti::Statement>(2); }
24 
29  IntrusivePtr<Scope> scope() const { return childs()[2].scope(); }
30 
31  bool operator==(const For& other) const {
32  return id() == other.id() && sequence() == other.sequence() && body() == other.body();
33  }
34 
36  auto& _sequenceNode() { return childs()[1]; }
37 
39  auto& _bodyNode() { return childs()[2]; }
40 
42  auto isEqual(const Statement& other) const { return node::isEqual(this, other); }
43 
45  auto properties() const { return node::Properties{}; }
46 };
47 
48 } // namespace statement
49 } // namespace hilti
auto & childs() const
Definition: node.h:445
Definition: for.h:16
auto & _bodyNode()
Definition: for.h:39
IntrusivePtr< Scope > scope() const
Definition: for.h:29
Definition: meta.h:18
auto properties() const
Definition: for.h:45
Definition: statement.h:14
Definition: intrusive-ptr.h:69
auto isEqual(const Statement &other) const
Definition: for.h:42
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:83
auto & _sequenceNode()
Definition: for.h:36
Definition: id.h:18
Definition: node.h:318