aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/rust-gcc.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/rust-gcc.cc')
-rw-r--r--gcc/rust/rust-gcc.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 0729b1e..82ebb98 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -326,6 +326,10 @@ public:
Bstatement *except_stmt,
Bstatement *finally_stmt, Location);
+ Bexpression *loop_expression (Bblock *body, Location);
+
+ Bexpression *exit_expression (Bexpression *condition, Location);
+
// Blocks.
Bblock *block (Bfunction *, Bblock *, const std::vector<Bvariable *> &,
@@ -2201,6 +2205,25 @@ Gcc_backend::if_statement (Bfunction *, Bexpression *condition,
return this->make_statement (ret);
}
+// Loops
+
+Bexpression *
+Gcc_backend::loop_expression (Bblock *body, Location locus)
+{
+ tree loop_expr_tree = fold_build1_loc (locus.gcc_location (), LOOP_EXPR,
+ void_type_node, body->get_tree ());
+ return this->make_expression (loop_expr_tree);
+}
+
+Bexpression *
+Gcc_backend::exit_expression (Bexpression *condition, Location locus)
+{
+ tree cond_tree = condition->get_tree ();
+ tree exit_expr_tree = fold_build1_loc (locus.gcc_location (), EXIT_EXPR,
+ void_type_node, cond_tree);
+ return this->make_expression (exit_expr_tree);
+}
+
// Switch.
Bstatement *