From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 05/12] Move "components" and "associations" into ada_parse_state
Date: Thu, 21 Mar 2024 13:03:33 -0600 [thread overview]
Message-ID: <20240321-ada-iterated-assign-v1-5-925cdd4f1f4a@adacore.com> (raw)
In-Reply-To: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com>
This patch moves the "components" and "associations" globals into
ada_parse_state.
---
gdb/ada-exp.y | 32 +++++++++++++++-----------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index a8066414468..25809b6aa24 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -65,6 +65,8 @@ struct name_info {
static struct parser_state *pstate = NULL;
+using namespace expr;
+
/* Data that must be held for the duration of a parse. */
struct ada_parse_state
@@ -82,6 +84,12 @@ struct ada_parse_state
return result.get ();
}
+ /* The components being constructed during this parse. */
+ std::vector<ada_component_up> components;
+
+ /* The associations being constructed during this parse. */
+ std::vector<ada_association_up> associations;
+
private:
/* We don't have a good way to manage non-POD data in Yacc, so store
@@ -126,8 +134,6 @@ static struct type *type_for_char (struct parser_state *, ULONGEST);
static struct type *type_system_address (struct parser_state *);
-using namespace expr;
-
/* Handle Ada type resolution for OP. DEPROCEDURE_P and CONTEXT_TYPE
are passed to the resolve method, if called. */
static operation_up
@@ -336,16 +342,13 @@ ada_funcall (int nargs)
pstate->push (std::move (funcall));
}
-/* The components being constructed during this parse. */
-static std::vector<ada_component_up> components;
-
/* Create a new ada_component_up of the indicated type and arguments,
and push it on the global 'components' vector. */
template<typename T, typename... Arg>
void
push_component (Arg... args)
{
- components.emplace_back (new T (std::forward<Arg> (args)...));
+ ada_parser->components.emplace_back (new T (std::forward<Arg> (args)...));
}
/* Examine the final element of the 'components' vector, and return it
@@ -355,7 +358,7 @@ push_component (Arg... args)
static ada_choices_component *
choice_component ()
{
- ada_component *last = components.back ().get ();
+ ada_component *last = ada_parser->components.back ().get ();
return gdb::checked_static_cast<ada_choices_component *> (last);
}
@@ -364,8 +367,8 @@ choice_component ()
static ada_component_up
pop_component ()
{
- ada_component_up result = std::move (components.back ());
- components.pop_back ();
+ ada_component_up result = std::move (ada_parser->components.back ());
+ ada_parser->components.pop_back ();
return result;
}
@@ -380,16 +383,13 @@ pop_components (int n)
return result;
}
-/* The associations being constructed during this parse. */
-static std::vector<ada_association_up> associations;
-
/* Create a new ada_association_up of the indicated type and
arguments, and push it on the global 'associations' vector. */
template<typename T, typename... Arg>
void
push_association (Arg... args)
{
- associations.emplace_back (new T (std::forward<Arg> (args)...));
+ ada_parser->associations.emplace_back (new T (std::forward<Arg> (args)...));
}
/* Pop the most recent association from the global stack, and return
@@ -397,8 +397,8 @@ push_association (Arg... args)
static ada_association_up
pop_association ()
{
- ada_association_up result = std::move (associations.back ());
- associations.pop_back ();
+ ada_association_up result = std::move (ada_parser->associations.back ());
+ ada_parser->associations.pop_back ();
return result;
}
@@ -1257,8 +1257,6 @@ ada_parse (struct parser_state *par_state)
lexer_init (yyin); /* (Re-)initialize lexer. */
obstack_free (&temp_parse_space, NULL);
obstack_init (&temp_parse_space);
- components.clear ();
- associations.clear ();
assignments.clear ();
iterated_associations.clear ();
--
2.43.0
next prev parent reply other threads:[~2024-03-21 19:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-21 19:03 [PATCH 00/12] Ada iterated assignment, plus parser cleanups Tom Tromey
2024-03-21 19:03 ` [PATCH 01/12] Introduce and use aggregate_assigner type Tom Tromey
2024-03-21 19:03 ` [PATCH 02/12] Implement Ada 2022 iterated assignment Tom Tromey
2024-03-21 19:03 ` [PATCH 03/12] Introduce ada_parse_state Tom Tromey
2024-03-21 19:03 ` [PATCH 04/12] Move "int_storage" global into ada_parse_state Tom Tromey
2024-03-21 19:03 ` Tom Tromey [this message]
2024-03-21 19:03 ` [PATCH 06/12] Move "assignments" " Tom Tromey
2024-03-21 19:03 ` [PATCH 07/12] Move "iterated_associations" " Tom Tromey
2024-03-21 19:03 ` [PATCH 08/12] Move "temp_parse_space" " Tom Tromey
2024-03-21 19:03 ` [PATCH 09/12] Move "paren_depth" " Tom Tromey
2024-03-21 19:03 ` [PATCH 10/12] Move "returned_complete" " Tom Tromey
2024-03-21 19:03 ` [PATCH 11/12] Remove "numbuf" global Tom Tromey
2024-03-21 19:03 ` [PATCH 12/12] Constify ada-lex.l:attributes Tom Tromey
2024-04-02 17:35 ` [PATCH 00/12] Ada iterated assignment, plus parser cleanups 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=20240321-ada-iterated-assign-v1-5-925cdd4f1f4a@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