]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: 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)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 24 Mar 2025 12:06:59 +0000 (13:06 +0100)
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 567e6c4350952ed8637b3ea76c5ac24c7feb0bf2..4d94f0da573cd863dd3469b619ae074227b20658 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 3b9990a4969ac6a43c4eace50c17601ee66c56bf..47e8f7f5bbb018231d8a3f66c3cde4b9801fba5b 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;