+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.
+
2019-04-04 Tom Tromey <tom@tromey.com>
* rust-exp.y (struct rust_parser) <lex_hex, lex_escape,
exp : exp '('
/* This is to save the value of arglist_len
being accumulated by an outer function call. */
- { start_arglist (); }
+ { pstate->start_arglist (); }
arglist ')' %prec ARROW
{ write_exp_elt_opcode (pstate, OP_FUNCALL);
write_exp_elt_longcst (pstate,
- (LONGEST) end_arglist ());
+ pstate->end_arglist ());
write_exp_elt_opcode (pstate, OP_FUNCALL); }
;
"func()::static_var" further below, which uses
function_method_void. */
exp : exp '(' ')' %prec ARROW
- { start_arglist ();
+ { pstate->start_arglist ();
write_exp_elt_opcode (pstate, OP_FUNCALL);
write_exp_elt_longcst (pstate,
- (LONGEST) end_arglist ());
+ pstate->end_arglist ());
write_exp_elt_opcode (pstate, OP_FUNCALL); }
;
/* This is to save the value of arglist_len
being accumulated by an outer function call. */
- start_arglist ();
+ pstate->start_arglist ();
}
arglist ')' %prec ARROW
{
write_exp_elt_opcode (pstate, OP_FUNCALL);
write_exp_elt_longcst (pstate,
- (LONGEST) end_arglist ());
+ pstate->end_arglist ());
write_exp_elt_opcode (pstate, OP_FUNCALL);
}
;
lcurly : '{'
- { start_arglist (); }
+ { pstate->start_arglist (); }
;
arglist :
;
arglist : exp
- { arglist_len = 1; }
+ { pstate->arglist_len = 1; }
;
arglist : arglist ',' exp %prec ABOVE_COMMA
- { arglist_len++; }
+ { pstate->arglist_len++; }
;
function_method: exp '(' parameter_typelist ')' const_or_volatile
;
rcurly : '}'
- { $$ = end_arglist () - 1; }
+ { $$ = pstate->end_arglist () - 1; }
;
exp : lcurly arglist rcurly %prec ARROW
{ write_exp_elt_opcode (pstate, OP_ARRAY);
ArgumentList:
AssignExpression
- { arglist_len = 1; }
+ { pstate->arglist_len = 1; }
| ArgumentList ',' AssignExpression
- { arglist_len++; }
+ { pstate->arglist_len++; }
;
ArgumentList_opt:
/* EMPTY */
- { arglist_len = 0; }
+ { pstate->arglist_len = 0; }
| ArgumentList
;
CallExpression:
PostfixExpression '('
- { start_arglist (); }
+ { pstate->start_arglist (); }
ArgumentList_opt ')'
{ write_exp_elt_opcode (pstate, OP_FUNCALL);
- write_exp_elt_longcst (pstate, (LONGEST) end_arglist ());
+ write_exp_elt_longcst (pstate, pstate->end_arglist ());
write_exp_elt_opcode (pstate, OP_FUNCALL); }
;
IndexExpression:
PostfixExpression '[' ArgumentList ']'
- { if (arglist_len > 0)
+ { if (pstate->arglist_len > 0)
{
write_exp_elt_opcode (pstate, MULTI_SUBSCRIPT);
- write_exp_elt_longcst (pstate, (LONGEST) arglist_len);
+ write_exp_elt_longcst (pstate, pstate->arglist_len);
write_exp_elt_opcode (pstate, MULTI_SUBSCRIPT);
}
else
ArrayLiteral:
'[' ArgumentList_opt ']'
- { $$ = arglist_len; }
+ { $$ = pstate->arglist_len; }
;
IdentifierExp:
later in eval.c. */
exp : exp '('
- { start_arglist (); }
+ { pstate->start_arglist (); }
arglist ')'
{ write_exp_elt_opcode (pstate,
OP_F77_UNDETERMINED_ARGLIST);
write_exp_elt_longcst (pstate,
- (LONGEST) end_arglist ());
+ pstate->end_arglist ());
write_exp_elt_opcode (pstate,
OP_F77_UNDETERMINED_ARGLIST); }
;
;
arglist : exp
- { arglist_len = 1; }
+ { pstate->arglist_len = 1; }
;
arglist : subrange
- { arglist_len = 1; }
+ { pstate->arglist_len = 1; }
;
arglist : arglist ',' exp %prec ABOVE_COMMA
- { arglist_len++; }
+ { pstate->arglist_len++; }
;
/* There are four sorts of subrange types in F90. */
exp : exp '('
/* This is to save the value of arglist_len
being accumulated by an outer function call. */
- { start_arglist (); }
+ { pstate->start_arglist (); }
arglist ')' %prec LEFT_ARROW
{ write_exp_elt_opcode (pstate, OP_FUNCALL);
write_exp_elt_longcst (pstate,
- (LONGEST) end_arglist ());
+ pstate->end_arglist ());
write_exp_elt_opcode (pstate, OP_FUNCALL); }
;
lcurly : '{'
- { start_arglist (); }
+ { pstate->start_arglist (); }
;
arglist :
;
arglist : exp
- { arglist_len = 1; }
+ { pstate->arglist_len = 1; }
;
arglist : arglist ',' exp %prec ABOVE_COMMA
- { arglist_len++; }
+ { pstate->arglist_len++; }
;
rcurly : '}'
- { $$ = end_arglist () - 1; }
+ { $$ = pstate->end_arglist () - 1; }
;
exp : lcurly type rcurly exp %prec UNARY
/* This function just saves the number of arguments
that follow in the list. It is *not* specific to
function types */
- { start_arglist(); }
+ { pstate->start_arglist(); }
non_empty_arglist ']' %prec DOT
{ write_exp_elt_opcode (pstate, MULTI_SUBSCRIPT);
write_exp_elt_longcst (pstate,
- (LONGEST) end_arglist());
+ pstate->end_arglist());
write_exp_elt_opcode (pstate, MULTI_SUBSCRIPT); }
;
exp : exp '('
/* This is to save the value of arglist_len
being accumulated by an outer function call. */
- { start_arglist (); }
+ { pstate->start_arglist (); }
arglist ')' %prec DOT
{ write_exp_elt_opcode (pstate, OP_FUNCALL);
write_exp_elt_longcst (pstate,
- (LONGEST) end_arglist ());
+ pstate->end_arglist ());
write_exp_elt_opcode (pstate, OP_FUNCALL); }
;
;
arglist : exp
- { arglist_len = 1; }
+ { pstate->arglist_len = 1; }
;
arglist : arglist ',' exp %prec ABOVE_COMMA
- { arglist_len++; }
+ { pstate->arglist_len++; }
;
non_empty_arglist
: exp
- { arglist_len = 1; }
+ { pstate->arglist_len = 1; }
;
non_empty_arglist
: non_empty_arglist ',' exp %prec ABOVE_COMMA
- { arglist_len++; }
+ { pstate->arglist_len++; }
;
/* GDB construct */
/* This is to save the value of arglist_len
being accumulated by an outer function call. */
{ push_current_type ();
- start_arglist (); }
+ pstate->start_arglist (); }
arglist ')' %prec ARROW
{ write_exp_elt_opcode (pstate, OP_FUNCALL);
write_exp_elt_longcst (pstate,
- (LONGEST) end_arglist ());
+ pstate->end_arglist ());
write_exp_elt_opcode (pstate, OP_FUNCALL);
pop_current_type ();
if (current_type)
arglist :
| exp
- { arglist_len = 1; }
+ { pstate->arglist_len = 1; }
| arglist ',' exp %prec ABOVE_COMMA
- { arglist_len++; }
+ { pstate->arglist_len++; }
;
exp : type '(' exp ')' %prec UNARY
\f
/* Global variables declared in parser-defs.h (and commented there). */
innermost_block_tracker innermost_block;
-int arglist_len;
static struct type_stack type_stack;
/* True if parsing an expression to attempt completion. */
m_innermost_block = b;
}
-/* Data structure for saving values of arglist_len for function calls whose
- arguments contain other function calls. */
-
-static std::vector<int> *funcall_chain;
-
-/* Begin counting arguments for a function call,
- saving the data about any containing call. */
-
-void
-start_arglist (void)
-{
- 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 (void)
-{
- int val = arglist_len;
- arglist_len = funcall_chain->back ();
- funcall_chain->pop_back ();
- return val;
-}
-
\f
/* See definition in parser-defs.h. */
if (*stringptr == 0 || **stringptr == 0)
error_no_arg (_("expression to compute"));
- std::vector<int> funcalls;
- scoped_restore save_funcall_chain = make_scoped_restore (&funcall_chain,
- &funcalls);
-
const struct block *expression_context_block = block;
CORE_ADDR expression_context_pc = 0;
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. */
/* 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
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. */
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);