mirror of
https://github.com/gcc-mirror/gcc.git
synced 2024-11-21 13:40:47 +00:00
gccrs: 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>
This commit is contained in:
parent
10c9b9f0cc
commit
f730dff173
@ -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 (
|
||||
|
Loading…
Reference in New Issue
Block a user