10 #include <hilti/ast/id.h> 11 #include <hilti/ast/type.h> 25 auto id()
const {
return children()[0].tryAs<
ID>(); }
26 const auto& type()
const {
return child<Type>(1); }
31 bool operator==(
const Element& other)
const {
return id() == other.id() && type() == other.type(); }
41 Tuple(std::vector<Type> t,
Meta m =
Meta()) :
TypeBase(nodes(_typesToElements(std::move(t))), std::move(m)) {}
42 Tuple(std::vector<tuple::Element> e,
Meta m =
Meta()) :
TypeBase(nodes(std::move(e)), std::move(m)) {}
45 auto elements()
const {
return children<tuple::Element>(0, -1); }
46 std::optional<std::pair<int, const type::tuple::Element*>> elementByID(
const ID&
id)
const;
48 bool operator==(
const Tuple& other)
const {
49 if ( _wildcard || other._wildcard )
50 return _wildcard && other._wildcard;
52 return elements() == other.elements();
56 auto isEqual(
const Type& other)
const {
return node::isEqual(
this, other); }
61 return std::all_of(cs.begin(), cs.end(), [&](
const auto& c) {
62 auto t = c.template tryAs<Type>();
63 return ! t || type::detail::isResolved(*t, rstate);
76 std::vector<tuple::Element> _typesToElements(std::vector<Type>&& types) {
77 std::vector<tuple::Element> elements;
78 elements.reserve(types.size());
79 for (
auto&& t : types )
80 elements.emplace_back(std::move(t), t.meta());
85 bool _wildcard =
false;
auto properties() const
Definition: tuple.h:73
const Node none
Definition: node.cc:14
const auto & children() const
Definition: node.h:472
auto isEqual(const Type &other) const
Definition: tuple.h:56
auto _isResolved(ResolvedState *rstate) const
Definition: tuple.h:58
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:98
auto properties() const
Definition: tuple.h:29
auto typeParameters() const
Definition: tuple.h:68
auto isWildcard() const
Definition: tuple.h:70