]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Add proc macros abstractions to crate structure
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Mon, 31 Jul 2023 16:31:51 +0000 (18:31 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:04:33 +0000 (19:04 +0100)
Add multiple setters for a crate object in order to add macro
abstractions previously introduced.

gcc/rust/ChangeLog:

* ast/rust-ast.h (struct Crate): Add proc macro members.

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

index b78c4291e7aeba6b5838acc1386ae328eac98e8a..ca117842a24bb86ebd47ad67bae0922a09b2a901 100644 (file)
@@ -2026,6 +2026,10 @@ struct Crate
 
   NodeId node_id;
 
+  std::vector<AttributeProcMacro> attribute_macros;
+  std::vector<CustomDeriveProcMacro> derive_macros;
+  std::vector<BangProcMacro> bang_macros;
+
 public:
   // Constructor
   Crate (std::vector<std::unique_ptr<Item>> items,
@@ -2088,6 +2092,16 @@ public:
   {
     items = std::move (new_items);
   }
+
+  void add_bang_macro (ProcMacro::Bang macro) { bang_macros.push_back (macro); }
+  void add_attribute_macro (ProcMacro::Attribute macro)
+  {
+    attribute_macros.push_back (macro);
+  }
+  void add_derive_macro (ProcMacro::CustomDerive macro)
+  {
+    derive_macros.push_back (macro);
+  }
 };
 
 // Base path expression AST node - abstract