Spicy
type-wrapped.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 TypeWrapped : public NodeBase, public trait::isExpression {
14 public:
15  TypeWrapped(Expression e, Type t, Meta m = Meta()) : NodeBase(nodes(std::move(e), std::move(t)), std::move(m)) {}
16 
17  const auto& expression() const { return child<Expression>(0); }
18 
19  bool operator==(const TypeWrapped& other) const {
20  return expression() == other.expression() && type() == other.type();
21  }
22 
24  bool isLhs() const { return expression().isLhs(); }
26  bool isTemporary() const { return expression().isTemporary(); }
28  const Type& type() const { return children()[1].as<Type>(); }
29 
31  auto isConstant() const { return expression().isConstant(); }
33  auto isEqual(const Expression& other) const { return node::isEqual(this, other); }
34 
36  auto properties() const { return node::Properties{}; }
37 };
38 
39 } // namespace expression
40 } // namespace hilti
const Type & type() const
Definition: type-wrapped.h:28
const auto & children() const
Definition: node.h:470
Definition: expression.h:17
auto properties() const
Definition: type-wrapped.h:36
Definition: meta.h:18
Definition: type.h:159
Definition: type-wrapped.h:13
auto isConstant() const
Definition: type-wrapped.h:31
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:99
bool isLhs() const
Definition: type-wrapped.h:24
auto isEqual(const Expression &other) const
Definition: type-wrapped.h:33
bool isTemporary() const
Definition: type-wrapped.h:26
Definition: node.h:358