Spicy
bytes.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/type.h>
8 #include <hilti/ast/types/integer.h>
9 
10 namespace hilti {
11 namespace type {
12 
13 namespace bytes {
14 
16 class Iterator : public TypeBase,
22 public:
23  Iterator(Meta m = Meta()) : TypeBase(std::move(m)) {}
24 
25  bool operator==(const Iterator& /* other */) const { return true; }
26 
28  auto isEqual(const Type& other) const { return node::isEqual(this, other); }
30  Type dereferencedType() const;
32  auto properties() const { return node::Properties{}; }
33 };
34 
35 } // namespace bytes
36 
39 public:
40  Bytes(Meta m = Meta()) : TypeBase(std::move(m)) {}
41 
42  bool operator==(const Bytes& /* other */) const { return true; }
43 
45  auto isEqual(const Type& other) const { return node::isEqual(this, other); }
47  Type elementType() const { return type::UnsignedInteger(8); }
48 
50  Type iteratorType(bool /* const_ */) const { return bytes::Iterator(meta()); }
52  auto properties() const { return node::Properties{}; }
53 
54 private:
55  std::optional<Node> _etype;
56 };
57 
58 namespace detail::bytes {
59 inline Node element_type = Node(type::UnsignedInteger(8, Location()));
60 } // namespace detail::bytes
61 
62 inline Type bytes::Iterator::dereferencedType() const { return type::UnsignedInteger(8); }
63 
64 } // namespace type
65 
66 } // namespace hilti
auto isEqual(const Type &other) const
Definition: bytes.h:28
auto properties() const
Definition: bytes.h:52
Definition: type.h:26
Type elementType() const
Definition: bytes.h:47
Definition: type.h:27
Definition: meta.h:18
Definition: integer.h:53
Definition: bytes.h:38
Definition: bytes.h:16
Definition: type.h:25
auto properties() const
Definition: bytes.h:32
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:83
Type dereferencedType() const
Definition: bytes.h:62
Definition: type.h:152
Type iteratorType(bool) const
Definition: bytes.h:50
Definition: node.h:97
Definition: type.h:23
Definition: location.h:17
auto isEqual(const Type &other) const
Definition: bytes.h:45
auto & meta() const
Definition: node.h:449