aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-fmt.h
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-02-22 14:59:17 +0100
committerCohenArthur <arthur.cohen@embecosm.com>2024-03-01 15:42:36 +0000
commit3ff0f1a7bf230d641503fd1d2a2dc8066a729259 (patch)
tree2ac649ca99b85fc8863d06ceff8a4185bf30ff97 /gcc/rust/ast/rust-fmt.h
parentafed72d7137afe4ab4c7db44262379ba6dda4eb9 (diff)
downloadgcc-3ff0f1a7bf230d641503fd1d2a2dc8066a729259.zip
gcc-3ff0f1a7bf230d641503fd1d2a2dc8066a729259.tar.gz
gcc-3ff0f1a7bf230d641503fd1d2a2dc8066a729259.tar.bz2
lower: Add base for lowering FormatArgs nodes
gcc/rust/ChangeLog: * Make-lang.in: Compile the new source file. * ast/rust-ast-collector.cc (TokenCollector::visit): Error out when visiting FormatArgs nodes. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise. * ast/rust-ast.cc (FormatArgs::get_locus): New. * ast/rust-builtin-ast-nodes.h: Improve FormatArgs API. * ast/rust-fmt.cc (Pieces::~Pieces): Cleanup. (Pieces::Pieces): Likewise. * ast/rust-fmt.h (struct Pieces): Add pieces_vector member. * hir/rust-ast-lower-format-args.cc: New file. * hir/rust-ast-lower-format-args.h: New file.
Diffstat (limited to 'gcc/rust/ast/rust-fmt.h')
-rw-r--r--gcc/rust/ast/rust-fmt.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/gcc/rust/ast/rust-fmt.h b/gcc/rust/ast/rust-fmt.h
index 22447c4..ba412f9 100644
--- a/gcc/rust/ast/rust-fmt.h
+++ b/gcc/rust/ast/rust-fmt.h
@@ -262,6 +262,8 @@ struct Pieces
Pieces (Pieces &&other);
+ const std::vector<Piece> &get_pieces () const { return pieces_vector; }
+
// {
// slice = clone_pieces (&other.slice);
// to_parse = other.to_parse;
@@ -270,10 +272,17 @@ struct Pieces
// }
private:
- Pieces (PieceSlice slice, std::string &&to_parse)
- : slice (slice), to_parse (std::move (to_parse))
+ Pieces (std::vector<Piece> &&pieces_vector, PieceSlice slice,
+ std::string &&to_parse)
+ : pieces_vector (std::move (pieces_vector)), slice (slice),
+ to_parse (std::move (to_parse))
{}
+ std::vector<Piece> pieces_vector;
+
+ // this memory is held for FFI reasons - it needs to be released and cloned
+ // precisely, so try to not access it/modify it if possible. you should
+ // instead work with `pieces_vector`
PieceSlice slice;
std::string to_parse;
};