Spicy
stream.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::type {
11 
12 namespace stream {
13 
15 class Iterator : public TypeBase,
21 public:
22  Iterator(Meta m = Meta()) : TypeBase(nodes(type::UnsignedInteger(8)), std::move(m)) {}
23 
24  bool operator==(const Iterator& /* other */) const { return true; }
25 
27  auto isEqual(const Type& other) const { return node::isEqual(this, other); }
29  auto _isResolved(ResolvedState* rstate) const { return true; }
31  const Type& dereferencedType() const { return child<Type>(0); }
33  auto properties() const { return node::Properties{}; }
34 };
35 
38 public:
39  View(const Meta& m = Meta()) : TypeBase(nodes(stream::Iterator(m)), m) {}
40 
41  bool operator==(const View& /* other */) const { return true; }
42 
44  auto isEqual(const Type& other) const { return node::isEqual(this, other); }
46  auto _isResolved(ResolvedState* rstate) const { return true; }
48  const Type& elementType() const { return iteratorType(true).dereferencedType(); }
50  const Type& iteratorType(bool /* const_ */) const { return child<Type>(0); }
52  auto properties() const { return node::Properties{}; }
53 };
54 
55 } // namespace stream
56 
58 class Stream : public TypeBase,
64 public:
65  Stream(const Meta& m = Meta()) : TypeBase(nodes(stream::View(m)), m) {}
66 
67  bool operator==(const Stream& /* other */) const { return true; }
68 
70  auto isEqual(const Type& other) const { return node::isEqual(this, other); }
72  auto _isResolved(ResolvedState* rstate) const { return true; }
74  const Type& elementType() const { return iteratorType(true).dereferencedType(); }
76  const Type& iteratorType(bool /* const_ */) const { return viewType().iteratorType(true); }
78  const Type& viewType() const { return child<Type>(0); }
80  auto properties() const { return node::Properties{}; }
81 };
82 
83 namespace detail::stream {
84 inline Node element_type = Node(type::UnsignedInteger(8, Location()));
85 } // namespace detail::stream
86 
87 } // namespace hilti::type
auto _isResolved(ResolvedState *rstate) const
Definition: stream.h:46
auto _isResolved(ResolvedState *rstate) const
Definition: stream.h:72
auto isEqual(const Type &other) const
Definition: stream.h:44
const Type & elementType() const
Definition: stream.h:48
auto properties() const
Definition: stream.h:80
Definition: type.h:35
auto _isResolved(ResolvedState *rstate) const
Definition: stream.h:29
const Type & iteratorType(bool) const
Definition: stream.h:76
auto isEqual(const Type &other) const
Definition: stream.h:27
Definition: stream.h:58
const Type & elementType() const
Definition: stream.h:74
const Type & viewType() const
Definition: stream.h:78
Definition: type.h:36
Definition: meta.h:19
Definition: integer.h:53
const Type & dereferencedType() const
Definition: stream.h:31
Definition: type.h:158
const Type & iteratorType(bool) const
Definition: stream.h:50
Definition: type.h:40
Definition: stream.h:15
Definition: type.h:34
auto isEqual(const Type &other) const
Definition: stream.h:70
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:97
Definition: stream.h:37
Definition: type.h:197
Definition: type.h:41
Definition: node.h:111
Definition: type.h:32
Definition: location.h:18
auto properties() const
Definition: stream.h:33
auto properties() const
Definition: stream.h:52
Definition: type.h:25