diff options
Diffstat (limited to 'gcc/rust/backend/rust-compile-context.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-context.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 25c9b89..288b917 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -162,6 +162,21 @@ public: return true; } + void insert_label_decl (HirId id, ::Blabel *label) + { + compiled_labels[id] = label; + } + + bool lookup_label_decl (HirId id, ::Blabel **label) + { + auto it = compiled_labels.find (id); + if (it == compiled_labels.end ()) + return false; + + *label = it->second; + return true; + } + void push_fn (::Bfunction *fn, ::Bvariable *ret_addr) { fn_stack.push_back (fncontext{fn, ret_addr}); @@ -193,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; @@ -205,8 +231,10 @@ private: std::map<HirId, ::Btype *> compiled_type_map; std::map<HirId, ::Bfunction *> compiled_fn_map; std::map<HirId, ::Bexpression *> compiled_consts; + 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; |