aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-context.h
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-12-14 21:11:04 +0000
committerPhilip Herron <philip.herron@embecosm.com>2021-12-18 20:20:49 +0000
commit52ee02f4012d0d5d4363ebb4e71e57b053acf072 (patch)
tree0cfaf806ac4ef1afbd32014133611c6e4cbf3305 /gcc/rust/backend/rust-compile-context.h
parenta8a345642a2a150a35b68e2f19b90abf105700c5 (diff)
downloadgcc-52ee02f4012d0d5d4363ebb4e71e57b053acf072.zip
gcc-52ee02f4012d0d5d4363ebb4e71e57b053acf072.tar.gz
gcc-52ee02f4012d0d5d4363ebb4e71e57b053acf072.tar.bz2
Add support for enums on the match expression
This is our initial first pass of adding support for the MatchExpr though two things stand out here. We need to switch over to using a GCC enumeral type for the union qualifier so we get advantage of the GCC code to ensure all variants are being addressed. We also need to fix out enum type to get better gdb support which might be simply chaning over to the qual_union_type. Fixes #190
Diffstat (limited to 'gcc/rust/backend/rust-compile-context.h')
-rw-r--r--gcc/rust/backend/rust-compile-context.h16
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 6347e76..896d42e 100644
--- a/gcc/rust/backend/rust-compile-context.h
+++ b/gcc/rust/backend/rust-compile-context.h
@@ -233,6 +233,21 @@ public:
return true;
}
+ void insert_pattern_binding (HirId id, tree binding)
+ {
+ implicit_pattern_bindings[id] = binding;
+ }
+
+ bool lookup_pattern_binding (HirId id, tree *binding)
+ {
+ auto it = implicit_pattern_bindings.find (id);
+ if (it == implicit_pattern_bindings.end ())
+ return false;
+
+ *binding = it->second;
+ return true;
+ }
+
void push_fn (tree fn, ::Bvariable *ret_addr)
{
fn_stack.push_back (fncontext{fn, ret_addr});
@@ -326,6 +341,7 @@ private:
std::map<const TyTy::BaseType *, std::pair<HirId, tree>> mono;
std::map<DefId, std::vector<std::pair<const TyTy::BaseType *, tree>>>
mono_fns;
+ std::map<HirId, tree> implicit_pattern_bindings;
// To GCC middle-end
std::vector<tree> type_decls;