diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-02-10 17:51:58 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-02-10 18:10:57 +0000 |
commit | 0c7d0135663b6f0d94e0ffd931366ba2b32f8b2c (patch) | |
tree | 5955326e3e944c45de7a96eb989adb2cd7c4538a /gcc/rust/backend/rust-compile-context.h | |
parent | d02ab5925b612678beb975d99951b1d2052958a1 (diff) | |
download | gcc-0c7d0135663b6f0d94e0ffd931366ba2b32f8b2c.zip gcc-0c7d0135663b6f0d94e0ffd931366ba2b32f8b2c.tar.gz gcc-0c7d0135663b6f0d94e0ffd931366ba2b32f8b2c.tar.bz2 |
Add support to break from loops with a value
This adds support to make the break value assignable such that the loop
now becomes akin to a BlockExpr
Fixes #108 #106
Diffstat (limited to 'gcc/rust/backend/rust-compile-context.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-context.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 8a74a05..288b917 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -208,6 +208,17 @@ public: return false; } + void push_loop_context (Bvariable *var) { loop_value_stack.push_back (var); } + + Bvariable *peek_loop_context () { return loop_value_stack.back (); } + + Bvariable *pop_loop_context () + { + auto back = loop_value_stack.back (); + loop_value_stack.pop_back (); + return back; + } + private: ::Backend *backend; Resolver::Resolver *resolver; @@ -223,6 +234,7 @@ private: std::map<HirId, ::Blabel *> compiled_labels; std::vector< ::std::vector<Bstatement *> > statements; std::vector< ::Bblock *> scope_stack; + std::vector< ::Bvariable *> loop_value_stack; // To GCC middle-end std::vector< ::Btype *> type_decls; |