From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 4A78F386F422; Tue, 7 May 2024 16:22:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A78F386F422 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1715098959; bh=G1kjWoN4bNDnubjUId6NWxrF3vCC37ZexgsZSRJjFjw=; h=From:To:Subject:Date:From; b=hafSsUxIweOyNnp9j0qJSIrNx+MIszwEWE1VTWEed5yY3UNeD+7RqlSoL/T+LIUgN Pnqava9kVCiUc2Cj9xv+UDawLugEueu9/M5v66bVTyNE1NeMWqTaMVoPfs7C87k8+E xCQktEKrqmXvJ/vF2eb1cHDBGQRmciiQSD4pp5DY= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] format-args: Add base for expanding FormatArgs nodes X-Act-Checkin: gcc X-Git-Author: Arthur Cohen X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: b85dc7014c821466bb411a14b7f5d6de4077eae6 X-Git-Newrev: da10bf56cf11207877c3a552cffb472702d1b772 Message-Id: <20240507162239.4A78F386F422@sourceware.org> Date: Tue, 7 May 2024 16:22:39 +0000 (GMT) List-Id: https://gcc.gnu.org/g:da10bf56cf11207877c3a552cffb472702d1b772 commit da10bf56cf11207877c3a552cffb472702d1b772 Author: Arthur Cohen Date: Thu Feb 29 13:01:32 2024 +0100 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. Diff: --- gcc/rust/Make-lang.in | 1 + gcc/rust/expand/rust-expand-format-args.cc | 43 ++++++++++++++++++++++++++++++ gcc/rust/expand/rust-expand-format-args.h | 32 ++++++++++++++++++++++ gcc/rust/hir/rust-ast-lower-expr.cc | 4 --- 4 files changed, 76 insertions(+), 4 deletions(-) diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in index 8a324c8c0792..8112b7cc3fb2 100644 --- a/gcc/rust/Make-lang.in +++ b/gcc/rust/Make-lang.in @@ -205,6 +205,7 @@ GRS_OBJS = \ rust/rust-unicode.o \ rust/rust-punycode.o \ rust/rust-lang-item.o \ + rust/rust-expand-format-args.o \ $(END) # removed object files from here 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 000000000000..52249cb17e3d --- /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 +// . + +#include "rust-expand-format-args.h" +#include "rust-builtin-ast-nodes.h" + +namespace Rust { + +tl::optional +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 000000000000..1481f3605ed8 --- /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 +// . + +#ifndef RUST_EXPAND_FORMAT_ARGS_H +#define RUST_EXPAND_FORMAT_ARGS_H + +#include "optional.h" +#include "rust-ast-fragment.h" + +namespace Rust { + +tl::optional +expand_format_args (AST::FormatArgs &fmt); + +} // namespace Rust + +#endif //! RUST_EXPAND_FORMAT_ARGS_H diff --git a/gcc/rust/hir/rust-ast-lower-expr.cc b/gcc/rust/hir/rust-ast-lower-expr.cc index 6944db9b9ccf..c414643bb915 100644 --- a/gcc/rust/hir/rust-ast-lower-expr.cc +++ b/gcc/rust/hir/rust-ast-lower-expr.cc @@ -19,7 +19,6 @@ #include "rust-ast-lower-expr.h" #include "rust-ast-lower-base.h" #include "rust-ast-lower-block.h" -#include "rust-ast-lower-format-args.h" #include "rust-ast-lower-struct-field-expr.h" #include "rust-ast-lower-pattern.h" #include "rust-ast-lower-type.h" @@ -824,9 +823,6 @@ ASTLoweringExpr::visit (AST::ClosureExprInnerTyped &expr) void ASTLoweringExpr::visit (AST::FormatArgs &fmt) { - // Lowering FormatArgs is complex, and this file is already very long - translated = FormatArgsLowering ().go (fmt); - rust_sorry_at (fmt.get_locus (), "FormatArgs lowering is not implemented yet"); }