aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-ast-builder.cc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2025-01-23 11:42:38 +0000
committerCohenArthur <arthur.cohen@embecosm.com>2025-02-02 18:31:22 +0000
commit4a053730c5c880984be1a7f8b6cfb19b62aa3331 (patch)
tree1fdc15785cdce84d06fa8a6e86c5271275f3479d /gcc/rust/ast/rust-ast-builder.cc
parentdf1a65d6d275e097f73bb0c6652061e4dca240ab (diff)
downloadgcc-4a053730c5c880984be1a7f8b6cfb19b62aa3331.zip
gcc-4a053730c5c880984be1a7f8b6cfb19b62aa3331.tar.gz
gcc-4a053730c5c880984be1a7f8b6cfb19b62aa3331.tar.bz2
ast: builder: Add Return expression builder
gcc/rust/ChangeLog: * ast/rust-ast-builder.h: Declare it. * ast/rust-ast-builder.cc (Builder::return_expr): Define it.
Diffstat (limited to 'gcc/rust/ast/rust-ast-builder.cc')
-rw-r--r--gcc/rust/ast/rust-ast-builder.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/rust/ast/rust-ast-builder.cc b/gcc/rust/ast/rust-ast-builder.cc
index 963ba99..0538998 100644
--- a/gcc/rust/ast/rust-ast-builder.cc
+++ b/gcc/rust/ast/rust-ast-builder.cc
@@ -276,6 +276,13 @@ Builder::block (std::vector<std::unique_ptr<Stmt>> &&stmts,
LoopLabel::error (), loc, loc));
}
+std::unique_ptr<Expr>
+Builder::return_expr (std::unique_ptr<Expr> &&to_return)
+{
+ return std::unique_ptr<Expr> (
+ new ReturnExpr (std::move (to_return), {}, loc));
+}
+
std::unique_ptr<Stmt>
Builder::let (std::unique_ptr<Pattern> pattern, std::unique_ptr<Type> type,
std::unique_ptr<Expr> init) const