Spicy
integer.h
1 // Copyright (c) 2020-2021 by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 #include <utility>
6 #include <vector>
7 
8 #include <hilti/ast/type.h>
9 
10 namespace hilti {
11 namespace type {
12 
13 namespace detail {
14 
15 // CHECK: IntegerBase = TypeBase
18 public:
19  IntegerBase(Wildcard /*unused*/, Meta m = Meta()) : TypeBase(std::move(m)), _wildcard(true) {}
20  IntegerBase(int width, Meta m = Meta()) : TypeBase(std::move(m)), _width(width) {}
21  IntegerBase(Meta m = Meta()) : TypeBase(std::move(m)) {}
22 
23  auto width() const { return _width; }
24 
26  auto isWildcard() const { return _wildcard; }
27 
29  auto properties() const { return node::Properties{{"width", _width}}; }
30 
31 private:
32  bool _wildcard = false;
33  int _width = 0;
34 };
35 
36 } // namespace detail
37 
40 public:
41  using detail::IntegerBase::IntegerBase;
42 
43  bool operator==(const SignedInteger& other) const { return width() == other.width(); }
44 
46  std::vector<Node> typeParameters() const;
47 
49  auto isEqual(const Type& other) const { return node::isEqual(this, other); }
50 };
51 
54 public:
55  using detail::IntegerBase::IntegerBase;
56 
57  bool operator==(const UnsignedInteger& other) const { return width() == other.width(); }
58 
60  std::vector<Node> typeParameters() const;
61 
63  auto isEqual(const Type& other) const { return node::isEqual(this, other); }
64 };
65 
66 } // namespace type
67 } // namespace hilti
auto isEqual(const Type &other) const
Definition: integer.h:63
auto isWildcard() const
Definition: integer.h:26
auto isEqual(const Type &other) const
Definition: integer.h:49
Definition: meta.h:18
Definition: integer.h:53
Definition: integer.h:39
auto properties() const
Definition: integer.h:29
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:83
Definition: type.h:152
Definition: type.h:23
Definition: type.h:249
Definition: integer.h:17