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::type {
11 
12 namespace detail {
13 
14 // CHECK: IntegerBase = TypeBase
17 public:
18  IntegerBase(Wildcard /*unused*/, Meta m = Meta()) : TypeBase(std::move(m)), _wildcard(true) {}
19  IntegerBase(int width, Meta m = Meta()) : TypeBase(std::move(m)), _width(width) {}
20  IntegerBase(Meta m = Meta()) : TypeBase(std::move(m)) {}
21 
22  auto width() const { return _width; }
23 
25  auto isWildcard() const { return _wildcard; }
27  auto _isResolved(ResolvedState* rstate) const { return true; }
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 hilti::type
auto isEqual(const Type &other) const
Definition: integer.h:63
auto isWildcard() const
Definition: integer.h:25
Definition: type.h:34
auto isEqual(const Type &other) const
Definition: integer.h:49
Definition: meta.h:19
Definition: integer.h:53
Definition: type.h:160
Definition: integer.h:39
auto properties() const
Definition: integer.h:29
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:97
Definition: type.h:206
Definition: type.h:33
Definition: type.h:277
Definition: integer.h:16
Definition: type.h:26
auto _isResolved(ResolvedState *rstate) const
Definition: integer.h:27