Spicy
union.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/ctor.h>
8 #include <hilti/ast/expression.h>
9 #include <hilti/ast/id.h>
10 #include <hilti/ast/types/struct.h>
11 
12 namespace hilti {
13 namespace ctor {
14 
16 class Union : public NodeBase, public hilti::trait::isCtor {
17 public:
18  Union(Type unit_type, Expression value, Meta m = Meta())
19  : NodeBase(nodes(std::move(unit_type), std::move(value)), std::move(m)) {}
20 
22  Expression value() const { return child<Expression>(1); }
23 
24  bool operator==(const Union& other) const { return type() == other.type() && value() == other.value(); }
25 
27  Type type() const { return child<Type>(0); }
28 
30  bool isConstant() const { return true; }
32  auto isLhs() const { return false; }
34  auto isTemporary() const { return true; }
36  auto isEqual(const Ctor& other) const { return node::isEqual(this, other); }
37 
39  auto properties() const { return node::Properties{}; }
40 };
41 
42 } // namespace ctor
43 } // namespace hilti
Type type() const
Definition: union.h:27
auto isLhs() const
Definition: union.h:32
auto isEqual(const Ctor &other) const
Definition: union.h:36
auto properties() const
Definition: union.h:39
auto isTemporary() const
Definition: union.h:34
Expression value() const
Definition: union.h:22
Definition: meta.h:18
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:83
Definition: ctor.h:15
bool isConstant() const
Definition: union.h:30
Definition: node.h:318
Definition: union.h:16