diff options
author | Paul N. Hilfinger <hilfinger@adacore.com> | 2003-09-25 08:40:45 +0000 |
---|---|---|
committer | Paul N. Hilfinger <hilfinger@adacore.com> | 2003-09-25 08:40:45 +0000 |
commit | 5f9769d1720b4b1d0e6375a1eb6a554fa3b29b90 (patch) | |
tree | 679dfc6b1c2d81114573bd1b7162c9a28c80de82 /gdb/expprint.c | |
parent | 243ef1e0a514f0be42d0d56ba8b8f467d381bd62 (diff) | |
download | gdb-5f9769d1720b4b1d0e6375a1eb6a554fa3b29b90.zip gdb-5f9769d1720b4b1d0e6375a1eb6a554fa3b29b90.tar.gz gdb-5f9769d1720b4b1d0e6375a1eb6a554fa3b29b90.tar.bz2 |
* parser-defs.h (struct exp_descriptor): New definition, containing
language-specific info for printing, prefixifying, dumping, and
evaluating expressions.
(exp_descriptor_standard): Declare new variable.
(print_subexp): Make global and declare here (from expprint.c).
(dump_subexp): Ditto.
(dump_subexp_body_standard): Declare.
(operator_length_standard): Declare.
(op_name_standard): Declare.
(print_subexp): Declare.
(print_subexp_standard): Declare.
* language.h (struct language_defn): Add la_exp_desc field to hold
pointer to table for language-specific operators.
Remove evaluate_exp field, which is now in struct exp_descriptor.
* parse.c (operator_length): Move most code to new
operator_length_standard function. Use language-specific information.
(operator_length_standard): New function taking most code from
operator_length.
(exp_descriptor_standard): New constant.
* expression.h (enum exp_opcode): Add definitions of OP_EXTENDED0
and OP_EXTENDED_LAST.
* expprint.c (print_subexp): Use language-specific print_subexp.
Make global; remove static declaration.
Move most code to print_subexp_standard.
(print_subexp_standard): New function, containing code formerly in
print_subexp.
(op_name): Add expression to argument signature.
Use langauge-specific op_name.
Move most code to op_name_standard.
(op_name_standard): New function, containing code formerly in op_name.
(dump_subexp): Use new version of op_name function.
Use language-specific dump_subexp_body, and move most existing code to
dump_subexp_body_standard.
(dump_raw_expression): Use new op_name interface.
(dump_subexp_body): Move most code to dump_subexp_body_standard.
(dump_subexp_body_standard): New function, containing code formerly
in dump_subexp_body.
* language.c (unknown_language): Add default la_exp_desc field and
remove evaluate_exp field.
(auto_language): Ditto.
(local_language): Ditto.
* f-lang.c (f_language_defn): Ditto.
* c-lang.c (c_language_defn): Ditto.
(cplus_language_defn): Ditto.
(asm_language_defn): Ditto.
(minimal_language_defn): Ditto.
* p-lang.c (pascal_language_defn): Ditto.
* m2-lang.c (m2_language_defn): Ditto.
* objc-lang.c (objc_language_defn): Ditto.
* jv-lang.c (exp_descriptor_java): New variable, containing
Java-specific expression evaluator.
(java_language_defn): Add la_exp_desc field and remove evaluate_exp
field.
* scm-lang.c (exp_descriptor_scm): New variable, containing
Scheme-specific expression evaluator.
(scm_language_defn): Add la_exp_desc field and remove evaluate_exp
field.
* objc-lang.c (print_object_command): Take evaluate_exp from the
la_exp_desc field.
* Makefile.in (eval.o): Add dependency on parser-defs.h.
* eval.c: Include parser-defs.h for the full declaration of
la_exp_desc's type.
(evaluate_subexp): Get evaluate_exp out of la_exp_desc field.
Diffstat (limited to 'gdb/expprint.c')
-rw-r--r-- | gdb/expprint.c | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/gdb/expprint.c b/gdb/expprint.c index 8db4c36..5949475 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -36,11 +36,6 @@ #include <ctype.h> #endif -/* Prototypes for local functions */ - -static void print_subexp (struct expression *, int *, struct ui_file *, - enum precedence); - void print_expression (struct expression *exp, struct ui_file *stream) { @@ -53,10 +48,19 @@ print_expression (struct expression *exp, struct ui_file *stream) if the precedence of the main operator of this subexpression is less, parentheses are needed here. */ -static void +void print_subexp (struct expression *exp, int *pos, struct ui_file *stream, enum precedence prec) { + exp->language_defn->la_exp_desc->print_subexp (exp, pos, stream, prec); +} + +/* Standard implementation of print_subexp for use in language_defn + vectors. */ +void +print_subexp_standard (struct expression *exp, int *pos, + struct ui_file *stream, enum precedence prec) +{ unsigned tem; const struct op_print *op_print_tab; int pc; @@ -547,11 +551,22 @@ op_string (enum exp_opcode op) /* Support for dumping the raw data from expressions in a human readable form. */ -static char *op_name (int opcode); +static char *op_name (struct expression *, enum exp_opcode); static int dump_subexp_body (struct expression *exp, struct ui_file *, int); +/* Name for OPCODE, when it appears in expression EXP. */ + static char * -op_name (int opcode) +op_name (struct expression *exp, enum exp_opcode opcode) +{ + return exp->language_defn->la_exp_desc->op_name (opcode); +} + +/* Default name for the standard operator OPCODE (i.e., one defined in + the definition of enum exp_opcode). */ + +char * +op_name_standard (enum exp_opcode opcode) { switch (opcode) { @@ -756,7 +771,7 @@ dump_raw_expression (struct expression *exp, struct ui_file *stream, for (elt = 0; elt < exp->nelts; elt++) { fprintf_filtered (stream, "\t%5d ", elt); - opcode_name = op_name (exp->elts[elt].opcode); + opcode_name = op_name (exp, exp->elts[elt].opcode); fprintf_filtered (stream, "%20s ", opcode_name); print_longest (stream, 'd', 0, exp->elts[elt].longconst); @@ -791,7 +806,7 @@ dump_subexp (struct expression *exp, struct ui_file *stream, int elt) fprintf_filtered (stream, " "); indent += 2; - fprintf_filtered (stream, "%-20s ", op_name (exp->elts[elt].opcode)); + fprintf_filtered (stream, "%-20s ", op_name (exp, exp->elts[elt].opcode)); elt = dump_subexp_body (exp, stream, elt); @@ -807,6 +822,15 @@ dump_subexp (struct expression *exp, struct ui_file *stream, int elt) static int dump_subexp_body (struct expression *exp, struct ui_file *stream, int elt) { + return exp->language_defn->la_exp_desc->dump_subexp_body (exp, stream, elt); +} + +/* Default value for subexp_body in exp_descriptor vector. */ + +int +dump_subexp_body_standard (struct expression *exp, + struct ui_file *stream, int elt) +{ int opcode = exp->elts[elt++].opcode; switch (opcode) |