diff options
author | badumbatish <tanghocle456@gmail.com> | 2024-07-20 00:44:26 -0700 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-17 16:35:53 +0100 |
commit | 29873023eddd5b1a71fec048431cb90186e23704 (patch) | |
tree | 12dbb68a5a002af4d5302776cdadc09b4123c093 /gcc | |
parent | af969f521be3f46bbd22e701b4d82e3065b4ecb9 (diff) | |
download | gcc-29873023eddd5b1a71fec048431cb90186e23704.zip gcc-29873023eddd5b1a71fec048431cb90186e23704.tar.gz gcc-29873023eddd5b1a71fec048431cb90186e23704.tar.bz2 |
gccrs: Added options for ParseMode
gcc/rust/ChangeLog:
* ast/rust-fmt.cc (Pieces::collect):
Added options for ParseMode
* ast/rust-fmt.h (collect_pieces): Likewise.
(struct Pieces): Likewise.
* expand/rust-macro-builtins-format-args.cc (MacroBuiltin::format_args_handler):
Likewise.
libgrust/ChangeLog:
* libformat_parser/generic_format_parser/src/lib.rs: Likewise.
* libformat_parser/src/bin.rs: Likewise.
* libformat_parser/src/lib.rs: Likewise.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/ast/rust-fmt.cc | 6 | ||||
-rw-r--r-- | gcc/rust/ast/rust-fmt.h | 11 | ||||
-rw-r--r-- | gcc/rust/expand/rust-macro-builtins-format-args.cc | 6 |
3 files changed, 17 insertions, 6 deletions
diff --git a/gcc/rust/ast/rust-fmt.cc b/gcc/rust/ast/rust-fmt.cc index cc48c2e..a29c820 100644 --- a/gcc/rust/ast/rust-fmt.cc +++ b/gcc/rust/ast/rust-fmt.cc @@ -29,9 +29,11 @@ ffi::RustHamster::to_string () const } Pieces -Pieces::collect (const std::string &to_parse, bool append_newline) +Pieces::collect (const std::string &to_parse, bool append_newline, + ffi::ParseMode parse_mode) { - auto handle = ffi::collect_pieces (to_parse.c_str (), append_newline); + auto handle + = ffi::collect_pieces (to_parse.c_str (), append_newline, parse_mode); // this performs multiple copies, can we avoid them maybe? // TODO: Instead of just creating a vec of, basically, `ffi::Piece`s, we diff --git a/gcc/rust/ast/rust-fmt.h b/gcc/rust/ast/rust-fmt.h index 31100ea..1db391b 100644 --- a/gcc/rust/ast/rust-fmt.h +++ b/gcc/rust/ast/rust-fmt.h @@ -258,10 +258,16 @@ struct FormatArgsHandle RustString rust_string; }; +typedef enum +{ + Format, + InlineAsm, +} ParseMode; + extern "C" { FormatArgsHandle -collect_pieces (const char *input, bool append_newline); +collect_pieces (const char *input, bool append_newline, ParseMode parse_mode); FormatArgsHandle clone_pieces (const FormatArgsHandle &); @@ -274,7 +280,8 @@ void destroy_pieces (FormatArgsHandle); struct Pieces { - static Pieces collect (const std::string &to_parse, bool append_newline); + static Pieces collect (const std::string &to_parse, bool append_newline, + ffi::ParseMode parse_mode); ~Pieces (); Pieces (const Pieces &other); diff --git a/gcc/rust/expand/rust-macro-builtins-format-args.cc b/gcc/rust/expand/rust-macro-builtins-format-args.cc index 031007b..8eb32d5 100644 --- a/gcc/rust/expand/rust-macro-builtins-format-args.cc +++ b/gcc/rust/expand/rust-macro-builtins-format-args.cc @@ -16,6 +16,7 @@ // along with GCC; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. #include "rust-ast-fragment.h" +#include "rust-fmt.h" #include "rust-macro-builtins-helpers.h" #include "rust-expand-format-args.h" @@ -162,7 +163,8 @@ MacroBuiltin::format_args_handler (location_t invoc_locus, if (append_newline) fmt_str += '\n'; - auto pieces = Fmt::Pieces::collect (fmt_str, append_newline); + auto pieces = Fmt::Pieces::collect (fmt_str, append_newline, + Fmt::ffi::ParseMode::Format); // TODO: // do the transformation into an AST::FormatArgs node @@ -191,4 +193,4 @@ MacroBuiltin::format_args_handler (location_t invoc_locus, // invoc.get_delim_tok_tree ().to_token_stream ()); } -} // namespace Rust
\ No newline at end of file +} // namespace Rust |