diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-02-10 10:33:33 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-02-10 18:10:57 +0000 |
commit | ae273ffac99cb75d832a11a83fd63291bb74cbdc (patch) | |
tree | a3d9a44ebe75c96fac728c8f4ed3d0796664ed29 /gcc/rust/ast/rust-expr.h | |
parent | 016c40bedc7e3f53e2c413895f77c0d9f723eb3c (diff) | |
download | gcc-ae273ffac99cb75d832a11a83fd63291bb74cbdc.zip gcc-ae273ffac99cb75d832a11a83fd63291bb74cbdc.tar.gz gcc-ae273ffac99cb75d832a11a83fd63291bb74cbdc.tar.bz2 |
Support Break without label and expression
This reuses GENERICS LOOP_EXPR and EXIT_EXPR to implement the infinite
loop.
Addresses: #106 #108
Diffstat (limited to 'gcc/rust/ast/rust-expr.h')
-rw-r--r-- | gcc/rust/ast/rust-expr.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index 50006d1..52e3abc 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -3103,6 +3103,8 @@ public: return break_expr; } + Lifetime &get_label () { return label; } + protected: /* Use covariance to implement clone function as returning this object rather * than base */ @@ -3670,11 +3672,14 @@ class LoopLabel /*: public Node*/ Lifetime label; // or type LIFETIME_OR_LABEL Location locus; + NodeId node_id; + public: std::string as_string () const; LoopLabel (Lifetime loop_label, Location locus = Location ()) - : label (std::move (loop_label)), locus (locus) + : label (std::move (loop_label)), locus (locus), + node_id (Analysis::Mappings::get ()->get_next_node_id ()) {} // Returns whether the LoopLabel is in an error state. @@ -3684,6 +3689,10 @@ public: static LoopLabel error () { return LoopLabel (Lifetime::error ()); } Location get_locus () const { return locus; } + + Lifetime &get_lifetime () { return label; } + + NodeId get_node_id () const { return node_id; } }; // Base loop expression AST node - aka LoopExpr @@ -3743,6 +3752,8 @@ protected: public: bool has_loop_label () const { return !loop_label.is_error (); } + LoopLabel &get_loop_label () { return loop_label; } + Location get_locus () const { return locus; } Location get_locus_slow () const override { return get_locus (); } |