Spicy
coerced.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/expression.h>
8 
9 namespace hilti {
10 namespace expression {
11 
13 class Coerced : public NodeBase, public trait::isExpression {
14 public:
15  Coerced(Expression e, Type t, Meta m = Meta()) : NodeBase({std::move(e), std::move(t)}, std::move(m)) {}
16 
17  const auto& expression() const { return child<Expression>(0); }
18 
19  bool operator==(const Coerced& other) const { return expression() == other.expression() && type() == other.type(); }
20 
22  bool isLhs() const { return expression().isLhs(); }
24  bool isTemporary() const { return true; }
26  Type type() const { return type::nonConstant(type::effectiveType(child<Type>(1))); }
28  auto isConstant() const { return expression().isConstant(); }
30  auto isEqual(const Expression& other) const { return node::isEqual(this, other); }
31 
33  auto properties() const { return node::Properties{}; }
34 };
35 
36 } // namespace expression
37 } // namespace hilti
Definition: coerced.h:13
auto properties() const
Definition: coerced.h:33
Type type() const
Definition: coerced.h:26
auto isConstant() const
Definition: coerced.h:28
Definition: expression.h:16
Definition: meta.h:18
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:83
bool isTemporary() const
Definition: coerced.h:24
bool isLhs() const
Definition: coerced.h:22
auto isEqual(const Expression &other) const
Definition: coerced.h:30
Definition: node.h:318