aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/expand
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2023-11-30 14:11:41 +0100
committerCohenArthur <arthur.cohen@embecosm.com>2024-02-26 17:32:38 +0000
commit7b25f53a416868059299661ddf769ec4c9c2516d (patch)
tree78fb5b2af443b15fcd5dbc97a5bb73d6faae7288 /gcc/rust/expand
parent486b2043a08ff49605ea7d52fc2c3f5403d72079 (diff)
downloadgcc-7b25f53a416868059299661ddf769ec4c9c2516d.zip
gcc-7b25f53a416868059299661ddf769ec4c9c2516d.tar.gz
gcc-7b25f53a416868059299661ddf769ec4c9c2516d.tar.bz2
libgrust: Add format_parser library
Compile libformat_parser and link to it. gcc/rust/ChangeLog: * Make-lang.in: Compile libformat_parser. * ast/rust-fmt.cc: New FFI definitions. * ast/rust-fmt.h: Likewise. * expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler): Call into libformat_parser. * expand/rust-macro-builtins.h: Define format_args!() handler proper. libgrust/ChangeLog: * libformat_parser/Cargo.lock: New file. * libformat_parser/Cargo.toml: New file. * libformat_parser/generic_format_parser/Cargo.toml: New file. * libformat_parser/generic_format_parser/src/lib.rs: New file. * libformat_parser/src/bin.rs: New file. * libformat_parser/src/lib.rs: New file.
Diffstat (limited to 'gcc/rust/expand')
-rw-r--r--gcc/rust/expand/rust-macro-builtins.cc12
-rw-r--r--gcc/rust/expand/rust-macro-builtins.h3
2 files changed, 14 insertions, 1 deletions
diff --git a/gcc/rust/expand/rust-macro-builtins.cc b/gcc/rust/expand/rust-macro-builtins.cc
index 71da575..0e57406 100644
--- a/gcc/rust/expand/rust-macro-builtins.cc
+++ b/gcc/rust/expand/rust-macro-builtins.cc
@@ -30,6 +30,7 @@
#include "rust-parse.h"
#include "rust-session-manager.h"
#include "rust-attribute-values.h"
+#include "rust-fmt.h"
namespace Rust {
@@ -89,8 +90,8 @@ std::unordered_map<std::string, AST::MacroTranscriberFunc>
{"env", MacroBuiltin::env_handler},
{"cfg", MacroBuiltin::cfg_handler},
{"include", MacroBuiltin::include_handler},
+ {"format_args", MacroBuiltin::format_args_handler},
/* Unimplemented macro builtins */
- {"format_args", MacroBuiltin::sorry},
{"option_env", MacroBuiltin::sorry},
{"format_args_nl", MacroBuiltin::sorry},
{"concat_idents", MacroBuiltin::sorry},
@@ -943,6 +944,15 @@ MacroBuiltin::stringify_handler (location_t invoc_locus,
}
tl::optional<AST::Fragment>
+MacroBuiltin::format_args_handler (location_t invoc_locus,
+ AST::MacroInvocData &invoc)
+{
+ Fmt::Pieces::collect ("heyo this {is} what I {} want to {3}, {parse}");
+
+ return AST::Fragment::create_empty ();
+}
+
+tl::optional<AST::Fragment>
MacroBuiltin::sorry (location_t invoc_locus, AST::MacroInvocData &invoc)
{
rust_sorry_at (invoc_locus, "unimplemented builtin macro: %qs",
diff --git a/gcc/rust/expand/rust-macro-builtins.h b/gcc/rust/expand/rust-macro-builtins.h
index 6a84a8b..f9ab3fc 100644
--- a/gcc/rust/expand/rust-macro-builtins.h
+++ b/gcc/rust/expand/rust-macro-builtins.h
@@ -157,6 +157,9 @@ public:
static tl::optional<AST::Fragment> line_handler (location_t invoc_locus,
AST::MacroInvocData &invoc);
+ static tl::optional<AST::Fragment>
+ format_args_handler (location_t invoc_locus, AST::MacroInvocData &invoc);
+
static tl::optional<AST::Fragment> sorry (location_t invoc_locus,
AST::MacroInvocData &invoc);