Spicy
property.h
1 // Copyright (c) 2020-2021 by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 #include <string>
6 #include <utility>
7 
8 #include <hilti/ast/declaration.h>
9 #include <hilti/ast/expression.h>
10 #include <hilti/ast/id.h>
11 
12 namespace hilti {
13 namespace declaration {
14 
17 public:
18  Property(ID id, Meta m = Meta()) : NodeBase(nodes(std::move(id), node::none), std::move(m)) {}
19 
20  Property(ID id, hilti::Expression attr, Meta m = Meta())
21  : NodeBase(nodes(std::move(id), std::move(attr)), std::move(m)) {}
22 
23  auto expression() const { return childs()[1].tryReferenceAs<hilti::Expression>(); }
24 
25  bool operator==(const Property& other) const { return id() == other.id() && expression() == other.expression(); }
26 
28  bool isConstant() const { return true; }
30  const ID& id() const { return child<ID>(0); }
32  Linkage linkage() const { return Linkage::Private; }
34  std::string displayName() const { return "property"; };
36  auto isEqual(const Declaration& other) const { return node::isEqual(this, other); }
37 
39  auto properties() const { return node::Properties{}; }
40 };
41 
42 } // namespace declaration
43 } // namespace hilti
bool isConstant() const
Definition: property.h:28
auto & childs() const
Definition: node.h:445
Linkage linkage() const
Definition: property.h:32
auto properties() const
Definition: property.h:39
const ID & id() const
Definition: property.h:30
const Node none
Definition: node.cc:12
std::string displayName() const
Definition: property.h:34
Definition: meta.h:18
Definition: property.h:16
auto isEqual(const Declaration &other) const
Definition: property.h:36
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:83
Definition: declaration.h:15
Definition: id.h:18
Definition: node.h:318