Spicy
deferred.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 #include <hilti/ast/types/result.h>
9 
10 namespace hilti {
11 namespace expression {
12 
19 class Deferred : public NodeBase, public trait::isExpression {
20 public:
21  Deferred(Expression e, Meta m = Meta()) : NodeBase({std::move(e)}, std::move(m)) {}
22  Deferred(Expression e, bool catch_exception, Meta m = Meta())
23  : NodeBase({std::move(e)}, std::move(m)), _catch_exception(catch_exception) {}
24 
25  const auto& expression() const { return child<Expression>(0); }
26  bool catchException() const { return _catch_exception; }
27 
28  bool operator==(const Deferred& other) const { return expression() == other.expression(); }
29 
31  bool isLhs() const { return false; }
33  bool isTemporary() const { return true; }
35  auto type() const {
36  return _catch_exception ? Type(type::Result(expression().type(), meta())) : expression().type();
37  }
39  auto isConstant() const { return expression().isConstant(); }
41  auto isEqual(const Expression& other) const { return node::isEqual(this, other); }
42 
44  auto properties() const { return node::Properties{{"catch_exception", _catch_exception}}; }
45 
46 private:
47  bool _catch_exception;
48 };
49 
50 } // namespace expression
51 } // namespace hilti
bool isLhs() const
Definition: deferred.h:31
bool isTemporary() const
Definition: deferred.h:33
auto isConstant() const
Definition: deferred.h:39
Definition: expression.h:16
Definition: meta.h:18
auto isEqual(const Expression &other) const
Definition: deferred.h:41
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:83
auto properties() const
Definition: deferred.h:44
auto & meta() const
Definition: node.h:449
Definition: deferred.h:19
Definition: result.h:13
auto type() const
Definition: deferred.h:35
Definition: node.h:318