Spicy
member.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/id.h>
8 #include <hilti/ast/node.h>
9 #include <hilti/ast/node_ref.h>
10 #include <hilti/ast/types/member.h>
11 #include <hilti/base/logger.h>
12 
13 namespace hilti {
14 namespace expression {
15 
18 public:
19  Member(ID id, Meta m = Meta()) : NodeBase({id, Type(type::Member(std::move(id))), node::none}, std::move(m)) {}
20  Member(ID id, Type member_type, Meta m = Meta())
21  : NodeBase({id, std::move(member_type), Type(type::Member(std::move(id)))}, std::move(m)) {}
22 
23  const auto& id() const { return child<ID>(0); }
24  auto memberType() const { return type::effectiveOptionalType(childs()[1].tryAs<Type>()); }
25 
26  bool operator==(const Member& other) const { return id() == other.id() && type() == other.type(); }
27 
29  bool isLhs() const { return true; }
31  bool isTemporary() const { return false; }
33  Type type() const { return type::effectiveType(child<Type>(1)); }
35  auto isConstant() const { return true; }
37  auto isEqual(const Expression& other) const { return node::isEqual(this, other); }
38 
40  auto properties() const { return node::Properties{}; }
41 };
42 
43 } // namespace expression
44 } // namespace hilti
Definition: member.h:17
bool isLhs() const
Definition: member.h:29
auto isConstant() const
Definition: member.h:35
auto & childs() const
Definition: node.h:445
auto isEqual(const Expression &other) const
Definition: member.h:37
const Node none
Definition: node.cc:12
Definition: member.h:16
Definition: expression.h:16
Definition: meta.h:18
auto properties() const
Definition: member.h:40
Type type() const
Definition: member.h:33
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:83
bool isTemporary() const
Definition: member.h:31
Definition: id.h:18
Definition: node.h:318