aboutsummaryrefslogtreecommitdiff
path: root/gdb/parser-defs.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-03-24 21:38:40 -0600
committerTom Tromey <tom@tromey.com>2019-04-04 19:55:11 -0600
commit43476f0b1b628352ad8e3064e50128cb3461d3d0 (patch)
tree5d836e9a33199397d2aeba188216a6478688ca94 /gdb/parser-defs.h
parent5776fca307b8af3d852525b77e9b917a9aa97370 (diff)
downloadbinutils-43476f0b1b628352ad8e3064e50128cb3461d3d0.zip
binutils-43476f0b1b628352ad8e3064e50128cb3461d3d0.tar.gz
binutils-43476f0b1b628352ad8e3064e50128cb3461d3d0.tar.bz2
Move arglist_len et al to parser_state
This moves arglist_len, start_arglist, and end_arglist to parser_state. gdb/ChangeLog 2019-04-04 Tom Tromey <tom@tromey.com> * parser-defs.h (struct parser_state) <start_arglist, end_arglist>: New methods. <arglist_len, m_funcall_chain>: New members. (arglist_len, start_arglist, end_arglist): Don't declare. * parse.c (arglist_len, funcall_chain): Remove global. (start_arglist, end_arglist): Remove functions. (parse_exp_in_context): Update. * p-exp.y: Update rules. * m2-exp.y: Update rules. * go-exp.y: Update rules. * f-exp.y: Update rules. * d-exp.y: Update rules. * c-exp.y: Update rules.
Diffstat (limited to 'gdb/parser-defs.h')
-rw-r--r--gdb/parser-defs.h39
1 files changed, 32 insertions, 7 deletions
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index 66828e0..a015115 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -101,6 +101,27 @@ struct parser_state : public expr_builder
DISABLE_COPY_AND_ASSIGN (parser_state);
+ /* Begin counting arguments for a function call,
+ saving the data about any containing call. */
+
+ void start_arglist ()
+ {
+ m_funcall_chain.push_back (arglist_len);
+ arglist_len = 0;
+ }
+
+ /* Return the number of arguments in a function call just terminated,
+ and restore the data for the containing function call. */
+
+ int end_arglist ()
+ {
+ int val = arglist_len;
+ arglist_len = m_funcall_chain.back ();
+ m_funcall_chain.pop_back ();
+ return val;
+ }
+
+
/* If this is nonzero, this block is used as the lexical context for
symbol names. */
@@ -125,6 +146,17 @@ struct parser_state : public expr_builder
/* After a token has been recognized, this variable points to it.
Currently used only for error reporting. */
const char *prev_lexptr = nullptr;
+
+ /* Number of arguments seen so far in innermost function call. */
+
+ int arglist_len = 0;
+
+private:
+
+ /* Data structure for saving values of arglist_len for function calls whose
+ arguments contain other function calls. */
+
+ std::vector<int> m_funcall_chain;
};
/* When parsing expressions we track the innermost block that was
@@ -185,9 +217,6 @@ private:
once the parse is complete. */
extern innermost_block_tracker innermost_block;
-/* Number of arguments seen so far in innermost function call. */
-extern int arglist_len;
-
/* A string token, either a char-string or bit-string. Char-strings are
used, for example, for the names of symbols. */
@@ -311,10 +340,6 @@ extern void mark_struct_expression (struct expr_builder *);
extern const char *find_template_name_end (const char *);
-extern void start_arglist (void);
-
-extern int end_arglist (void);
-
extern char *copy_name (struct stoken);
extern void insert_type (enum type_pieces);