9 #include <hilti/ast/declaration.h> 10 #include <hilti/ast/declarations/type.h> 11 #include <hilti/ast/node_ref.h> 12 #include <hilti/ast/type.h> 13 #include <hilti/ast/types/unknown.h> 35 using Callback = std::function<Type(Node&)>;
36 using Callback2 = std::function<Type(Node&, Node&)>;
39 :
TypeBase(nodes(
node::none), std::move(m)), _node(std::move(r)), _callback(std::move(cb)) {}
44 _node2(std::move(r2)),
45 _callback2(std::move(cb)) {}
47 :
TypeBase(nodes(std::move(e)), std::move(m)), _callback(std::move(cb)) {}
50 :
TypeBase(nodes(std::move(t)), std::move(m)), _callback(std::move(cb)) {}
52 :
TypeBase(nodes(std::move(t), std::move(n)), std::move(m)), _callback2(std::move(cb2)) {}
57 return type::effectiveType(_callback(*_node));
58 else if ( _callback2 ) {
60 return type::effectiveType(_callback2(*_node, *_node2));
63 return type::effectiveType(_node->template as<Type>());
66 if (
auto e =
childs()[0].tryAs<Expression>() ) {
68 return type::effectiveType(_callback(const_cast<Node&>(
childs()[0])));
69 else if ( _callback2 )
70 return type::effectiveType(_callback2(const_cast<Node&>(
childs()[0]), const_cast<Node&>(
childs()[1])));
72 if ( ! _change_constness_to.has_value() )
75 if ( *_change_constness_to )
76 return type::constant(e->type());
78 return type::nonConstant(e->type());
81 if (
auto t =
childs()[0].tryAs<Type>() ) {
83 return type::effectiveType(_callback(const_cast<Node&>(
childs()[0])));
84 else if ( _callback2 )
85 return type::effectiveType(_callback2(const_cast<Node&>(
childs()[0]), const_cast<Node&>(
childs()[1])));
93 bool operator==(
const Computed& other)
const {
return type() == other.type(); }
96 bool isEqual(
const Type& other)
const {
return type() == other; }
100 std::vector<Node> typeParameters()
const {
return type().typeParameters(); }
101 bool isWildcard()
const {
return type().isWildcard(); }
102 Type iteratorType(
bool const_)
const {
return type().iteratorType(const_); }
103 Type viewType()
const {
return type().viewType(); }
104 Type dereferencedType()
const {
return type().dereferencedType(); }
105 Type elementType()
const {
return type().elementType(); }
124 Callback2 _callback2;
125 std::optional<bool> _change_constness_to;
std::string renderedRid() const
Definition: node_ref.h:68
auto & childs() const
Definition: node.h:445
Type effectiveType() const
Definition: computed.h:98
const Node none
Definition: node.cc:12
Definition: computed.h:28
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:83
Definition: node_ref.h:44
auto properties() const
Definition: computed.h:108
bool isEqual(const Type &other) const
Definition: computed.h:96