From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 5/6] Remove some Ada parser helper functions
Date: Tue, 28 Mar 2023 09:49:41 -0600 [thread overview]
Message-ID: <20230328-expr-128-bit-v1-5-f9eeb0143318@adacore.com> (raw)
In-Reply-To: <20230328-expr-128-bit-v1-0-f9eeb0143318@adacore.com>
These helper functions in the Ada parser don't seem all that
worthwhile to me, so this patch removes them.
---
gdb/ada-exp.y | 52 ++++++---------------------------
gdb/ada-lex.l | 8 ++---
gdb/testsuite/gdb.base/parse_number.exp | 2 ++
3 files changed, 15 insertions(+), 47 deletions(-)
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index a9c37bedff0..4095106bb09 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -93,18 +93,8 @@ static const struct block *block_lookup (const struct block *, const char *);
static void write_ambiguous_var (struct parser_state *,
const struct block *, const char *, int);
-static struct type *type_int (struct parser_state *);
-
-static struct type *type_long (struct parser_state *);
-
-static struct type *type_long_long (struct parser_state *);
-
-static struct type *type_long_double (struct parser_state *);
-
static struct type *type_for_char (struct parser_state *, ULONGEST);
-static struct type *type_boolean (struct parser_state *);
-
static struct type *type_system_address (struct parser_state *);
static std::string find_completion_bounds (struct parser_state *);
@@ -934,9 +924,15 @@ primary : STRING
;
primary : TRUEKEYWORD
- { write_int (pstate, 1, type_boolean (pstate)); }
+ {
+ write_int (pstate, 1,
+ parse_type (pstate)->builtin_bool);
+ }
| FALSEKEYWORD
- { write_int (pstate, 0, type_boolean (pstate)); }
+ {
+ write_int (pstate, 0,
+ parse_type (pstate)->builtin_bool);
+ }
;
primary : NEW NAME
@@ -1268,7 +1264,7 @@ write_object_renaming (struct parser_state *par_state,
if (next == renaming_expr)
goto BadEncoding;
renaming_expr = next;
- write_int (par_state, val, type_int (par_state));
+ write_int (par_state, val, parse_type (par_state)->builtin_int);
}
else
{
@@ -1841,30 +1837,6 @@ write_name_assoc (struct parser_state *par_state, struct stoken name)
push_association<ada_name_association> (ada_pop ());
}
-static struct type *
-type_int (struct parser_state *par_state)
-{
- return parse_type (par_state)->builtin_int;
-}
-
-static struct type *
-type_long (struct parser_state *par_state)
-{
- return parse_type (par_state)->builtin_long;
-}
-
-static struct type *
-type_long_long (struct parser_state *par_state)
-{
- return parse_type (par_state)->builtin_long_long;
-}
-
-static struct type *
-type_long_double (struct parser_state *par_state)
-{
- return parse_type (par_state)->builtin_long_double;
-}
-
static struct type *
type_for_char (struct parser_state *par_state, ULONGEST value)
{
@@ -1880,12 +1852,6 @@ type_for_char (struct parser_state *par_state, ULONGEST value)
"wide_wide_character");
}
-static struct type *
-type_boolean (struct parser_state *par_state)
-{
- return parse_type (par_state)->builtin_bool;
-}
-
static struct type *
type_system_address (struct parser_state *par_state)
{
diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l
index 69fc14f7107..0634f337cb2 100644
--- a/gdb/ada-lex.l
+++ b/gdb/ada-lex.l
@@ -471,9 +471,9 @@ processInt (struct parser_state *par_state, const char *base0,
ULONGEST value = result.as_integer<ULONGEST> ();
if (fits_in_type (1, value, int_bits, true))
- yylval.typed_val.type = type_int (par_state);
+ yylval.typed_val.type = parse_type (par_state)->builtin_int;
else if (fits_in_type (1, value, long_bits, true))
- yylval.typed_val.type = type_long (par_state);
+ yylval.typed_val.type = parse_type (par_state)->builtin_long;
else if (fits_in_type (1, value, long_bits, false))
{
/* We have a number representable as an unsigned integer quantity.
@@ -494,7 +494,7 @@ processInt (struct parser_state *par_state, const char *base0,
return INT;
}
else if (fits_in_type (1, value, long_long_bits, true))
- yylval.typed_val.type = type_long_long (par_state);
+ yylval.typed_val.type = parse_type (par_state)->builtin_long_long;
else if (fits_in_type (1, value, long_long_bits, false))
{
yylval.typed_val.type
@@ -518,7 +518,7 @@ processInt (struct parser_state *par_state, const char *base0,
static int
processReal (struct parser_state *par_state, const char *num0)
{
- yylval.typed_val_float.type = type_long_double (par_state);
+ yylval.typed_val_float.type = parse_type (par_state)->builtin_long_double;
bool parsed = parse_float (num0, strlen (num0),
yylval.typed_val_float.type,
diff --git a/gdb/testsuite/gdb.base/parse_number.exp b/gdb/testsuite/gdb.base/parse_number.exp
index 5dd4fa705e9..8800dead53b 100644
--- a/gdb/testsuite/gdb.base/parse_number.exp
+++ b/gdb/testsuite/gdb.base/parse_number.exp
@@ -145,6 +145,8 @@ proc parse_number { lang n } {
} elseif { [fits_in_type $n $long_long_bits u] } {
# Note: Interprets ULLONG_MAX as -1.
return [list "<$sizeof_long_long-byte integer>" $n]
+ } elseif { [fits_in_type $n 128 u] } {
+ return [list "<16-byte integer>" $n]
} else {
# Overflow.
return [list $re_overflow $re_overflow]
--
2.39.1
next prev parent reply other threads:[~2023-03-28 15:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-28 15:49 [PATCH 0/6] Add 128-bit integers to Ada and Rust parsers Tom Tromey
2023-03-28 15:49 ` [PATCH 1/6] Additions to gdb_mpz Tom Tromey
2023-03-28 15:49 ` [PATCH 2/6] Convert long_const_operation to use gdb_mpz Tom Tromey
2023-03-28 15:49 ` [PATCH 3/6] Add 128-bit integer support to the Rust parser Tom Tromey
2023-03-28 15:49 ` [PATCH 4/6] Add overload of fits_in_type Tom Tromey
2023-03-28 15:49 ` Tom Tromey [this message]
2023-03-28 15:49 ` [PATCH 6/6] Add 128-bit integer support to the Ada parser Tom Tromey
2023-04-17 17:03 ` [PATCH 0/6] Add 128-bit integers to Ada and Rust parsers Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230328-expr-128-bit-v1-5-f9eeb0143318@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).