From f915a3fe9027a8eececd16425d890480bfec2fe7 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Wed, 6 Sep 2023 14:34:45 +0200 Subject: [PATCH] gccrs: Add containers for proc macro collection mappings 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 --- gcc/rust/backend/rust-compile-context.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index ff44c1ea7790..79e3457f1103 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -38,6 +38,13 @@ struct fncontext TyTy::BaseType *retty; }; +struct CustomDeriveInfo +{ + tree fndecl; + std::string trait_name; + std::vector 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 implicit_pattern_bindings; std::map main_variants; + std::vector custom_derive_macros; + std::vector attribute_macros; + std::vector bang_macros; + // closure bindings std::vector closure_scope_bindings; std::map> closure_bindings; -- 2.47.2