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 {
11 namespace type {
12 
13 namespace stream {
14 
16 class Iterator : public TypeBase,
22 public:
23  Iterator(Meta m = Meta()) : TypeBase(nodes(type::UnsignedInteger(8)), 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  auto _isResolved(ResolvedState* rstate) const { return true; }
32  const Type& dereferencedType() const { return child<Type>(0); }
34  auto properties() const { return node::Properties{}; }
35 };
36 
39 public:
40  View(Meta m = Meta()) : TypeBase(nodes(stream::Iterator(m)), m) {}
41 
42  bool operator==(const View& /* other */) const { return true; }
43 
45  auto isEqual(const Type& other) const { return node::isEqual(this, other); }
47  auto _isResolved(ResolvedState* rstate) const { return true; }
49  const Type& elementType() const { return iteratorType(true).dereferencedType(); }
51  const Type& iteratorType(bool /* const_ */) const { return child<Type>(0); }
53  auto properties() const { return node::Properties{}; }
54 };
55 
56 } // namespace stream
57 
59 class Stream : public TypeBase,
65 public:
66  Stream(Meta m = Meta()) : TypeBase(nodes(stream::View(m)), m) {}
67 
68  bool operator==(const Stream& /* other */) const { return true; }
69 
71  auto isEqual(const Type& other) const { return node::isEqual(this, other); }
73  auto _isResolved(ResolvedState* rstate) const { return true; }
75  const Type& elementType() const { return iteratorType(true).dereferencedType(); }
77  const Type& iteratorType(bool /* const_ */) const { return viewType().iteratorType(true); }
79  const Type& viewType() const { return child<Type>(0); }
81  auto properties() const { return node::Properties{}; }
82 };
83 
84 namespace detail::stream {
85 inline Node element_type = Node(type::UnsignedInteger(8, Location()));
86 } // namespace detail::stream
87 
88 } // namespace type
89 
90 } // namespace hilti
auto _isResolved(ResolvedState *rstate) const
Definition: stream.h:47
auto _isResolved(ResolvedState *rstate) const
Definition: stream.h:73
auto isEqual(const Type &other) const
Definition: stream.h:45
const Type & elementType() const
Definition: stream.h:49
auto properties() const
Definition: stream.h:81
Definition: type.h:36
auto _isResolved(ResolvedState *rstate) const
Definition: stream.h:30
const Type & iteratorType(bool) const
Definition: stream.h:77
auto isEqual(const Type &other) const
Definition: stream.h:28
Definition: stream.h:59
const Type & elementType() const
Definition: stream.h:75
const Type & viewType() const
Definition: stream.h:79
Definition: type.h:37
Definition: meta.h:18
Definition: integer.h:54
const Type & dereferencedType() const
Definition: stream.h:32
Definition: type.h:159
const Type & iteratorType(bool) const
Definition: stream.h:51
Definition: type.h:41
Definition: stream.h:16
Definition: type.h:35
auto isEqual(const Type &other) const
Definition: stream.h:71
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:99
Definition: stream.h:38
Definition: type.h:198
Definition: type.h:42
Definition: node.h:113
Definition: type.h:33
Definition: location.h:17
auto properties() const
Definition: stream.h:34
auto properties() const
Definition: stream.h:53