9 #include <hilti/ast/builder/type.h> 10 #include <hilti/ast/ctor.h> 11 #include <hilti/ast/expression.h> 12 #include <hilti/ast/types/map.h> 13 #include <hilti/ast/types/unknown.h> 21 using Element = std::pair<Expression, Expression>;
22 Map(
const std::vector<Element>& e,
const Meta& m =
Meta())
24 Map(Type key, Type value,
const std::vector<Element>& e,
Meta m =
Meta())
25 :
NodeBase(nodes(std::move(key), std::move(value), _flatten(e)), std::move(m)) {}
27 auto keyType()
const {
28 if (
auto t =
childs()[0].tryAs<Type>() )
29 return type::effectiveType(*t);
38 auto elementType()
const {
39 if (
auto t =
childs()[1].tryAs<Type>() )
40 return type::effectiveType(*t);
50 auto exprs = childs<Expression>(2, -1);
51 std::vector<Element> elems;
52 for (
auto&& i = exprs.begin(); i != exprs.end(); i += 2 )
53 elems.emplace_back(std::make_pair(std::move(*i), std::move(*(i + 1))));
57 bool operator==(
const Map& other)
const {
58 return keyType() == other.keyType() && elementType() == other.elementType() && value() == other.value();
66 auto isLhs()
const {
return false; }
70 auto isEqual(
const Ctor& other)
const {
return node::isEqual(
this, other); }
75 std::vector<Expression> _flatten(
const std::vector<Element>& elems) {
76 std::vector<Expression> exprs;
77 for (
auto&& e : elems ) {
78 exprs.emplace_back(e.first);
79 exprs.emplace_back(e.second);
auto properties() const
Definition: map.h:72
auto & childs() const
Definition: node.h:445
auto type() const
Definition: map.h:62
const Node none
Definition: node.cc:12
bool isConstant() const
Definition: map.h:64
auto isTemporary() const
Definition: map.h:68
auto isEqual(const Ctor &other) const
Definition: map.h:70
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:83
auto & meta() const
Definition: node.h:449
auto isLhs() const
Definition: map.h:66