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 
16 class Property : public DeclarationBase {
17 public:
18  Property(ID id, Meta m = Meta()) : DeclarationBase(nodes(std::move(id), node::none), std::move(m)) {}
19 
20  Property(ID id, hilti::Expression attr, Meta m = Meta())
21  : DeclarationBase(nodes(std::move(id), std::move(attr)), std::move(m)) {}
22 
23  auto expression() const { return childs()[1].tryAs<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
Definition: declaration.h:53
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:14
std::string displayName() const
Definition: property.h:34
Definition: meta.h:18
Definition: declaration.h:87
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:99
const auto & childs() const
Definition: node.h:470
Definition: id.h:18