Spicy
statement.h
1 // Copyright (c) 2020-2021 by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 #include <utility>
6 
7 #include <hilti/ast/node.h>
8 #include <hilti/base/type_erase.h>
9 
10 namespace hilti {
11 
12 namespace trait {
14 class isStatement : public isNode {};
15 } // namespace trait
16 
17 namespace statement::detail {
18 #include <hilti/autogen/__statement.h>
19 
21 inline Node to_node(Statement t) { return Node(std::move(t)); }
22 
24 inline std::ostream& operator<<(std::ostream& out, Statement s) { return out << to_node(std::move(s)); }
25 
26 inline bool operator==(const Statement& x, const Statement& y) {
27  if ( &x == &y )
28  return true;
29 
30  assert(x.isEqual(y) == y.isEqual(x)); // Expected to be symmetric.
31  return x.isEqual(y);
32 }
33 
34 inline bool operator!=(const Statement& s1, const Statement& s2) { return ! (s1 == s2); }
35 
36 } // namespace statement::detail
37 
38 using Statement = statement::detail::Statement;
39 
41 template<typename T, typename std::enable_if_t<std::is_base_of<trait::isStatement, T>::value>* = nullptr>
42 inline Node to_node(T t) {
43  return Node(Statement(std::move(t)));
44 }
45 
46 } // namespace hilti
Definition: statement.h:14
Definition: node.h:112
Definition: node.h:21