8 #include <hilti/ast/expression.h> 9 #include <hilti/ast/expressions/unresolved-operator.h> 10 #include <hilti/ast/node.h> 11 #include <hilti/ast/operator.h> 12 #include <hilti/ast/types/id.h> 20 namespace expression {
21 namespace resolved_operator {
23 #include <hilti/autogen/__resolved-operator.h> 25 inline Node to_node(ResolvedOperator t) {
return Node(std::move(t)); }
27 inline std::ostream& operator<<(std::ostream& out, ResolvedOperator i) {
return out << to_node(std::move(i)); }
32 using ResolvedOperator = resolved_operator::detail::ResolvedOperator;
33 using resolved_operator::detail::to_node;
41 inline Type type_to_store(Type t) {
58 :
NodeBase(nodes(detail::type_to_store(op.result(operands)), operands), std::move(meta)), _operator(op) {}
60 const auto& operator_()
const {
return _operator; }
61 auto kind()
const {
return _operator.kind(); }
64 const auto& operands()
const {
65 if ( _cache.operands.empty() )
66 _cache.operands = childs<Expression>(1, -1);
68 return _cache.operands;
71 const auto& result()
const {
73 return *_cache.result;
75 if ( ! childs()[0].isA<type::Unknown>() )
76 _cache.result = child<Type>(0);
79 _cache.result = _operator.result(operands());
81 return *_cache.result;
84 const auto& op0()
const {
return child<Expression>(1); }
85 const auto& op1()
const {
return child<Expression>(2); }
86 const auto& op2()
const {
return child<Expression>(3); }
87 auto hasOp0()
const {
return ! childs().empty(); }
88 auto hasOp1()
const {
return childs().size() >= 3; }
89 auto hasOp2()
const {
return childs().size() >= 4; }
90 void setOp0(
const Expression& e) { childs()[1] = e; }
91 void setOp1(
const Expression& e) { childs()[2] = e; }
92 void setOp2(
const Expression& e) { childs()[3] = e; }
94 bool operator==(
const ResolvedOperator& other)
const {
95 return operator_() == other.operator_() && operands() == other.operands();
99 bool isLhs()
const {
return operator_().isLhs(); }
103 auto type()
const {
return type::effectiveType(result()); }
105 auto isEqual(
const Expression& other)
const {
return node::isEqual(
this, other); }
114 _cache.result.reset();
115 _cache.operands.clear();
119 ::hilti::operator_::detail::Operator _operator;
122 std::optional<Type> result;
123 std::vector<Expression> operands;
127 namespace resolved_operator {
136 inline hilti::Expression setOp0(
const expression::ResolvedOperator& r, Expression e) {
137 auto x = r._clone().as<expression::ResolvedOperator>();
138 x.setOp0(std::move(e));
149 inline hilti::Expression setOp1(
const expression::ResolvedOperator& r, Expression e) {
150 auto x = r._clone().as<expression::ResolvedOperator>();
151 x.setOp1(std::move(e));
162 inline hilti::Expression setOp2(
const expression::ResolvedOperator& r, Expression e) {
163 auto x = r._clone().as<expression::ResolvedOperator>();
164 x.setOp2(std::move(e));
auto isEqual(const Expression &other) const
Definition: resolved-operator.h:105
bool isTemporary() const
Definition: resolved-operator.h:101
Definition: expression.h:16
auto properties() const
Definition: resolved-operator.h:111
void clearCache()
Definition: resolved-operator.h:113
auto type() const
Definition: resolved-operator.h:103
Definition: resolved-operator.h:55
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:83
bool isLhs() const
Definition: resolved-operator.h:99
bool isConstant() const
Definition: resolved-operator.h:108
Definition: resolved-operator.h:17