From: Pierre-Emmanuel Patry <[email protected]>
Extern block metadata is required to identify intrinsics from an extern
crate.
gcc/rust/ChangeLog:
* metadata/rust-export-metadata.cc (ExportContext::begin_extern_block):
Dump the prefix of an extern block.
(ExportContext::end_extern_block): Likewise with extern block suffix.
* metadata/rust-export-metadata.h: Add function prototypes.
Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
---
gcc/rust/metadata/rust-export-metadata.cc | 18 ++++++++++++++++++
gcc/rust/metadata/rust-export-metadata.h | 2 ++
2 files changed, 20 insertions(+)
diff --git a/gcc/rust/metadata/rust-export-metadata.cc
b/gcc/rust/metadata/rust-export-metadata.cc
index 93574284c52..3388d0e920d 100644
--- a/gcc/rust/metadata/rust-export-metadata.cc
+++ b/gcc/rust/metadata/rust-export-metadata.cc
@@ -106,6 +106,18 @@ ExportContext::emit_function (AST::Function &fn)
public_interface_buffer += oss.str ();
}
+void
+ExportContext::begin_extern_block (AST::ExternBlock &block)
+{
+ public_interface_buffer += "extern \"" + block.get_abi () + "\" {\n";
+}
+
+void
+ExportContext::end_extern_block ()
+{
+ public_interface_buffer += "}\n";
+}
+
void
ExportContext::begin_module (const AST::Module &module)
{
@@ -152,6 +164,12 @@ public:
{
ctx.emit_function (function);
}
+ void visit (AST::ExternBlock &block) override
+ {
+ ctx.begin_extern_block (block);
+ AST::DefaultASTVisitor::visit (block);
+ ctx.end_extern_block ();
+ }
void visit (AST::Trait &trait) override { ctx.emit_trait (trait); }
void visit (AST::Module &module) override
{
diff --git a/gcc/rust/metadata/rust-export-metadata.h
b/gcc/rust/metadata/rust-export-metadata.h
index 399b9295175..17dc20a7d5f 100644
--- a/gcc/rust/metadata/rust-export-metadata.h
+++ b/gcc/rust/metadata/rust-export-metadata.h
@@ -42,6 +42,8 @@ public:
void emit_trait (AST::Trait &trait);
void emit_function (AST::Function &fn);
+ void begin_extern_block (AST::ExternBlock &block);
+ void end_extern_block ();
void emit_use_declaration (AST::UseDeclaration &use_decl);
void begin_module (const AST::Module &module);
void end_module (const AST::Module &module);
--
2.50.1