Spicy
return.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/statement.h>
9 
10 namespace hilti::statement {
11 
13 class Return : public NodeBase, public hilti::trait::isStatement {
14 public:
15  Return(Meta m = Meta()) : NodeBase({node::none}, std::move(m)) {}
16  Return(hilti::Expression e, Meta m = Meta()) : NodeBase({std::move(e)}, std::move(m)) {}
17 
18  auto expression() const { return children()[0].tryAs<hilti::Expression>(); }
19 
20  void setExpression(const hilti::Expression& c) { children()[0] = c; }
21 
22  bool operator==(const Return& other) const { return expression() == other.expression(); }
23 
25  auto isEqual(const Statement& other) const { return node::isEqual(this, other); }
26 
28  auto properties() const { return node::Properties{}; }
29 };
30 
31 } // namespace hilti::statement
auto isEqual(const Statement &other) const
Definition: return.h:25
const Node none
Definition: node.cc:14
const auto & children() const
Definition: node.h:471
Definition: meta.h:19
Definition: return.h:13
Definition: statement.h:14
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:97
auto properties() const
Definition: return.h:28
Definition: node.h:359