diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-02-29 13:01:32 +0100 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2024-03-19 17:37:38 +0000 |
commit | da10bf56cf11207877c3a552cffb472702d1b772 (patch) | |
tree | ace63d8606e66d1c1db2b4925892a808f453ceb5 /gcc/rust/expand | |
parent | b85dc7014c821466bb411a14b7f5d6de4077eae6 (diff) | |
download | gcc-da10bf56cf11207877c3a552cffb472702d1b772.zip gcc-da10bf56cf11207877c3a552cffb472702d1b772.tar.gz gcc-da10bf56cf11207877c3a552cffb472702d1b772.tar.bz2 |
format-args: Add base for expanding FormatArgs nodes
gcc/rust/ChangeLog:
* Make-lang.in: Add new object.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Remove calls to
FormatArgsLowering.
* expand/rust-expand-format-args.cc: New file.
* expand/rust-expand-format-args.h: New file.
Diffstat (limited to 'gcc/rust/expand')
-rw-r--r-- | gcc/rust/expand/rust-expand-format-args.cc | 43 | ||||
-rw-r--r-- | gcc/rust/expand/rust-expand-format-args.h | 32 |
2 files changed, 75 insertions, 0 deletions
diff --git a/gcc/rust/expand/rust-expand-format-args.cc b/gcc/rust/expand/rust-expand-format-args.cc new file mode 100644 index 0000000..52249cb --- /dev/null +++ b/gcc/rust/expand/rust-expand-format-args.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2024 Free Software Foundation, Inc. + +// This file is part of GCC. + +// GCC is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 3, or (at your option) any later +// version. + +// GCC is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. + +// You should have received a copy of the GNU General Public License +// along with GCC; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#include "rust-expand-format-args.h" +#include "rust-builtin-ast-nodes.h" + +namespace Rust { + +tl::optional<AST::Fragment> +expand_format_args (AST::FormatArgs &fmt) +{ + for (const auto &node : fmt.get_template ().get_pieces ()) + { + switch (node.tag) + { + case Fmt::Piece::Tag::String: + // rust_debug ("[ARTHUR]: %s", node.string._0.c_str ()); + + case Fmt::Piece::Tag::NextArgument: + rust_debug ("[ARTHUR]: NextArgument"); + break; + } + } + + return tl::nullopt; +} + +} // namespace Rust diff --git a/gcc/rust/expand/rust-expand-format-args.h b/gcc/rust/expand/rust-expand-format-args.h new file mode 100644 index 0000000..1481f36 --- /dev/null +++ b/gcc/rust/expand/rust-expand-format-args.h @@ -0,0 +1,32 @@ +// Copyright (C) 2024 Free Software Foundation, Inc. + +// This file is part of GCC. + +// GCC is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 3, or (at your option) any later +// version. + +// GCC is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. + +// You should have received a copy of the GNU General Public License +// along with GCC; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +#ifndef RUST_EXPAND_FORMAT_ARGS_H +#define RUST_EXPAND_FORMAT_ARGS_H + +#include "optional.h" +#include "rust-ast-fragment.h" + +namespace Rust { + +tl::optional<AST::Fragment> +expand_format_args (AST::FormatArgs &fmt); + +} // namespace Rust + +#endif //! RUST_EXPAND_FORMAT_ARGS_H |