diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-02-10 15:47:14 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-02-10 18:10:57 +0000 |
commit | 06c9fd97bf3d86a08eadcadb1bc59cb392116d16 (patch) | |
tree | a74de9189504af72dff442103b5a323c7a74b48b /gcc/rust/backend/rust-compile-context.h | |
parent | f10e695fc508c472c77e968e644f710806f82f54 (diff) | |
download | gcc-06c9fd97bf3d86a08eadcadb1bc59cb392116d16.zip gcc-06c9fd97bf3d86a08eadcadb1bc59cb392116d16.tar.gz gcc-06c9fd97bf3d86a08eadcadb1bc59cb392116d16.tar.bz2 |
Support LoopLabels and break to label.
This allows for the Rust refernece example for loop labels to be compiled.
Fixes #107
Diffstat (limited to 'gcc/rust/backend/rust-compile-context.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-context.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 25c9b89..8a74a05 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}); @@ -205,6 +220,7 @@ 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; |