Spicy
unit-hook.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 <spicy/ast/aliases.h>
8 #include <spicy/ast/types/unit-item.h>
9 #include <spicy/ast/types/unit.h>
10 
11 namespace spicy::type::unit::item {
12 
15 public:
16  UnitHook(ID id, Hook hook, Meta m = Meta()) : NodeBase(nodes(std::move(id), std::move(hook)), std::move(m)) {}
17 
18  const auto& id() const { return child<ID>(0); }
19  const auto& hook() const { return child<Hook>(1); }
20  const auto& location() const { return childs()[0].location(); }
21 
22  bool operator==(const UnitHook& other) const { return id() == other.id() && hook() == other.hook(); }
23 
24  // Unit field interface
25  Type itemType() const { return hook().type(); }
26  auto isEqual(const Item& other) const { return node::isEqual(this, other); }
27 
28  // Node interface.
29  auto properties() const { return node::Properties{}; }
30 };
31 
32 } // namespace spicy::type::unit::item
NodeBase(Meta meta)
Definition: node.h:325
auto & childs() const
Definition: node.h:445
Definition: hook.h:17
Definition: meta.h:18
Definition: unit-hook.h:14
Definition: unit-item.h:19
Definition: location.h:86
Definition: unit-item.h:39
Definition: id.h:18
Definition: node.h:318