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::declaration {
13 
15 class Property : public DeclarationBase {
16 public:
17  Property(ID id, Meta m = Meta()) : DeclarationBase(nodes(std::move(id), node::none), std::move(m)) {}
18 
19  Property(ID id, hilti::Expression attr, Meta m = Meta())
20  : DeclarationBase(nodes(std::move(id), std::move(attr)), std::move(m)) {}
21 
22  auto expression() const { return children()[1].tryAs<hilti::Expression>(); }
23 
24  bool operator==(const Property& other) const { return id() == other.id() && expression() == other.expression(); }
25 
27  bool isConstant() const { return true; }
29  const ID& id() const { return child<ID>(0); }
31  Linkage linkage() const { return Linkage::Private; }
33  std::string displayName() const { return "property"; };
35  auto isEqual(const Declaration& other) const { return node::isEqual(this, other); }
36 
38  auto properties() const { return node::Properties{}; }
39 };
40 
41 } // namespace hilti::declaration
bool isConstant() const
Definition: property.h:27
Definition: declaration.h:54
Linkage linkage() const
Definition: property.h:31
auto properties() const
Definition: property.h:38
const ID & id() const
Definition: property.h:29
const Node none
Definition: node.cc:14
const auto & children() const
Definition: node.h:472
std::string displayName() const
Definition: property.h:33
Definition: meta.h:19
Definition: declaration.h:88
Definition: property.h:15
auto isEqual(const Declaration &other) const
Definition: property.h:35
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:98
Definition: declaration.h:19
Definition: id.h:18