Spicy
result.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  Result(Wildcard /*unused*/, Meta m = Meta()) : TypeBase({node::none}, std::move(m)), _wildcard(true) {}
16  Result(Type ct, Meta m = Meta()) : TypeBase({std::move(ct)}, std::move(m)) {}
17 
18  Type dereferencedType() const {
19  if ( auto t = childs()[0].tryAs<Type>() )
20  return *t;
21 
22  return type::unknown;
23  }
24 
25  bool operator==(const Result& other) const { return dereferencedType() == other.dereferencedType(); }
26 
28  auto isEqual(const Type& other) const { return node::isEqual(this, other); }
30  auto typeParameters() const { return childs(); }
32  auto isWildcard() const { return _wildcard; }
33 
35  auto properties() const { return node::Properties{}; }
36 
37 private:
38  bool _wildcard = false;
39 };
40 
41 } // namespace type
42 } // namespace hilti
auto isWildcard() const
Definition: result.h:32
auto & childs() const
Definition: node.h:445
auto typeParameters() const
Definition: result.h:30
const Node none
Definition: node.cc:12
auto isEqual(const Type &other) const
Definition: result.h:28
Definition: meta.h:18
auto properties() const
Definition: result.h:35
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: result.h:13