]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add containers for proc macro collection mappings
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Wed, 6 Sep 2023 12:34:45 +0000 (14:34 +0200)
committerPhilip Herron <philip.herron@embecosm.com>
Tue, 31 Oct 2023 11:39:08 +0000 (11:39 +0000)
Add one container for each kind of procedural macro mapping. Also add a
new structure to gather informations required for derive procedural
macros. Add different functions to fill those new containers.

gcc/rust/ChangeLog:

* backend/rust-compile-context.h (struct CustomDeriveInfo): Add
new derive procedural macro metadata information holder for
mappings.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/backend/rust-compile-context.h

index e60d32ca94112f485337a13a632768fd65fc7913..c4bb8177b68c1f7861e8b602bf8f4d0b529ea84e 100644 (file)
@@ -38,6 +38,13 @@ struct fncontext
   TyTy::BaseType *retty;
 };
 
+struct CustomDeriveInfo
+{
+  tree fndecl;
+  std::string trait_name;
+  std::vector<std::string> attributes;
+};
+
 class Context
 {
 public:
@@ -357,6 +364,18 @@ public:
 
   static hashval_t type_hasher (tree type);
 
+  void collect_attribute_proc_macro (tree fndecl)
+  {
+    attribute_macros.push_back (fndecl);
+  }
+
+  void collect_bang_proc_macro (tree fndecl) { bang_macros.push_back (fndecl); }
+
+  void collect_derive_proc_macro (CustomDeriveInfo macro)
+  {
+    custom_derive_macros.push_back (macro);
+  }
+
 private:
   Resolver::Resolver *resolver;
   Resolver::TypeCheckContext *tyctx;
@@ -381,6 +400,10 @@ private:
   std::map<HirId, tree> implicit_pattern_bindings;
   std::map<hashval_t, tree> main_variants;
 
+  std::vector<CustomDeriveInfo> custom_derive_macros;
+  std::vector<tree> attribute_macros;
+  std::vector<tree> bang_macros;
+
   // closure bindings
   std::vector<HirId> closure_scope_bindings;
   std::map<HirId, std::map<HirId, tree>> closure_bindings;