]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ast-builder: Add new functions to create type paths.
authorArthur Cohen <arthur.cohen@embecosm.com>
Wed, 29 Jan 2025 18:11:28 +0000 (18:11 +0000)
committerCohenArthur <arthur.cohen@embecosm.com>
Sun, 2 Feb 2025 18:29:35 +0000 (18:29 +0000)
gcc/rust/ChangeLog:

* ast/rust-ast-builder.cc (Builder::type_path): New functions.
* ast/rust-ast-builder.h: Declare them.

gcc/rust/ast/rust-ast-builder.cc
gcc/rust/ast/rust-ast-builder.h

index b3ee387ef9c1fdc5e65816f323fe3aeb921a1d52..4afe329107641b521d9560d92d5438031cf7f990 100644 (file)
@@ -158,13 +158,32 @@ Builder::single_generic_type_path (LangItem::Kind lang_item,
   return std::unique_ptr<Type> (new TypePath (std::move (segments), loc));
 }
 
+TypePath
+Builder::type_path (std::vector<std::unique_ptr<TypePathSegment>> &&segments,
+                   bool opening_scope) const
+{
+  return TypePath (std::move (segments), loc, opening_scope);
+}
+
+TypePath
+Builder::type_path (std::vector<std::string> &&segments,
+                   bool opening_scope) const
+{
+  auto type_segments = std::vector<std::unique_ptr<TypePathSegment>> ();
+
+  for (auto &&segment : segments)
+    type_segments.emplace_back (type_path_segment (segment));
+
+  return TypePath (std::move (type_segments), loc, opening_scope);
+}
+
 TypePath
 Builder::type_path (std::unique_ptr<TypePathSegment> &&segment) const
 {
   auto segments = std::vector<std::unique_ptr<TypePathSegment>> ();
   segments.emplace_back (std::move (segment));
 
-  return TypePath (std::move (segments), loc);
+  return type_path (std::move (segments));
 }
 
 TypePath
index 372e355fa9b60e1c38b6b131df3ebf900677bb70..333b6791ad2c9970f9932bc01b8da3302315ddd0 100644 (file)
@@ -132,6 +132,10 @@ public:
   std::unique_ptr<Type> single_generic_type_path (LangItem::Kind lang_item,
                                                  GenericArgs args) const;
 
+  TypePath type_path (std::vector<std::unique_ptr<TypePathSegment>> &&segment,
+                     bool opening_scope = false) const;
+  TypePath type_path (std::vector<std::string> &&segments,
+                     bool opening_scope = false) const;
   TypePath type_path (std::unique_ptr<TypePathSegment> &&segment) const;
   TypePath type_path (std::string type) const;
   TypePath type_path (LangItem::Kind lang_item) const;