Remove `expout*' globals from parser-defs.h
This commit removes the "expout*" globals from our parser code, turning them into a structure that is passed when an expression needs to be evaluated. This is the initial step to make our parser less "globalized". This is mostly a mechanical patch, which creates a structure containing the "expout*" globals and then modify all the functions that handle them in order to take the structure as argument. It is big, and has been reviewed at least 4 times, so I think everything is covered. Below you can see the message links from the discussions: - First attempt: <https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html> Message-ID: <m3k44s7qej.fsf@gmail.com> - Second attempt: <https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html> Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com> - Third attempt: <https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html> Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com> - Fourth (last) attempt: <https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html> Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com> gdb/ 2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com> Remove some globals from our parser. * language.c (unk_lang_parser): Add "struct parser_state" argument. * language.h (struct language_defn) <la_parser>: Likewise. * parse.c (expout, expout_size, expout_ptr): Remove variables. (initialize_expout): Add "struct parser_state" argument. Rewrite function to use the parser state. (reallocate_expout, write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_msymbol, mark_struct_expression, write_dollar_variable): Likewise. (parse_exp_in_context_1): Use parser state. (insert_type_address_space): Add "struct parser_state" argument. Use parser state. (increase_expout_size): New function. * parser-defs.h: Forward declare "struct language_defn" and "struct parser_state". (expout, expout_size, expout_ptr): Remove extern declarations. (parse_gdbarch, parse_language): Rewrite macro declarations to accept the parser state. (struct parser_state): New struct. (initialize_expout, reallocate_expout, write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_decfloatcst, write_exp_elt_type, write_exp_elt_intern, write_exp_string, write_exp_string_vector, write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile, write_exp_msymbol, write_dollar_variable, mark_struct_expression, insert_type_address_space): Add "struct parser_state" argument. (increase_expout_size): New function. * utils.c (do_clear_parser_state): New function. (make_cleanup_clear_parser_state): Likewise. * utils.h (make_cleanup_clear_parser_state): New function prototype. * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Update calls to write_exp* in order to pass the parser state. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. (stap_parse_single_operand): Likewise. (stap_parse_argument_1): Likewise. (stap_parse_argument): Use parser state. * stap-probe.h: Include "parser-defs.h". (struct stap_parse_info) <pstate>: New field. * c-exp.y (parse_type): Rewrite to use parser state. (yyparse): Redefine to c_parse_internal. (pstate): New global variable. (parse_number): Add "struct parser_state" argument. (write_destructor_name): Likewise. (type_exp): Update calls to write_exp* and similars in order to use parser state. (exp1, exp, variable, qualified_name, space_identifier, typename, typebase): Likewise. (write_destructor_name, parse_number, lex_one_token, classify_name, classify_inner_name, c_parse): Add "struct parser_state" argument. Update function to use parser state. * c-lang.h: Forward declare "struct parser_state". (c_parse): Add "struct parser_state" argument. * ada-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to ada_parse_internal. (pstate): New variable. (write_int, write_object_renaming, write_var_or_type, write_name_assoc, write_exp_op_with_string, write_ambiguous_var, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. (exp1, primary, simple_exp, relation, and_exp, and_then_exp, or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix, var_or_type, aggregate, aggregate_component_list, positional_list, others, component_group, component_associations): Update calls to write_exp* and similar functions in order to use parser state. (ada_parse, write_var_from_sym, write_int, write_exp_op_with_string, write_object_renaming, find_primitive_type, write_selectors, write_ambiguous_var, write_var_or_type, write_name_assoc, type_int, type_long, type_long_long, type_float, type_double, type_long_double, type_char, type_boolean, type_system_address): Add "struct parser_state" argument. Adjust function to use parser state. * ada-lang.c (parse): Likewise. * ada-lang.h: Forward declare "struct parser_state". (ada_parse): Add "struct parser_state" argument. * ada-lex.l (processInt, processReal): Likewise. Adjust all calls to both functions. * f-exp.y (parse_type, parse_f_type): Rewrite macros to use parser state. (yyparse): Redefine macro to f_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp, subrange, typebase): Update calls to write_exp* and similars in order to use parser state. (parse_number): Adjust code to use parser state. (yylex): Likewise. (f_parse): New function. * f-lang.h: Forward declare "struct parser_state". (f_parse): Add "struct parser_state" argument. * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use parser state. (yyparse): Redefine macro for java_parse_internal. (pstate): New variable. (push_expression_name, push_expression_name, insert_exp): Add "struct parser_state" argument. (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType, FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess, FuncStart, MethodInvocation, ArrayAccess, PostfixExpression, PostIncrementExpression, PostDecrementExpression, UnaryExpression, PreIncrementExpression, PreDecrementExpression, UnaryExpressionNotPlusMinus, CastExpression, MultiplicativeExpression, AdditiveExpression, ShiftExpression, RelationalExpression, EqualityExpression, AndExpression, ExclusiveOrExpression, InclusiveOrExpression, ConditionalAndExpression, ConditionalOrExpression, ConditionalExpression, Assignment, LeftHandSide): Update calls to write_exp* and similars in order to use parser state. (parse_number): Ajust code to use parser state. (yylex): Likewise. (java_parse): New function. (push_variable): Add "struct parser_state" argument. Adjust code to user parser state. (push_fieldnames, push_qualified_expression_name, push_expression_name, insert_exp): Likewise. * jv-lang.h: Forward declare "struct parser_state". (java_parse): Add "struct parser_state" argument. * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use parser state. (yyparse): Redefine macro to m2_parse_internal. (pstate): New variable. (type_exp, exp, fblock, variable, type): Update calls to write_exp* and similars to use parser state. (yylex): Likewise. (m2_parse): New function. * m2-lang.h: Forward declare "struct parser_state". (m2_parse): Add "struct parser_state" argument. * objc-lang.c (end_msglist): Add "struct parser_state" argument. * objc-lang.h: Forward declare "struct parser_state". (end_msglist): Add "struct parser_state" argument. * p-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to pascal_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, qualified_name, variable): Update calls to write_exp* and similars in order to use parser state. (parse_number, yylex): Adjust code to use parser state. (pascal_parse): New function. * p-lang.h: Forward declare "struct parser_state". (pascal_parse): Add "struct parser_state" argument. * go-exp.y (parse_type): Rewrite macro to use parser state. (yyparse): Redefine macro to go_parse_internal. (pstate): New variable. (parse_number): Add "struct parser_state" argument. (type_exp, exp1, exp, variable, type): Update calls to write_exp* and similars in order to use parser state. (parse_number, lex_one_token, classify_name, yylex): Adjust code to use parser state. (go_parse): Likewise. * go-lang.h: Forward declare "struct parser_state". (go_parse): Add "struct parser_state" argument.
This commit is contained in:
parent
342587c494
commit
410a0ff2df
31 changed files with 2038 additions and 1548 deletions
165
gdb/ChangeLog
165
gdb/ChangeLog
|
@ -1,3 +1,168 @@
|
|||
2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com>
|
||||
|
||||
Remove some globals from our parser.
|
||||
* language.c (unk_lang_parser): Add "struct parser_state"
|
||||
argument.
|
||||
* language.h (struct language_defn) <la_parser>: Likewise.
|
||||
* parse.c (expout, expout_size, expout_ptr): Remove variables.
|
||||
(initialize_expout): Add "struct parser_state" argument.
|
||||
Rewrite function to use the parser state.
|
||||
(reallocate_expout, write_exp_elt, write_exp_elt_opcode,
|
||||
write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile,
|
||||
write_exp_elt_longcst, write_exp_elt_dblcst,
|
||||
write_exp_elt_decfloatcst, write_exp_elt_type,
|
||||
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
|
||||
write_exp_bitstring, write_exp_msymbol, mark_struct_expression,
|
||||
write_dollar_variable): Likewise.
|
||||
(parse_exp_in_context_1): Use parser state.
|
||||
(insert_type_address_space): Add "struct parser_state" argument.
|
||||
Use parser state.
|
||||
(increase_expout_size): New function.
|
||||
* parser-defs.h: Forward declare "struct language_defn" and
|
||||
"struct parser_state".
|
||||
(expout, expout_size, expout_ptr): Remove extern declarations.
|
||||
(parse_gdbarch, parse_language): Rewrite macro declarations to
|
||||
accept the parser state.
|
||||
(struct parser_state): New struct.
|
||||
(initialize_expout, reallocate_expout, write_exp_elt_opcode,
|
||||
write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst,
|
||||
write_exp_elt_decfloatcst, write_exp_elt_type,
|
||||
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
|
||||
write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile,
|
||||
write_exp_msymbol, write_dollar_variable,
|
||||
mark_struct_expression, insert_type_address_space): Add "struct
|
||||
parser_state" argument.
|
||||
(increase_expout_size): New function.
|
||||
* utils.c (do_clear_parser_state): New function.
|
||||
(make_cleanup_clear_parser_state): Likewise.
|
||||
* utils.h (make_cleanup_clear_parser_state): New function
|
||||
prototype.
|
||||
* aarch64-linux-tdep.c (aarch64_stap_parse_special_token):
|
||||
Update calls to write_exp* in order to pass the parser state.
|
||||
* arm-linux-tdep.c (arm_stap_parse_special_token): Likewise.
|
||||
* i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise.
|
||||
(i386_stap_parse_special_token_three_arg_disp): Likewise.
|
||||
* ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise.
|
||||
* stap-probe.c (stap_parse_register_operand): Likewise.
|
||||
(stap_parse_single_operand): Likewise.
|
||||
(stap_parse_argument_1): Likewise.
|
||||
(stap_parse_argument): Use parser state.
|
||||
* stap-probe.h: Include "parser-defs.h".
|
||||
(struct stap_parse_info) <pstate>: New field.
|
||||
* c-exp.y (parse_type): Rewrite to use parser state.
|
||||
(yyparse): Redefine to c_parse_internal.
|
||||
(pstate): New global variable.
|
||||
(parse_number): Add "struct parser_state" argument.
|
||||
(write_destructor_name): Likewise.
|
||||
(type_exp): Update calls to write_exp* and similars in order to
|
||||
use parser state.
|
||||
(exp1, exp, variable, qualified_name, space_identifier,
|
||||
typename, typebase): Likewise.
|
||||
(write_destructor_name, parse_number, lex_one_token,
|
||||
classify_name, classify_inner_name, c_parse): Add "struct
|
||||
parser_state" argument. Update function to use parser state.
|
||||
* c-lang.h: Forward declare "struct parser_state".
|
||||
(c_parse): Add "struct parser_state" argument.
|
||||
* ada-exp.y (parse_type): Rewrite macro to use parser state.
|
||||
(yyparse): Redefine macro to ada_parse_internal.
|
||||
(pstate): New variable.
|
||||
(write_int, write_object_renaming, write_var_or_type,
|
||||
write_name_assoc, write_exp_op_with_string, write_ambiguous_var,
|
||||
type_int, type_long, type_long_long, type_float, type_double,
|
||||
type_long_double, type_char, type_boolean, type_system_address):
|
||||
Add "struct parser_state" argument.
|
||||
(exp1, primary, simple_exp, relation, and_exp, and_then_exp,
|
||||
or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix,
|
||||
var_or_type, aggregate, aggregate_component_list,
|
||||
positional_list, others, component_group,
|
||||
component_associations): Update calls to write_exp* and similar
|
||||
functions in order to use parser state.
|
||||
(ada_parse, write_var_from_sym, write_int,
|
||||
write_exp_op_with_string, write_object_renaming,
|
||||
find_primitive_type, write_selectors, write_ambiguous_var,
|
||||
write_var_or_type, write_name_assoc, type_int, type_long,
|
||||
type_long_long, type_float, type_double, type_long_double,
|
||||
type_char, type_boolean, type_system_address): Add "struct
|
||||
parser_state" argument. Adjust function to use parser state.
|
||||
* ada-lang.c (parse): Likewise.
|
||||
* ada-lang.h: Forward declare "struct parser_state".
|
||||
(ada_parse): Add "struct parser_state" argument.
|
||||
* ada-lex.l (processInt, processReal): Likewise. Adjust all
|
||||
calls to both functions.
|
||||
* f-exp.y (parse_type, parse_f_type): Rewrite macros to use
|
||||
parser state.
|
||||
(yyparse): Redefine macro to f_parse_internal.
|
||||
(pstate): New variable.
|
||||
(parse_number): Add "struct parser_state" argument.
|
||||
(type_exp, exp, subrange, typebase): Update calls to write_exp*
|
||||
and similars in order to use parser state.
|
||||
(parse_number): Adjust code to use parser state.
|
||||
(yylex): Likewise.
|
||||
(f_parse): New function.
|
||||
* f-lang.h: Forward declare "struct parser_state".
|
||||
(f_parse): Add "struct parser_state" argument.
|
||||
* jv-exp.y (parse_type, parse_java_type): Rewrite macros to use
|
||||
parser state.
|
||||
(yyparse): Redefine macro for java_parse_internal.
|
||||
(pstate): New variable.
|
||||
(push_expression_name, push_expression_name, insert_exp): Add
|
||||
"struct parser_state" argument.
|
||||
(type_exp, StringLiteral, Literal, PrimitiveType, IntegralType,
|
||||
FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess,
|
||||
FuncStart, MethodInvocation, ArrayAccess, PostfixExpression,
|
||||
PostIncrementExpression, PostDecrementExpression,
|
||||
UnaryExpression, PreIncrementExpression, PreDecrementExpression,
|
||||
UnaryExpressionNotPlusMinus, CastExpression,
|
||||
MultiplicativeExpression, AdditiveExpression, ShiftExpression,
|
||||
RelationalExpression, EqualityExpression, AndExpression,
|
||||
ExclusiveOrExpression, InclusiveOrExpression,
|
||||
ConditionalAndExpression, ConditionalOrExpression,
|
||||
ConditionalExpression, Assignment, LeftHandSide): Update
|
||||
calls to write_exp* and similars in order to use parser state.
|
||||
(parse_number): Ajust code to use parser state.
|
||||
(yylex): Likewise.
|
||||
(java_parse): New function.
|
||||
(push_variable): Add "struct parser_state" argument. Adjust
|
||||
code to user parser state.
|
||||
(push_fieldnames, push_qualified_expression_name,
|
||||
push_expression_name, insert_exp): Likewise.
|
||||
* jv-lang.h: Forward declare "struct parser_state".
|
||||
(java_parse): Add "struct parser_state" argument.
|
||||
* m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use
|
||||
parser state.
|
||||
(yyparse): Redefine macro to m2_parse_internal.
|
||||
(pstate): New variable.
|
||||
(type_exp, exp, fblock, variable, type): Update calls to
|
||||
write_exp* and similars to use parser state.
|
||||
(yylex): Likewise.
|
||||
(m2_parse): New function.
|
||||
* m2-lang.h: Forward declare "struct parser_state".
|
||||
(m2_parse): Add "struct parser_state" argument.
|
||||
* objc-lang.c (end_msglist): Add "struct parser_state" argument.
|
||||
* objc-lang.h: Forward declare "struct parser_state".
|
||||
(end_msglist): Add "struct parser_state" argument.
|
||||
* p-exp.y (parse_type): Rewrite macro to use parser state.
|
||||
(yyparse): Redefine macro to pascal_parse_internal.
|
||||
(pstate): New variable.
|
||||
(parse_number): Add "struct parser_state" argument.
|
||||
(type_exp, exp1, exp, qualified_name, variable): Update calls to
|
||||
write_exp* and similars in order to use parser state.
|
||||
(parse_number, yylex): Adjust code to use parser state.
|
||||
(pascal_parse): New function.
|
||||
* p-lang.h: Forward declare "struct parser_state".
|
||||
(pascal_parse): Add "struct parser_state" argument.
|
||||
* go-exp.y (parse_type): Rewrite macro to use parser state.
|
||||
(yyparse): Redefine macro to go_parse_internal.
|
||||
(pstate): New variable.
|
||||
(parse_number): Add "struct parser_state" argument.
|
||||
(type_exp, exp1, exp, variable, type): Update calls to
|
||||
write_exp* and similars in order to use parser state.
|
||||
(parse_number, lex_one_token, classify_name, yylex): Adjust code
|
||||
to use parser state.
|
||||
(go_parse): Likewise.
|
||||
* go-lang.h: Forward declare "struct parser_state".
|
||||
(go_parse): Add "struct parser_state" argument.
|
||||
|
||||
2014-03-27 Doug Evans <dje@google.com>
|
||||
|
||||
* dwarf2read.c (read_str_index): Delete arg cu. All callers updated.
|
||||
|
|
|
@ -352,28 +352,28 @@ aarch64_stap_parse_special_token (struct gdbarch *gdbarch,
|
|||
return 0;
|
||||
|
||||
/* The displacement. */
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
|
||||
write_exp_elt_longcst (displacement);
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
||||
write_exp_elt_type (&p->pstate, builtin_type (gdbarch)->builtin_long);
|
||||
write_exp_elt_longcst (&p->pstate, displacement);
|
||||
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
||||
if (got_minus)
|
||||
write_exp_elt_opcode (UNOP_NEG);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_NEG);
|
||||
|
||||
/* The register name. */
|
||||
write_exp_elt_opcode (OP_REGISTER);
|
||||
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
||||
str.ptr = regname;
|
||||
str.length = len;
|
||||
write_exp_string (str);
|
||||
write_exp_elt_opcode (OP_REGISTER);
|
||||
write_exp_string (&p->pstate, str);
|
||||
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
||||
|
||||
write_exp_elt_opcode (BINOP_ADD);
|
||||
write_exp_elt_opcode (&p->pstate, BINOP_ADD);
|
||||
|
||||
/* Casting to the expected type. */
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_type (lookup_pointer_type (p->arg_type));
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_CAST);
|
||||
write_exp_elt_type (&p->pstate, lookup_pointer_type (p->arg_type));
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_CAST);
|
||||
|
||||
write_exp_elt_opcode (UNOP_IND);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_IND);
|
||||
|
||||
p->arg = tmp;
|
||||
}
|
||||
|
|
488
gdb/ada-exp.y
488
gdb/ada-exp.y
File diff suppressed because it is too large
Load diff
|
@ -13376,10 +13376,10 @@ emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
|
|||
}
|
||||
|
||||
static int
|
||||
parse (void)
|
||||
parse (struct parser_state *ps)
|
||||
{
|
||||
warnings_issued = 0;
|
||||
return ada_parse ();
|
||||
return ada_parse (ps);
|
||||
}
|
||||
|
||||
static const struct exp_descriptor ada_exp_descriptor = {
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
struct frame_info;
|
||||
struct inferior;
|
||||
struct type_print_options;
|
||||
struct parser_state;
|
||||
|
||||
#include "value.h"
|
||||
#include "gdbtypes.h"
|
||||
|
@ -169,7 +170,7 @@ extern int ada_get_field_index (const struct type *type,
|
|||
const char *field_name,
|
||||
int maybe_missing);
|
||||
|
||||
extern int ada_parse (void); /* Defined in ada-exp.y */
|
||||
extern int ada_parse (struct parser_state *); /* Defined in ada-exp.y */
|
||||
|
||||
extern void ada_error (char *); /* Defined in ada-exp.y */
|
||||
|
||||
|
|
|
@ -48,8 +48,9 @@ POSEXP (e"+"?{NUM10})
|
|||
static char numbuf[NUMERAL_WIDTH];
|
||||
static void canonicalizeNumeral (char *s1, const char *);
|
||||
static struct stoken processString (const char*, int);
|
||||
static int processInt (const char *, const char *, const char *);
|
||||
static int processReal (const char *);
|
||||
static int processInt (struct parser_state *, const char *, const char *,
|
||||
const char *);
|
||||
static int processReal (struct parser_state *, const char *);
|
||||
static struct stoken processId (const char *, int);
|
||||
static int processAttribute (const char *);
|
||||
static int find_dot_all (const char *);
|
||||
|
@ -89,40 +90,42 @@ static int find_dot_all (const char *);
|
|||
|
||||
{NUM10}{POSEXP} {
|
||||
canonicalizeNumeral (numbuf, yytext);
|
||||
return processInt (NULL, numbuf, strrchr(numbuf, 'e')+1);
|
||||
return processInt (pstate, NULL, numbuf,
|
||||
strrchr (numbuf, 'e') + 1);
|
||||
}
|
||||
|
||||
{NUM10} {
|
||||
canonicalizeNumeral (numbuf, yytext);
|
||||
return processInt (NULL, numbuf, NULL);
|
||||
return processInt (pstate, NULL, numbuf, NULL);
|
||||
}
|
||||
|
||||
{NUM10}"#"{HEXDIG}({HEXDIG}|_)*"#"{POSEXP} {
|
||||
canonicalizeNumeral (numbuf, yytext);
|
||||
return processInt (numbuf,
|
||||
return processInt (pstate, numbuf,
|
||||
strchr (numbuf, '#') + 1,
|
||||
strrchr(numbuf, '#') + 1);
|
||||
}
|
||||
|
||||
{NUM10}"#"{HEXDIG}({HEXDIG}|_)*"#" {
|
||||
canonicalizeNumeral (numbuf, yytext);
|
||||
return processInt (numbuf, strchr (numbuf, '#') + 1, NULL);
|
||||
return processInt (pstate, numbuf, strchr (numbuf, '#') + 1,
|
||||
NULL);
|
||||
}
|
||||
|
||||
"0x"{HEXDIG}+ {
|
||||
canonicalizeNumeral (numbuf, yytext+2);
|
||||
return processInt ("16#", numbuf, NULL);
|
||||
return processInt (pstate, "16#", numbuf, NULL);
|
||||
}
|
||||
|
||||
|
||||
{NUM10}"."{NUM10}{EXP} {
|
||||
canonicalizeNumeral (numbuf, yytext);
|
||||
return processReal (numbuf);
|
||||
return processReal (pstate, numbuf);
|
||||
}
|
||||
|
||||
{NUM10}"."{NUM10} {
|
||||
canonicalizeNumeral (numbuf, yytext);
|
||||
return processReal (numbuf);
|
||||
return processReal (pstate, numbuf);
|
||||
}
|
||||
|
||||
{NUM10}"#"{NUM16}"."{NUM16}"#"{EXP} {
|
||||
|
@ -134,14 +137,14 @@ static int find_dot_all (const char *);
|
|||
}
|
||||
|
||||
<INITIAL>"'"({GRAPHIC}|\")"'" {
|
||||
yylval.typed_val.type = type_char ();
|
||||
yylval.typed_val.type = type_char (pstate);
|
||||
yylval.typed_val.val = yytext[1];
|
||||
return CHARLIT;
|
||||
}
|
||||
|
||||
<INITIAL>"'[\""{HEXDIG}{2}"\"]'" {
|
||||
int v;
|
||||
yylval.typed_val.type = type_char ();
|
||||
yylval.typed_val.type = type_char (pstate);
|
||||
sscanf (yytext+3, "%2x", &v);
|
||||
yylval.typed_val.val = v;
|
||||
return CHARLIT;
|
||||
|
@ -324,7 +327,8 @@ canonicalizeNumeral (char *s1, const char *s2)
|
|||
*/
|
||||
|
||||
static int
|
||||
processInt (const char *base0, const char *num0, const char *exp0)
|
||||
processInt (struct parser_state *par_state, const char *base0,
|
||||
const char *num0, const char *exp0)
|
||||
{
|
||||
ULONGEST result;
|
||||
long exp;
|
||||
|
@ -360,11 +364,11 @@ processInt (const char *base0, const char *num0, const char *exp0)
|
|||
exp -= 1;
|
||||
}
|
||||
|
||||
if ((result >> (gdbarch_int_bit (parse_gdbarch)-1)) == 0)
|
||||
yylval.typed_val.type = type_int ();
|
||||
else if ((result >> (gdbarch_long_bit (parse_gdbarch)-1)) == 0)
|
||||
yylval.typed_val.type = type_long ();
|
||||
else if (((result >> (gdbarch_long_bit (parse_gdbarch)-1)) >> 1) == 0)
|
||||
if ((result >> (gdbarch_int_bit (parse_gdbarch (par_state))-1)) == 0)
|
||||
yylval.typed_val.type = type_int (par_state);
|
||||
else if ((result >> (gdbarch_long_bit (parse_gdbarch (par_state))-1)) == 0)
|
||||
yylval.typed_val.type = type_long (par_state);
|
||||
else if (((result >> (gdbarch_long_bit (parse_gdbarch (par_state))-1)) >> 1) == 0)
|
||||
{
|
||||
/* We have a number representable as an unsigned integer quantity.
|
||||
For consistency with the C treatment, we will treat it as an
|
||||
|
@ -374,7 +378,7 @@ processInt (const char *base0, const char *num0, const char *exp0)
|
|||
assignment does the trick (no, it doesn't; read the reference manual).
|
||||
*/
|
||||
yylval.typed_val.type
|
||||
= builtin_type (parse_gdbarch)->builtin_unsigned_long;
|
||||
= builtin_type (parse_gdbarch (par_state))->builtin_unsigned_long;
|
||||
if (result & LONGEST_SIGN)
|
||||
yylval.typed_val.val =
|
||||
(LONGEST) (result & ~LONGEST_SIGN)
|
||||
|
@ -384,24 +388,24 @@ processInt (const char *base0, const char *num0, const char *exp0)
|
|||
return INT;
|
||||
}
|
||||
else
|
||||
yylval.typed_val.type = type_long_long ();
|
||||
yylval.typed_val.type = type_long_long (par_state);
|
||||
|
||||
yylval.typed_val.val = (LONGEST) result;
|
||||
return INT;
|
||||
}
|
||||
|
||||
static int
|
||||
processReal (const char *num0)
|
||||
processReal (struct parser_state *par_state, const char *num0)
|
||||
{
|
||||
sscanf (num0, "%" DOUBLEST_SCAN_FORMAT, &yylval.typed_val_float.dval);
|
||||
|
||||
yylval.typed_val_float.type = type_float ();
|
||||
if (sizeof(DOUBLEST) >= gdbarch_double_bit (parse_gdbarch)
|
||||
yylval.typed_val_float.type = type_float (par_state);
|
||||
if (sizeof(DOUBLEST) >= gdbarch_double_bit (parse_gdbarch (par_state))
|
||||
/ TARGET_CHAR_BIT)
|
||||
yylval.typed_val_float.type = type_double ();
|
||||
if (sizeof(DOUBLEST) >= gdbarch_long_double_bit (parse_gdbarch)
|
||||
yylval.typed_val_float.type = type_double (par_state);
|
||||
if (sizeof(DOUBLEST) >= gdbarch_long_double_bit (parse_gdbarch (par_state))
|
||||
/ TARGET_CHAR_BIT)
|
||||
yylval.typed_val_float.type = type_long_double ();
|
||||
yylval.typed_val_float.type = type_long_double (par_state);
|
||||
|
||||
return FLOAT;
|
||||
}
|
||||
|
|
|
@ -1206,28 +1206,28 @@ arm_stap_parse_special_token (struct gdbarch *gdbarch,
|
|||
return 0;
|
||||
|
||||
/* The displacement. */
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
|
||||
write_exp_elt_longcst (displacement);
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
||||
write_exp_elt_type (&p->pstate, builtin_type (gdbarch)->builtin_long);
|
||||
write_exp_elt_longcst (&p->pstate, displacement);
|
||||
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
||||
if (got_minus)
|
||||
write_exp_elt_opcode (UNOP_NEG);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_NEG);
|
||||
|
||||
/* The register name. */
|
||||
write_exp_elt_opcode (OP_REGISTER);
|
||||
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
||||
str.ptr = regname;
|
||||
str.length = len;
|
||||
write_exp_string (str);
|
||||
write_exp_elt_opcode (OP_REGISTER);
|
||||
write_exp_string (&p->pstate, str);
|
||||
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
||||
|
||||
write_exp_elt_opcode (BINOP_ADD);
|
||||
write_exp_elt_opcode (&p->pstate, BINOP_ADD);
|
||||
|
||||
/* Casting to the expected type. */
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_type (lookup_pointer_type (p->arg_type));
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_CAST);
|
||||
write_exp_elt_type (&p->pstate, lookup_pointer_type (p->arg_type));
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_CAST);
|
||||
|
||||
write_exp_elt_opcode (UNOP_IND);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_IND);
|
||||
|
||||
p->arg = tmp;
|
||||
}
|
||||
|
|
698
gdb/c-exp.y
698
gdb/c-exp.y
File diff suppressed because it is too large
Load diff
|
@ -24,6 +24,7 @@
|
|||
struct ui_file;
|
||||
struct language_arch_info;
|
||||
struct type_print_options;
|
||||
struct parser_state;
|
||||
|
||||
#include "value.h"
|
||||
#include "macroexp.h"
|
||||
|
@ -57,7 +58,7 @@ enum c_string_type
|
|||
|
||||
/* Defined in c-exp.y. */
|
||||
|
||||
extern int c_parse (void);
|
||||
extern int c_parse (struct parser_state *);
|
||||
|
||||
extern void c_error (char *);
|
||||
|
||||
|
|
276
gdb/f-exp.y
276
gdb/f-exp.y
|
@ -54,8 +54,8 @@
|
|||
#include "block.h"
|
||||
#include <ctype.h>
|
||||
|
||||
#define parse_type builtin_type (parse_gdbarch)
|
||||
#define parse_f_type builtin_f_type (parse_gdbarch)
|
||||
#define parse_type(ps) builtin_type (parse_gdbarch (ps))
|
||||
#define parse_f_type(ps) builtin_f_type (parse_gdbarch (ps))
|
||||
|
||||
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
|
||||
as well as gratuitiously global symbol names, so we can have multiple
|
||||
|
@ -65,7 +65,7 @@
|
|||
generators need to be fixed instead of adding those names to this list. */
|
||||
|
||||
#define yymaxdepth f_maxdepth
|
||||
#define yyparse f_parse
|
||||
#define yyparse f_parse_internal
|
||||
#define yylex f_lex
|
||||
#define yyerror f_error
|
||||
#define yylval f_lval
|
||||
|
@ -117,6 +117,11 @@
|
|||
|
||||
#define YYFPRINTF parser_fprintf
|
||||
|
||||
/* The state of the parser, used internally when we are parsing the
|
||||
expression. */
|
||||
|
||||
static struct parser_state *pstate = NULL;
|
||||
|
||||
int yyparse (void);
|
||||
|
||||
static int yylex (void);
|
||||
|
@ -157,7 +162,8 @@ static int match_string_literal (void);
|
|||
|
||||
%{
|
||||
/* YYSTYPE gets defined by %union */
|
||||
static int parse_number (const char *, int, int, YYSTYPE *);
|
||||
static int parse_number (struct parser_state *, const char *, int,
|
||||
int, YYSTYPE *);
|
||||
%}
|
||||
|
||||
%type <voidval> exp type_exp start variable
|
||||
|
@ -239,9 +245,9 @@ start : exp
|
|||
;
|
||||
|
||||
type_exp: type
|
||||
{ write_exp_elt_opcode(OP_TYPE);
|
||||
write_exp_elt_type($1);
|
||||
write_exp_elt_opcode(OP_TYPE); }
|
||||
{ write_exp_elt_opcode (pstate, OP_TYPE);
|
||||
write_exp_elt_type (pstate, $1);
|
||||
write_exp_elt_opcode (pstate, OP_TYPE); }
|
||||
;
|
||||
|
||||
exp : '(' exp ')'
|
||||
|
@ -250,27 +256,27 @@ exp : '(' exp ')'
|
|||
|
||||
/* Expressions, not including the comma operator. */
|
||||
exp : '*' exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_IND); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_IND); }
|
||||
;
|
||||
|
||||
exp : '&' exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_ADDR); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_ADDR); }
|
||||
;
|
||||
|
||||
exp : '-' exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_NEG); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_NEG); }
|
||||
;
|
||||
|
||||
exp : BOOL_NOT exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT); }
|
||||
;
|
||||
|
||||
exp : '~' exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_COMPLEMENT); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_COMPLEMENT); }
|
||||
;
|
||||
|
||||
exp : SIZEOF exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_SIZEOF); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_SIZEOF); }
|
||||
;
|
||||
|
||||
/* No more explicit array operators, we treat everything in F77 as
|
||||
|
@ -281,9 +287,12 @@ exp : SIZEOF exp %prec UNARY
|
|||
exp : exp '('
|
||||
{ start_arglist (); }
|
||||
arglist ')'
|
||||
{ write_exp_elt_opcode (OP_F77_UNDETERMINED_ARGLIST);
|
||||
write_exp_elt_longcst ((LONGEST) end_arglist ());
|
||||
write_exp_elt_opcode (OP_F77_UNDETERMINED_ARGLIST); }
|
||||
{ write_exp_elt_opcode (pstate,
|
||||
OP_F77_UNDETERMINED_ARGLIST);
|
||||
write_exp_elt_longcst (pstate,
|
||||
(LONGEST) end_arglist ());
|
||||
write_exp_elt_opcode (pstate,
|
||||
OP_F77_UNDETERMINED_ARGLIST); }
|
||||
;
|
||||
|
||||
arglist :
|
||||
|
@ -304,27 +313,27 @@ arglist : arglist ',' exp %prec ABOVE_COMMA
|
|||
/* There are four sorts of subrange types in F90. */
|
||||
|
||||
subrange: exp ':' exp %prec ABOVE_COMMA
|
||||
{ write_exp_elt_opcode (OP_F90_RANGE);
|
||||
write_exp_elt_longcst (NONE_BOUND_DEFAULT);
|
||||
write_exp_elt_opcode (OP_F90_RANGE); }
|
||||
{ write_exp_elt_opcode (pstate, OP_F90_RANGE);
|
||||
write_exp_elt_longcst (pstate, NONE_BOUND_DEFAULT);
|
||||
write_exp_elt_opcode (pstate, OP_F90_RANGE); }
|
||||
;
|
||||
|
||||
subrange: exp ':' %prec ABOVE_COMMA
|
||||
{ write_exp_elt_opcode (OP_F90_RANGE);
|
||||
write_exp_elt_longcst (HIGH_BOUND_DEFAULT);
|
||||
write_exp_elt_opcode (OP_F90_RANGE); }
|
||||
{ write_exp_elt_opcode (pstate, OP_F90_RANGE);
|
||||
write_exp_elt_longcst (pstate, HIGH_BOUND_DEFAULT);
|
||||
write_exp_elt_opcode (pstate, OP_F90_RANGE); }
|
||||
;
|
||||
|
||||
subrange: ':' exp %prec ABOVE_COMMA
|
||||
{ write_exp_elt_opcode (OP_F90_RANGE);
|
||||
write_exp_elt_longcst (LOW_BOUND_DEFAULT);
|
||||
write_exp_elt_opcode (OP_F90_RANGE); }
|
||||
{ write_exp_elt_opcode (pstate, OP_F90_RANGE);
|
||||
write_exp_elt_longcst (pstate, LOW_BOUND_DEFAULT);
|
||||
write_exp_elt_opcode (pstate, OP_F90_RANGE); }
|
||||
;
|
||||
|
||||
subrange: ':' %prec ABOVE_COMMA
|
||||
{ write_exp_elt_opcode (OP_F90_RANGE);
|
||||
write_exp_elt_longcst (BOTH_BOUND_DEFAULT);
|
||||
write_exp_elt_opcode (OP_F90_RANGE); }
|
||||
{ write_exp_elt_opcode (pstate, OP_F90_RANGE);
|
||||
write_exp_elt_longcst (pstate, BOTH_BOUND_DEFAULT);
|
||||
write_exp_elt_opcode (pstate, OP_F90_RANGE); }
|
||||
;
|
||||
|
||||
complexnum: exp ',' exp
|
||||
|
@ -332,133 +341,139 @@ complexnum: exp ',' exp
|
|||
;
|
||||
|
||||
exp : '(' complexnum ')'
|
||||
{ write_exp_elt_opcode(OP_COMPLEX);
|
||||
write_exp_elt_type (parse_f_type->builtin_complex_s16);
|
||||
write_exp_elt_opcode(OP_COMPLEX); }
|
||||
{ write_exp_elt_opcode (pstate, OP_COMPLEX);
|
||||
write_exp_elt_type (pstate,
|
||||
parse_f_type (pstate)
|
||||
->builtin_complex_s16);
|
||||
write_exp_elt_opcode (pstate, OP_COMPLEX); }
|
||||
;
|
||||
|
||||
exp : '(' type ')' exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_type ($2);
|
||||
write_exp_elt_opcode (UNOP_CAST); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_CAST);
|
||||
write_exp_elt_type (pstate, $2);
|
||||
write_exp_elt_opcode (pstate, UNOP_CAST); }
|
||||
;
|
||||
|
||||
exp : exp '%' name
|
||||
{ write_exp_elt_opcode (STRUCTOP_STRUCT);
|
||||
write_exp_string ($3);
|
||||
write_exp_elt_opcode (STRUCTOP_STRUCT); }
|
||||
{ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
|
||||
write_exp_string (pstate, $3);
|
||||
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
|
||||
;
|
||||
|
||||
/* Binary operators in order of decreasing precedence. */
|
||||
|
||||
exp : exp '@' exp
|
||||
{ write_exp_elt_opcode (BINOP_REPEAT); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_REPEAT); }
|
||||
;
|
||||
|
||||
exp : exp STARSTAR exp
|
||||
{ write_exp_elt_opcode (BINOP_EXP); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_EXP); }
|
||||
;
|
||||
|
||||
exp : exp '*' exp
|
||||
{ write_exp_elt_opcode (BINOP_MUL); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_MUL); }
|
||||
;
|
||||
|
||||
exp : exp '/' exp
|
||||
{ write_exp_elt_opcode (BINOP_DIV); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_DIV); }
|
||||
;
|
||||
|
||||
exp : exp '+' exp
|
||||
{ write_exp_elt_opcode (BINOP_ADD); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_ADD); }
|
||||
;
|
||||
|
||||
exp : exp '-' exp
|
||||
{ write_exp_elt_opcode (BINOP_SUB); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_SUB); }
|
||||
;
|
||||
|
||||
exp : exp LSH exp
|
||||
{ write_exp_elt_opcode (BINOP_LSH); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LSH); }
|
||||
;
|
||||
|
||||
exp : exp RSH exp
|
||||
{ write_exp_elt_opcode (BINOP_RSH); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_RSH); }
|
||||
;
|
||||
|
||||
exp : exp EQUAL exp
|
||||
{ write_exp_elt_opcode (BINOP_EQUAL); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_EQUAL); }
|
||||
;
|
||||
|
||||
exp : exp NOTEQUAL exp
|
||||
{ write_exp_elt_opcode (BINOP_NOTEQUAL); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_NOTEQUAL); }
|
||||
;
|
||||
|
||||
exp : exp LEQ exp
|
||||
{ write_exp_elt_opcode (BINOP_LEQ); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LEQ); }
|
||||
;
|
||||
|
||||
exp : exp GEQ exp
|
||||
{ write_exp_elt_opcode (BINOP_GEQ); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_GEQ); }
|
||||
;
|
||||
|
||||
exp : exp LESSTHAN exp
|
||||
{ write_exp_elt_opcode (BINOP_LESS); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LESS); }
|
||||
;
|
||||
|
||||
exp : exp GREATERTHAN exp
|
||||
{ write_exp_elt_opcode (BINOP_GTR); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_GTR); }
|
||||
;
|
||||
|
||||
exp : exp '&' exp
|
||||
{ write_exp_elt_opcode (BINOP_BITWISE_AND); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_BITWISE_AND); }
|
||||
;
|
||||
|
||||
exp : exp '^' exp
|
||||
{ write_exp_elt_opcode (BINOP_BITWISE_XOR); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_BITWISE_XOR); }
|
||||
;
|
||||
|
||||
exp : exp '|' exp
|
||||
{ write_exp_elt_opcode (BINOP_BITWISE_IOR); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_BITWISE_IOR); }
|
||||
;
|
||||
|
||||
exp : exp BOOL_AND exp
|
||||
{ write_exp_elt_opcode (BINOP_LOGICAL_AND); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LOGICAL_AND); }
|
||||
;
|
||||
|
||||
|
||||
exp : exp BOOL_OR exp
|
||||
{ write_exp_elt_opcode (BINOP_LOGICAL_OR); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LOGICAL_OR); }
|
||||
;
|
||||
|
||||
exp : exp '=' exp
|
||||
{ write_exp_elt_opcode (BINOP_ASSIGN); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_ASSIGN); }
|
||||
;
|
||||
|
||||
exp : exp ASSIGN_MODIFY exp
|
||||
{ write_exp_elt_opcode (BINOP_ASSIGN_MODIFY);
|
||||
write_exp_elt_opcode ($2);
|
||||
write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY);
|
||||
write_exp_elt_opcode (pstate, $2);
|
||||
write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY); }
|
||||
;
|
||||
|
||||
exp : INT
|
||||
{ write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type ($1.type);
|
||||
write_exp_elt_longcst ((LONGEST)($1.val));
|
||||
write_exp_elt_opcode (OP_LONG); }
|
||||
{ write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_type (pstate, $1.type);
|
||||
write_exp_elt_longcst (pstate, (LONGEST) ($1.val));
|
||||
write_exp_elt_opcode (pstate, OP_LONG); }
|
||||
;
|
||||
|
||||
exp : NAME_OR_INT
|
||||
{ YYSTYPE val;
|
||||
parse_number ($1.stoken.ptr, $1.stoken.length, 0, &val);
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (val.typed_val.type);
|
||||
write_exp_elt_longcst ((LONGEST)val.typed_val.val);
|
||||
write_exp_elt_opcode (OP_LONG); }
|
||||
parse_number (pstate, $1.stoken.ptr,
|
||||
$1.stoken.length, 0, &val);
|
||||
write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_type (pstate, val.typed_val.type);
|
||||
write_exp_elt_longcst (pstate,
|
||||
(LONGEST)val.typed_val.val);
|
||||
write_exp_elt_opcode (pstate, OP_LONG); }
|
||||
;
|
||||
|
||||
exp : FLOAT
|
||||
{ write_exp_elt_opcode (OP_DOUBLE);
|
||||
write_exp_elt_type (parse_f_type->builtin_real_s8);
|
||||
write_exp_elt_dblcst ($1);
|
||||
write_exp_elt_opcode (OP_DOUBLE); }
|
||||
{ write_exp_elt_opcode (pstate, OP_DOUBLE);
|
||||
write_exp_elt_type (pstate,
|
||||
parse_f_type (pstate)
|
||||
->builtin_real_s8);
|
||||
write_exp_elt_dblcst (pstate, $1);
|
||||
write_exp_elt_opcode (pstate, OP_DOUBLE); }
|
||||
;
|
||||
|
||||
exp : variable
|
||||
|
@ -468,25 +483,28 @@ exp : VARIABLE
|
|||
;
|
||||
|
||||
exp : SIZEOF '(' type ')' %prec UNARY
|
||||
{ write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (parse_f_type->builtin_integer);
|
||||
{ write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_type (pstate,
|
||||
parse_f_type (pstate)
|
||||
->builtin_integer);
|
||||
CHECK_TYPEDEF ($3);
|
||||
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
|
||||
write_exp_elt_opcode (OP_LONG); }
|
||||
write_exp_elt_longcst (pstate,
|
||||
(LONGEST) TYPE_LENGTH ($3));
|
||||
write_exp_elt_opcode (pstate, OP_LONG); }
|
||||
;
|
||||
|
||||
exp : BOOLEAN_LITERAL
|
||||
{ write_exp_elt_opcode (OP_BOOL);
|
||||
write_exp_elt_longcst ((LONGEST) $1);
|
||||
write_exp_elt_opcode (OP_BOOL);
|
||||
{ write_exp_elt_opcode (pstate, OP_BOOL);
|
||||
write_exp_elt_longcst (pstate, (LONGEST) $1);
|
||||
write_exp_elt_opcode (pstate, OP_BOOL);
|
||||
}
|
||||
;
|
||||
|
||||
exp : STRING_LITERAL
|
||||
{
|
||||
write_exp_elt_opcode (OP_STRING);
|
||||
write_exp_string ($1);
|
||||
write_exp_elt_opcode (OP_STRING);
|
||||
write_exp_elt_opcode (pstate, OP_STRING);
|
||||
write_exp_string (pstate, $1);
|
||||
write_exp_elt_opcode (pstate, OP_STRING);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -502,13 +520,13 @@ variable: name_not_typename
|
|||
innermost_block))
|
||||
innermost_block = block_found;
|
||||
}
|
||||
write_exp_elt_opcode (OP_VAR_VALUE);
|
||||
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
|
||||
/* We want to use the selected frame, not
|
||||
another more inner frame which happens to
|
||||
be in the same block. */
|
||||
write_exp_elt_block (NULL);
|
||||
write_exp_elt_sym (sym);
|
||||
write_exp_elt_opcode (OP_VAR_VALUE);
|
||||
write_exp_elt_block (pstate, NULL);
|
||||
write_exp_elt_sym (pstate, sym);
|
||||
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
@ -519,7 +537,7 @@ variable: name_not_typename
|
|||
msymbol =
|
||||
lookup_bound_minimal_symbol (arg);
|
||||
if (msymbol.minsym != NULL)
|
||||
write_exp_msymbol (msymbol);
|
||||
write_exp_msymbol (pstate, msymbol);
|
||||
else if (!have_full_symbols () && !have_partial_symbols ())
|
||||
error (_("No symbol table is loaded. Use the \"file\" command."));
|
||||
else
|
||||
|
@ -560,7 +578,8 @@ ptype : typebase
|
|||
{
|
||||
range_type =
|
||||
create_range_type ((struct type *) NULL,
|
||||
parse_f_type->builtin_integer,
|
||||
parse_f_type (pstate)
|
||||
->builtin_integer,
|
||||
0, array_size - 1);
|
||||
follow_type =
|
||||
create_array_type ((struct type *) NULL,
|
||||
|
@ -606,31 +625,31 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */
|
|||
: TYPENAME
|
||||
{ $$ = $1.type; }
|
||||
| INT_KEYWORD
|
||||
{ $$ = parse_f_type->builtin_integer; }
|
||||
{ $$ = parse_f_type (pstate)->builtin_integer; }
|
||||
| INT_S2_KEYWORD
|
||||
{ $$ = parse_f_type->builtin_integer_s2; }
|
||||
{ $$ = parse_f_type (pstate)->builtin_integer_s2; }
|
||||
| CHARACTER
|
||||
{ $$ = parse_f_type->builtin_character; }
|
||||
{ $$ = parse_f_type (pstate)->builtin_character; }
|
||||
| LOGICAL_S8_KEYWORD
|
||||
{ $$ = parse_f_type->builtin_logical_s8; }
|
||||
{ $$ = parse_f_type (pstate)->builtin_logical_s8; }
|
||||
| LOGICAL_KEYWORD
|
||||
{ $$ = parse_f_type->builtin_logical; }
|
||||
{ $$ = parse_f_type (pstate)->builtin_logical; }
|
||||
| LOGICAL_S2_KEYWORD
|
||||
{ $$ = parse_f_type->builtin_logical_s2; }
|
||||
{ $$ = parse_f_type (pstate)->builtin_logical_s2; }
|
||||
| LOGICAL_S1_KEYWORD
|
||||
{ $$ = parse_f_type->builtin_logical_s1; }
|
||||
{ $$ = parse_f_type (pstate)->builtin_logical_s1; }
|
||||
| REAL_KEYWORD
|
||||
{ $$ = parse_f_type->builtin_real; }
|
||||
{ $$ = parse_f_type (pstate)->builtin_real; }
|
||||
| REAL_S8_KEYWORD
|
||||
{ $$ = parse_f_type->builtin_real_s8; }
|
||||
{ $$ = parse_f_type (pstate)->builtin_real_s8; }
|
||||
| REAL_S16_KEYWORD
|
||||
{ $$ = parse_f_type->builtin_real_s16; }
|
||||
{ $$ = parse_f_type (pstate)->builtin_real_s16; }
|
||||
| COMPLEX_S8_KEYWORD
|
||||
{ $$ = parse_f_type->builtin_complex_s8; }
|
||||
{ $$ = parse_f_type (pstate)->builtin_complex_s8; }
|
||||
| COMPLEX_S16_KEYWORD
|
||||
{ $$ = parse_f_type->builtin_complex_s16; }
|
||||
{ $$ = parse_f_type (pstate)->builtin_complex_s16; }
|
||||
| COMPLEX_S32_KEYWORD
|
||||
{ $$ = parse_f_type->builtin_complex_s32; }
|
||||
{ $$ = parse_f_type (pstate)->builtin_complex_s32; }
|
||||
;
|
||||
|
||||
nonempty_typelist
|
||||
|
@ -669,7 +688,8 @@ name_not_typename : NAME
|
|||
/*** Needs some error checking for the float case ***/
|
||||
|
||||
static int
|
||||
parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
|
||||
parse_number (struct parser_state *par_state,
|
||||
const char *p, int len, int parsed_float, YYSTYPE *putithere)
|
||||
{
|
||||
LONGEST n = 0;
|
||||
LONGEST prevn = 0;
|
||||
|
@ -775,20 +795,24 @@ parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
|
|||
are the same size. So we shift it twice, with fewer bits
|
||||
each time, for the same result. */
|
||||
|
||||
if ((gdbarch_int_bit (parse_gdbarch) != gdbarch_long_bit (parse_gdbarch)
|
||||
if ((gdbarch_int_bit (parse_gdbarch (par_state))
|
||||
!= gdbarch_long_bit (parse_gdbarch (par_state))
|
||||
&& ((n >> 2)
|
||||
>> (gdbarch_int_bit (parse_gdbarch)-2))) /* Avoid shift warning */
|
||||
>> (gdbarch_int_bit (parse_gdbarch (par_state))-2))) /* Avoid
|
||||
shift warning */
|
||||
|| long_p)
|
||||
{
|
||||
high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch)-1);
|
||||
unsigned_type = parse_type->builtin_unsigned_long;
|
||||
signed_type = parse_type->builtin_long;
|
||||
high_bit = ((ULONGEST)1)
|
||||
<< (gdbarch_long_bit (parse_gdbarch (par_state))-1);
|
||||
unsigned_type = parse_type (par_state)->builtin_unsigned_long;
|
||||
signed_type = parse_type (par_state)->builtin_long;
|
||||
}
|
||||
else
|
||||
{
|
||||
high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch)-1);
|
||||
unsigned_type = parse_type->builtin_unsigned_int;
|
||||
signed_type = parse_type->builtin_int;
|
||||
high_bit =
|
||||
((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch (par_state)) - 1);
|
||||
unsigned_type = parse_type (par_state)->builtin_unsigned_int;
|
||||
signed_type = parse_type (par_state)->builtin_int;
|
||||
}
|
||||
|
||||
putithere->typed_val.val = n;
|
||||
|
@ -1090,7 +1114,8 @@ yylex (void)
|
|||
&& (*p < 'A' || *p > 'Z')))
|
||||
break;
|
||||
}
|
||||
toktype = parse_number (tokstart, p - tokstart, got_dot|got_e|got_d,
|
||||
toktype = parse_number (pstate, tokstart, p - tokstart,
|
||||
got_dot|got_e|got_d,
|
||||
&yylval);
|
||||
if (toktype == ERROR)
|
||||
{
|
||||
|
@ -1164,7 +1189,7 @@ yylex (void)
|
|||
|
||||
if (*tokstart == '$')
|
||||
{
|
||||
write_dollar_variable (yylval.sval);
|
||||
write_dollar_variable (pstate, yylval.sval);
|
||||
return VARIABLE;
|
||||
}
|
||||
|
||||
|
@ -1192,8 +1217,8 @@ yylex (void)
|
|||
|
||||
sym = lookup_symbol (tmp, expression_context_block,
|
||||
lookup_domains[i],
|
||||
parse_language->la_language == language_cplus
|
||||
? &is_a_field_of_this : NULL);
|
||||
parse_language (pstate)->la_language
|
||||
== language_cplus ? &is_a_field_of_this : NULL);
|
||||
if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
|
||||
{
|
||||
yylval.tsym.type = SYMBOL_TYPE (sym);
|
||||
|
@ -1205,8 +1230,8 @@ yylex (void)
|
|||
}
|
||||
|
||||
yylval.tsym.type
|
||||
= language_lookup_primitive_type_by_name (parse_language,
|
||||
parse_gdbarch, tmp);
|
||||
= language_lookup_primitive_type_by_name (parse_language (pstate),
|
||||
parse_gdbarch (pstate), tmp);
|
||||
if (yylval.tsym.type != NULL)
|
||||
return TYPENAME;
|
||||
|
||||
|
@ -1218,7 +1243,7 @@ yylex (void)
|
|||
|| (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
|
||||
{
|
||||
YYSTYPE newlval; /* Its value is ignored. */
|
||||
hextype = parse_number (tokstart, namelen, 0, &newlval);
|
||||
hextype = parse_number (pstate, tokstart, namelen, 0, &newlval);
|
||||
if (hextype == INT)
|
||||
{
|
||||
yylval.ssym.sym = sym;
|
||||
|
@ -1234,6 +1259,21 @@ yylex (void)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
f_parse (struct parser_state *par_state)
|
||||
{
|
||||
int result;
|
||||
struct cleanup *c = make_cleanup_clear_parser_state (&pstate);
|
||||
|
||||
/* Setting up the parser state. */
|
||||
gdb_assert (par_state != NULL);
|
||||
pstate = par_state;
|
||||
|
||||
result = yyparse ();
|
||||
do_cleanups (c);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
yyerror (char *msg)
|
||||
{
|
||||
|
|
|
@ -21,8 +21,9 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
struct type_print_options;
|
||||
struct parser_state;
|
||||
|
||||
extern int f_parse (void);
|
||||
extern int f_parse (struct parser_state *);
|
||||
|
||||
extern void f_error (char *); /* Defined in f-exp.y */
|
||||
|
||||
|
|
268
gdb/go-exp.y
268
gdb/go-exp.y
|
@ -66,7 +66,7 @@
|
|||
#include "charset.h"
|
||||
#include "block.h"
|
||||
|
||||
#define parse_type builtin_type (parse_gdbarch)
|
||||
#define parse_type(ps) builtin_type (parse_gdbarch (ps))
|
||||
|
||||
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
|
||||
as well as gratuitiously global symbol names, so we can have multiple
|
||||
|
@ -122,6 +122,11 @@
|
|||
|
||||
#define YYFPRINTF parser_fprintf
|
||||
|
||||
/* The state of the parser, used internally when we are parsing the
|
||||
expression. */
|
||||
|
||||
static struct parser_state *pstate = NULL;
|
||||
|
||||
int yyparse (void);
|
||||
|
||||
static int yylex (void);
|
||||
|
@ -158,7 +163,8 @@ void yyerror (char *);
|
|||
|
||||
%{
|
||||
/* YYSTYPE gets defined by %union. */
|
||||
static int parse_number (const char *, int, int, YYSTYPE *);
|
||||
static int parse_number (struct parser_state *,
|
||||
const char *, int, int, YYSTYPE *);
|
||||
static int parse_go_float (struct gdbarch *gdbarch, const char *p, int len,
|
||||
DOUBLEST *d, struct type **t);
|
||||
%}
|
||||
|
@ -239,77 +245,77 @@ start : exp1
|
|||
;
|
||||
|
||||
type_exp: type
|
||||
{ write_exp_elt_opcode(OP_TYPE);
|
||||
write_exp_elt_type($1);
|
||||
write_exp_elt_opcode(OP_TYPE); }
|
||||
{ write_exp_elt_opcode (pstate, OP_TYPE);
|
||||
write_exp_elt_type (pstate, $1);
|
||||
write_exp_elt_opcode (pstate, OP_TYPE); }
|
||||
;
|
||||
|
||||
/* Expressions, including the comma operator. */
|
||||
exp1 : exp
|
||||
| exp1 ',' exp
|
||||
{ write_exp_elt_opcode (BINOP_COMMA); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_COMMA); }
|
||||
;
|
||||
|
||||
/* Expressions, not including the comma operator. */
|
||||
exp : '*' exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_IND); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_IND); }
|
||||
;
|
||||
|
||||
exp : '&' exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_ADDR); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_ADDR); }
|
||||
;
|
||||
|
||||
exp : '-' exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_NEG); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_NEG); }
|
||||
;
|
||||
|
||||
exp : '+' exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_PLUS); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_PLUS); }
|
||||
;
|
||||
|
||||
exp : '!' exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT); }
|
||||
;
|
||||
|
||||
exp : '^' exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_COMPLEMENT); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_COMPLEMENT); }
|
||||
;
|
||||
|
||||
exp : exp INCREMENT %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_POSTINCREMENT); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_POSTINCREMENT); }
|
||||
;
|
||||
|
||||
exp : exp DECREMENT %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_POSTDECREMENT); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_POSTDECREMENT); }
|
||||
;
|
||||
|
||||
/* foo->bar is not in Go. May want as a gdb extension. Later. */
|
||||
|
||||
exp : exp '.' name_not_typename
|
||||
{ write_exp_elt_opcode (STRUCTOP_STRUCT);
|
||||
write_exp_string ($3.stoken);
|
||||
write_exp_elt_opcode (STRUCTOP_STRUCT); }
|
||||
{ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
|
||||
write_exp_string (pstate, $3.stoken);
|
||||
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
|
||||
;
|
||||
|
||||
exp : exp '.' name_not_typename COMPLETE
|
||||
{ mark_struct_expression ();
|
||||
write_exp_elt_opcode (STRUCTOP_STRUCT);
|
||||
write_exp_string ($3.stoken);
|
||||
write_exp_elt_opcode (STRUCTOP_STRUCT); }
|
||||
{ mark_struct_expression (pstate);
|
||||
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
|
||||
write_exp_string (pstate, $3.stoken);
|
||||
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
|
||||
;
|
||||
|
||||
exp : exp '.' COMPLETE
|
||||
{ struct stoken s;
|
||||
mark_struct_expression ();
|
||||
write_exp_elt_opcode (STRUCTOP_STRUCT);
|
||||
mark_struct_expression (pstate);
|
||||
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
|
||||
s.ptr = "";
|
||||
s.length = 0;
|
||||
write_exp_string (s);
|
||||
write_exp_elt_opcode (STRUCTOP_STRUCT); }
|
||||
write_exp_string (pstate, s);
|
||||
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
|
||||
;
|
||||
|
||||
exp : exp '[' exp1 ']'
|
||||
{ write_exp_elt_opcode (BINOP_SUBSCRIPT); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT); }
|
||||
;
|
||||
|
||||
exp : exp '('
|
||||
|
@ -317,9 +323,10 @@ exp : exp '('
|
|||
being accumulated by an outer function call. */
|
||||
{ start_arglist (); }
|
||||
arglist ')' %prec LEFT_ARROW
|
||||
{ write_exp_elt_opcode (OP_FUNCALL);
|
||||
write_exp_elt_longcst ((LONGEST) end_arglist ());
|
||||
write_exp_elt_opcode (OP_FUNCALL); }
|
||||
{ write_exp_elt_opcode (pstate, OP_FUNCALL);
|
||||
write_exp_elt_longcst (pstate,
|
||||
(LONGEST) end_arglist ());
|
||||
write_exp_elt_opcode (pstate, OP_FUNCALL); }
|
||||
;
|
||||
|
||||
lcurly : '{'
|
||||
|
@ -342,15 +349,15 @@ rcurly : '}'
|
|||
;
|
||||
|
||||
exp : lcurly type rcurly exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_MEMVAL);
|
||||
write_exp_elt_type ($2);
|
||||
write_exp_elt_opcode (UNOP_MEMVAL); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_MEMVAL);
|
||||
write_exp_elt_type (pstate, $2);
|
||||
write_exp_elt_opcode (pstate, UNOP_MEMVAL); }
|
||||
;
|
||||
|
||||
exp : type '(' exp ')' %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_type ($1);
|
||||
write_exp_elt_opcode (UNOP_CAST); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_CAST);
|
||||
write_exp_elt_type (pstate, $1);
|
||||
write_exp_elt_opcode (pstate, UNOP_CAST); }
|
||||
;
|
||||
|
||||
exp : '(' exp1 ')'
|
||||
|
@ -360,100 +367,100 @@ exp : '(' exp1 ')'
|
|||
/* Binary operators in order of decreasing precedence. */
|
||||
|
||||
exp : exp '@' exp
|
||||
{ write_exp_elt_opcode (BINOP_REPEAT); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_REPEAT); }
|
||||
;
|
||||
|
||||
exp : exp '*' exp
|
||||
{ write_exp_elt_opcode (BINOP_MUL); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_MUL); }
|
||||
;
|
||||
|
||||
exp : exp '/' exp
|
||||
{ write_exp_elt_opcode (BINOP_DIV); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_DIV); }
|
||||
;
|
||||
|
||||
exp : exp '%' exp
|
||||
{ write_exp_elt_opcode (BINOP_REM); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_REM); }
|
||||
;
|
||||
|
||||
exp : exp '+' exp
|
||||
{ write_exp_elt_opcode (BINOP_ADD); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_ADD); }
|
||||
;
|
||||
|
||||
exp : exp '-' exp
|
||||
{ write_exp_elt_opcode (BINOP_SUB); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_SUB); }
|
||||
;
|
||||
|
||||
exp : exp LSH exp
|
||||
{ write_exp_elt_opcode (BINOP_LSH); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LSH); }
|
||||
;
|
||||
|
||||
exp : exp RSH exp
|
||||
{ write_exp_elt_opcode (BINOP_RSH); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_RSH); }
|
||||
;
|
||||
|
||||
exp : exp EQUAL exp
|
||||
{ write_exp_elt_opcode (BINOP_EQUAL); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_EQUAL); }
|
||||
;
|
||||
|
||||
exp : exp NOTEQUAL exp
|
||||
{ write_exp_elt_opcode (BINOP_NOTEQUAL); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_NOTEQUAL); }
|
||||
;
|
||||
|
||||
exp : exp LEQ exp
|
||||
{ write_exp_elt_opcode (BINOP_LEQ); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LEQ); }
|
||||
;
|
||||
|
||||
exp : exp GEQ exp
|
||||
{ write_exp_elt_opcode (BINOP_GEQ); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_GEQ); }
|
||||
;
|
||||
|
||||
exp : exp '<' exp
|
||||
{ write_exp_elt_opcode (BINOP_LESS); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LESS); }
|
||||
;
|
||||
|
||||
exp : exp '>' exp
|
||||
{ write_exp_elt_opcode (BINOP_GTR); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_GTR); }
|
||||
;
|
||||
|
||||
exp : exp '&' exp
|
||||
{ write_exp_elt_opcode (BINOP_BITWISE_AND); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_BITWISE_AND); }
|
||||
;
|
||||
|
||||
exp : exp '^' exp
|
||||
{ write_exp_elt_opcode (BINOP_BITWISE_XOR); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_BITWISE_XOR); }
|
||||
;
|
||||
|
||||
exp : exp '|' exp
|
||||
{ write_exp_elt_opcode (BINOP_BITWISE_IOR); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_BITWISE_IOR); }
|
||||
;
|
||||
|
||||
exp : exp ANDAND exp
|
||||
{ write_exp_elt_opcode (BINOP_LOGICAL_AND); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LOGICAL_AND); }
|
||||
;
|
||||
|
||||
exp : exp OROR exp
|
||||
{ write_exp_elt_opcode (BINOP_LOGICAL_OR); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LOGICAL_OR); }
|
||||
;
|
||||
|
||||
exp : exp '?' exp ':' exp %prec '?'
|
||||
{ write_exp_elt_opcode (TERNOP_COND); }
|
||||
{ write_exp_elt_opcode (pstate, TERNOP_COND); }
|
||||
;
|
||||
|
||||
exp : exp '=' exp
|
||||
{ write_exp_elt_opcode (BINOP_ASSIGN); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_ASSIGN); }
|
||||
;
|
||||
|
||||
exp : exp ASSIGN_MODIFY exp
|
||||
{ write_exp_elt_opcode (BINOP_ASSIGN_MODIFY);
|
||||
write_exp_elt_opcode ($2);
|
||||
write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY);
|
||||
write_exp_elt_opcode (pstate, $2);
|
||||
write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY); }
|
||||
;
|
||||
|
||||
exp : INT
|
||||
{ write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type ($1.type);
|
||||
write_exp_elt_longcst ((LONGEST)($1.val));
|
||||
write_exp_elt_opcode (OP_LONG); }
|
||||
{ write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_type (pstate, $1.type);
|
||||
write_exp_elt_longcst (pstate, (LONGEST)($1.val));
|
||||
write_exp_elt_opcode (pstate, OP_LONG); }
|
||||
;
|
||||
|
||||
exp : CHAR
|
||||
|
@ -461,28 +468,28 @@ exp : CHAR
|
|||
struct stoken_vector vec;
|
||||
vec.len = 1;
|
||||
vec.tokens = &$1;
|
||||
write_exp_string_vector ($1.type, &vec);
|
||||
write_exp_string_vector (pstate, $1.type, &vec);
|
||||
}
|
||||
;
|
||||
|
||||
exp : NAME_OR_INT
|
||||
{ YYSTYPE val;
|
||||
parse_number ($1.stoken.ptr, $1.stoken.length,
|
||||
0, &val);
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (val.typed_val_int.type);
|
||||
write_exp_elt_longcst ((LONGEST)
|
||||
parse_number (pstate, $1.stoken.ptr,
|
||||
$1.stoken.length, 0, &val);
|
||||
write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_type (pstate, val.typed_val_int.type);
|
||||
write_exp_elt_longcst (pstate, (LONGEST)
|
||||
val.typed_val_int.val);
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_opcode (pstate, OP_LONG);
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
exp : FLOAT
|
||||
{ write_exp_elt_opcode (OP_DOUBLE);
|
||||
write_exp_elt_type ($1.type);
|
||||
write_exp_elt_dblcst ($1.dval);
|
||||
write_exp_elt_opcode (OP_DOUBLE); }
|
||||
{ write_exp_elt_opcode (pstate, OP_DOUBLE);
|
||||
write_exp_elt_type (pstate, $1.type);
|
||||
write_exp_elt_dblcst (pstate, $1.dval);
|
||||
write_exp_elt_opcode (pstate, OP_DOUBLE); }
|
||||
;
|
||||
|
||||
exp : variable
|
||||
|
@ -490,26 +497,29 @@ exp : variable
|
|||
|
||||
exp : DOLLAR_VARIABLE
|
||||
{
|
||||
write_dollar_variable ($1);
|
||||
write_dollar_variable (pstate, $1);
|
||||
}
|
||||
;
|
||||
|
||||
exp : SIZEOF_KEYWORD '(' type ')' %prec UNARY
|
||||
{
|
||||
/* TODO(dje): Go objects in structs. */
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_opcode (pstate, OP_LONG);
|
||||
/* TODO(dje): What's the right type here? */
|
||||
write_exp_elt_type (parse_type->builtin_unsigned_int);
|
||||
write_exp_elt_type
|
||||
(pstate,
|
||||
parse_type (pstate)->builtin_unsigned_int);
|
||||
CHECK_TYPEDEF ($3);
|
||||
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_longcst (pstate,
|
||||
(LONGEST) TYPE_LENGTH ($3));
|
||||
write_exp_elt_opcode (pstate, OP_LONG);
|
||||
}
|
||||
;
|
||||
|
||||
exp : SIZEOF_KEYWORD '(' exp ')' %prec UNARY
|
||||
{
|
||||
/* TODO(dje): Go objects in structs. */
|
||||
write_exp_elt_opcode (UNOP_SIZEOF);
|
||||
write_exp_elt_opcode (pstate, UNOP_SIZEOF);
|
||||
}
|
||||
|
||||
string_exp:
|
||||
|
@ -552,7 +562,8 @@ exp : string_exp %prec ABOVE_COMMA
|
|||
{
|
||||
int i;
|
||||
|
||||
write_exp_string_vector (0 /*always utf8*/, &$1);
|
||||
write_exp_string_vector (pstate, 0 /*always utf8*/,
|
||||
&$1);
|
||||
for (i = 0; i < $1.len; ++i)
|
||||
free ($1.tokens[i].ptr);
|
||||
free ($1.tokens);
|
||||
|
@ -560,15 +571,15 @@ exp : string_exp %prec ABOVE_COMMA
|
|||
;
|
||||
|
||||
exp : TRUE_KEYWORD
|
||||
{ write_exp_elt_opcode (OP_BOOL);
|
||||
write_exp_elt_longcst ((LONGEST) $1);
|
||||
write_exp_elt_opcode (OP_BOOL); }
|
||||
{ write_exp_elt_opcode (pstate, OP_BOOL);
|
||||
write_exp_elt_longcst (pstate, (LONGEST) $1);
|
||||
write_exp_elt_opcode (pstate, OP_BOOL); }
|
||||
;
|
||||
|
||||
exp : FALSE_KEYWORD
|
||||
{ write_exp_elt_opcode (OP_BOOL);
|
||||
write_exp_elt_longcst ((LONGEST) $1);
|
||||
write_exp_elt_opcode (OP_BOOL); }
|
||||
{ write_exp_elt_opcode (pstate, OP_BOOL);
|
||||
write_exp_elt_longcst (pstate, (LONGEST) $1);
|
||||
write_exp_elt_opcode (pstate, OP_BOOL); }
|
||||
;
|
||||
|
||||
variable: name_not_typename ENTRY
|
||||
|
@ -581,9 +592,9 @@ variable: name_not_typename ENTRY
|
|||
"parameters, not for \"%s\""),
|
||||
copy_name ($1.stoken));
|
||||
|
||||
write_exp_elt_opcode (OP_VAR_ENTRY_VALUE);
|
||||
write_exp_elt_sym (sym);
|
||||
write_exp_elt_opcode (OP_VAR_ENTRY_VALUE);
|
||||
write_exp_elt_opcode (pstate, OP_VAR_ENTRY_VALUE);
|
||||
write_exp_elt_sym (pstate, sym);
|
||||
write_exp_elt_opcode (pstate, OP_VAR_ENTRY_VALUE);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -600,13 +611,13 @@ variable: name_not_typename
|
|||
innermost_block = block_found;
|
||||
}
|
||||
|
||||
write_exp_elt_opcode (OP_VAR_VALUE);
|
||||
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
|
||||
/* We want to use the selected frame, not
|
||||
another more inner frame which happens to
|
||||
be in the same block. */
|
||||
write_exp_elt_block (NULL);
|
||||
write_exp_elt_sym (sym);
|
||||
write_exp_elt_opcode (OP_VAR_VALUE);
|
||||
write_exp_elt_block (pstate, NULL);
|
||||
write_exp_elt_sym (pstate, sym);
|
||||
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
|
||||
}
|
||||
else if ($1.is_a_field_of_this)
|
||||
{
|
||||
|
@ -622,7 +633,7 @@ variable: name_not_typename
|
|||
msymbol =
|
||||
lookup_bound_minimal_symbol (arg);
|
||||
if (msymbol.minsym != NULL)
|
||||
write_exp_msymbol (msymbol);
|
||||
write_exp_msymbol (pstate, msymbol);
|
||||
else if (!have_full_symbols ()
|
||||
&& !have_partial_symbols ())
|
||||
error (_("No symbol table is loaded. "
|
||||
|
@ -652,7 +663,7 @@ type /* Implements (approximately): [*] type-specifier */
|
|||
expression_context_block); }
|
||||
*/
|
||||
| BYTE_KEYWORD
|
||||
{ $$ = builtin_go_type (parse_gdbarch)
|
||||
{ $$ = builtin_go_type (parse_gdbarch (pstate))
|
||||
->builtin_uint8; }
|
||||
;
|
||||
|
||||
|
@ -704,7 +715,8 @@ parse_go_float (struct gdbarch *gdbarch, const char *p, int len,
|
|||
as our YYSTYPE is different than c-exp.y's */
|
||||
|
||||
static int
|
||||
parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
|
||||
parse_number (struct parser_state *par_state,
|
||||
const char *p, int len, int parsed_float, YYSTYPE *putithere)
|
||||
{
|
||||
/* FIXME: Shouldn't these be unsigned? We don't deal with negative values
|
||||
here, and we do kind of silly things like cast to unsigned. */
|
||||
|
@ -729,7 +741,7 @@ parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
|
|||
|
||||
if (parsed_float)
|
||||
{
|
||||
if (! parse_go_float (parse_gdbarch, p, len,
|
||||
if (! parse_go_float (parse_gdbarch (par_state), p, len,
|
||||
&putithere->typed_val_float.dval,
|
||||
&putithere->typed_val_float.type))
|
||||
return ERROR;
|
||||
|
@ -845,9 +857,10 @@ parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
|
|||
|
||||
un = (ULONGEST)n >> 2;
|
||||
if (long_p == 0
|
||||
&& (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
|
||||
&& (un >> (gdbarch_int_bit (parse_gdbarch (par_state)) - 2)) == 0)
|
||||
{
|
||||
high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
|
||||
high_bit
|
||||
= ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch (par_state)) - 1);
|
||||
|
||||
/* A large decimal (not hex or octal) constant (between INT_MAX
|
||||
and UINT_MAX) is a long or unsigned long, according to ANSI,
|
||||
|
@ -855,28 +868,29 @@ parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
|
|||
int. This probably should be fixed. GCC gives a warning on
|
||||
such constants. */
|
||||
|
||||
unsigned_type = parse_type->builtin_unsigned_int;
|
||||
signed_type = parse_type->builtin_int;
|
||||
unsigned_type = parse_type (par_state)->builtin_unsigned_int;
|
||||
signed_type = parse_type (par_state)->builtin_int;
|
||||
}
|
||||
else if (long_p <= 1
|
||||
&& (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
|
||||
&& (un >> (gdbarch_long_bit (parse_gdbarch (par_state)) - 2)) == 0)
|
||||
{
|
||||
high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
|
||||
unsigned_type = parse_type->builtin_unsigned_long;
|
||||
signed_type = parse_type->builtin_long;
|
||||
high_bit
|
||||
= ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch (par_state)) - 1);
|
||||
unsigned_type = parse_type (par_state)->builtin_unsigned_long;
|
||||
signed_type = parse_type (par_state)->builtin_long;
|
||||
}
|
||||
else
|
||||
{
|
||||
int shift;
|
||||
if (sizeof (ULONGEST) * HOST_CHAR_BIT
|
||||
< gdbarch_long_long_bit (parse_gdbarch))
|
||||
< gdbarch_long_long_bit (parse_gdbarch (par_state)))
|
||||
/* A long long does not fit in a LONGEST. */
|
||||
shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
|
||||
else
|
||||
shift = (gdbarch_long_long_bit (parse_gdbarch) - 1);
|
||||
shift = (gdbarch_long_long_bit (parse_gdbarch (par_state)) - 1);
|
||||
high_bit = (ULONGEST) 1 << shift;
|
||||
unsigned_type = parse_type->builtin_unsigned_long_long;
|
||||
signed_type = parse_type->builtin_long_long;
|
||||
unsigned_type = parse_type (par_state)->builtin_unsigned_long_long;
|
||||
signed_type = parse_type (par_state)->builtin_long_long;
|
||||
}
|
||||
|
||||
putithere->typed_val_int.val = n;
|
||||
|
@ -1044,7 +1058,7 @@ static int last_was_structop;
|
|||
/* Read one token, getting characters through lexptr. */
|
||||
|
||||
static int
|
||||
lex_one_token (void)
|
||||
lex_one_token (struct parser_state *par_state)
|
||||
{
|
||||
int c;
|
||||
int namelen;
|
||||
|
@ -1175,7 +1189,8 @@ lex_one_token (void)
|
|||
&& (*p < 'A' || *p > 'Z')))
|
||||
break;
|
||||
}
|
||||
toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
|
||||
toktype = parse_number (par_state, tokstart, p - tokstart,
|
||||
got_dot|got_e, &yylval);
|
||||
if (toktype == ERROR)
|
||||
{
|
||||
char *err_copy = (char *) alloca (p - tokstart + 1);
|
||||
|
@ -1431,7 +1446,7 @@ classify_packaged_name (const struct block *block)
|
|||
The result is one of NAME, NAME_OR_INT, or TYPENAME. */
|
||||
|
||||
static int
|
||||
classify_name (const struct block *block)
|
||||
classify_name (struct parser_state *par_state, const struct block *block)
|
||||
{
|
||||
struct type *type;
|
||||
struct symbol *sym;
|
||||
|
@ -1441,8 +1456,9 @@ classify_name (const struct block *block)
|
|||
copy = copy_name (yylval.sval);
|
||||
|
||||
/* Try primitive types first so they win over bad/weird debug info. */
|
||||
type = language_lookup_primitive_type_by_name (parse_language,
|
||||
parse_gdbarch, copy);
|
||||
type = language_lookup_primitive_type_by_name (parse_language (par_state),
|
||||
parse_gdbarch (par_state),
|
||||
copy);
|
||||
if (type != NULL)
|
||||
{
|
||||
/* NOTE: We take advantage of the fact that yylval coming in was a
|
||||
|
@ -1498,7 +1514,8 @@ classify_name (const struct block *block)
|
|||
|| (copy[0] >= 'A' && copy[0] < 'A' + input_radix - 10))
|
||||
{
|
||||
YYSTYPE newlval; /* Its value is ignored. */
|
||||
int hextype = parse_number (copy, yylval.sval.length, 0, &newlval);
|
||||
int hextype = parse_number (par_state, copy, yylval.sval.length,
|
||||
0, &newlval);
|
||||
if (hextype == INT)
|
||||
{
|
||||
yylval.ssym.sym = NULL;
|
||||
|
@ -1531,7 +1548,7 @@ yylex (void)
|
|||
}
|
||||
popping = 0;
|
||||
|
||||
current.token = lex_one_token ();
|
||||
current.token = lex_one_token (pstate);
|
||||
|
||||
/* TODO: Need a way to force specifying name1 as a package.
|
||||
.name1.name2 ? */
|
||||
|
@ -1542,14 +1559,14 @@ yylex (void)
|
|||
/* See if we have "name1 . name2". */
|
||||
|
||||
current.value = yylval;
|
||||
next.token = lex_one_token ();
|
||||
next.token = lex_one_token (pstate);
|
||||
next.value = yylval;
|
||||
|
||||
if (next.token == '.')
|
||||
{
|
||||
token_and_value name2;
|
||||
|
||||
name2.token = lex_one_token ();
|
||||
name2.token = lex_one_token (pstate);
|
||||
name2.value = yylval;
|
||||
|
||||
if (name2.token == NAME)
|
||||
|
@ -1588,16 +1605,23 @@ yylex (void)
|
|||
|
||||
popping = 1;
|
||||
yylval = current.value;
|
||||
return classify_name (expression_context_block);
|
||||
return classify_name (pstate, expression_context_block);
|
||||
}
|
||||
|
||||
int
|
||||
go_parse (void)
|
||||
go_parse (struct parser_state *par_state)
|
||||
{
|
||||
int result;
|
||||
struct cleanup *back_to = make_cleanup (null_cleanup, NULL);
|
||||
struct cleanup *back_to;
|
||||
|
||||
/* Setting up the parser state. */
|
||||
gdb_assert (par_state != NULL);
|
||||
pstate = par_state;
|
||||
|
||||
back_to = make_cleanup (null_cleanup, NULL);
|
||||
|
||||
make_cleanup_restore_integer (&yydebug);
|
||||
make_cleanup_clear_parser_state (&pstate);
|
||||
yydebug = parser_debug;
|
||||
|
||||
/* Initialize some state used by the lexer. */
|
||||
|
|
|
@ -26,6 +26,8 @@ struct type_print_options;
|
|||
#include "symtab.h"
|
||||
#include "value.h"
|
||||
|
||||
struct parser_state;
|
||||
|
||||
struct builtin_go_type
|
||||
{
|
||||
struct type *builtin_void;
|
||||
|
@ -56,7 +58,7 @@ enum go_type
|
|||
|
||||
/* Defined in go-exp.y. */
|
||||
|
||||
extern int go_parse (void);
|
||||
extern int go_parse (struct parser_state *);
|
||||
|
||||
extern void go_error (char *);
|
||||
|
||||
|
|
|
@ -3766,33 +3766,36 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
|
|||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
|
||||
write_exp_elt_longcst (displacements[i]);
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
||||
write_exp_elt_type
|
||||
(&p->pstate, builtin_type (gdbarch)->builtin_long);
|
||||
write_exp_elt_longcst (&p->pstate, displacements[i]);
|
||||
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
||||
if (got_minus[i])
|
||||
write_exp_elt_opcode (UNOP_NEG);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_NEG);
|
||||
}
|
||||
|
||||
write_exp_elt_opcode (OP_REGISTER);
|
||||
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
||||
str.ptr = regname;
|
||||
str.length = len;
|
||||
write_exp_string (str);
|
||||
write_exp_elt_opcode (OP_REGISTER);
|
||||
write_exp_string (&p->pstate, str);
|
||||
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
||||
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_type (builtin_type (gdbarch)->builtin_data_ptr);
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_CAST);
|
||||
write_exp_elt_type (&p->pstate,
|
||||
builtin_type (gdbarch)->builtin_data_ptr);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_CAST);
|
||||
|
||||
write_exp_elt_opcode (BINOP_ADD);
|
||||
write_exp_elt_opcode (BINOP_ADD);
|
||||
write_exp_elt_opcode (BINOP_ADD);
|
||||
write_exp_elt_opcode (&p->pstate, BINOP_ADD);
|
||||
write_exp_elt_opcode (&p->pstate, BINOP_ADD);
|
||||
write_exp_elt_opcode (&p->pstate, BINOP_ADD);
|
||||
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_type (lookup_pointer_type (p->arg_type));
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_CAST);
|
||||
write_exp_elt_type (&p->pstate,
|
||||
lookup_pointer_type (p->arg_type));
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_CAST);
|
||||
|
||||
write_exp_elt_opcode (UNOP_IND);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_IND);
|
||||
|
||||
p->arg = s;
|
||||
|
||||
|
@ -3912,47 +3915,50 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
|
|||
|
||||
if (offset)
|
||||
{
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
|
||||
write_exp_elt_longcst (offset);
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
||||
write_exp_elt_type (&p->pstate,
|
||||
builtin_type (gdbarch)->builtin_long);
|
||||
write_exp_elt_longcst (&p->pstate, offset);
|
||||
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
||||
if (offset_minus)
|
||||
write_exp_elt_opcode (UNOP_NEG);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_NEG);
|
||||
}
|
||||
|
||||
write_exp_elt_opcode (OP_REGISTER);
|
||||
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
||||
base_token.ptr = base;
|
||||
base_token.length = len_base;
|
||||
write_exp_string (base_token);
|
||||
write_exp_elt_opcode (OP_REGISTER);
|
||||
write_exp_string (&p->pstate, base_token);
|
||||
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
||||
|
||||
if (offset)
|
||||
write_exp_elt_opcode (BINOP_ADD);
|
||||
write_exp_elt_opcode (&p->pstate, BINOP_ADD);
|
||||
|
||||
write_exp_elt_opcode (OP_REGISTER);
|
||||
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
||||
index_token.ptr = index;
|
||||
index_token.length = len_index;
|
||||
write_exp_string (index_token);
|
||||
write_exp_elt_opcode (OP_REGISTER);
|
||||
write_exp_string (&p->pstate, index_token);
|
||||
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
||||
|
||||
if (size)
|
||||
{
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
|
||||
write_exp_elt_longcst (size);
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
||||
write_exp_elt_type (&p->pstate,
|
||||
builtin_type (gdbarch)->builtin_long);
|
||||
write_exp_elt_longcst (&p->pstate, size);
|
||||
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
||||
if (size_minus)
|
||||
write_exp_elt_opcode (UNOP_NEG);
|
||||
write_exp_elt_opcode (BINOP_MUL);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_NEG);
|
||||
write_exp_elt_opcode (&p->pstate, BINOP_MUL);
|
||||
}
|
||||
|
||||
write_exp_elt_opcode (BINOP_ADD);
|
||||
write_exp_elt_opcode (&p->pstate, BINOP_ADD);
|
||||
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_type (lookup_pointer_type (p->arg_type));
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_CAST);
|
||||
write_exp_elt_type (&p->pstate,
|
||||
lookup_pointer_type (p->arg_type));
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_CAST);
|
||||
|
||||
write_exp_elt_opcode (UNOP_IND);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_IND);
|
||||
|
||||
p->arg = s;
|
||||
|
||||
|
|
368
gdb/jv-exp.y
368
gdb/jv-exp.y
|
@ -49,8 +49,8 @@
|
|||
#include "block.h"
|
||||
#include "completer.h"
|
||||
|
||||
#define parse_type builtin_type (parse_gdbarch)
|
||||
#define parse_java_type builtin_java_type (parse_gdbarch)
|
||||
#define parse_type(ps) builtin_type (parse_gdbarch (ps))
|
||||
#define parse_java_type(ps) builtin_java_type (parse_gdbarch (ps))
|
||||
|
||||
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
|
||||
as well as gratuitiously global symbol names, so we can have multiple
|
||||
|
@ -60,7 +60,7 @@
|
|||
generators need to be fixed instead of adding those names to this list. */
|
||||
|
||||
#define yymaxdepth java_maxdepth
|
||||
#define yyparse java_parse
|
||||
#define yyparse java_parse_internal
|
||||
#define yylex java_lex
|
||||
#define yyerror java_error
|
||||
#define yylval java_lval
|
||||
|
@ -112,6 +112,11 @@
|
|||
|
||||
#define YYFPRINTF parser_fprintf
|
||||
|
||||
/* The state of the parser, used internally when we are parsing the
|
||||
expression. */
|
||||
|
||||
static struct parser_state *pstate = NULL;
|
||||
|
||||
int yyparse (void);
|
||||
|
||||
static int yylex (void);
|
||||
|
@ -119,11 +124,11 @@ static int yylex (void);
|
|||
void yyerror (char *);
|
||||
|
||||
static struct type *java_type_from_name (struct stoken);
|
||||
static void push_expression_name (struct stoken);
|
||||
static void push_fieldnames (struct stoken);
|
||||
static void push_expression_name (struct parser_state *, struct stoken);
|
||||
static void push_fieldnames (struct parser_state *, struct stoken);
|
||||
|
||||
static struct expression *copy_exp (struct expression *, int);
|
||||
static void insert_exp (int, struct expression *);
|
||||
static void insert_exp (struct parser_state *, int, struct expression *);
|
||||
|
||||
%}
|
||||
|
||||
|
@ -155,7 +160,8 @@ static void insert_exp (int, struct expression *);
|
|||
|
||||
%{
|
||||
/* YYSTYPE gets defined by %union */
|
||||
static int parse_number (const char *, int, int, YYSTYPE *);
|
||||
static int parse_number (struct parser_state *, const char *, int,
|
||||
int, YYSTYPE *);
|
||||
%}
|
||||
|
||||
%type <lval> rcurly Dims Dims_opt
|
||||
|
@ -215,9 +221,9 @@ start : exp1
|
|||
|
||||
type_exp: PrimitiveOrArrayType
|
||||
{
|
||||
write_exp_elt_opcode(OP_TYPE);
|
||||
write_exp_elt_type($1);
|
||||
write_exp_elt_opcode(OP_TYPE);
|
||||
write_exp_elt_opcode (pstate, OP_TYPE);
|
||||
write_exp_elt_type (pstate, $1);
|
||||
write_exp_elt_opcode (pstate, OP_TYPE);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -229,36 +235,38 @@ PrimitiveOrArrayType:
|
|||
StringLiteral:
|
||||
STRING_LITERAL
|
||||
{
|
||||
write_exp_elt_opcode (OP_STRING);
|
||||
write_exp_string ($1);
|
||||
write_exp_elt_opcode (OP_STRING);
|
||||
write_exp_elt_opcode (pstate, OP_STRING);
|
||||
write_exp_string (pstate, $1);
|
||||
write_exp_elt_opcode (pstate, OP_STRING);
|
||||
}
|
||||
;
|
||||
|
||||
Literal:
|
||||
INTEGER_LITERAL
|
||||
{ write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type ($1.type);
|
||||
write_exp_elt_longcst ((LONGEST)($1.val));
|
||||
write_exp_elt_opcode (OP_LONG); }
|
||||
{ write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_type (pstate, $1.type);
|
||||
write_exp_elt_longcst (pstate, (LONGEST)($1.val));
|
||||
write_exp_elt_opcode (pstate, OP_LONG); }
|
||||
| NAME_OR_INT
|
||||
{ YYSTYPE val;
|
||||
parse_number ($1.ptr, $1.length, 0, &val);
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (val.typed_val_int.type);
|
||||
write_exp_elt_longcst ((LONGEST)val.typed_val_int.val);
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
parse_number (pstate, $1.ptr, $1.length, 0, &val);
|
||||
write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_type (pstate, val.typed_val_int.type);
|
||||
write_exp_elt_longcst (pstate,
|
||||
(LONGEST) val.typed_val_int.val);
|
||||
write_exp_elt_opcode (pstate, OP_LONG);
|
||||
}
|
||||
| FLOATING_POINT_LITERAL
|
||||
{ write_exp_elt_opcode (OP_DOUBLE);
|
||||
write_exp_elt_type ($1.type);
|
||||
write_exp_elt_dblcst ($1.dval);
|
||||
write_exp_elt_opcode (OP_DOUBLE); }
|
||||
{ write_exp_elt_opcode (pstate, OP_DOUBLE);
|
||||
write_exp_elt_type (pstate, $1.type);
|
||||
write_exp_elt_dblcst (pstate, $1.dval);
|
||||
write_exp_elt_opcode (pstate, OP_DOUBLE); }
|
||||
| BOOLEAN_LITERAL
|
||||
{ write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (parse_java_type->builtin_boolean);
|
||||
write_exp_elt_longcst ((LONGEST)$1);
|
||||
write_exp_elt_opcode (OP_LONG); }
|
||||
{ write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_type (pstate,
|
||||
parse_java_type (pstate)->builtin_boolean);
|
||||
write_exp_elt_longcst (pstate, (LONGEST)$1);
|
||||
write_exp_elt_opcode (pstate, OP_LONG); }
|
||||
| StringLiteral
|
||||
;
|
||||
|
||||
|
@ -272,7 +280,7 @@ Type:
|
|||
PrimitiveType:
|
||||
NumericType
|
||||
| BOOLEAN
|
||||
{ $$ = parse_java_type->builtin_boolean; }
|
||||
{ $$ = parse_java_type (pstate)->builtin_boolean; }
|
||||
;
|
||||
|
||||
NumericType:
|
||||
|
@ -282,22 +290,22 @@ NumericType:
|
|||
|
||||
IntegralType:
|
||||
BYTE
|
||||
{ $$ = parse_java_type->builtin_byte; }
|
||||
{ $$ = parse_java_type (pstate)->builtin_byte; }
|
||||
| SHORT
|
||||
{ $$ = parse_java_type->builtin_short; }
|
||||
{ $$ = parse_java_type (pstate)->builtin_short; }
|
||||
| INT
|
||||
{ $$ = parse_java_type->builtin_int; }
|
||||
{ $$ = parse_java_type (pstate)->builtin_int; }
|
||||
| LONG
|
||||
{ $$ = parse_java_type->builtin_long; }
|
||||
{ $$ = parse_java_type (pstate)->builtin_long; }
|
||||
| CHAR
|
||||
{ $$ = parse_java_type->builtin_char; }
|
||||
{ $$ = parse_java_type (pstate)->builtin_char; }
|
||||
;
|
||||
|
||||
FloatingPointType:
|
||||
FLOAT
|
||||
{ $$ = parse_java_type->builtin_float; }
|
||||
{ $$ = parse_java_type (pstate)->builtin_float; }
|
||||
| DOUBLE
|
||||
{ $$ = parse_java_type->builtin_double; }
|
||||
{ $$ = parse_java_type (pstate)->builtin_double; }
|
||||
;
|
||||
|
||||
/* UNUSED:
|
||||
|
@ -367,7 +375,7 @@ type_exp: type
|
|||
/* Expressions, including the comma operator. */
|
||||
exp1 : Expression
|
||||
| exp1 ',' Expression
|
||||
{ write_exp_elt_opcode (BINOP_COMMA); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_COMMA); }
|
||||
;
|
||||
|
||||
Primary:
|
||||
|
@ -383,10 +391,10 @@ PrimaryNoNewArray:
|
|||
| MethodInvocation
|
||||
| ArrayAccess
|
||||
| lcurly ArgumentList rcurly
|
||||
{ write_exp_elt_opcode (OP_ARRAY);
|
||||
write_exp_elt_longcst ((LONGEST) 0);
|
||||
write_exp_elt_longcst ((LONGEST) $3);
|
||||
write_exp_elt_opcode (OP_ARRAY); }
|
||||
{ write_exp_elt_opcode (pstate, OP_ARRAY);
|
||||
write_exp_elt_longcst (pstate, (LONGEST) 0);
|
||||
write_exp_elt_longcst (pstate, (LONGEST) $3);
|
||||
write_exp_elt_opcode (pstate, OP_ARRAY); }
|
||||
;
|
||||
|
||||
lcurly:
|
||||
|
@ -451,24 +459,24 @@ Dims_opt:
|
|||
|
||||
FieldAccess:
|
||||
Primary '.' SimpleName
|
||||
{ push_fieldnames ($3); }
|
||||
{ push_fieldnames (pstate, $3); }
|
||||
| VARIABLE '.' SimpleName
|
||||
{ push_fieldnames ($3); }
|
||||
{ push_fieldnames (pstate, $3); }
|
||||
/*| SUPER '.' SimpleName { FIXME } */
|
||||
;
|
||||
|
||||
FuncStart:
|
||||
Name '('
|
||||
{ push_expression_name ($1); }
|
||||
{ push_expression_name (pstate, $1); }
|
||||
;
|
||||
|
||||
MethodInvocation:
|
||||
FuncStart
|
||||
{ start_arglist(); }
|
||||
ArgumentList_opt ')'
|
||||
{ write_exp_elt_opcode (OP_FUNCALL);
|
||||
write_exp_elt_longcst ((LONGEST) end_arglist ());
|
||||
write_exp_elt_opcode (OP_FUNCALL); }
|
||||
{ write_exp_elt_opcode (pstate, OP_FUNCALL);
|
||||
write_exp_elt_longcst (pstate, (LONGEST) end_arglist ());
|
||||
write_exp_elt_opcode (pstate, OP_FUNCALL); }
|
||||
| Primary '.' SimpleName '(' ArgumentList_opt ')'
|
||||
{ error (_("Form of method invocation not implemented")); }
|
||||
| SUPER '.' SimpleName '(' ArgumentList_opt ')'
|
||||
|
@ -485,24 +493,27 @@ ArrayAccess:
|
|||
for our parsing kludges. */
|
||||
struct expression *name_expr;
|
||||
|
||||
push_expression_name ($1);
|
||||
name_expr = copy_exp (expout, expout_ptr);
|
||||
expout_ptr -= name_expr->nelts;
|
||||
insert_exp (expout_ptr-length_of_subexp (expout, expout_ptr),
|
||||
push_expression_name (pstate, $1);
|
||||
name_expr = copy_exp (pstate->expout, pstate->expout_ptr);
|
||||
pstate->expout_ptr -= name_expr->nelts;
|
||||
insert_exp (pstate,
|
||||
pstate->expout_ptr
|
||||
- length_of_subexp (pstate->expout,
|
||||
pstate->expout_ptr),
|
||||
name_expr);
|
||||
free (name_expr);
|
||||
write_exp_elt_opcode (BINOP_SUBSCRIPT);
|
||||
write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT);
|
||||
}
|
||||
| VARIABLE '[' Expression ']'
|
||||
{ write_exp_elt_opcode (BINOP_SUBSCRIPT); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT); }
|
||||
| PrimaryNoNewArray '[' Expression ']'
|
||||
{ write_exp_elt_opcode (BINOP_SUBSCRIPT); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT); }
|
||||
;
|
||||
|
||||
PostfixExpression:
|
||||
Primary
|
||||
| Name
|
||||
{ push_expression_name ($1); }
|
||||
{ push_expression_name (pstate, $1); }
|
||||
| VARIABLE
|
||||
/* Already written by write_dollar_variable. */
|
||||
| PostIncrementExpression
|
||||
|
@ -511,12 +522,12 @@ PostfixExpression:
|
|||
|
||||
PostIncrementExpression:
|
||||
PostfixExpression INCREMENT
|
||||
{ write_exp_elt_opcode (UNOP_POSTINCREMENT); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_POSTINCREMENT); }
|
||||
;
|
||||
|
||||
PostDecrementExpression:
|
||||
PostfixExpression DECREMENT
|
||||
{ write_exp_elt_opcode (UNOP_POSTDECREMENT); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_POSTDECREMENT); }
|
||||
;
|
||||
|
||||
UnaryExpression:
|
||||
|
@ -524,144 +535,151 @@ UnaryExpression:
|
|||
| PreDecrementExpression
|
||||
| '+' UnaryExpression
|
||||
| '-' UnaryExpression
|
||||
{ write_exp_elt_opcode (UNOP_NEG); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_NEG); }
|
||||
| '*' UnaryExpression
|
||||
{ write_exp_elt_opcode (UNOP_IND); } /*FIXME not in Java */
|
||||
{ write_exp_elt_opcode (pstate,
|
||||
UNOP_IND); } /*FIXME not in Java */
|
||||
| UnaryExpressionNotPlusMinus
|
||||
;
|
||||
|
||||
PreIncrementExpression:
|
||||
INCREMENT UnaryExpression
|
||||
{ write_exp_elt_opcode (UNOP_PREINCREMENT); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_PREINCREMENT); }
|
||||
;
|
||||
|
||||
PreDecrementExpression:
|
||||
DECREMENT UnaryExpression
|
||||
{ write_exp_elt_opcode (UNOP_PREDECREMENT); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_PREDECREMENT); }
|
||||
;
|
||||
|
||||
UnaryExpressionNotPlusMinus:
|
||||
PostfixExpression
|
||||
| '~' UnaryExpression
|
||||
{ write_exp_elt_opcode (UNOP_COMPLEMENT); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_COMPLEMENT); }
|
||||
| '!' UnaryExpression
|
||||
{ write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT); }
|
||||
| CastExpression
|
||||
;
|
||||
|
||||
CastExpression:
|
||||
'(' PrimitiveType Dims_opt ')' UnaryExpression
|
||||
{ write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_type (java_array_type ($2, $3));
|
||||
write_exp_elt_opcode (UNOP_CAST); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_CAST);
|
||||
write_exp_elt_type (pstate, java_array_type ($2, $3));
|
||||
write_exp_elt_opcode (pstate, UNOP_CAST); }
|
||||
| '(' Expression ')' UnaryExpressionNotPlusMinus
|
||||
{
|
||||
int last_exp_size = length_of_subexp(expout, expout_ptr);
|
||||
int last_exp_size = length_of_subexp (pstate->expout,
|
||||
pstate->expout_ptr);
|
||||
struct type *type;
|
||||
int i;
|
||||
int base = expout_ptr - last_exp_size - 3;
|
||||
if (base < 0 || expout->elts[base+2].opcode != OP_TYPE)
|
||||
int base = pstate->expout_ptr - last_exp_size - 3;
|
||||
|
||||
if (base < 0
|
||||
|| pstate->expout->elts[base+2].opcode != OP_TYPE)
|
||||
error (_("Invalid cast expression"));
|
||||
type = expout->elts[base+1].type;
|
||||
type = pstate->expout->elts[base+1].type;
|
||||
/* Remove the 'Expression' and slide the
|
||||
UnaryExpressionNotPlusMinus down to replace it. */
|
||||
for (i = 0; i < last_exp_size; i++)
|
||||
expout->elts[base + i] = expout->elts[base + i + 3];
|
||||
expout_ptr -= 3;
|
||||
pstate->expout->elts[base + i]
|
||||
= pstate->expout->elts[base + i + 3];
|
||||
pstate->expout_ptr -= 3;
|
||||
if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
|
||||
type = lookup_pointer_type (type);
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_type (type);
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_opcode (pstate, UNOP_CAST);
|
||||
write_exp_elt_type (pstate, type);
|
||||
write_exp_elt_opcode (pstate, UNOP_CAST);
|
||||
}
|
||||
| '(' Name Dims ')' UnaryExpressionNotPlusMinus
|
||||
{ write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_type (java_array_type (java_type_from_name ($2), $3));
|
||||
write_exp_elt_opcode (UNOP_CAST); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_CAST);
|
||||
write_exp_elt_type (pstate,
|
||||
java_array_type (java_type_from_name
|
||||
($2), $3));
|
||||
write_exp_elt_opcode (pstate, UNOP_CAST); }
|
||||
;
|
||||
|
||||
|
||||
MultiplicativeExpression:
|
||||
UnaryExpression
|
||||
| MultiplicativeExpression '*' UnaryExpression
|
||||
{ write_exp_elt_opcode (BINOP_MUL); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_MUL); }
|
||||
| MultiplicativeExpression '/' UnaryExpression
|
||||
{ write_exp_elt_opcode (BINOP_DIV); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_DIV); }
|
||||
| MultiplicativeExpression '%' UnaryExpression
|
||||
{ write_exp_elt_opcode (BINOP_REM); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_REM); }
|
||||
;
|
||||
|
||||
AdditiveExpression:
|
||||
MultiplicativeExpression
|
||||
| AdditiveExpression '+' MultiplicativeExpression
|
||||
{ write_exp_elt_opcode (BINOP_ADD); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_ADD); }
|
||||
| AdditiveExpression '-' MultiplicativeExpression
|
||||
{ write_exp_elt_opcode (BINOP_SUB); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_SUB); }
|
||||
;
|
||||
|
||||
ShiftExpression:
|
||||
AdditiveExpression
|
||||
| ShiftExpression LSH AdditiveExpression
|
||||
{ write_exp_elt_opcode (BINOP_LSH); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LSH); }
|
||||
| ShiftExpression RSH AdditiveExpression
|
||||
{ write_exp_elt_opcode (BINOP_RSH); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_RSH); }
|
||||
/* | ShiftExpression >>> AdditiveExpression { FIXME } */
|
||||
;
|
||||
|
||||
RelationalExpression:
|
||||
ShiftExpression
|
||||
| RelationalExpression '<' ShiftExpression
|
||||
{ write_exp_elt_opcode (BINOP_LESS); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LESS); }
|
||||
| RelationalExpression '>' ShiftExpression
|
||||
{ write_exp_elt_opcode (BINOP_GTR); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_GTR); }
|
||||
| RelationalExpression LEQ ShiftExpression
|
||||
{ write_exp_elt_opcode (BINOP_LEQ); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LEQ); }
|
||||
| RelationalExpression GEQ ShiftExpression
|
||||
{ write_exp_elt_opcode (BINOP_GEQ); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_GEQ); }
|
||||
/* | RelationalExpresion INSTANCEOF ReferenceType { FIXME } */
|
||||
;
|
||||
|
||||
EqualityExpression:
|
||||
RelationalExpression
|
||||
| EqualityExpression EQUAL RelationalExpression
|
||||
{ write_exp_elt_opcode (BINOP_EQUAL); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_EQUAL); }
|
||||
| EqualityExpression NOTEQUAL RelationalExpression
|
||||
{ write_exp_elt_opcode (BINOP_NOTEQUAL); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_NOTEQUAL); }
|
||||
;
|
||||
|
||||
AndExpression:
|
||||
EqualityExpression
|
||||
| AndExpression '&' EqualityExpression
|
||||
{ write_exp_elt_opcode (BINOP_BITWISE_AND); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_BITWISE_AND); }
|
||||
;
|
||||
|
||||
ExclusiveOrExpression:
|
||||
AndExpression
|
||||
| ExclusiveOrExpression '^' AndExpression
|
||||
{ write_exp_elt_opcode (BINOP_BITWISE_XOR); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_BITWISE_XOR); }
|
||||
;
|
||||
InclusiveOrExpression:
|
||||
ExclusiveOrExpression
|
||||
| InclusiveOrExpression '|' ExclusiveOrExpression
|
||||
{ write_exp_elt_opcode (BINOP_BITWISE_IOR); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_BITWISE_IOR); }
|
||||
;
|
||||
|
||||
ConditionalAndExpression:
|
||||
InclusiveOrExpression
|
||||
| ConditionalAndExpression ANDAND InclusiveOrExpression
|
||||
{ write_exp_elt_opcode (BINOP_LOGICAL_AND); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LOGICAL_AND); }
|
||||
;
|
||||
|
||||
ConditionalOrExpression:
|
||||
ConditionalAndExpression
|
||||
| ConditionalOrExpression OROR ConditionalAndExpression
|
||||
{ write_exp_elt_opcode (BINOP_LOGICAL_OR); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LOGICAL_OR); }
|
||||
;
|
||||
|
||||
ConditionalExpression:
|
||||
ConditionalOrExpression
|
||||
| ConditionalOrExpression '?' Expression ':' ConditionalExpression
|
||||
{ write_exp_elt_opcode (TERNOP_COND); }
|
||||
{ write_exp_elt_opcode (pstate, TERNOP_COND); }
|
||||
;
|
||||
|
||||
AssignmentExpression:
|
||||
|
@ -671,16 +689,16 @@ AssignmentExpression:
|
|||
|
||||
Assignment:
|
||||
LeftHandSide '=' ConditionalExpression
|
||||
{ write_exp_elt_opcode (BINOP_ASSIGN); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_ASSIGN); }
|
||||
| LeftHandSide ASSIGN_MODIFY ConditionalExpression
|
||||
{ write_exp_elt_opcode (BINOP_ASSIGN_MODIFY);
|
||||
write_exp_elt_opcode ($2);
|
||||
write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY);
|
||||
write_exp_elt_opcode (pstate, $2);
|
||||
write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY); }
|
||||
;
|
||||
|
||||
LeftHandSide:
|
||||
ForcedName
|
||||
{ push_expression_name ($1); }
|
||||
{ push_expression_name (pstate, $1); }
|
||||
| VARIABLE
|
||||
/* Already written by write_dollar_variable. */
|
||||
| FieldAccess
|
||||
|
@ -700,7 +718,8 @@ Expression:
|
|||
/*** Needs some error checking for the float case ***/
|
||||
|
||||
static int
|
||||
parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
|
||||
parse_number (struct parser_state *par_state,
|
||||
const char *p, int len, int parsed_float, YYSTYPE *putithere)
|
||||
{
|
||||
ULONGEST n = 0;
|
||||
ULONGEST limit, limit_div_base;
|
||||
|
@ -721,16 +740,17 @@ parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
|
|||
suffix_len = p + len - suffix;
|
||||
|
||||
if (suffix_len == 0)
|
||||
putithere->typed_val_float.type = parse_type->builtin_double;
|
||||
putithere->typed_val_float.type
|
||||
= parse_type (par_state)->builtin_double;
|
||||
else if (suffix_len == 1)
|
||||
{
|
||||
/* See if it has `f' or `d' suffix (float or double). */
|
||||
if (tolower (*suffix) == 'f')
|
||||
putithere->typed_val_float.type =
|
||||
parse_type->builtin_float;
|
||||
parse_type (par_state)->builtin_float;
|
||||
else if (tolower (*suffix) == 'd')
|
||||
putithere->typed_val_float.type =
|
||||
parse_type->builtin_double;
|
||||
parse_type (par_state)->builtin_double;
|
||||
else
|
||||
return ERROR;
|
||||
}
|
||||
|
@ -777,12 +797,12 @@ parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
|
|||
limit = ((limit << 16) << 16) | limit;
|
||||
if (c == 'l' || c == 'L')
|
||||
{
|
||||
type = parse_java_type->builtin_long;
|
||||
type = parse_java_type (par_state)->builtin_long;
|
||||
len--;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = parse_java_type->builtin_int;
|
||||
type = parse_java_type (par_state)->builtin_int;
|
||||
}
|
||||
limit_div_base = limit / (ULONGEST) base;
|
||||
|
||||
|
@ -807,11 +827,13 @@ parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
|
|||
|
||||
/* If the type is bigger than a 32-bit signed integer can be, implicitly
|
||||
promote to long. Java does not do this, so mark it as
|
||||
parse_type->builtin_uint64 rather than parse_java_type->builtin_long.
|
||||
parse_type (par_state)->builtin_uint64 rather than
|
||||
parse_java_type (par_state)->builtin_long.
|
||||
0x80000000 will become -0x80000000 instead of 0x80000000L, because we
|
||||
don't know the sign at this point. */
|
||||
if (type == parse_java_type->builtin_int && n > (ULONGEST)0x80000000)
|
||||
type = parse_type->builtin_uint64;
|
||||
if (type == parse_java_type (par_state)->builtin_int
|
||||
&& n > (ULONGEST)0x80000000)
|
||||
type = parse_type (par_state)->builtin_uint64;
|
||||
|
||||
putithere->typed_val_int.val = n;
|
||||
putithere->typed_val_int.type = type;
|
||||
|
@ -909,12 +931,12 @@ yylex (void)
|
|||
lexptr++;
|
||||
c = *lexptr++;
|
||||
if (c == '\\')
|
||||
c = parse_escape (parse_gdbarch, &lexptr);
|
||||
c = parse_escape (parse_gdbarch (pstate), &lexptr);
|
||||
else if (c == '\'')
|
||||
error (_("Empty character constant"));
|
||||
|
||||
yylval.typed_val_int.val = c;
|
||||
yylval.typed_val_int.type = parse_java_type->builtin_char;
|
||||
yylval.typed_val_int.type = parse_java_type (pstate)->builtin_char;
|
||||
|
||||
c = *lexptr++;
|
||||
if (c != '\'')
|
||||
|
@ -1007,7 +1029,8 @@ yylex (void)
|
|||
&& (*p < 'A' || *p > 'Z')))
|
||||
break;
|
||||
}
|
||||
toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
|
||||
toktype = parse_number (pstate, tokstart, p - tokstart,
|
||||
got_dot|got_e, &yylval);
|
||||
if (toktype == ERROR)
|
||||
{
|
||||
char *err_copy = (char *) alloca (p - tokstart + 1);
|
||||
|
@ -1072,7 +1095,7 @@ yylex (void)
|
|||
break;
|
||||
case '\\':
|
||||
tokptr++;
|
||||
c = parse_escape (parse_gdbarch, &tokptr);
|
||||
c = parse_escape (parse_gdbarch (pstate), &tokptr);
|
||||
if (c == -1)
|
||||
{
|
||||
continue;
|
||||
|
@ -1184,7 +1207,7 @@ yylex (void)
|
|||
|
||||
if (*tokstart == '$')
|
||||
{
|
||||
write_dollar_variable (yylval.sval);
|
||||
write_dollar_variable (pstate, yylval.sval);
|
||||
return VARIABLE;
|
||||
}
|
||||
|
||||
|
@ -1195,13 +1218,29 @@ yylex (void)
|
|||
(tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
|
||||
{
|
||||
YYSTYPE newlval; /* Its value is ignored. */
|
||||
int hextype = parse_number (tokstart, namelen, 0, &newlval);
|
||||
int hextype = parse_number (pstate, tokstart, namelen, 0, &newlval);
|
||||
if (hextype == INTEGER_LITERAL)
|
||||
return NAME_OR_INT;
|
||||
}
|
||||
return IDENTIFIER;
|
||||
}
|
||||
|
||||
int
|
||||
java_parse (struct parser_state *par_state)
|
||||
{
|
||||
int result;
|
||||
struct cleanup *c = make_cleanup_clear_parser_state (&pstate);
|
||||
|
||||
/* Setting up the parser state. */
|
||||
gdb_assert (par_state != NULL);
|
||||
pstate = par_state;
|
||||
|
||||
result = yyparse ();
|
||||
do_cleanups (c);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
yyerror (char *msg)
|
||||
{
|
||||
|
@ -1228,11 +1267,12 @@ java_type_from_name (struct stoken name)
|
|||
Otherwise, return 0. */
|
||||
|
||||
static int
|
||||
push_variable (struct stoken name)
|
||||
push_variable (struct parser_state *par_state, struct stoken name)
|
||||
{
|
||||
char *tmp = copy_name (name);
|
||||
struct field_of_this_result is_a_field_of_this;
|
||||
struct symbol *sym;
|
||||
|
||||
sym = lookup_symbol (tmp, expression_context_block, VAR_DOMAIN,
|
||||
&is_a_field_of_this);
|
||||
if (sym && SYMBOL_CLASS (sym) != LOC_TYPEDEF)
|
||||
|
@ -1244,12 +1284,12 @@ push_variable (struct stoken name)
|
|||
innermost_block = block_found;
|
||||
}
|
||||
|
||||
write_exp_elt_opcode (OP_VAR_VALUE);
|
||||
write_exp_elt_opcode (par_state, OP_VAR_VALUE);
|
||||
/* We want to use the selected frame, not another more inner frame
|
||||
which happens to be in the same block. */
|
||||
write_exp_elt_block (NULL);
|
||||
write_exp_elt_sym (sym);
|
||||
write_exp_elt_opcode (OP_VAR_VALUE);
|
||||
write_exp_elt_block (par_state, NULL);
|
||||
write_exp_elt_sym (par_state, sym);
|
||||
write_exp_elt_opcode (par_state, OP_VAR_VALUE);
|
||||
return 1;
|
||||
}
|
||||
if (is_a_field_of_this.type != NULL)
|
||||
|
@ -1259,11 +1299,11 @@ push_variable (struct stoken name)
|
|||
if (innermost_block == 0 ||
|
||||
contained_in (block_found, innermost_block))
|
||||
innermost_block = block_found;
|
||||
write_exp_elt_opcode (OP_THIS);
|
||||
write_exp_elt_opcode (OP_THIS);
|
||||
write_exp_elt_opcode (STRUCTOP_PTR);
|
||||
write_exp_string (name);
|
||||
write_exp_elt_opcode (STRUCTOP_PTR);
|
||||
write_exp_elt_opcode (par_state, OP_THIS);
|
||||
write_exp_elt_opcode (par_state, OP_THIS);
|
||||
write_exp_elt_opcode (par_state, STRUCTOP_PTR);
|
||||
write_exp_string (par_state, name);
|
||||
write_exp_elt_opcode (par_state, STRUCTOP_PTR);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -1274,7 +1314,7 @@ push_variable (struct stoken name)
|
|||
qualified name (has '.'), generate a field access for each part. */
|
||||
|
||||
static void
|
||||
push_fieldnames (struct stoken name)
|
||||
push_fieldnames (struct parser_state *par_state, struct stoken name)
|
||||
{
|
||||
int i;
|
||||
struct stoken token;
|
||||
|
@ -1285,9 +1325,9 @@ push_fieldnames (struct stoken name)
|
|||
{
|
||||
/* token.ptr is start of current field name. */
|
||||
token.length = &name.ptr[i] - token.ptr;
|
||||
write_exp_elt_opcode (STRUCTOP_PTR);
|
||||
write_exp_string (token);
|
||||
write_exp_elt_opcode (STRUCTOP_PTR);
|
||||
write_exp_elt_opcode (par_state, STRUCTOP_PTR);
|
||||
write_exp_string (par_state, token);
|
||||
write_exp_elt_opcode (par_state, STRUCTOP_PTR);
|
||||
token.ptr += token.length + 1;
|
||||
}
|
||||
if (i >= name.length)
|
||||
|
@ -1299,7 +1339,8 @@ push_fieldnames (struct stoken name)
|
|||
Handle a qualified name, where DOT_INDEX is the index of the first '.' */
|
||||
|
||||
static void
|
||||
push_qualified_expression_name (struct stoken name, int dot_index)
|
||||
push_qualified_expression_name (struct parser_state *par_state,
|
||||
struct stoken name, int dot_index)
|
||||
{
|
||||
struct stoken token;
|
||||
char *tmp;
|
||||
|
@ -1308,11 +1349,11 @@ push_qualified_expression_name (struct stoken name, int dot_index)
|
|||
token.ptr = name.ptr;
|
||||
token.length = dot_index;
|
||||
|
||||
if (push_variable (token))
|
||||
if (push_variable (par_state, token))
|
||||
{
|
||||
token.ptr = name.ptr + dot_index + 1;
|
||||
token.length = name.length - dot_index - 1;
|
||||
push_fieldnames (token);
|
||||
push_fieldnames (par_state, token);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1326,9 +1367,9 @@ push_qualified_expression_name (struct stoken name, int dot_index)
|
|||
{
|
||||
if (dot_index == name.length)
|
||||
{
|
||||
write_exp_elt_opcode(OP_TYPE);
|
||||
write_exp_elt_type(typ);
|
||||
write_exp_elt_opcode(OP_TYPE);
|
||||
write_exp_elt_opcode (par_state, OP_TYPE);
|
||||
write_exp_elt_type (par_state, typ);
|
||||
write_exp_elt_opcode (par_state, OP_TYPE);
|
||||
return;
|
||||
}
|
||||
dot_index++; /* Skip '.' */
|
||||
|
@ -1339,16 +1380,16 @@ push_qualified_expression_name (struct stoken name, int dot_index)
|
|||
dot_index++;
|
||||
token.ptr = name.ptr;
|
||||
token.length = dot_index;
|
||||
write_exp_elt_opcode (OP_SCOPE);
|
||||
write_exp_elt_type (typ);
|
||||
write_exp_string (token);
|
||||
write_exp_elt_opcode (OP_SCOPE);
|
||||
write_exp_elt_opcode (par_state, OP_SCOPE);
|
||||
write_exp_elt_type (par_state, typ);
|
||||
write_exp_string (par_state, token);
|
||||
write_exp_elt_opcode (par_state, OP_SCOPE);
|
||||
if (dot_index < name.length)
|
||||
{
|
||||
dot_index++;
|
||||
name.ptr += dot_index;
|
||||
name.length -= dot_index;
|
||||
push_fieldnames (name);
|
||||
push_fieldnames (par_state, name);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1365,7 +1406,7 @@ push_qualified_expression_name (struct stoken name, int dot_index)
|
|||
Handle VAR, TYPE, TYPE.FIELD1....FIELDN and VAR.FIELD1....FIELDN. */
|
||||
|
||||
static void
|
||||
push_expression_name (struct stoken name)
|
||||
push_expression_name (struct parser_state *par_state, struct stoken name)
|
||||
{
|
||||
char *tmp;
|
||||
struct type *typ;
|
||||
|
@ -1376,22 +1417,22 @@ push_expression_name (struct stoken name)
|
|||
if (name.ptr[i] == '.')
|
||||
{
|
||||
/* It's a Qualified Expression Name. */
|
||||
push_qualified_expression_name (name, i);
|
||||
push_qualified_expression_name (par_state, name, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* It's a Simple Expression Name. */
|
||||
|
||||
if (push_variable (name))
|
||||
if (push_variable (par_state, name))
|
||||
return;
|
||||
tmp = copy_name (name);
|
||||
typ = java_lookup_class (tmp);
|
||||
if (typ != NULL)
|
||||
{
|
||||
write_exp_elt_opcode(OP_TYPE);
|
||||
write_exp_elt_type(typ);
|
||||
write_exp_elt_opcode(OP_TYPE);
|
||||
write_exp_elt_opcode (par_state, OP_TYPE);
|
||||
write_exp_elt_type (par_state, typ);
|
||||
write_exp_elt_opcode (par_state, OP_TYPE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1399,7 +1440,7 @@ push_expression_name (struct stoken name)
|
|||
|
||||
msymbol = lookup_bound_minimal_symbol (tmp);
|
||||
if (msymbol.minsym != NULL)
|
||||
write_exp_msymbol (msymbol);
|
||||
write_exp_msymbol (par_state, msymbol);
|
||||
else if (!have_full_symbols () && !have_partial_symbols ())
|
||||
error (_("No symbol table is loaded. Use the \"file\" command"));
|
||||
else
|
||||
|
@ -1423,6 +1464,7 @@ copy_exp (struct expression *expr, int endpos)
|
|||
int len = length_of_subexp (expr, endpos);
|
||||
struct expression *new
|
||||
= (struct expression *) malloc (sizeof (*new) + EXP_ELEM_TO_BYTES (len));
|
||||
|
||||
new->nelts = len;
|
||||
memcpy (new->elts, expr->elts + endpos - len, EXP_ELEM_TO_BYTES (len));
|
||||
new->language_defn = 0;
|
||||
|
@ -1432,27 +1474,19 @@ copy_exp (struct expression *expr, int endpos)
|
|||
|
||||
/* Insert the expression NEW into the current expression (expout) at POS. */
|
||||
static void
|
||||
insert_exp (int pos, struct expression *new)
|
||||
insert_exp (struct parser_state *par_state, int pos, struct expression *new)
|
||||
{
|
||||
int newlen = new->nelts;
|
||||
int i;
|
||||
|
||||
/* Grow expout if necessary. In this function's only use at present,
|
||||
this should never be necessary. */
|
||||
if (expout_ptr + newlen > expout_size)
|
||||
{
|
||||
expout_size = max (expout_size * 2, expout_ptr + newlen + 10);
|
||||
expout = (struct expression *)
|
||||
realloc ((char *) expout, (sizeof (struct expression)
|
||||
+ EXP_ELEM_TO_BYTES (expout_size)));
|
||||
}
|
||||
increase_expout_size (par_state, newlen);
|
||||
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = expout_ptr - 1; i >= pos; i--)
|
||||
expout->elts[i + newlen] = expout->elts[i];
|
||||
}
|
||||
for (i = par_state->expout_ptr - 1; i >= pos; i--)
|
||||
par_state->expout->elts[i + newlen] = par_state->expout->elts[i];
|
||||
|
||||
memcpy (expout->elts + pos, new->elts, EXP_ELEM_TO_BYTES (newlen));
|
||||
expout_ptr += newlen;
|
||||
memcpy (par_state->expout->elts + pos, new->elts,
|
||||
EXP_ELEM_TO_BYTES (newlen));
|
||||
par_state->expout_ptr += newlen;
|
||||
}
|
||||
|
|
|
@ -22,8 +22,9 @@
|
|||
|
||||
struct value;
|
||||
struct type_print_options;
|
||||
struct parser_state;
|
||||
|
||||
extern int java_parse (void); /* Defined in jv-exp.y */
|
||||
extern int java_parse (struct parser_state *); /* Defined in jv-exp.y */
|
||||
|
||||
extern void java_error (char *); /* Defined in jv-exp.y */
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ extern void _initialize_language (void);
|
|||
|
||||
static void unk_lang_error (char *);
|
||||
|
||||
static int unk_lang_parser (void);
|
||||
static int unk_lang_parser (struct parser_state *);
|
||||
|
||||
static void show_check (char *, int);
|
||||
|
||||
|
@ -694,7 +694,7 @@ default_get_string (struct value *value, gdb_byte **buffer, int *length,
|
|||
/* Define the language that is no language. */
|
||||
|
||||
static int
|
||||
unk_lang_parser (void)
|
||||
unk_lang_parser (struct parser_state *ps)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ struct ui_file;
|
|||
struct value_print_options;
|
||||
struct type_print_options;
|
||||
struct lang_varobj_ops;
|
||||
struct parser_state;
|
||||
|
||||
#define MAX_FORTRAN_DIMS 7 /* Maximum number of F77 array dims. */
|
||||
|
||||
|
@ -164,7 +165,7 @@ struct language_defn
|
|||
|
||||
/* Parser function. */
|
||||
|
||||
int (*la_parser) (void);
|
||||
int (*la_parser) (struct parser_state *);
|
||||
|
||||
/* Parser error function. */
|
||||
|
||||
|
|
275
gdb/m2-exp.y
275
gdb/m2-exp.y
|
@ -49,8 +49,8 @@
|
|||
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
|
||||
#include "block.h"
|
||||
|
||||
#define parse_type builtin_type (parse_gdbarch)
|
||||
#define parse_m2_type builtin_m2_type (parse_gdbarch)
|
||||
#define parse_type(ps) builtin_type (parse_gdbarch (ps))
|
||||
#define parse_m2_type(ps) builtin_m2_type (parse_gdbarch (ps))
|
||||
|
||||
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
|
||||
as well as gratuitiously global symbol names, so we can have multiple
|
||||
|
@ -60,7 +60,7 @@
|
|||
generators need to be fixed instead of adding those names to this list. */
|
||||
|
||||
#define yymaxdepth m2_maxdepth
|
||||
#define yyparse m2_parse
|
||||
#define yyparse m2_parse_internal
|
||||
#define yylex m2_lex
|
||||
#define yyerror m2_error
|
||||
#define yylval m2_lval
|
||||
|
@ -112,6 +112,11 @@
|
|||
|
||||
#define YYFPRINTF parser_fprintf
|
||||
|
||||
/* The state of the parser, used internally when we are parsing the
|
||||
expression. */
|
||||
|
||||
static struct parser_state *pstate = NULL;
|
||||
|
||||
int yyparse (void);
|
||||
|
||||
static int yylex (void);
|
||||
|
@ -204,31 +209,31 @@ start : exp
|
|||
;
|
||||
|
||||
type_exp: type
|
||||
{ write_exp_elt_opcode(OP_TYPE);
|
||||
write_exp_elt_type($1);
|
||||
write_exp_elt_opcode(OP_TYPE);
|
||||
{ write_exp_elt_opcode (pstate, OP_TYPE);
|
||||
write_exp_elt_type (pstate, $1);
|
||||
write_exp_elt_opcode (pstate, OP_TYPE);
|
||||
}
|
||||
;
|
||||
|
||||
/* Expressions */
|
||||
|
||||
exp : exp '^' %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_IND); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_IND); }
|
||||
;
|
||||
|
||||
exp : '-'
|
||||
{ number_sign = -1; }
|
||||
exp %prec UNARY
|
||||
{ number_sign = 1;
|
||||
write_exp_elt_opcode (UNOP_NEG); }
|
||||
write_exp_elt_opcode (pstate, UNOP_NEG); }
|
||||
;
|
||||
|
||||
exp : '+' exp %prec UNARY
|
||||
{ write_exp_elt_opcode(UNOP_PLUS); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_PLUS); }
|
||||
;
|
||||
|
||||
exp : not_exp exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT); }
|
||||
;
|
||||
|
||||
not_exp : NOT
|
||||
|
@ -236,88 +241,90 @@ not_exp : NOT
|
|||
;
|
||||
|
||||
exp : CAP '(' exp ')'
|
||||
{ write_exp_elt_opcode (UNOP_CAP); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_CAP); }
|
||||
;
|
||||
|
||||
exp : ORD '(' exp ')'
|
||||
{ write_exp_elt_opcode (UNOP_ORD); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_ORD); }
|
||||
;
|
||||
|
||||
exp : ABS '(' exp ')'
|
||||
{ write_exp_elt_opcode (UNOP_ABS); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_ABS); }
|
||||
;
|
||||
|
||||
exp : HIGH '(' exp ')'
|
||||
{ write_exp_elt_opcode (UNOP_HIGH); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_HIGH); }
|
||||
;
|
||||
|
||||
exp : MIN_FUNC '(' type ')'
|
||||
{ write_exp_elt_opcode (UNOP_MIN);
|
||||
write_exp_elt_type ($3);
|
||||
write_exp_elt_opcode (UNOP_MIN); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_MIN);
|
||||
write_exp_elt_type (pstate, $3);
|
||||
write_exp_elt_opcode (pstate, UNOP_MIN); }
|
||||
;
|
||||
|
||||
exp : MAX_FUNC '(' type ')'
|
||||
{ write_exp_elt_opcode (UNOP_MAX);
|
||||
write_exp_elt_type ($3);
|
||||
write_exp_elt_opcode (UNOP_MAX); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_MAX);
|
||||
write_exp_elt_type (pstate, $3);
|
||||
write_exp_elt_opcode (pstate, UNOP_MAX); }
|
||||
;
|
||||
|
||||
exp : FLOAT_FUNC '(' exp ')'
|
||||
{ write_exp_elt_opcode (UNOP_FLOAT); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_FLOAT); }
|
||||
;
|
||||
|
||||
exp : VAL '(' type ',' exp ')'
|
||||
{ write_exp_elt_opcode (BINOP_VAL);
|
||||
write_exp_elt_type ($3);
|
||||
write_exp_elt_opcode (BINOP_VAL); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_VAL);
|
||||
write_exp_elt_type (pstate, $3);
|
||||
write_exp_elt_opcode (pstate, BINOP_VAL); }
|
||||
;
|
||||
|
||||
exp : CHR '(' exp ')'
|
||||
{ write_exp_elt_opcode (UNOP_CHR); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_CHR); }
|
||||
;
|
||||
|
||||
exp : ODD '(' exp ')'
|
||||
{ write_exp_elt_opcode (UNOP_ODD); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_ODD); }
|
||||
;
|
||||
|
||||
exp : TRUNC '(' exp ')'
|
||||
{ write_exp_elt_opcode (UNOP_TRUNC); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_TRUNC); }
|
||||
;
|
||||
|
||||
exp : TSIZE '(' exp ')'
|
||||
{ write_exp_elt_opcode (UNOP_SIZEOF); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_SIZEOF); }
|
||||
;
|
||||
|
||||
exp : SIZE exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_SIZEOF); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_SIZEOF); }
|
||||
;
|
||||
|
||||
|
||||
exp : INC '(' exp ')'
|
||||
{ write_exp_elt_opcode(UNOP_PREINCREMENT); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_PREINCREMENT); }
|
||||
;
|
||||
|
||||
exp : INC '(' exp ',' exp ')'
|
||||
{ write_exp_elt_opcode(BINOP_ASSIGN_MODIFY);
|
||||
write_exp_elt_opcode(BINOP_ADD);
|
||||
write_exp_elt_opcode(BINOP_ASSIGN_MODIFY); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY);
|
||||
write_exp_elt_opcode (pstate, BINOP_ADD);
|
||||
write_exp_elt_opcode (pstate,
|
||||
BINOP_ASSIGN_MODIFY); }
|
||||
;
|
||||
|
||||
exp : DEC '(' exp ')'
|
||||
{ write_exp_elt_opcode(UNOP_PREDECREMENT);}
|
||||
{ write_exp_elt_opcode (pstate, UNOP_PREDECREMENT);}
|
||||
;
|
||||
|
||||
exp : DEC '(' exp ',' exp ')'
|
||||
{ write_exp_elt_opcode(BINOP_ASSIGN_MODIFY);
|
||||
write_exp_elt_opcode(BINOP_SUB);
|
||||
write_exp_elt_opcode(BINOP_ASSIGN_MODIFY); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY);
|
||||
write_exp_elt_opcode (pstate, BINOP_SUB);
|
||||
write_exp_elt_opcode (pstate,
|
||||
BINOP_ASSIGN_MODIFY); }
|
||||
;
|
||||
|
||||
exp : exp DOT NAME
|
||||
{ write_exp_elt_opcode (STRUCTOP_STRUCT);
|
||||
write_exp_string ($3);
|
||||
write_exp_elt_opcode (STRUCTOP_STRUCT); }
|
||||
{ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
|
||||
write_exp_string (pstate, $3);
|
||||
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
|
||||
;
|
||||
|
||||
exp : set
|
||||
|
@ -349,13 +356,14 @@ exp : exp '['
|
|||
function types */
|
||||
{ start_arglist(); }
|
||||
non_empty_arglist ']' %prec DOT
|
||||
{ write_exp_elt_opcode (MULTI_SUBSCRIPT);
|
||||
write_exp_elt_longcst ((LONGEST) end_arglist());
|
||||
write_exp_elt_opcode (MULTI_SUBSCRIPT); }
|
||||
{ write_exp_elt_opcode (pstate, MULTI_SUBSCRIPT);
|
||||
write_exp_elt_longcst (pstate,
|
||||
(LONGEST) end_arglist());
|
||||
write_exp_elt_opcode (pstate, MULTI_SUBSCRIPT); }
|
||||
;
|
||||
|
||||
exp : exp '[' exp ']'
|
||||
{ write_exp_elt_opcode (BINOP_SUBSCRIPT); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT); }
|
||||
;
|
||||
|
||||
exp : exp '('
|
||||
|
@ -363,9 +371,10 @@ exp : exp '('
|
|||
being accumulated by an outer function call. */
|
||||
{ start_arglist (); }
|
||||
arglist ')' %prec DOT
|
||||
{ write_exp_elt_opcode (OP_FUNCALL);
|
||||
write_exp_elt_longcst ((LONGEST) end_arglist ());
|
||||
write_exp_elt_opcode (OP_FUNCALL); }
|
||||
{ write_exp_elt_opcode (pstate, OP_FUNCALL);
|
||||
write_exp_elt_longcst (pstate,
|
||||
(LONGEST) end_arglist ());
|
||||
write_exp_elt_opcode (pstate, OP_FUNCALL); }
|
||||
;
|
||||
|
||||
arglist :
|
||||
|
@ -391,15 +400,15 @@ non_empty_arglist
|
|||
|
||||
/* GDB construct */
|
||||
exp : '{' type '}' exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_MEMVAL);
|
||||
write_exp_elt_type ($2);
|
||||
write_exp_elt_opcode (UNOP_MEMVAL); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_MEMVAL);
|
||||
write_exp_elt_type (pstate, $2);
|
||||
write_exp_elt_opcode (pstate, UNOP_MEMVAL); }
|
||||
;
|
||||
|
||||
exp : type '(' exp ')' %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_type ($1);
|
||||
write_exp_elt_opcode (UNOP_CAST); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_CAST);
|
||||
write_exp_elt_type (pstate, $1);
|
||||
write_exp_elt_opcode (pstate, UNOP_CAST); }
|
||||
;
|
||||
|
||||
exp : '(' exp ')'
|
||||
|
@ -411,131 +420,140 @@ exp : '(' exp ')'
|
|||
|
||||
/* GDB construct */
|
||||
exp : exp '@' exp
|
||||
{ write_exp_elt_opcode (BINOP_REPEAT); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_REPEAT); }
|
||||
;
|
||||
|
||||
exp : exp '*' exp
|
||||
{ write_exp_elt_opcode (BINOP_MUL); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_MUL); }
|
||||
;
|
||||
|
||||
exp : exp '/' exp
|
||||
{ write_exp_elt_opcode (BINOP_DIV); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_DIV); }
|
||||
;
|
||||
|
||||
exp : exp DIV exp
|
||||
{ write_exp_elt_opcode (BINOP_INTDIV); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_INTDIV); }
|
||||
;
|
||||
|
||||
exp : exp MOD exp
|
||||
{ write_exp_elt_opcode (BINOP_REM); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_REM); }
|
||||
;
|
||||
|
||||
exp : exp '+' exp
|
||||
{ write_exp_elt_opcode (BINOP_ADD); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_ADD); }
|
||||
;
|
||||
|
||||
exp : exp '-' exp
|
||||
{ write_exp_elt_opcode (BINOP_SUB); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_SUB); }
|
||||
;
|
||||
|
||||
exp : exp '=' exp
|
||||
{ write_exp_elt_opcode (BINOP_EQUAL); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_EQUAL); }
|
||||
;
|
||||
|
||||
exp : exp NOTEQUAL exp
|
||||
{ write_exp_elt_opcode (BINOP_NOTEQUAL); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_NOTEQUAL); }
|
||||
| exp '#' exp
|
||||
{ write_exp_elt_opcode (BINOP_NOTEQUAL); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_NOTEQUAL); }
|
||||
;
|
||||
|
||||
exp : exp LEQ exp
|
||||
{ write_exp_elt_opcode (BINOP_LEQ); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LEQ); }
|
||||
;
|
||||
|
||||
exp : exp GEQ exp
|
||||
{ write_exp_elt_opcode (BINOP_GEQ); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_GEQ); }
|
||||
;
|
||||
|
||||
exp : exp '<' exp
|
||||
{ write_exp_elt_opcode (BINOP_LESS); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LESS); }
|
||||
;
|
||||
|
||||
exp : exp '>' exp
|
||||
{ write_exp_elt_opcode (BINOP_GTR); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_GTR); }
|
||||
;
|
||||
|
||||
exp : exp LOGICAL_AND exp
|
||||
{ write_exp_elt_opcode (BINOP_LOGICAL_AND); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LOGICAL_AND); }
|
||||
;
|
||||
|
||||
exp : exp OROR exp
|
||||
{ write_exp_elt_opcode (BINOP_LOGICAL_OR); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LOGICAL_OR); }
|
||||
;
|
||||
|
||||
exp : exp ASSIGN exp
|
||||
{ write_exp_elt_opcode (BINOP_ASSIGN); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_ASSIGN); }
|
||||
;
|
||||
|
||||
|
||||
/* Constants */
|
||||
|
||||
exp : M2_TRUE
|
||||
{ write_exp_elt_opcode (OP_BOOL);
|
||||
write_exp_elt_longcst ((LONGEST) $1);
|
||||
write_exp_elt_opcode (OP_BOOL); }
|
||||
{ write_exp_elt_opcode (pstate, OP_BOOL);
|
||||
write_exp_elt_longcst (pstate, (LONGEST) $1);
|
||||
write_exp_elt_opcode (pstate, OP_BOOL); }
|
||||
;
|
||||
|
||||
exp : M2_FALSE
|
||||
{ write_exp_elt_opcode (OP_BOOL);
|
||||
write_exp_elt_longcst ((LONGEST) $1);
|
||||
write_exp_elt_opcode (OP_BOOL); }
|
||||
{ write_exp_elt_opcode (pstate, OP_BOOL);
|
||||
write_exp_elt_longcst (pstate, (LONGEST) $1);
|
||||
write_exp_elt_opcode (pstate, OP_BOOL); }
|
||||
;
|
||||
|
||||
exp : INT
|
||||
{ write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (parse_m2_type->builtin_int);
|
||||
write_exp_elt_longcst ((LONGEST) $1);
|
||||
write_exp_elt_opcode (OP_LONG); }
|
||||
{ write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_type (pstate,
|
||||
parse_m2_type (pstate)->builtin_int);
|
||||
write_exp_elt_longcst (pstate, (LONGEST) $1);
|
||||
write_exp_elt_opcode (pstate, OP_LONG); }
|
||||
;
|
||||
|
||||
exp : UINT
|
||||
{
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (parse_m2_type->builtin_card);
|
||||
write_exp_elt_longcst ((LONGEST) $1);
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_type (pstate,
|
||||
parse_m2_type (pstate)
|
||||
->builtin_card);
|
||||
write_exp_elt_longcst (pstate, (LONGEST) $1);
|
||||
write_exp_elt_opcode (pstate, OP_LONG);
|
||||
}
|
||||
;
|
||||
|
||||
exp : CHAR
|
||||
{ write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (parse_m2_type->builtin_char);
|
||||
write_exp_elt_longcst ((LONGEST) $1);
|
||||
write_exp_elt_opcode (OP_LONG); }
|
||||
{ write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_type (pstate,
|
||||
parse_m2_type (pstate)
|
||||
->builtin_char);
|
||||
write_exp_elt_longcst (pstate, (LONGEST) $1);
|
||||
write_exp_elt_opcode (pstate, OP_LONG); }
|
||||
;
|
||||
|
||||
|
||||
exp : FLOAT
|
||||
{ write_exp_elt_opcode (OP_DOUBLE);
|
||||
write_exp_elt_type (parse_m2_type->builtin_real);
|
||||
write_exp_elt_dblcst ($1);
|
||||
write_exp_elt_opcode (OP_DOUBLE); }
|
||||
{ write_exp_elt_opcode (pstate, OP_DOUBLE);
|
||||
write_exp_elt_type (pstate,
|
||||
parse_m2_type (pstate)
|
||||
->builtin_real);
|
||||
write_exp_elt_dblcst (pstate, $1);
|
||||
write_exp_elt_opcode (pstate, OP_DOUBLE); }
|
||||
;
|
||||
|
||||
exp : variable
|
||||
;
|
||||
|
||||
exp : SIZE '(' type ')' %prec UNARY
|
||||
{ write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (parse_type->builtin_int);
|
||||
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
|
||||
write_exp_elt_opcode (OP_LONG); }
|
||||
{ write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_type (pstate,
|
||||
parse_type (pstate)->builtin_int);
|
||||
write_exp_elt_longcst (pstate,
|
||||
(LONGEST) TYPE_LENGTH ($3));
|
||||
write_exp_elt_opcode (pstate, OP_LONG); }
|
||||
;
|
||||
|
||||
exp : STRING
|
||||
{ write_exp_elt_opcode (OP_M2_STRING);
|
||||
write_exp_string ($1);
|
||||
write_exp_elt_opcode (OP_M2_STRING); }
|
||||
{ write_exp_elt_opcode (pstate, OP_M2_STRING);
|
||||
write_exp_string (pstate, $1);
|
||||
write_exp_elt_opcode (pstate, OP_M2_STRING); }
|
||||
;
|
||||
|
||||
/* This will be used for extensions later. Like adding modules. */
|
||||
|
@ -545,7 +563,8 @@ block : fblock
|
|||
|
||||
fblock : BLOCKNAME
|
||||
{ struct symbol *sym
|
||||
= lookup_symbol (copy_name ($1), expression_context_block,
|
||||
= lookup_symbol (copy_name ($1),
|
||||
expression_context_block,
|
||||
VAR_DOMAIN, 0);
|
||||
$$ = sym;}
|
||||
;
|
||||
|
@ -565,10 +584,10 @@ fblock : block COLONCOLON BLOCKNAME
|
|||
|
||||
/* Useful for assigning to PROCEDURE variables */
|
||||
variable: fblock
|
||||
{ write_exp_elt_opcode(OP_VAR_VALUE);
|
||||
write_exp_elt_block (NULL);
|
||||
write_exp_elt_sym ($1);
|
||||
write_exp_elt_opcode (OP_VAR_VALUE); }
|
||||
{ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
|
||||
write_exp_elt_block (pstate, NULL);
|
||||
write_exp_elt_sym (pstate, $1);
|
||||
write_exp_elt_opcode (pstate, OP_VAR_VALUE); }
|
||||
;
|
||||
|
||||
/* GDB internal ($foo) variable */
|
||||
|
@ -591,11 +610,11 @@ variable: block COLONCOLON NAME
|
|||
innermost_block = block_found;
|
||||
}
|
||||
|
||||
write_exp_elt_opcode (OP_VAR_VALUE);
|
||||
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
|
||||
/* block_found is set by lookup_symbol. */
|
||||
write_exp_elt_block (block_found);
|
||||
write_exp_elt_sym (sym);
|
||||
write_exp_elt_opcode (OP_VAR_VALUE); }
|
||||
write_exp_elt_block (pstate, block_found);
|
||||
write_exp_elt_sym (pstate, sym);
|
||||
write_exp_elt_opcode (pstate, OP_VAR_VALUE); }
|
||||
;
|
||||
|
||||
/* Base case for variables. */
|
||||
|
@ -617,13 +636,13 @@ variable: NAME
|
|||
innermost_block = block_found;
|
||||
}
|
||||
|
||||
write_exp_elt_opcode (OP_VAR_VALUE);
|
||||
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
|
||||
/* We want to use the selected frame, not
|
||||
another more inner frame which happens to
|
||||
be in the same block. */
|
||||
write_exp_elt_block (NULL);
|
||||
write_exp_elt_sym (sym);
|
||||
write_exp_elt_opcode (OP_VAR_VALUE);
|
||||
write_exp_elt_block (pstate, NULL);
|
||||
write_exp_elt_sym (pstate, sym);
|
||||
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -633,7 +652,7 @@ variable: NAME
|
|||
msymbol =
|
||||
lookup_bound_minimal_symbol (arg);
|
||||
if (msymbol.minsym != NULL)
|
||||
write_exp_msymbol (msymbol);
|
||||
write_exp_msymbol (pstate, msymbol);
|
||||
else if (!have_full_symbols () && !have_partial_symbols ())
|
||||
error (_("No symbol table is loaded. Use the \"symbol-file\" command."));
|
||||
else
|
||||
|
@ -645,7 +664,8 @@ variable: NAME
|
|||
|
||||
type
|
||||
: TYPENAME
|
||||
{ $$ = lookup_typename (parse_language, parse_gdbarch,
|
||||
{ $$ = lookup_typename (parse_language (pstate),
|
||||
parse_gdbarch (pstate),
|
||||
copy_name ($1),
|
||||
expression_context_block, 0); }
|
||||
|
||||
|
@ -805,8 +825,8 @@ static struct keyword keytab[] =
|
|||
|
||||
/* Read one token, getting characters through lexptr. */
|
||||
|
||||
/* This is where we will check to make sure that the language and the operators used are
|
||||
compatible */
|
||||
/* This is where we will check to make sure that the language and the
|
||||
operators used are compatible */
|
||||
|
||||
static int
|
||||
yylex (void)
|
||||
|
@ -992,7 +1012,7 @@ yylex (void)
|
|||
|
||||
if (*tokstart == '$')
|
||||
{
|
||||
write_dollar_variable (yylval.sval);
|
||||
write_dollar_variable (pstate, yylval.sval);
|
||||
return INTERNAL_VAR;
|
||||
}
|
||||
|
||||
|
@ -1012,8 +1032,9 @@ yylex (void)
|
|||
sym = lookup_symbol (tmp, expression_context_block, VAR_DOMAIN, 0);
|
||||
if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
|
||||
return BLOCKNAME;
|
||||
if (lookup_typename (parse_language, parse_gdbarch,
|
||||
copy_name (yylval.sval), expression_context_block, 1))
|
||||
if (lookup_typename (parse_language (pstate), parse_gdbarch (pstate),
|
||||
copy_name (yylval.sval),
|
||||
expression_context_block, 1))
|
||||
return TYPENAME;
|
||||
|
||||
if(sym)
|
||||
|
@ -1070,6 +1091,22 @@ yylex (void)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
m2_parse (struct parser_state *par_state)
|
||||
{
|
||||
int result;
|
||||
struct cleanup *c = make_cleanup_clear_parser_state (&pstate);
|
||||
|
||||
/* Setting up the parser state. */
|
||||
gdb_assert (par_state != NULL);
|
||||
pstate = par_state;
|
||||
|
||||
result = yyparse ();
|
||||
do_cleanups (c);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
yyerror (char *msg)
|
||||
{
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
struct type_print_options;
|
||||
struct parser_state;
|
||||
|
||||
extern int m2_parse (void); /* Defined in m2-exp.y */
|
||||
extern int m2_parse (struct parser_state *); /* Defined in m2-exp.y */
|
||||
|
||||
extern void m2_error (char *); /* Defined in m2-exp.y */
|
||||
|
||||
|
|
|
@ -465,7 +465,7 @@ add_msglist(struct stoken *str, int addcolon)
|
|||
}
|
||||
|
||||
int
|
||||
end_msglist(void)
|
||||
end_msglist (struct parser_state *ps)
|
||||
{
|
||||
int val = msglist_len;
|
||||
struct selname *sel = selname_chain;
|
||||
|
@ -475,12 +475,12 @@ end_msglist(void)
|
|||
selname_chain = sel->next;
|
||||
msglist_len = sel->msglist_len;
|
||||
msglist_sel = sel->msglist_sel;
|
||||
selid = lookup_child_selector (parse_gdbarch, p);
|
||||
selid = lookup_child_selector (parse_gdbarch (ps), p);
|
||||
if (!selid)
|
||||
error (_("Can't find selector \"%s\""), p);
|
||||
write_exp_elt_longcst (selid);
|
||||
write_exp_elt_longcst (ps, selid);
|
||||
xfree(p);
|
||||
write_exp_elt_longcst (val); /* Number of args */
|
||||
write_exp_elt_longcst (ps, val); /* Number of args */
|
||||
xfree(sel);
|
||||
|
||||
return val;
|
||||
|
|
|
@ -26,6 +26,7 @@ struct stoken;
|
|||
|
||||
struct value;
|
||||
struct block;
|
||||
struct parser_state;
|
||||
|
||||
extern CORE_ADDR lookup_objc_class (struct gdbarch *gdbarch,
|
||||
char *classname);
|
||||
|
@ -45,7 +46,7 @@ extern struct value *value_nsstring (struct gdbarch *gdbarch,
|
|||
/* for parsing Objective C */
|
||||
extern void start_msglist (void);
|
||||
extern void add_msglist (struct stoken *str, int addcolon);
|
||||
extern int end_msglist (void);
|
||||
extern int end_msglist (struct parser_state *);
|
||||
|
||||
struct symbol *lookup_struct_typedef (char *name, const struct block *block,
|
||||
int noerr);
|
||||
|
|
352
gdb/p-exp.y
352
gdb/p-exp.y
|
@ -57,7 +57,7 @@
|
|||
#include "block.h"
|
||||
#include "completer.h"
|
||||
|
||||
#define parse_type builtin_type (parse_gdbarch)
|
||||
#define parse_type(ps) builtin_type (parse_gdbarch (ps))
|
||||
|
||||
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
|
||||
as well as gratuitiously global symbol names, so we can have multiple
|
||||
|
@ -67,7 +67,7 @@
|
|||
generators need to be fixed instead of adding those names to this list. */
|
||||
|
||||
#define yymaxdepth pascal_maxdepth
|
||||
#define yyparse pascal_parse
|
||||
#define yyparse pascal_parse_internal
|
||||
#define yylex pascal_lex
|
||||
#define yyerror pascal_error
|
||||
#define yylval pascal_lval
|
||||
|
@ -119,6 +119,11 @@
|
|||
|
||||
#define YYFPRINTF parser_fprintf
|
||||
|
||||
/* The state of the parser, used internally when we are parsing the
|
||||
expression. */
|
||||
|
||||
static struct parser_state *pstate = NULL;
|
||||
|
||||
int yyparse (void);
|
||||
|
||||
static int yylex (void);
|
||||
|
@ -159,7 +164,8 @@ static char *uptok (const char *, int);
|
|||
|
||||
%{
|
||||
/* YYSTYPE gets defined by %union */
|
||||
static int parse_number (const char *, int, int, YYSTYPE *);
|
||||
static int parse_number (struct parser_state *,
|
||||
const char *, int, int, YYSTYPE *);
|
||||
|
||||
static struct type *current_type;
|
||||
static struct internalvar *intvar;
|
||||
|
@ -252,44 +258,44 @@ normal_start :
|
|||
;
|
||||
|
||||
type_exp: type
|
||||
{ write_exp_elt_opcode(OP_TYPE);
|
||||
write_exp_elt_type($1);
|
||||
write_exp_elt_opcode(OP_TYPE);
|
||||
{ write_exp_elt_opcode (pstate, OP_TYPE);
|
||||
write_exp_elt_type (pstate, $1);
|
||||
write_exp_elt_opcode (pstate, OP_TYPE);
|
||||
current_type = $1; } ;
|
||||
|
||||
/* Expressions, including the comma operator. */
|
||||
exp1 : exp
|
||||
| exp1 ',' exp
|
||||
{ write_exp_elt_opcode (BINOP_COMMA); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_COMMA); }
|
||||
;
|
||||
|
||||
/* Expressions, not including the comma operator. */
|
||||
exp : exp '^' %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_IND);
|
||||
{ write_exp_elt_opcode (pstate, UNOP_IND);
|
||||
if (current_type)
|
||||
current_type = TYPE_TARGET_TYPE (current_type); }
|
||||
;
|
||||
|
||||
exp : '@' exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_ADDR);
|
||||
{ write_exp_elt_opcode (pstate, UNOP_ADDR);
|
||||
if (current_type)
|
||||
current_type = TYPE_POINTER_TYPE (current_type); }
|
||||
;
|
||||
|
||||
exp : '-' exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_NEG); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_NEG); }
|
||||
;
|
||||
|
||||
exp : NOT exp %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT); }
|
||||
;
|
||||
|
||||
exp : INCREMENT '(' exp ')' %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_PREINCREMENT); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_PREINCREMENT); }
|
||||
;
|
||||
|
||||
exp : DECREMENT '(' exp ')' %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_PREDECREMENT); }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_PREDECREMENT); }
|
||||
;
|
||||
|
||||
|
||||
|
@ -298,9 +304,9 @@ field_exp : exp '.' %prec UNARY
|
|||
;
|
||||
|
||||
exp : field_exp FIELDNAME
|
||||
{ write_exp_elt_opcode (STRUCTOP_STRUCT);
|
||||
write_exp_string ($2);
|
||||
write_exp_elt_opcode (STRUCTOP_STRUCT);
|
||||
{ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
|
||||
write_exp_string (pstate, $2);
|
||||
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
|
||||
search_field = 0;
|
||||
if (current_type)
|
||||
{
|
||||
|
@ -316,9 +322,9 @@ exp : field_exp FIELDNAME
|
|||
|
||||
|
||||
exp : field_exp name
|
||||
{ write_exp_elt_opcode (STRUCTOP_STRUCT);
|
||||
write_exp_string ($2);
|
||||
write_exp_elt_opcode (STRUCTOP_STRUCT);
|
||||
{ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
|
||||
write_exp_string (pstate, $2);
|
||||
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
|
||||
search_field = 0;
|
||||
if (current_type)
|
||||
{
|
||||
|
@ -332,19 +338,19 @@ exp : field_exp name
|
|||
}
|
||||
;
|
||||
exp : field_exp name COMPLETE
|
||||
{ mark_struct_expression ();
|
||||
write_exp_elt_opcode (STRUCTOP_STRUCT);
|
||||
write_exp_string ($2);
|
||||
write_exp_elt_opcode (STRUCTOP_STRUCT); }
|
||||
{ mark_struct_expression (pstate);
|
||||
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
|
||||
write_exp_string (pstate, $2);
|
||||
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
|
||||
;
|
||||
exp : field_exp COMPLETE
|
||||
{ struct stoken s;
|
||||
mark_struct_expression ();
|
||||
write_exp_elt_opcode (STRUCTOP_STRUCT);
|
||||
mark_struct_expression (pstate);
|
||||
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
|
||||
s.ptr = "";
|
||||
s.length = 0;
|
||||
write_exp_string (s);
|
||||
write_exp_elt_opcode (STRUCTOP_STRUCT); }
|
||||
write_exp_string (pstate, s);
|
||||
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
|
||||
;
|
||||
|
||||
exp : exp '['
|
||||
|
@ -365,14 +371,14 @@ exp : exp '['
|
|||
strcpy (buf, arrayname);
|
||||
current_type = TYPE_FIELD_TYPE (current_type,
|
||||
arrayfieldindex - 1);
|
||||
write_exp_elt_opcode (STRUCTOP_STRUCT);
|
||||
write_exp_string (stringsval);
|
||||
write_exp_elt_opcode (STRUCTOP_STRUCT);
|
||||
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
|
||||
write_exp_string (pstate, stringsval);
|
||||
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
|
||||
}
|
||||
push_current_type (); }
|
||||
exp1 ']'
|
||||
{ pop_current_type ();
|
||||
write_exp_elt_opcode (BINOP_SUBSCRIPT);
|
||||
write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT);
|
||||
if (current_type)
|
||||
current_type = TYPE_TARGET_TYPE (current_type); }
|
||||
;
|
||||
|
@ -383,9 +389,10 @@ exp : exp '('
|
|||
{ push_current_type ();
|
||||
start_arglist (); }
|
||||
arglist ')' %prec ARROW
|
||||
{ write_exp_elt_opcode (OP_FUNCALL);
|
||||
write_exp_elt_longcst ((LONGEST) end_arglist ());
|
||||
write_exp_elt_opcode (OP_FUNCALL);
|
||||
{ write_exp_elt_opcode (pstate, OP_FUNCALL);
|
||||
write_exp_elt_longcst (pstate,
|
||||
(LONGEST) end_arglist ());
|
||||
write_exp_elt_opcode (pstate, OP_FUNCALL);
|
||||
pop_current_type ();
|
||||
if (current_type)
|
||||
current_type = TYPE_TARGET_TYPE (current_type);
|
||||
|
@ -406,11 +413,11 @@ exp : type '(' exp ')' %prec UNARY
|
|||
if ((TYPE_CODE (current_type) == TYPE_CODE_PTR)
|
||||
&& (TYPE_CODE (TYPE_TARGET_TYPE (current_type)) == TYPE_CODE_CLASS)
|
||||
&& (TYPE_CODE ($1) == TYPE_CODE_CLASS))
|
||||
write_exp_elt_opcode (UNOP_IND);
|
||||
write_exp_elt_opcode (pstate, UNOP_IND);
|
||||
}
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_type ($1);
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_opcode (pstate, UNOP_CAST);
|
||||
write_exp_elt_type (pstate, $1);
|
||||
write_exp_elt_opcode (pstate, UNOP_CAST);
|
||||
current_type = $1; }
|
||||
;
|
||||
|
||||
|
@ -421,7 +428,7 @@ exp : '(' exp1 ')'
|
|||
/* Binary operators in order of decreasing precedence. */
|
||||
|
||||
exp : exp '*' exp
|
||||
{ write_exp_elt_opcode (BINOP_MUL); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_MUL); }
|
||||
;
|
||||
|
||||
exp : exp '/' {
|
||||
|
@ -433,135 +440,138 @@ exp : exp '/' {
|
|||
if (leftdiv_is_integer && current_type
|
||||
&& is_integral_type (current_type))
|
||||
{
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_type (parse_type->builtin_long_double);
|
||||
current_type = parse_type->builtin_long_double;
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_opcode (pstate, UNOP_CAST);
|
||||
write_exp_elt_type (pstate,
|
||||
parse_type (pstate)
|
||||
->builtin_long_double);
|
||||
current_type
|
||||
= parse_type (pstate)->builtin_long_double;
|
||||
write_exp_elt_opcode (pstate, UNOP_CAST);
|
||||
leftdiv_is_integer = 0;
|
||||
}
|
||||
|
||||
write_exp_elt_opcode (BINOP_DIV);
|
||||
write_exp_elt_opcode (pstate, BINOP_DIV);
|
||||
}
|
||||
;
|
||||
|
||||
exp : exp DIV exp
|
||||
{ write_exp_elt_opcode (BINOP_INTDIV); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_INTDIV); }
|
||||
;
|
||||
|
||||
exp : exp MOD exp
|
||||
{ write_exp_elt_opcode (BINOP_REM); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_REM); }
|
||||
;
|
||||
|
||||
exp : exp '+' exp
|
||||
{ write_exp_elt_opcode (BINOP_ADD); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_ADD); }
|
||||
;
|
||||
|
||||
exp : exp '-' exp
|
||||
{ write_exp_elt_opcode (BINOP_SUB); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_SUB); }
|
||||
;
|
||||
|
||||
exp : exp LSH exp
|
||||
{ write_exp_elt_opcode (BINOP_LSH); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LSH); }
|
||||
;
|
||||
|
||||
exp : exp RSH exp
|
||||
{ write_exp_elt_opcode (BINOP_RSH); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_RSH); }
|
||||
;
|
||||
|
||||
exp : exp '=' exp
|
||||
{ write_exp_elt_opcode (BINOP_EQUAL);
|
||||
current_type = parse_type->builtin_bool;
|
||||
{ write_exp_elt_opcode (pstate, BINOP_EQUAL);
|
||||
current_type = parse_type (pstate)->builtin_bool;
|
||||
}
|
||||
;
|
||||
|
||||
exp : exp NOTEQUAL exp
|
||||
{ write_exp_elt_opcode (BINOP_NOTEQUAL);
|
||||
current_type = parse_type->builtin_bool;
|
||||
{ write_exp_elt_opcode (pstate, BINOP_NOTEQUAL);
|
||||
current_type = parse_type (pstate)->builtin_bool;
|
||||
}
|
||||
;
|
||||
|
||||
exp : exp LEQ exp
|
||||
{ write_exp_elt_opcode (BINOP_LEQ);
|
||||
current_type = parse_type->builtin_bool;
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LEQ);
|
||||
current_type = parse_type (pstate)->builtin_bool;
|
||||
}
|
||||
;
|
||||
|
||||
exp : exp GEQ exp
|
||||
{ write_exp_elt_opcode (BINOP_GEQ);
|
||||
current_type = parse_type->builtin_bool;
|
||||
{ write_exp_elt_opcode (pstate, BINOP_GEQ);
|
||||
current_type = parse_type (pstate)->builtin_bool;
|
||||
}
|
||||
;
|
||||
|
||||
exp : exp '<' exp
|
||||
{ write_exp_elt_opcode (BINOP_LESS);
|
||||
current_type = parse_type->builtin_bool;
|
||||
{ write_exp_elt_opcode (pstate, BINOP_LESS);
|
||||
current_type = parse_type (pstate)->builtin_bool;
|
||||
}
|
||||
;
|
||||
|
||||
exp : exp '>' exp
|
||||
{ write_exp_elt_opcode (BINOP_GTR);
|
||||
current_type = parse_type->builtin_bool;
|
||||
{ write_exp_elt_opcode (pstate, BINOP_GTR);
|
||||
current_type = parse_type (pstate)->builtin_bool;
|
||||
}
|
||||
;
|
||||
|
||||
exp : exp ANDAND exp
|
||||
{ write_exp_elt_opcode (BINOP_BITWISE_AND); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_BITWISE_AND); }
|
||||
;
|
||||
|
||||
exp : exp XOR exp
|
||||
{ write_exp_elt_opcode (BINOP_BITWISE_XOR); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_BITWISE_XOR); }
|
||||
;
|
||||
|
||||
exp : exp OR exp
|
||||
{ write_exp_elt_opcode (BINOP_BITWISE_IOR); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_BITWISE_IOR); }
|
||||
;
|
||||
|
||||
exp : exp ASSIGN exp
|
||||
{ write_exp_elt_opcode (BINOP_ASSIGN); }
|
||||
{ write_exp_elt_opcode (pstate, BINOP_ASSIGN); }
|
||||
;
|
||||
|
||||
exp : TRUEKEYWORD
|
||||
{ write_exp_elt_opcode (OP_BOOL);
|
||||
write_exp_elt_longcst ((LONGEST) $1);
|
||||
current_type = parse_type->builtin_bool;
|
||||
write_exp_elt_opcode (OP_BOOL); }
|
||||
{ write_exp_elt_opcode (pstate, OP_BOOL);
|
||||
write_exp_elt_longcst (pstate, (LONGEST) $1);
|
||||
current_type = parse_type (pstate)->builtin_bool;
|
||||
write_exp_elt_opcode (pstate, OP_BOOL); }
|
||||
;
|
||||
|
||||
exp : FALSEKEYWORD
|
||||
{ write_exp_elt_opcode (OP_BOOL);
|
||||
write_exp_elt_longcst ((LONGEST) $1);
|
||||
current_type = parse_type->builtin_bool;
|
||||
write_exp_elt_opcode (OP_BOOL); }
|
||||
{ write_exp_elt_opcode (pstate, OP_BOOL);
|
||||
write_exp_elt_longcst (pstate, (LONGEST) $1);
|
||||
current_type = parse_type (pstate)->builtin_bool;
|
||||
write_exp_elt_opcode (pstate, OP_BOOL); }
|
||||
;
|
||||
|
||||
exp : INT
|
||||
{ write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type ($1.type);
|
||||
{ write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_type (pstate, $1.type);
|
||||
current_type = $1.type;
|
||||
write_exp_elt_longcst ((LONGEST)($1.val));
|
||||
write_exp_elt_opcode (OP_LONG); }
|
||||
write_exp_elt_longcst (pstate, (LONGEST)($1.val));
|
||||
write_exp_elt_opcode (pstate, OP_LONG); }
|
||||
;
|
||||
|
||||
exp : NAME_OR_INT
|
||||
{ YYSTYPE val;
|
||||
parse_number ($1.stoken.ptr,
|
||||
parse_number (pstate, $1.stoken.ptr,
|
||||
$1.stoken.length, 0, &val);
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (val.typed_val_int.type);
|
||||
write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_type (pstate, val.typed_val_int.type);
|
||||
current_type = val.typed_val_int.type;
|
||||
write_exp_elt_longcst ((LONGEST)
|
||||
write_exp_elt_longcst (pstate, (LONGEST)
|
||||
val.typed_val_int.val);
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_opcode (pstate, OP_LONG);
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
exp : FLOAT
|
||||
{ write_exp_elt_opcode (OP_DOUBLE);
|
||||
write_exp_elt_type ($1.type);
|
||||
{ write_exp_elt_opcode (pstate, OP_DOUBLE);
|
||||
write_exp_elt_type (pstate, $1.type);
|
||||
current_type = $1.type;
|
||||
write_exp_elt_dblcst ($1.dval);
|
||||
write_exp_elt_opcode (OP_DOUBLE); }
|
||||
write_exp_elt_dblcst (pstate, $1.dval);
|
||||
write_exp_elt_opcode (pstate, OP_DOUBLE); }
|
||||
;
|
||||
|
||||
exp : variable
|
||||
|
@ -574,7 +584,7 @@ exp : VARIABLE
|
|||
struct value * val, * mark;
|
||||
|
||||
mark = value_mark ();
|
||||
val = value_of_internalvar (parse_gdbarch,
|
||||
val = value_of_internalvar (parse_gdbarch (pstate),
|
||||
intvar);
|
||||
current_type = value_type (val);
|
||||
value_release_to_mark (mark);
|
||||
|
@ -583,17 +593,19 @@ exp : VARIABLE
|
|||
;
|
||||
|
||||
exp : SIZEOF '(' type ')' %prec UNARY
|
||||
{ write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (parse_type->builtin_int);
|
||||
current_type = parse_type->builtin_int;
|
||||
{ write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_type (pstate,
|
||||
parse_type (pstate)->builtin_int);
|
||||
current_type = parse_type (pstate)->builtin_int;
|
||||
CHECK_TYPEDEF ($3);
|
||||
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
|
||||
write_exp_elt_opcode (OP_LONG); }
|
||||
write_exp_elt_longcst (pstate,
|
||||
(LONGEST) TYPE_LENGTH ($3));
|
||||
write_exp_elt_opcode (pstate, OP_LONG); }
|
||||
;
|
||||
|
||||
exp : SIZEOF '(' exp ')' %prec UNARY
|
||||
{ write_exp_elt_opcode (UNOP_SIZEOF);
|
||||
current_type = parse_type->builtin_int; }
|
||||
{ write_exp_elt_opcode (pstate, UNOP_SIZEOF);
|
||||
current_type = parse_type (pstate)->builtin_int; }
|
||||
|
||||
exp : STRING
|
||||
{ /* C strings are converted into array constants with
|
||||
|
@ -605,19 +617,25 @@ exp : STRING
|
|||
|
||||
while (count-- > 0)
|
||||
{
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (parse_type->builtin_char);
|
||||
write_exp_elt_longcst ((LONGEST)(*sp++));
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_type (pstate,
|
||||
parse_type (pstate)
|
||||
->builtin_char);
|
||||
write_exp_elt_longcst (pstate,
|
||||
(LONGEST) (*sp++));
|
||||
write_exp_elt_opcode (pstate, OP_LONG);
|
||||
}
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (parse_type->builtin_char);
|
||||
write_exp_elt_longcst ((LONGEST)'\0');
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_opcode (OP_ARRAY);
|
||||
write_exp_elt_longcst ((LONGEST) 0);
|
||||
write_exp_elt_longcst ((LONGEST) ($1.length));
|
||||
write_exp_elt_opcode (OP_ARRAY); }
|
||||
write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_type (pstate,
|
||||
parse_type (pstate)
|
||||
->builtin_char);
|
||||
write_exp_elt_longcst (pstate, (LONGEST)'\0');
|
||||
write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_opcode (pstate, OP_ARRAY);
|
||||
write_exp_elt_longcst (pstate, (LONGEST) 0);
|
||||
write_exp_elt_longcst (pstate,
|
||||
(LONGEST) ($1.length));
|
||||
write_exp_elt_opcode (pstate, OP_ARRAY); }
|
||||
;
|
||||
|
||||
/* Object pascal */
|
||||
|
@ -625,10 +643,11 @@ exp : THIS
|
|||
{
|
||||
struct value * this_val;
|
||||
struct type * this_type;
|
||||
write_exp_elt_opcode (OP_THIS);
|
||||
write_exp_elt_opcode (OP_THIS);
|
||||
write_exp_elt_opcode (pstate, OP_THIS);
|
||||
write_exp_elt_opcode (pstate, OP_THIS);
|
||||
/* We need type of this. */
|
||||
this_val = value_of_this_silent (parse_language);
|
||||
this_val
|
||||
= value_of_this_silent (parse_language (pstate));
|
||||
if (this_val)
|
||||
this_type = value_type (this_val);
|
||||
else
|
||||
|
@ -638,7 +657,7 @@ exp : THIS
|
|||
if (TYPE_CODE (this_type) == TYPE_CODE_PTR)
|
||||
{
|
||||
this_type = TYPE_TARGET_TYPE (this_type);
|
||||
write_exp_elt_opcode (UNOP_IND);
|
||||
write_exp_elt_opcode (pstate, UNOP_IND);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -684,11 +703,11 @@ variable: block COLONCOLON name
|
|||
error (_("No symbol \"%s\" in specified context."),
|
||||
copy_name ($3));
|
||||
|
||||
write_exp_elt_opcode (OP_VAR_VALUE);
|
||||
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
|
||||
/* block_found is set by lookup_symbol. */
|
||||
write_exp_elt_block (block_found);
|
||||
write_exp_elt_sym (sym);
|
||||
write_exp_elt_opcode (OP_VAR_VALUE); }
|
||||
write_exp_elt_block (pstate, block_found);
|
||||
write_exp_elt_sym (pstate, sym);
|
||||
write_exp_elt_opcode (pstate, OP_VAR_VALUE); }
|
||||
;
|
||||
|
||||
qualified_name: typebase COLONCOLON name
|
||||
|
@ -699,10 +718,10 @@ qualified_name: typebase COLONCOLON name
|
|||
error (_("`%s' is not defined as an aggregate type."),
|
||||
TYPE_NAME (type));
|
||||
|
||||
write_exp_elt_opcode (OP_SCOPE);
|
||||
write_exp_elt_type (type);
|
||||
write_exp_string ($3);
|
||||
write_exp_elt_opcode (OP_SCOPE);
|
||||
write_exp_elt_opcode (pstate, OP_SCOPE);
|
||||
write_exp_elt_type (pstate, type);
|
||||
write_exp_string (pstate, $3);
|
||||
write_exp_elt_opcode (pstate, OP_SCOPE);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -718,16 +737,16 @@ variable: qualified_name
|
|||
VAR_DOMAIN, NULL);
|
||||
if (sym)
|
||||
{
|
||||
write_exp_elt_opcode (OP_VAR_VALUE);
|
||||
write_exp_elt_block (NULL);
|
||||
write_exp_elt_sym (sym);
|
||||
write_exp_elt_opcode (OP_VAR_VALUE);
|
||||
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
|
||||
write_exp_elt_block (pstate, NULL);
|
||||
write_exp_elt_sym (pstate, sym);
|
||||
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
|
||||
break;
|
||||
}
|
||||
|
||||
msymbol = lookup_bound_minimal_symbol (name);
|
||||
if (msymbol.minsym != NULL)
|
||||
write_exp_msymbol (msymbol);
|
||||
write_exp_msymbol (pstate, msymbol);
|
||||
else if (!have_full_symbols ()
|
||||
&& !have_partial_symbols ())
|
||||
error (_("No symbol table is loaded. "
|
||||
|
@ -751,13 +770,13 @@ variable: name_not_typename
|
|||
innermost_block = block_found;
|
||||
}
|
||||
|
||||
write_exp_elt_opcode (OP_VAR_VALUE);
|
||||
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
|
||||
/* We want to use the selected frame, not
|
||||
another more inner frame which happens to
|
||||
be in the same block. */
|
||||
write_exp_elt_block (NULL);
|
||||
write_exp_elt_sym (sym);
|
||||
write_exp_elt_opcode (OP_VAR_VALUE);
|
||||
write_exp_elt_block (pstate, NULL);
|
||||
write_exp_elt_sym (pstate, sym);
|
||||
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
|
||||
current_type = sym->type; }
|
||||
else if ($1.is_a_field_of_this)
|
||||
{
|
||||
|
@ -770,13 +789,14 @@ variable: name_not_typename
|
|||
|| contained_in (block_found,
|
||||
innermost_block))
|
||||
innermost_block = block_found;
|
||||
write_exp_elt_opcode (OP_THIS);
|
||||
write_exp_elt_opcode (OP_THIS);
|
||||
write_exp_elt_opcode (STRUCTOP_PTR);
|
||||
write_exp_string ($1.stoken);
|
||||
write_exp_elt_opcode (STRUCTOP_PTR);
|
||||
write_exp_elt_opcode (pstate, OP_THIS);
|
||||
write_exp_elt_opcode (pstate, OP_THIS);
|
||||
write_exp_elt_opcode (pstate, STRUCTOP_PTR);
|
||||
write_exp_string (pstate, $1.stoken);
|
||||
write_exp_elt_opcode (pstate, STRUCTOP_PTR);
|
||||
/* We need type of this. */
|
||||
this_val = value_of_this_silent (parse_language);
|
||||
this_val
|
||||
= value_of_this_silent (parse_language (pstate));
|
||||
if (this_val)
|
||||
this_type = value_type (this_val);
|
||||
else
|
||||
|
@ -796,7 +816,7 @@ variable: name_not_typename
|
|||
msymbol =
|
||||
lookup_bound_minimal_symbol (arg);
|
||||
if (msymbol.minsym != NULL)
|
||||
write_exp_msymbol (msymbol);
|
||||
write_exp_msymbol (pstate, msymbol);
|
||||
else if (!have_full_symbols ()
|
||||
&& !have_partial_symbols ())
|
||||
error (_("No symbol table is loaded. "
|
||||
|
@ -865,7 +885,8 @@ name_not_typename : NAME
|
|||
/*** Needs some error checking for the float case ***/
|
||||
|
||||
static int
|
||||
parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
|
||||
parse_number (struct parser_state *par_state,
|
||||
const char *p, int len, int parsed_float, YYSTYPE *putithere)
|
||||
{
|
||||
/* FIXME: Shouldn't these be unsigned? We don't deal with negative values
|
||||
here, and we do kind of silly things like cast to unsigned. */
|
||||
|
@ -890,7 +911,7 @@ parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
|
|||
|
||||
if (parsed_float)
|
||||
{
|
||||
if (! parse_c_float (parse_gdbarch, p, len,
|
||||
if (! parse_c_float (parse_gdbarch (par_state), p, len,
|
||||
&putithere->typed_val_float.dval,
|
||||
&putithere->typed_val_float.type))
|
||||
return ERROR;
|
||||
|
@ -996,9 +1017,10 @@ parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
|
|||
|
||||
un = (ULONGEST)n >> 2;
|
||||
if (long_p == 0
|
||||
&& (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
|
||||
&& (un >> (gdbarch_int_bit (parse_gdbarch (par_state)) - 2)) == 0)
|
||||
{
|
||||
high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
|
||||
high_bit
|
||||
= ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch (par_state)) - 1);
|
||||
|
||||
/* A large decimal (not hex or octal) constant (between INT_MAX
|
||||
and UINT_MAX) is a long or unsigned long, according to ANSI,
|
||||
|
@ -1006,28 +1028,29 @@ parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
|
|||
int. This probably should be fixed. GCC gives a warning on
|
||||
such constants. */
|
||||
|
||||
unsigned_type = parse_type->builtin_unsigned_int;
|
||||
signed_type = parse_type->builtin_int;
|
||||
unsigned_type = parse_type (par_state)->builtin_unsigned_int;
|
||||
signed_type = parse_type (par_state)->builtin_int;
|
||||
}
|
||||
else if (long_p <= 1
|
||||
&& (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
|
||||
&& (un >> (gdbarch_long_bit (parse_gdbarch (par_state)) - 2)) == 0)
|
||||
{
|
||||
high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
|
||||
unsigned_type = parse_type->builtin_unsigned_long;
|
||||
signed_type = parse_type->builtin_long;
|
||||
high_bit
|
||||
= ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch (par_state)) - 1);
|
||||
unsigned_type = parse_type (par_state)->builtin_unsigned_long;
|
||||
signed_type = parse_type (par_state)->builtin_long;
|
||||
}
|
||||
else
|
||||
{
|
||||
int shift;
|
||||
if (sizeof (ULONGEST) * HOST_CHAR_BIT
|
||||
< gdbarch_long_long_bit (parse_gdbarch))
|
||||
< gdbarch_long_long_bit (parse_gdbarch (par_state)))
|
||||
/* A long long does not fit in a LONGEST. */
|
||||
shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
|
||||
else
|
||||
shift = (gdbarch_long_long_bit (parse_gdbarch) - 1);
|
||||
shift = (gdbarch_long_long_bit (parse_gdbarch (par_state)) - 1);
|
||||
high_bit = (ULONGEST) 1 << shift;
|
||||
unsigned_type = parse_type->builtin_unsigned_long_long;
|
||||
signed_type = parse_type->builtin_long_long;
|
||||
unsigned_type = parse_type (par_state)->builtin_unsigned_long_long;
|
||||
signed_type = parse_type (par_state)->builtin_long_long;
|
||||
}
|
||||
|
||||
putithere->typed_val_int.val = n;
|
||||
|
@ -1195,12 +1218,12 @@ yylex (void)
|
|||
lexptr++;
|
||||
c = *lexptr++;
|
||||
if (c == '\\')
|
||||
c = parse_escape (parse_gdbarch, &lexptr);
|
||||
c = parse_escape (parse_gdbarch (pstate), &lexptr);
|
||||
else if (c == '\'')
|
||||
error (_("Empty character constant."));
|
||||
|
||||
yylval.typed_val_int.val = c;
|
||||
yylval.typed_val_int.type = parse_type->builtin_char;
|
||||
yylval.typed_val_int.type = parse_type (pstate)->builtin_char;
|
||||
|
||||
c = *lexptr++;
|
||||
if (c != '\'')
|
||||
|
@ -1298,7 +1321,7 @@ yylex (void)
|
|||
&& (*p < 'A' || *p > 'Z')))
|
||||
break;
|
||||
}
|
||||
toktype = parse_number (tokstart,
|
||||
toktype = parse_number (pstate, tokstart,
|
||||
p - tokstart, got_dot | got_e, &yylval);
|
||||
if (toktype == ERROR)
|
||||
{
|
||||
|
@ -1365,7 +1388,7 @@ yylex (void)
|
|||
break;
|
||||
case '\\':
|
||||
++tokptr;
|
||||
c = parse_escape (parse_gdbarch, &tokptr);
|
||||
c = parse_escape (parse_gdbarch (pstate), &tokptr);
|
||||
if (c == -1)
|
||||
{
|
||||
continue;
|
||||
|
@ -1508,7 +1531,7 @@ yylex (void)
|
|||
but this conflicts with the GDB use for debugger variables
|
||||
so in expression to enter hexadecimal values
|
||||
we still need to use C syntax with 0xff */
|
||||
write_dollar_variable (yylval.sval);
|
||||
write_dollar_variable (pstate, yylval.sval);
|
||||
tmp = alloca (namelen + 1);
|
||||
memcpy (tmp, tokstart, namelen);
|
||||
tmp[namelen] = '\0';
|
||||
|
@ -1688,8 +1711,8 @@ yylex (void)
|
|||
return TYPENAME;
|
||||
}
|
||||
yylval.tsym.type
|
||||
= language_lookup_primitive_type_by_name (parse_language,
|
||||
parse_gdbarch, tmp);
|
||||
= language_lookup_primitive_type_by_name (parse_language (pstate),
|
||||
parse_gdbarch (pstate), tmp);
|
||||
if (yylval.tsym.type != NULL)
|
||||
{
|
||||
free (uptokstart);
|
||||
|
@ -1704,7 +1727,7 @@ yylex (void)
|
|||
|| (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
|
||||
{
|
||||
YYSTYPE newlval; /* Its value is ignored. */
|
||||
hextype = parse_number (tokstart, namelen, 0, &newlval);
|
||||
hextype = parse_number (pstate, tokstart, namelen, 0, &newlval);
|
||||
if (hextype == INT)
|
||||
{
|
||||
yylval.ssym.sym = sym;
|
||||
|
@ -1722,6 +1745,21 @@ yylex (void)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
pascal_parse (struct parser_state *par_state)
|
||||
{
|
||||
int result;
|
||||
struct cleanup *c = make_cleanup_clear_parser_state (&pstate);
|
||||
|
||||
/* Setting up the parser state. */
|
||||
gdb_assert (par_state != NULL);
|
||||
pstate = par_state;
|
||||
|
||||
result = yyparse ();
|
||||
do_cleanups (c);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
yyerror (char *msg)
|
||||
{
|
||||
|
|
|
@ -20,11 +20,12 @@
|
|||
/* This file is derived from c-lang.h */
|
||||
|
||||
struct value;
|
||||
struct parser_state;
|
||||
|
||||
/* Defined in p-lang.c */
|
||||
extern const char *pascal_main_name (void);
|
||||
|
||||
extern int pascal_parse (void); /* Defined in p-exp.y */
|
||||
extern int pascal_parse (struct parser_state *); /* Defined in p-exp.y */
|
||||
|
||||
extern void pascal_error (char *); /* Defined in p-exp.y */
|
||||
|
||||
|
|
277
gdb/parse.c
277
gdb/parse.c
|
@ -67,9 +67,6 @@ const struct exp_descriptor exp_descriptor_standard =
|
|||
};
|
||||
|
||||
/* Global variables declared in parser-defs.h (and commented there). */
|
||||
struct expression *expout;
|
||||
int expout_size;
|
||||
int expout_ptr;
|
||||
const struct block *expression_context_block;
|
||||
CORE_ADDR expression_context_pc;
|
||||
const struct block *innermost_block;
|
||||
|
@ -185,118 +182,121 @@ free_funcalls (void *ignore)
|
|||
}
|
||||
}
|
||||
|
||||
/* This page contains the functions for adding data to the struct expression
|
||||
being constructed. */
|
||||
|
||||
/* See definition in parser-defs.h. */
|
||||
|
||||
void
|
||||
initialize_expout (int initial_size, const struct language_defn *lang,
|
||||
initialize_expout (struct parser_state *ps, size_t initial_size,
|
||||
const struct language_defn *lang,
|
||||
struct gdbarch *gdbarch)
|
||||
{
|
||||
expout_size = initial_size;
|
||||
expout_ptr = 0;
|
||||
expout = xmalloc (sizeof (struct expression)
|
||||
+ EXP_ELEM_TO_BYTES (expout_size));
|
||||
expout->language_defn = lang;
|
||||
expout->gdbarch = gdbarch;
|
||||
ps->expout_size = initial_size;
|
||||
ps->expout_ptr = 0;
|
||||
ps->expout = xmalloc (sizeof (struct expression)
|
||||
+ EXP_ELEM_TO_BYTES (ps->expout_size));
|
||||
ps->expout->language_defn = lang;
|
||||
ps->expout->gdbarch = gdbarch;
|
||||
}
|
||||
|
||||
/* See definition in parser-defs.h. */
|
||||
|
||||
void
|
||||
reallocate_expout (void)
|
||||
reallocate_expout (struct parser_state *ps)
|
||||
{
|
||||
/* Record the actual number of expression elements, and then
|
||||
reallocate the expression memory so that we free up any
|
||||
excess elements. */
|
||||
|
||||
expout->nelts = expout_ptr;
|
||||
expout = xrealloc ((char *) expout,
|
||||
sizeof (struct expression)
|
||||
+ EXP_ELEM_TO_BYTES (expout_ptr));
|
||||
ps->expout->nelts = ps->expout_ptr;
|
||||
ps->expout = (struct expression *)
|
||||
xrealloc (ps->expout,
|
||||
sizeof (struct expression)
|
||||
+ EXP_ELEM_TO_BYTES (ps->expout_ptr));
|
||||
}
|
||||
|
||||
/* This page contains the functions for adding data to the struct expression
|
||||
being constructed. */
|
||||
|
||||
/* Add one element to the end of the expression. */
|
||||
|
||||
/* To avoid a bug in the Sun 4 compiler, we pass things that can fit into
|
||||
a register through here. */
|
||||
|
||||
static void
|
||||
write_exp_elt (const union exp_element *expelt)
|
||||
write_exp_elt (struct parser_state *ps, const union exp_element *expelt)
|
||||
{
|
||||
if (expout_ptr >= expout_size)
|
||||
if (ps->expout_ptr >= ps->expout_size)
|
||||
{
|
||||
expout_size *= 2;
|
||||
expout = (struct expression *)
|
||||
xrealloc ((char *) expout, sizeof (struct expression)
|
||||
+ EXP_ELEM_TO_BYTES (expout_size));
|
||||
ps->expout_size *= 2;
|
||||
ps->expout = (struct expression *)
|
||||
xrealloc (ps->expout, sizeof (struct expression)
|
||||
+ EXP_ELEM_TO_BYTES (ps->expout_size));
|
||||
}
|
||||
expout->elts[expout_ptr++] = *expelt;
|
||||
ps->expout->elts[ps->expout_ptr++] = *expelt;
|
||||
}
|
||||
|
||||
void
|
||||
write_exp_elt_opcode (enum exp_opcode expelt)
|
||||
write_exp_elt_opcode (struct parser_state *ps, enum exp_opcode expelt)
|
||||
{
|
||||
union exp_element tmp;
|
||||
|
||||
memset (&tmp, 0, sizeof (union exp_element));
|
||||
tmp.opcode = expelt;
|
||||
write_exp_elt (&tmp);
|
||||
write_exp_elt (ps, &tmp);
|
||||
}
|
||||
|
||||
void
|
||||
write_exp_elt_sym (struct symbol *expelt)
|
||||
write_exp_elt_sym (struct parser_state *ps, struct symbol *expelt)
|
||||
{
|
||||
union exp_element tmp;
|
||||
|
||||
memset (&tmp, 0, sizeof (union exp_element));
|
||||
tmp.symbol = expelt;
|
||||
write_exp_elt (&tmp);
|
||||
write_exp_elt (ps, &tmp);
|
||||
}
|
||||
|
||||
void
|
||||
write_exp_elt_block (const struct block *b)
|
||||
write_exp_elt_block (struct parser_state *ps, const struct block *b)
|
||||
{
|
||||
union exp_element tmp;
|
||||
|
||||
memset (&tmp, 0, sizeof (union exp_element));
|
||||
tmp.block = b;
|
||||
write_exp_elt (&tmp);
|
||||
write_exp_elt (ps, &tmp);
|
||||
}
|
||||
|
||||
void
|
||||
write_exp_elt_objfile (struct objfile *objfile)
|
||||
write_exp_elt_objfile (struct parser_state *ps, struct objfile *objfile)
|
||||
{
|
||||
union exp_element tmp;
|
||||
|
||||
memset (&tmp, 0, sizeof (union exp_element));
|
||||
tmp.objfile = objfile;
|
||||
write_exp_elt (&tmp);
|
||||
write_exp_elt (ps, &tmp);
|
||||
}
|
||||
|
||||
void
|
||||
write_exp_elt_longcst (LONGEST expelt)
|
||||
write_exp_elt_longcst (struct parser_state *ps, LONGEST expelt)
|
||||
{
|
||||
union exp_element tmp;
|
||||
|
||||
memset (&tmp, 0, sizeof (union exp_element));
|
||||
tmp.longconst = expelt;
|
||||
write_exp_elt (&tmp);
|
||||
write_exp_elt (ps, &tmp);
|
||||
}
|
||||
|
||||
void
|
||||
write_exp_elt_dblcst (DOUBLEST expelt)
|
||||
write_exp_elt_dblcst (struct parser_state *ps, DOUBLEST expelt)
|
||||
{
|
||||
union exp_element tmp;
|
||||
|
||||
memset (&tmp, 0, sizeof (union exp_element));
|
||||
tmp.doubleconst = expelt;
|
||||
write_exp_elt (&tmp);
|
||||
write_exp_elt (ps, &tmp);
|
||||
}
|
||||
|
||||
void
|
||||
write_exp_elt_decfloatcst (gdb_byte expelt[16])
|
||||
write_exp_elt_decfloatcst (struct parser_state *ps, gdb_byte expelt[16])
|
||||
{
|
||||
union exp_element tmp;
|
||||
int index;
|
||||
|
@ -304,27 +304,27 @@ write_exp_elt_decfloatcst (gdb_byte expelt[16])
|
|||
for (index = 0; index < 16; index++)
|
||||
tmp.decfloatconst[index] = expelt[index];
|
||||
|
||||
write_exp_elt (&tmp);
|
||||
write_exp_elt (ps, &tmp);
|
||||
}
|
||||
|
||||
void
|
||||
write_exp_elt_type (struct type *expelt)
|
||||
write_exp_elt_type (struct parser_state *ps, struct type *expelt)
|
||||
{
|
||||
union exp_element tmp;
|
||||
|
||||
memset (&tmp, 0, sizeof (union exp_element));
|
||||
tmp.type = expelt;
|
||||
write_exp_elt (&tmp);
|
||||
write_exp_elt (ps, &tmp);
|
||||
}
|
||||
|
||||
void
|
||||
write_exp_elt_intern (struct internalvar *expelt)
|
||||
write_exp_elt_intern (struct parser_state *ps, struct internalvar *expelt)
|
||||
{
|
||||
union exp_element tmp;
|
||||
|
||||
memset (&tmp, 0, sizeof (union exp_element));
|
||||
tmp.internalvar = expelt;
|
||||
write_exp_elt (&tmp);
|
||||
write_exp_elt (ps, &tmp);
|
||||
}
|
||||
|
||||
/* Add a string constant to the end of the expression.
|
||||
|
@ -349,10 +349,10 @@ write_exp_elt_intern (struct internalvar *expelt)
|
|||
|
||||
|
||||
void
|
||||
write_exp_string (struct stoken str)
|
||||
write_exp_string (struct parser_state *ps, struct stoken str)
|
||||
{
|
||||
int len = str.length;
|
||||
int lenelt;
|
||||
size_t lenelt;
|
||||
char *strdata;
|
||||
|
||||
/* Compute the number of expression elements required to hold the string
|
||||
|
@ -362,28 +362,19 @@ write_exp_string (struct stoken str)
|
|||
|
||||
lenelt = 2 + BYTES_TO_EXP_ELEM (len + 1);
|
||||
|
||||
/* Ensure that we have enough available expression elements to store
|
||||
everything. */
|
||||
|
||||
if ((expout_ptr + lenelt) >= expout_size)
|
||||
{
|
||||
expout_size = max (expout_size * 2, expout_ptr + lenelt + 10);
|
||||
expout = (struct expression *)
|
||||
xrealloc ((char *) expout, (sizeof (struct expression)
|
||||
+ EXP_ELEM_TO_BYTES (expout_size)));
|
||||
}
|
||||
increase_expout_size (ps, lenelt);
|
||||
|
||||
/* Write the leading length expression element (which advances the current
|
||||
expression element index), then write the string constant followed by a
|
||||
terminating null byte, and then write the trailing length expression
|
||||
element. */
|
||||
|
||||
write_exp_elt_longcst ((LONGEST) len);
|
||||
strdata = (char *) &expout->elts[expout_ptr];
|
||||
write_exp_elt_longcst (ps, (LONGEST) len);
|
||||
strdata = (char *) &ps->expout->elts[ps->expout_ptr];
|
||||
memcpy (strdata, str.ptr, len);
|
||||
*(strdata + len) = '\0';
|
||||
expout_ptr += lenelt - 2;
|
||||
write_exp_elt_longcst ((LONGEST) len);
|
||||
ps->expout_ptr += lenelt - 2;
|
||||
write_exp_elt_longcst (ps, (LONGEST) len);
|
||||
}
|
||||
|
||||
/* Add a vector of string constants to the end of the expression.
|
||||
|
@ -400,9 +391,11 @@ write_exp_string (struct stoken str)
|
|||
long constant, followed by the contents of the string. */
|
||||
|
||||
void
|
||||
write_exp_string_vector (int type, struct stoken_vector *vec)
|
||||
write_exp_string_vector (struct parser_state *ps, int type,
|
||||
struct stoken_vector *vec)
|
||||
{
|
||||
int i, n_slots, len;
|
||||
int i, len;
|
||||
size_t n_slots;
|
||||
|
||||
/* Compute the size. We compute the size in number of slots to
|
||||
avoid issues with string padding. */
|
||||
|
@ -421,28 +414,22 @@ write_exp_string_vector (int type, struct stoken_vector *vec)
|
|||
len = EXP_ELEM_TO_BYTES (n_slots) - 1;
|
||||
|
||||
n_slots += 4;
|
||||
if ((expout_ptr + n_slots) >= expout_size)
|
||||
{
|
||||
expout_size = max (expout_size * 2, expout_ptr + n_slots + 10);
|
||||
expout = (struct expression *)
|
||||
xrealloc ((char *) expout, (sizeof (struct expression)
|
||||
+ EXP_ELEM_TO_BYTES (expout_size)));
|
||||
}
|
||||
increase_expout_size (ps, n_slots);
|
||||
|
||||
write_exp_elt_opcode (OP_STRING);
|
||||
write_exp_elt_longcst (len);
|
||||
write_exp_elt_longcst (type);
|
||||
write_exp_elt_opcode (ps, OP_STRING);
|
||||
write_exp_elt_longcst (ps, len);
|
||||
write_exp_elt_longcst (ps, type);
|
||||
|
||||
for (i = 0; i < vec->len; ++i)
|
||||
{
|
||||
write_exp_elt_longcst (vec->tokens[i].length);
|
||||
memcpy (&expout->elts[expout_ptr], vec->tokens[i].ptr,
|
||||
write_exp_elt_longcst (ps, vec->tokens[i].length);
|
||||
memcpy (&ps->expout->elts[ps->expout_ptr], vec->tokens[i].ptr,
|
||||
vec->tokens[i].length);
|
||||
expout_ptr += BYTES_TO_EXP_ELEM (vec->tokens[i].length);
|
||||
ps->expout_ptr += BYTES_TO_EXP_ELEM (vec->tokens[i].length);
|
||||
}
|
||||
|
||||
write_exp_elt_longcst (len);
|
||||
write_exp_elt_opcode (OP_STRING);
|
||||
write_exp_elt_longcst (ps, len);
|
||||
write_exp_elt_opcode (ps, OP_STRING);
|
||||
}
|
||||
|
||||
/* Add a bitstring constant to the end of the expression.
|
||||
|
@ -457,11 +444,11 @@ write_exp_string_vector (int type, struct stoken_vector *vec)
|
|||
either end of the bitstring. */
|
||||
|
||||
void
|
||||
write_exp_bitstring (struct stoken str)
|
||||
write_exp_bitstring (struct parser_state *ps, struct stoken str)
|
||||
{
|
||||
int bits = str.length; /* length in bits */
|
||||
int len = (bits + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT;
|
||||
int lenelt;
|
||||
size_t lenelt;
|
||||
char *strdata;
|
||||
|
||||
/* Compute the number of expression elements required to hold the bitstring,
|
||||
|
@ -470,33 +457,25 @@ write_exp_bitstring (struct stoken str)
|
|||
|
||||
lenelt = 2 + BYTES_TO_EXP_ELEM (len);
|
||||
|
||||
/* Ensure that we have enough available expression elements to store
|
||||
everything. */
|
||||
|
||||
if ((expout_ptr + lenelt) >= expout_size)
|
||||
{
|
||||
expout_size = max (expout_size * 2, expout_ptr + lenelt + 10);
|
||||
expout = (struct expression *)
|
||||
xrealloc ((char *) expout, (sizeof (struct expression)
|
||||
+ EXP_ELEM_TO_BYTES (expout_size)));
|
||||
}
|
||||
increase_expout_size (ps, lenelt);
|
||||
|
||||
/* Write the leading length expression element (which advances the current
|
||||
expression element index), then write the bitstring constant, and then
|
||||
write the trailing length expression element. */
|
||||
|
||||
write_exp_elt_longcst ((LONGEST) bits);
|
||||
strdata = (char *) &expout->elts[expout_ptr];
|
||||
write_exp_elt_longcst (ps, (LONGEST) bits);
|
||||
strdata = (char *) &ps->expout->elts[ps->expout_ptr];
|
||||
memcpy (strdata, str.ptr, len);
|
||||
expout_ptr += lenelt - 2;
|
||||
write_exp_elt_longcst ((LONGEST) bits);
|
||||
ps->expout_ptr += lenelt - 2;
|
||||
write_exp_elt_longcst (ps, (LONGEST) bits);
|
||||
}
|
||||
|
||||
/* Add the appropriate elements for a minimal symbol to the end of
|
||||
the expression. */
|
||||
|
||||
void
|
||||
write_exp_msymbol (struct bound_minimal_symbol bound_msym)
|
||||
write_exp_msymbol (struct parser_state *ps,
|
||||
struct bound_minimal_symbol bound_msym)
|
||||
{
|
||||
struct minimal_symbol *msymbol = bound_msym.minsym;
|
||||
struct objfile *objfile = bound_msym.objfile;
|
||||
|
@ -536,62 +515,62 @@ write_exp_msymbol (struct bound_minimal_symbol bound_msym)
|
|||
if (overlay_debugging)
|
||||
addr = symbol_overlayed_address (addr, section);
|
||||
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_opcode (ps, OP_LONG);
|
||||
/* Let's make the type big enough to hold a 64-bit address. */
|
||||
write_exp_elt_type (objfile_type (objfile)->builtin_core_addr);
|
||||
write_exp_elt_longcst ((LONGEST) addr);
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (ps, objfile_type (objfile)->builtin_core_addr);
|
||||
write_exp_elt_longcst (ps, (LONGEST) addr);
|
||||
write_exp_elt_opcode (ps, OP_LONG);
|
||||
|
||||
if (section && section->the_bfd_section->flags & SEC_THREAD_LOCAL)
|
||||
{
|
||||
write_exp_elt_opcode (UNOP_MEMVAL_TLS);
|
||||
write_exp_elt_objfile (objfile);
|
||||
write_exp_elt_type (objfile_type (objfile)->nodebug_tls_symbol);
|
||||
write_exp_elt_opcode (UNOP_MEMVAL_TLS);
|
||||
write_exp_elt_opcode (ps, UNOP_MEMVAL_TLS);
|
||||
write_exp_elt_objfile (ps, objfile);
|
||||
write_exp_elt_type (ps, objfile_type (objfile)->nodebug_tls_symbol);
|
||||
write_exp_elt_opcode (ps, UNOP_MEMVAL_TLS);
|
||||
return;
|
||||
}
|
||||
|
||||
write_exp_elt_opcode (UNOP_MEMVAL);
|
||||
write_exp_elt_opcode (ps, UNOP_MEMVAL);
|
||||
switch (type)
|
||||
{
|
||||
case mst_text:
|
||||
case mst_file_text:
|
||||
case mst_solib_trampoline:
|
||||
write_exp_elt_type (objfile_type (objfile)->nodebug_text_symbol);
|
||||
write_exp_elt_type (ps, objfile_type (objfile)->nodebug_text_symbol);
|
||||
break;
|
||||
|
||||
case mst_text_gnu_ifunc:
|
||||
write_exp_elt_type (objfile_type (objfile)
|
||||
->nodebug_text_gnu_ifunc_symbol);
|
||||
write_exp_elt_type (ps, objfile_type (objfile)
|
||||
->nodebug_text_gnu_ifunc_symbol);
|
||||
break;
|
||||
|
||||
case mst_data:
|
||||
case mst_file_data:
|
||||
case mst_bss:
|
||||
case mst_file_bss:
|
||||
write_exp_elt_type (objfile_type (objfile)->nodebug_data_symbol);
|
||||
write_exp_elt_type (ps, objfile_type (objfile)->nodebug_data_symbol);
|
||||
break;
|
||||
|
||||
case mst_slot_got_plt:
|
||||
write_exp_elt_type (objfile_type (objfile)->nodebug_got_plt_symbol);
|
||||
write_exp_elt_type (ps, objfile_type (objfile)->nodebug_got_plt_symbol);
|
||||
break;
|
||||
|
||||
default:
|
||||
write_exp_elt_type (objfile_type (objfile)->nodebug_unknown_symbol);
|
||||
write_exp_elt_type (ps, objfile_type (objfile)->nodebug_unknown_symbol);
|
||||
break;
|
||||
}
|
||||
write_exp_elt_opcode (UNOP_MEMVAL);
|
||||
write_exp_elt_opcode (ps, UNOP_MEMVAL);
|
||||
}
|
||||
|
||||
/* Mark the current index as the starting location of a structure
|
||||
expression. This is used when completing on field names. */
|
||||
|
||||
void
|
||||
mark_struct_expression (void)
|
||||
mark_struct_expression (struct parser_state *ps)
|
||||
{
|
||||
gdb_assert (parse_completion
|
||||
&& expout_tag_completion_type == TYPE_CODE_UNDEF);
|
||||
expout_last_struct = expout_ptr;
|
||||
expout_last_struct = ps->expout_ptr;
|
||||
}
|
||||
|
||||
/* Indicate that the current parser invocation is completing a tag.
|
||||
|
@ -638,7 +617,7 @@ mark_completion_tag (enum type_code tag, const char *ptr, int length)
|
|||
value in the value history, I.e. $$1 */
|
||||
|
||||
void
|
||||
write_dollar_variable (struct stoken str)
|
||||
write_dollar_variable (struct parser_state *ps, struct stoken str)
|
||||
{
|
||||
struct symbol *sym = NULL;
|
||||
struct bound_minimal_symbol msym;
|
||||
|
@ -676,7 +655,7 @@ write_dollar_variable (struct stoken str)
|
|||
|
||||
/* Handle tokens that refer to machine registers:
|
||||
$ followed by a register name. */
|
||||
i = user_reg_map_name_to_regnum (parse_gdbarch,
|
||||
i = user_reg_map_name_to_regnum (parse_gdbarch (ps),
|
||||
str.ptr + 1, str.length - 1);
|
||||
if (i >= 0)
|
||||
goto handle_register;
|
||||
|
@ -686,9 +665,9 @@ write_dollar_variable (struct stoken str)
|
|||
isym = lookup_only_internalvar (copy_name (str) + 1);
|
||||
if (isym)
|
||||
{
|
||||
write_exp_elt_opcode (OP_INTERNALVAR);
|
||||
write_exp_elt_intern (isym);
|
||||
write_exp_elt_opcode (OP_INTERNALVAR);
|
||||
write_exp_elt_opcode (ps, OP_INTERNALVAR);
|
||||
write_exp_elt_intern (ps, isym);
|
||||
write_exp_elt_opcode (ps, OP_INTERNALVAR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -699,36 +678,36 @@ write_dollar_variable (struct stoken str)
|
|||
VAR_DOMAIN, NULL);
|
||||
if (sym)
|
||||
{
|
||||
write_exp_elt_opcode (OP_VAR_VALUE);
|
||||
write_exp_elt_block (block_found); /* set by lookup_symbol */
|
||||
write_exp_elt_sym (sym);
|
||||
write_exp_elt_opcode (OP_VAR_VALUE);
|
||||
write_exp_elt_opcode (ps, OP_VAR_VALUE);
|
||||
write_exp_elt_block (ps, block_found); /* set by lookup_symbol */
|
||||
write_exp_elt_sym (ps, sym);
|
||||
write_exp_elt_opcode (ps, OP_VAR_VALUE);
|
||||
return;
|
||||
}
|
||||
msym = lookup_bound_minimal_symbol (copy_name (str));
|
||||
if (msym.minsym)
|
||||
{
|
||||
write_exp_msymbol (msym);
|
||||
write_exp_msymbol (ps, msym);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Any other names are assumed to be debugger internal variables. */
|
||||
|
||||
write_exp_elt_opcode (OP_INTERNALVAR);
|
||||
write_exp_elt_intern (create_internalvar (copy_name (str) + 1));
|
||||
write_exp_elt_opcode (OP_INTERNALVAR);
|
||||
write_exp_elt_opcode (ps, OP_INTERNALVAR);
|
||||
write_exp_elt_intern (ps, create_internalvar (copy_name (str) + 1));
|
||||
write_exp_elt_opcode (ps, OP_INTERNALVAR);
|
||||
return;
|
||||
handle_last:
|
||||
write_exp_elt_opcode (OP_LAST);
|
||||
write_exp_elt_longcst ((LONGEST) i);
|
||||
write_exp_elt_opcode (OP_LAST);
|
||||
write_exp_elt_opcode (ps, OP_LAST);
|
||||
write_exp_elt_longcst (ps, (LONGEST) i);
|
||||
write_exp_elt_opcode (ps, OP_LAST);
|
||||
return;
|
||||
handle_register:
|
||||
write_exp_elt_opcode (OP_REGISTER);
|
||||
write_exp_elt_opcode (ps, OP_REGISTER);
|
||||
str.length--;
|
||||
str.ptr++;
|
||||
write_exp_string (str);
|
||||
write_exp_elt_opcode (OP_REGISTER);
|
||||
write_exp_string (ps, str);
|
||||
write_exp_elt_opcode (ps, OP_REGISTER);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1161,6 +1140,7 @@ parse_exp_in_context_1 (const char **stringptr, CORE_ADDR pc,
|
|||
volatile struct gdb_exception except;
|
||||
struct cleanup *old_chain, *inner_chain;
|
||||
const struct language_defn *lang = NULL;
|
||||
struct parser_state ps;
|
||||
int subexp;
|
||||
|
||||
lexptr = *stringptr;
|
||||
|
@ -1233,47 +1213,48 @@ parse_exp_in_context_1 (const char **stringptr, CORE_ADDR pc,
|
|||
While we need CURRENT_LANGUAGE to be set to LANG (for lookup_symbol
|
||||
and others called from *.y) ensure CURRENT_LANGUAGE gets restored
|
||||
to the value matching SELECTED_FRAME as set by get_current_arch. */
|
||||
initialize_expout (10, lang, get_current_arch ());
|
||||
|
||||
initialize_expout (&ps, 10, lang, get_current_arch ());
|
||||
inner_chain = make_cleanup_restore_current_language ();
|
||||
set_language (lang->la_language);
|
||||
|
||||
TRY_CATCH (except, RETURN_MASK_ALL)
|
||||
{
|
||||
if (lang->la_parser ())
|
||||
if (lang->la_parser (&ps))
|
||||
lang->la_error (NULL);
|
||||
}
|
||||
if (except.reason < 0)
|
||||
{
|
||||
if (! parse_completion)
|
||||
{
|
||||
xfree (expout);
|
||||
xfree (ps.expout);
|
||||
throw_exception (except);
|
||||
}
|
||||
}
|
||||
|
||||
reallocate_expout ();
|
||||
reallocate_expout (&ps);
|
||||
|
||||
/* Convert expression from postfix form as generated by yacc
|
||||
parser, to a prefix form. */
|
||||
|
||||
if (expressiondebug)
|
||||
dump_raw_expression (expout, gdb_stdlog,
|
||||
dump_raw_expression (ps.expout, gdb_stdlog,
|
||||
"before conversion to prefix form");
|
||||
|
||||
subexp = prefixify_expression (expout);
|
||||
subexp = prefixify_expression (ps.expout);
|
||||
if (out_subexp)
|
||||
*out_subexp = subexp;
|
||||
|
||||
lang->la_post_parser (&expout, void_context_p);
|
||||
lang->la_post_parser (&ps.expout, void_context_p);
|
||||
|
||||
if (expressiondebug)
|
||||
dump_prefix_expression (expout, gdb_stdlog);
|
||||
dump_prefix_expression (ps.expout, gdb_stdlog);
|
||||
|
||||
do_cleanups (inner_chain);
|
||||
discard_cleanups (old_chain);
|
||||
|
||||
*stringptr = lexptr;
|
||||
return expout;
|
||||
return ps.expout;
|
||||
}
|
||||
|
||||
/* Parse STRING as an expression, and complain if this fails
|
||||
|
@ -1512,7 +1493,7 @@ push_type_int (int n)
|
|||
item. */
|
||||
|
||||
void
|
||||
insert_type_address_space (char *string)
|
||||
insert_type_address_space (struct parser_state *pstate, char *string)
|
||||
{
|
||||
union type_stack_elt element;
|
||||
int slot;
|
||||
|
@ -1527,7 +1508,8 @@ insert_type_address_space (char *string)
|
|||
|
||||
element.piece = tp_space_identifier;
|
||||
insert_into_type_stack (slot, element);
|
||||
element.int_val = address_space_name_to_int (parse_gdbarch, string);
|
||||
element.int_val = address_space_name_to_int (parse_gdbarch (pstate),
|
||||
string);
|
||||
insert_into_type_stack (slot, element);
|
||||
}
|
||||
|
||||
|
@ -1909,6 +1891,21 @@ exp_uses_objfile (struct expression *exp, struct objfile *objfile)
|
|||
return exp_iterate (exp, exp_uses_objfile_iter, objfile);
|
||||
}
|
||||
|
||||
/* See definition in parser-defs.h. */
|
||||
|
||||
void
|
||||
increase_expout_size (struct parser_state *ps, size_t lenelt)
|
||||
{
|
||||
if ((ps->expout_ptr + lenelt) >= ps->expout_size)
|
||||
{
|
||||
ps->expout_size = max (ps->expout_size * 2,
|
||||
ps->expout_ptr + lenelt + 10);
|
||||
ps->expout = (struct expression *)
|
||||
xrealloc (ps->expout, (sizeof (struct expression)
|
||||
+ EXP_ELEM_TO_BYTES (ps->expout_size)));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_initialize_parse (void)
|
||||
{
|
||||
|
|
|
@ -28,15 +28,29 @@
|
|||
#include "expression.h"
|
||||
|
||||
struct block;
|
||||
struct language_defn;
|
||||
struct internalvar;
|
||||
|
||||
extern int parser_debug;
|
||||
|
||||
extern struct expression *expout;
|
||||
extern int expout_size;
|
||||
extern int expout_ptr;
|
||||
#define parse_gdbarch(ps) ((ps)->expout->gdbarch)
|
||||
#define parse_language(ps) ((ps)->expout->language_defn)
|
||||
|
||||
#define parse_gdbarch (expout->gdbarch)
|
||||
#define parse_language (expout->language_defn)
|
||||
struct parser_state
|
||||
{
|
||||
/* The expression related to this parser state. */
|
||||
|
||||
struct expression *expout;
|
||||
|
||||
/* The size of the expression above. */
|
||||
|
||||
size_t expout_size;
|
||||
|
||||
/* The number of elements already in the expression. This is used
|
||||
to know where to put new elements. */
|
||||
|
||||
size_t expout_ptr;
|
||||
};
|
||||
|
||||
/* If this is nonzero, this block is used as the lexical context
|
||||
for symbol names. */
|
||||
|
@ -148,19 +162,21 @@ struct type_stack
|
|||
};
|
||||
|
||||
/* Helper function to initialize the expout, expout_size, expout_ptr
|
||||
trio before it is used to store expression elements created during
|
||||
the parsing of an expression. INITIAL_SIZE is the initial size of
|
||||
trio inside PS before it is used to store expression elements created
|
||||
during the parsing of an expression. INITIAL_SIZE is the initial size of
|
||||
the expout array. LANG is the language used to parse the expression.
|
||||
And GDBARCH is the gdbarch to use during parsing. */
|
||||
|
||||
extern void initialize_expout (int, const struct language_defn *,
|
||||
struct gdbarch *);
|
||||
extern void initialize_expout (struct parser_state *ps,
|
||||
size_t initial_size,
|
||||
const struct language_defn *lang,
|
||||
struct gdbarch *gdbarch);
|
||||
|
||||
/* Helper function that frees any unsed space in the expout array.
|
||||
It is generally used when the parser has just been parsed and
|
||||
created. */
|
||||
/* Helper function that reallocates the EXPOUT inside PS in order to
|
||||
eliminate any unused space. It is generally used when the expression
|
||||
has just been parsed and created. */
|
||||
|
||||
extern void reallocate_expout (void);
|
||||
extern void reallocate_expout (struct parser_state *ps);
|
||||
|
||||
/* Reverse an expression from suffix form (in which it is constructed)
|
||||
to prefix form (in which we can conveniently print or execute it).
|
||||
|
@ -171,35 +187,38 @@ extern void reallocate_expout (void);
|
|||
|
||||
extern int prefixify_expression (struct expression *expr);
|
||||
|
||||
extern void write_exp_elt_opcode (enum exp_opcode);
|
||||
extern void write_exp_elt_opcode (struct parser_state *, enum exp_opcode);
|
||||
|
||||
extern void write_exp_elt_sym (struct symbol *);
|
||||
extern void write_exp_elt_sym (struct parser_state *, struct symbol *);
|
||||
|
||||
extern void write_exp_elt_longcst (LONGEST);
|
||||
extern void write_exp_elt_longcst (struct parser_state *, LONGEST);
|
||||
|
||||
extern void write_exp_elt_dblcst (DOUBLEST);
|
||||
extern void write_exp_elt_dblcst (struct parser_state *, DOUBLEST);
|
||||
|
||||
extern void write_exp_elt_decfloatcst (gdb_byte *);
|
||||
extern void write_exp_elt_decfloatcst (struct parser_state *, gdb_byte *);
|
||||
|
||||
extern void write_exp_elt_type (struct type *);
|
||||
extern void write_exp_elt_type (struct parser_state *, struct type *);
|
||||
|
||||
extern void write_exp_elt_intern (struct internalvar *);
|
||||
extern void write_exp_elt_intern (struct parser_state *, struct internalvar *);
|
||||
|
||||
extern void write_exp_string (struct stoken);
|
||||
extern void write_exp_string (struct parser_state *, struct stoken);
|
||||
|
||||
void write_exp_string_vector (int type, struct stoken_vector *vec);
|
||||
void write_exp_string_vector (struct parser_state *, int type,
|
||||
struct stoken_vector *vec);
|
||||
|
||||
extern void write_exp_bitstring (struct stoken);
|
||||
extern void write_exp_bitstring (struct parser_state *, struct stoken);
|
||||
|
||||
extern void write_exp_elt_block (const struct block *);
|
||||
extern void write_exp_elt_block (struct parser_state *, const struct block *);
|
||||
|
||||
extern void write_exp_elt_objfile (struct objfile *objfile);
|
||||
extern void write_exp_elt_objfile (struct parser_state *,
|
||||
struct objfile *objfile);
|
||||
|
||||
extern void write_exp_msymbol (struct bound_minimal_symbol);
|
||||
extern void write_exp_msymbol (struct parser_state *,
|
||||
struct bound_minimal_symbol);
|
||||
|
||||
extern void write_dollar_variable (struct stoken str);
|
||||
extern void write_dollar_variable (struct parser_state *, struct stoken str);
|
||||
|
||||
extern void mark_struct_expression (void);
|
||||
extern void mark_struct_expression (struct parser_state *);
|
||||
|
||||
extern const char *find_template_name_end (const char *);
|
||||
|
||||
|
@ -215,7 +234,7 @@ extern void push_type (enum type_pieces);
|
|||
|
||||
extern void push_type_int (int);
|
||||
|
||||
extern void insert_type_address_space (char *);
|
||||
extern void insert_type_address_space (struct parser_state *, char *);
|
||||
|
||||
extern enum type_pieces pop_type (void);
|
||||
|
||||
|
@ -375,5 +394,11 @@ extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile);
|
|||
extern void mark_completion_tag (enum type_code, const char *ptr,
|
||||
int length);
|
||||
|
||||
/* Reallocate the `expout' pointer inside PS so that it can accommodate
|
||||
at least LENELT expression elements. This function does nothing if
|
||||
there is enough room for the elements. */
|
||||
|
||||
extern void increase_expout_size (struct parser_state *ps, size_t lenelt);
|
||||
|
||||
#endif /* PARSER_DEFS_H */
|
||||
|
||||
|
|
|
@ -978,11 +978,11 @@ ppc_stap_parse_special_token (struct gdbarch *gdbarch,
|
|||
error (_("Invalid register name `%s' on expression `%s'."),
|
||||
regname, p->saved_arg);
|
||||
|
||||
write_exp_elt_opcode (OP_REGISTER);
|
||||
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
||||
str.ptr = regname;
|
||||
str.length = len;
|
||||
write_exp_string (str);
|
||||
write_exp_elt_opcode (OP_REGISTER);
|
||||
write_exp_string (&p->pstate, str);
|
||||
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
||||
|
||||
p->arg = s;
|
||||
}
|
||||
|
|
|
@ -601,12 +601,12 @@ stap_parse_register_operand (struct stap_parse_info *p)
|
|||
p->arg = endp;
|
||||
|
||||
/* Generating the expression for the displacement. */
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
|
||||
write_exp_elt_longcst (displacement);
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
||||
write_exp_elt_type (&p->pstate, builtin_type (gdbarch)->builtin_long);
|
||||
write_exp_elt_longcst (&p->pstate, displacement);
|
||||
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
||||
if (got_minus)
|
||||
write_exp_elt_opcode (UNOP_NEG);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_NEG);
|
||||
}
|
||||
|
||||
/* Getting rid of register indirection prefix. */
|
||||
|
@ -660,23 +660,23 @@ stap_parse_register_operand (struct stap_parse_info *p)
|
|||
error (_("Invalid register name `%s' on expression `%s'."),
|
||||
regname, p->saved_arg);
|
||||
|
||||
write_exp_elt_opcode (OP_REGISTER);
|
||||
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
||||
str.ptr = regname;
|
||||
str.length = len;
|
||||
write_exp_string (str);
|
||||
write_exp_elt_opcode (OP_REGISTER);
|
||||
write_exp_string (&p->pstate, str);
|
||||
write_exp_elt_opcode (&p->pstate, OP_REGISTER);
|
||||
|
||||
if (indirect_p)
|
||||
{
|
||||
if (disp_p)
|
||||
write_exp_elt_opcode (BINOP_ADD);
|
||||
write_exp_elt_opcode (&p->pstate, BINOP_ADD);
|
||||
|
||||
/* Casting to the expected type. */
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_type (lookup_pointer_type (p->arg_type));
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_CAST);
|
||||
write_exp_elt_type (&p->pstate, lookup_pointer_type (p->arg_type));
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_CAST);
|
||||
|
||||
write_exp_elt_opcode (UNOP_IND);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_IND);
|
||||
}
|
||||
|
||||
/* Getting rid of the register name suffix. */
|
||||
|
@ -767,9 +767,9 @@ stap_parse_single_operand (struct stap_parse_info *p)
|
|||
++p->arg;
|
||||
stap_parse_argument_conditionally (p);
|
||||
if (c == '-')
|
||||
write_exp_elt_opcode (UNOP_NEG);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_NEG);
|
||||
else if (c == '~')
|
||||
write_exp_elt_opcode (UNOP_COMPLEMENT);
|
||||
write_exp_elt_opcode (&p->pstate, UNOP_COMPLEMENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -807,10 +807,11 @@ stap_parse_single_operand (struct stap_parse_info *p)
|
|||
const char *int_suffix;
|
||||
|
||||
/* We are dealing with a numeric constant. */
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
|
||||
write_exp_elt_longcst (number);
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
||||
write_exp_elt_type (&p->pstate,
|
||||
builtin_type (gdbarch)->builtin_long);
|
||||
write_exp_elt_longcst (&p->pstate, number);
|
||||
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
||||
|
||||
p->arg = tmp;
|
||||
|
||||
|
@ -837,10 +838,10 @@ stap_parse_single_operand (struct stap_parse_info *p)
|
|||
number = strtol (p->arg, &endp, 10);
|
||||
p->arg = endp;
|
||||
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
|
||||
write_exp_elt_longcst (number);
|
||||
write_exp_elt_opcode (OP_LONG);
|
||||
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
||||
write_exp_elt_type (&p->pstate, builtin_type (gdbarch)->builtin_long);
|
||||
write_exp_elt_longcst (&p->pstate, number);
|
||||
write_exp_elt_opcode (&p->pstate, OP_LONG);
|
||||
|
||||
if (stap_check_integer_suffix (gdbarch, p->arg, &int_suffix))
|
||||
p->arg += strlen (int_suffix);
|
||||
|
@ -987,7 +988,7 @@ stap_parse_argument_1 (struct stap_parse_info *p, int has_lhs,
|
|||
stap_parse_argument_1 (p, 1, lookahead_prec);
|
||||
}
|
||||
|
||||
write_exp_elt_opcode (opcode);
|
||||
write_exp_elt_opcode (&p->pstate, opcode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1028,8 +1029,8 @@ stap_parse_argument (const char **arg, struct type *atype,
|
|||
/* We need to initialize the expression buffer, in order to begin
|
||||
our parsing efforts. The language here does not matter, since we
|
||||
are using our own parser. */
|
||||
initialize_expout (10, current_language, gdbarch);
|
||||
back_to = make_cleanup (free_current_contents, &expout);
|
||||
initialize_expout (&p.pstate, 10, current_language, gdbarch);
|
||||
back_to = make_cleanup (free_current_contents, &p.pstate.expout);
|
||||
|
||||
p.saved_arg = *arg;
|
||||
p.arg = *arg;
|
||||
|
@ -1044,16 +1045,17 @@ stap_parse_argument (const char **arg, struct type *atype,
|
|||
gdb_assert (p.inside_paren_p == 0);
|
||||
|
||||
/* Casting the final expression to the appropriate type. */
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_type (atype);
|
||||
write_exp_elt_opcode (UNOP_CAST);
|
||||
write_exp_elt_opcode (&p.pstate, UNOP_CAST);
|
||||
write_exp_elt_type (&p.pstate, atype);
|
||||
write_exp_elt_opcode (&p.pstate, UNOP_CAST);
|
||||
|
||||
reallocate_expout ();
|
||||
reallocate_expout (&p.pstate);
|
||||
|
||||
p.arg = skip_spaces_const (p.arg);
|
||||
*arg = p.arg;
|
||||
|
||||
return expout;
|
||||
/* We can safely return EXPOUT here. */
|
||||
return p.pstate.expout;
|
||||
}
|
||||
|
||||
/* Function which parses an argument string from PROBE, correctly splitting
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
#if !defined (STAP_PROBE_H)
|
||||
#define STAP_PROBE_H 1
|
||||
|
||||
/* For `struct parser_state'. */
|
||||
#include "parser-defs.h"
|
||||
|
||||
/* Structure which holds information about the parsing process of one probe's
|
||||
argument. */
|
||||
|
||||
|
@ -28,6 +31,9 @@ struct stap_parse_info
|
|||
/* The probe's argument in a string format. */
|
||||
const char *arg;
|
||||
|
||||
/* The parser state to be used when generating the expression. */
|
||||
struct parser_state pstate;
|
||||
|
||||
/* A pointer to the full chain of arguments. This is useful for printing
|
||||
error messages. The parser functions should not modify this argument
|
||||
directly; instead, they should use the ARG pointer above. */
|
||||
|
|
18
gdb/utils.c
18
gdb/utils.c
|
@ -466,6 +466,24 @@ make_cleanup_restore_current_language (void)
|
|||
(void *) (uintptr_t) saved_lang);
|
||||
}
|
||||
|
||||
/* Helper function for make_cleanup_clear_parser_state. */
|
||||
|
||||
static void
|
||||
do_clear_parser_state (void *ptr)
|
||||
{
|
||||
struct parser_state **p = (struct parser_state **) ptr;
|
||||
|
||||
*p = NULL;
|
||||
}
|
||||
|
||||
/* Clean (i.e., set to NULL) the parser state variable P. */
|
||||
|
||||
struct cleanup *
|
||||
make_cleanup_clear_parser_state (struct parser_state **p)
|
||||
{
|
||||
return make_cleanup (do_clear_parser_state, (void *) p);
|
||||
}
|
||||
|
||||
/* This function is useful for cleanups.
|
||||
Do
|
||||
|
||||
|
|
|
@ -115,6 +115,10 @@ extern struct cleanup *make_cleanup_restore_current_language (void);
|
|||
|
||||
extern struct cleanup *make_cleanup_htab_delete (htab_t htab);
|
||||
|
||||
struct parser_state;
|
||||
extern struct cleanup *make_cleanup_clear_parser_state
|
||||
(struct parser_state **p);
|
||||
|
||||
extern void free_current_contents (void *);
|
||||
|
||||
extern void init_page_info (void);
|
||||
|
|
Loading…
Reference in a new issue