diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-05-11 12:23:38 +0200 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2023-05-17 16:13:45 +0000 |
commit | d8202b68bc67f7804755def780a3755e27bebec1 (patch) | |
tree | 2b765264f6bc289a2990e6d46df7c8e5b5ec3dc3 | |
parent | 4c34885a5afbda4bad5873668cdc6fddd2d1c29b (diff) | |
download | gcc-d8202b68bc67f7804755def780a3755e27bebec1.zip gcc-d8202b68bc67f7804755def780a3755e27bebec1.tar.gz gcc-d8202b68bc67f7804755def780a3755e27bebec1.tar.bz2 |
converter: Merge dispatch into one function
Floating point and integer dispatch now have almost the same behavior,
their code could therefore be merged.
gcc/rust/ChangeLog:
* util/rust-token-converter.cc (dispatch_float_literals): Remove
function.
(handle_suffix): Rename old dispatch and add one LitKind
argument.
(dispatch_integer_literals): Remove function.
(convert): Change call from dispatch to suffix handler.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r-- | gcc/rust/util/rust-token-converter.cc | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/gcc/rust/util/rust-token-converter.cc b/gcc/rust/util/rust-token-converter.cc index d56493f..871c8e0 100644 --- a/gcc/rust/util/rust-token-converter.cc +++ b/gcc/rust/util/rust-token-converter.cc @@ -51,23 +51,10 @@ pop_group (std::vector<ProcMacro::TokenStream> &streams, } static void -dispatch_float_literals (ProcMacro::TokenStream &ts, - const const_TokenPtr &token) +handle_suffix (ProcMacro::TokenStream &ts, const const_TokenPtr &token, + ProcMacro::LitKind kind) { auto str = token->as_string (); - auto kind = ProcMacro::LitKind::make_float (); - auto lookup = suffixes.lookup (token->get_type_hint ()); - auto suffix = suffixes.is_iter_ok (lookup) ? lookup->second : ""; - ts.push (ProcMacro::TokenTree::make_tokentree ( - ProcMacro::Literal::make_literal (kind, str, suffix))); -} - -static void -dispatch_integer_literals (ProcMacro::TokenStream &ts, - const const_TokenPtr &token) -{ - auto str = token->as_string (); - auto kind = ProcMacro::LitKind::make_integer (); auto lookup = suffixes.lookup (token->get_type_hint ()); auto suffix = suffixes.is_iter_ok (lookup) ? lookup->second : ""; ts.push (ProcMacro::TokenTree::make_tokentree ( @@ -85,10 +72,12 @@ convert (const std::vector<const_TokenPtr> &tokens) { // Literals case FLOAT_LITERAL: - dispatch_float_literals (trees.back (), token); + handle_suffix (trees.back (), token, + ProcMacro::LitKind::make_float ()); break; case INT_LITERAL: - dispatch_integer_literals (trees.back (), token); + handle_suffix (trees.back (), token, + ProcMacro::LitKind::make_integer ()); break; case CHAR_LITERAL: trees.back ().push (ProcMacro::TokenTree::make_tokentree ( |