|
16 | 16 | // along with GCC; see the file COPYING3. If not see
|
17 | 17 | // <http://www.gnu.org/licenses/>.
|
18 | 18 |
|
| 19 | +#include "libproc_macro_internal/tokenstream.h" |
| 20 | +#include "rust-token-converter.h" |
19 | 21 | #include "rust-system.h"
|
20 | 22 | #include "rust-macro-builtins.h"
|
21 | 23 | #include "rust-ast-fragment.h"
|
@@ -947,24 +949,26 @@ tl::optional<AST::Fragment>
|
947 | 949 | MacroBuiltin::format_args_handler (location_t invoc_locus,
|
948 | 950 | AST::MacroInvocData &invoc)
|
949 | 951 | {
|
950 |
| - auto fmt_expr |
951 |
| - = parse_single_string_literal (BuiltinMacro::FormatArgs, |
952 |
| - invoc.get_delim_tok_tree (), invoc_locus, |
953 |
| - invoc.get_expander ()); |
954 |
| - |
955 |
| - if (!fmt_expr) |
956 |
| - return AST::Fragment::create_error (); |
957 |
| - |
958 |
| - // if it is not a literal, it's an eager macro invocation - return it |
959 |
| - if (!fmt_expr->is_literal ()) |
960 |
| - { |
961 |
| - auto token_tree = invoc.get_delim_tok_tree (); |
962 |
| - return AST::Fragment ({AST::SingleASTNode (std::move (fmt_expr))}, |
963 |
| - token_tree.to_token_stream ()); |
964 |
| - } |
965 |
| - |
966 |
| - auto format_string = fmt_expr->as_string (); |
967 |
| - auto pieces = Fmt::Pieces::collect (format_string); |
| 952 | + auto tokens = invoc.get_delim_tok_tree ().to_token_stream (); |
| 953 | + tokens.erase (tokens.begin ()); |
| 954 | + tokens.pop_back (); |
| 955 | + |
| 956 | + std::stringstream stream; |
| 957 | + for (const auto &tok : tokens) |
| 958 | + stream << tok->as_string () << ' '; |
| 959 | + |
| 960 | + rust_debug ("[ARTHU]: `%s`", stream.str ().c_str ()); |
| 961 | + |
| 962 | + // FIXME: We need to handle this |
| 963 | + // // if it is not a literal, it's an eager macro invocation - return it |
| 964 | + // if (!fmt_expr->is_literal ()) |
| 965 | + // { |
| 966 | + // auto token_tree = invoc.get_delim_tok_tree (); |
| 967 | + // return AST::Fragment ({AST::SingleASTNode (std::move (fmt_expr))}, |
| 968 | + // token_tree.to_token_stream ()); |
| 969 | + // } |
| 970 | + |
| 971 | + auto pieces = Fmt::Pieces::collect (stream.str ()); |
968 | 972 |
|
969 | 973 | return AST::Fragment::create_empty ();
|
970 | 974 | }
|
|
0 commit comments