From: Arthur Cohen Date: Wed, 29 Jan 2025 18:11:28 +0000 (+0000) Subject: gccrs: ast-builder: Add new functions to create type paths. X-Git-Tag: basepoints/gcc-16~785 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4106b575c66c29de0231887eadc440d5772d447c;p=thirdparty%2Fgcc.git gccrs: ast-builder: Add new functions to create type paths. gcc/rust/ChangeLog: * ast/rust-ast-builder.cc (Builder::type_path): New functions. * ast/rust-ast-builder.h: Declare them. --- diff --git a/gcc/rust/ast/rust-ast-builder.cc b/gcc/rust/ast/rust-ast-builder.cc index 567e6c43509..4d94f0da573 100644 --- a/gcc/rust/ast/rust-ast-builder.cc +++ b/gcc/rust/ast/rust-ast-builder.cc @@ -158,13 +158,32 @@ Builder::single_generic_type_path (LangItem::Kind lang_item, return std::unique_ptr (new TypePath (std::move (segments), loc)); } +TypePath +Builder::type_path (std::vector> &&segments, + bool opening_scope) const +{ + return TypePath (std::move (segments), loc, opening_scope); +} + +TypePath +Builder::type_path (std::vector &&segments, + bool opening_scope) const +{ + auto type_segments = std::vector> (); + + 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 &&segment) const { auto segments = std::vector> (); segments.emplace_back (std::move (segment)); - return TypePath (std::move (segments), loc); + return type_path (std::move (segments)); } TypePath diff --git a/gcc/rust/ast/rust-ast-builder.h b/gcc/rust/ast/rust-ast-builder.h index 3b9990a4969..47e8f7f5bbb 100644 --- a/gcc/rust/ast/rust-ast-builder.h +++ b/gcc/rust/ast/rust-ast-builder.h @@ -132,6 +132,10 @@ public: std::unique_ptr single_generic_type_path (LangItem::Kind lang_item, GenericArgs args) const; + TypePath type_path (std::vector> &&segment, + bool opening_scope = false) const; + TypePath type_path (std::vector &&segments, + bool opening_scope = false) const; TypePath type_path (std::unique_ptr &&segment) const; TypePath type_path (std::string type) const; TypePath type_path (LangItem::Kind lang_item) const;