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 | |
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')
-rw-r--r-- | gcc/rust/ast/rust-ast.h | 13 | ||||
-rw-r--r-- | gcc/rust/ast/rust-expr.h | 13 |
2 files changed, 24 insertions, 2 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 392c36a..b61c8c3 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -1139,11 +1139,14 @@ private: Location locus; + NodeId node_id; + public: // Constructor Lifetime (LifetimeType type, std::string name = std::string (), Location locus = Location ()) - : lifetime_type (type), lifetime_name (std::move (name)), locus (locus) + : lifetime_type (type), lifetime_name (std::move (name)), locus (locus), + node_id (Analysis::Mappings::get ()->get_next_node_id ()) {} // Creates an "error" lifetime. @@ -1159,6 +1162,14 @@ public: void accept_vis (ASTVisitor &vis) override; + LifetimeType get_lifetime_type () { return lifetime_type; } + + Location get_locus () { return locus; } + + std::string get_lifetime_name () const { return lifetime_name; } + + NodeId get_node_id () const { return node_id; } + protected: /* Use covariance to implement clone function as returning this object rather * than base */ 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 (); } |