Spicy
exception.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 
9 namespace hilti {
10 namespace type {
11 
14 public:
15  Exception(Meta m = Meta()) : TypeBase({node::none}, std::move(m)) {}
16  Exception(Type base, Meta m = Meta()) : TypeBase({std::move(base)}, std::move(m)) {}
17  Exception(Wildcard /*unused*/, Meta m = Meta()) : TypeBase({node::none}, std::move(m)), _wildcard(true) {}
18 
19  std::optional<Type> baseType() const {
20  auto t = childs()[0].tryAs<Type>();
21  if ( t )
22  return type::effectiveType(*t);
23 
24  return {};
25  }
26 
27  bool operator==(const Exception& other) const { return baseType() == other.baseType(); }
28 
30  auto isEqual(const Type& other) const { return node::isEqual(this, other); }
32  auto typeParameters() const { return childs(); }
34  auto isWildcard() const { return _wildcard; }
36  auto properties() const { return node::Properties{}; }
37 
38 private:
39  bool _wildcard = false;
40 };
41 
42 } // namespace type
43 } // namespace hilti
auto & childs() const
Definition: node.h:445
auto isWildcard() const
Definition: exception.h:34
const Node none
Definition: node.cc:12
auto properties() const
Definition: exception.h:36
Definition: meta.h:18
Definition: exception.h:13
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:83
Definition: type.h:152
Definition: type.h:23
Definition: type.h:249
auto typeParameters() const
Definition: exception.h:32
auto isEqual(const Type &other) const
Definition: exception.h:30