* language.h (struct language_defn): New field evaluate_exp.

* c-lang.c (c_language_defn, cplus_language_defn, asm_langauge_defn),
	f-lang.c (f_language_defn), language.c (unknown_language_defn,
	auto_language_defn, local_language_defn), m2-lang.c (m2_language_defn):
	Set evaluate_exp to evaluate_subexp_standard.
	* ch-lang.c (evaluate_subexp_chill):  New function.  Chill-specific
	support for MULTI_SUBSCRIPT.
	(chill_language_defn):  Set evaluate_exp to evaluate_subexp_chill.
	* eval.c (enum noside):  Move from here ....
	* expression.h (enum noside):  ... to here.
	(evaluate_subexp_standard):  New prototype.
	* eval.c (evaluate_subexp):  Renamed to evaluate_subexp_standard.
	Removed lo-longer-needed test for chill_varying_type.
	(evaluate_subexp):  New.  Calls exp->language_defn->evaluate_exp.
This commit is contained in:
Per Bothner 1995-02-12 19:21:04 +00:00
parent 60438e8e3e
commit 7398958c7d
9 changed files with 119 additions and 55 deletions

View File

@ -1,5 +1,20 @@
Sun Feb 12 11:03:47 1995 Per Bothner <bothner@kalessin.cygnus.com>
* language.h (struct language_defn): New field evaluate_exp.
* c-lang.c (c_language_defn, cplus_language_defn, asm_langauge_defn),
f-lang.c (f_language_defn), language.c (unknown_language_defn,
auto_language_defn, local_language_defn), m2-lang.c (m2_language_defn):
Set evaluate_exp to evaluate_subexp_standard.
* ch-lang.c (evaluate_subexp_chill): New function. Chill-specific
support for MULTI_SUBSCRIPT.
(chill_language_defn): Set evaluate_exp to evaluate_subexp_chill.
* eval.c (enum noside): Move from here ....
* expression.h (enum noside): ... to here.
(evaluate_subexp_standard): New prototype.
* eval.c (evaluate_subexp): Renamed to evaluate_subexp_standard.
Removed lo-longer-needed test for chill_varying_type.
(evaluate_subexp): New. Calls exp->language_defn->evaluate_exp.
* ch-exp.y (maybe_expression_list): New non-terminal.
(primitive_value): Allow empty parameter list.

View File

@ -399,6 +399,7 @@ const struct language_defn c_language_defn = {
type_check_off,
c_parse,
c_error,
evaluate_subexp_standard,
c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
c_create_fundamental_type, /* Create fundamental type in this language */
@ -424,6 +425,7 @@ const struct language_defn cplus_language_defn = {
type_check_off,
c_parse,
c_error,
evaluate_subexp_standard,
c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
c_create_fundamental_type, /* Create fundamental type in this language */
@ -449,6 +451,7 @@ const struct language_defn asm_language_defn = {
type_check_off,
c_parse,
c_error,
evaluate_subexp_standard,
c_printchar, /* Print a character constant */
c_printstr, /* Function to print string constant */
c_create_fundamental_type, /* Create fundamental type in this language */

View File

@ -20,6 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "defs.h"
#include "symtab.h"
#include "gdbtypes.h"
#include "value.h"
#include "expression.h"
#include "parser-defs.h"
#include "language.h"
@ -269,7 +270,6 @@ static const struct op_print chill_op_print_tab[] = {
{"->", UNOP_ADDR, PREC_PREFIX, 0},
{NULL, 0, 0, 0}
};
/* The built-in types of Chill. */
@ -289,6 +289,54 @@ struct type ** const (chill_builtin_types[]) =
0
};
static value_ptr
evaluate_subexp_chill (expect_type, exp, pos, noside)
struct type *expect_type;
register struct expression *exp;
register int *pos;
enum noside noside;
{
int pc = *pos;
int tem, nargs;
value_ptr arg1;
value_ptr *argvec;
switch (exp->elts[*pos].opcode)
{
case MULTI_SUBSCRIPT:
if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
break;
(*pos) += 3;
nargs = longest_to_int (exp->elts[pc + 1].longconst);
arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
switch (TYPE_CODE (VALUE_TYPE (arg1)))
{
case TYPE_CODE_PTR:
case TYPE_CODE_FUNC:
/* It's a function call. */
/* Allocate arg vector, including space for the function to be
called in argvec[0] and a terminating NULL */
argvec = (value_ptr *) alloca (sizeof (value_ptr) * (nargs + 2));
argvec[0] = arg1;
tem = 1;
for (; tem <= nargs; tem++)
argvec[tem] = evaluate_subexp_with_coercion (exp, pos, noside);
argvec[tem] = 0; /* signal end of arglist */
return call_function_by_hand (argvec[0], nargs, argvec + 1);
}
while (nargs-- > 0)
{
value_ptr index = evaluate_subexp_with_coercion (exp, pos, noside);
arg1 = value_subscript (arg1, index);
}
return (arg1);
}
return evaluate_subexp_standard (expect_type, exp, pos, noside);
}
const struct language_defn chill_language_defn = {
"chill",
language_chill,
@ -297,6 +345,7 @@ const struct language_defn chill_language_defn = {
type_check_on,
chill_parse, /* parser */
chill_error, /* parser error function */
evaluate_subexp_chill,
chill_printchar, /* print a character constant */
chill_printstr, /* function to print a string constant */
chill_create_fundamental_type,/* Create fundamental type in this language */

View File

@ -30,37 +30,29 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "language.h" /* For CAST_IS_CONVERSION */
#include "f-lang.h" /* for array bound stuff */
/* Values of NOSIDE argument to eval_subexp. */
enum noside
{
EVAL_NORMAL,
EVAL_SKIP, /* Only effect is to increment pos. */
EVAL_AVOID_SIDE_EFFECTS /* Don't modify any variables or
call any functions. The value
returned will have the correct
type, and will have an
approximately correct lvalue
type (inaccuracy: anything that is
listed as being in a register in
the function in which it was
declared will be lval_register). */
};
/* Prototypes for local functions. */
static value_ptr evaluate_subexp_for_sizeof PARAMS ((struct expression *,
int *));
static value_ptr evaluate_subexp_with_coercion PARAMS ((struct expression *,
value_ptr evaluate_subexp_with_coercion PARAMS ((struct expression *,
int *, enum noside));
static value_ptr evaluate_subexp_for_address PARAMS ((struct expression *,
int *, enum noside));
static value_ptr evaluate_subexp PARAMS ((struct type *, struct expression *,
int *, enum noside));
#ifdef __GNUC__
inline
#endif
static value_ptr
evaluate_subexp (expect_type, exp, pos, noside)
struct type *expect_type;
register struct expression *exp;
register int *pos;
enum noside noside;
{
return (*exp->language_defn->evaluate_exp) (expect_type, exp, pos, noside);
}
/* Parse the string EXP as a C expression, evaluate it,
and return the result as a number. */
@ -223,8 +215,8 @@ evaluate_labeled_field_init (struct_val, fieldnop, exp, pos, noside)
return val;
}
static value_ptr
evaluate_subexp (expect_type, exp, pos, noside)
value_ptr
evaluate_subexp_standard (expect_type, exp, pos, noside)
struct type *expect_type;
register struct expression *exp;
register int *pos;
@ -654,19 +646,7 @@ evaluate_subexp (expect_type, exp, pos, noside)
at parse time. We have made all array subscript operations,
substring operations as well as function calls come here
and we now have to discover what the heck this thing actually was.
If it is an array, we massage it into a form that the
MULTI_F77_SUBSCRIPT operator can deal with. If it is
a function, we process just as if we got an OP_FUNCALL and
for a subscring operation, we perform the appropriate
substring operation. */
/* First get the nargs and then jump all the way over the:
OP_UNDETERMINED_ARGLIST
nargs
OP_UNDETERMINED_ARGLIST
instruction sequence */
If it is a function, we process just as if we got an OP_FUNCALL. */
nargs = longest_to_int (exp->elts[pc+1].longconst);
(*pos) += 2;
@ -952,8 +932,7 @@ evaluate_subexp (expect_type, exp, pos, noside)
}
}
if (binop_user_defined_p (op, arg1, arg2)
&& ! chill_varying_type (VALUE_TYPE (arg1)))
if (binop_user_defined_p (op, arg1, arg2))
{
arg1 = value_x_binop (arg1, arg2, op, OP_NULL);
}
@ -1045,9 +1024,7 @@ evaluate_subexp (expect_type, exp, pos, noside)
returns the correct type value */
VALUE_TYPE (arg1) = tmp_type;
arg1 = value_subscript (arg1, arg2);
return arg1;
return value_ind (value_add (value_coerce_array (arg1), arg2));
}
case BINOP_LOGICAL_AND:
@ -1488,7 +1465,7 @@ evaluate_subexp_for_address (exp, pos, noside)
*/
static value_ptr
value_ptr
evaluate_subexp_with_coercion (exp, pos, noside)
register struct expression *exp;
register int *pos;

View File

@ -132,13 +132,6 @@ enum exp_opcode
by each of the next following subexpressions, one per dimension. */
MULTI_SUBSCRIPT,
/* For Fortran array subscripting (column major style). Like the
Modula operator, we find that the dimensionality is
encoded in the operator. This operator is distinct
from the above one because it uses column-major array
ordering not row-major. */
MULTI_F77_SUBSCRIPT,
/* The OP_... series take immediate following arguments.
After the arguments come another OP_... (the same one)
so that the grouping can be recognized from the end. */
@ -193,11 +186,6 @@ enum exp_opcode
literal. It is followed by exactly two args that are doubles. */
OP_COMPLEX,
/* The following OP introduces a F77 substring operator.
It should have a string type and two integer types that follow
indicating the "from" and "to" for the substring. */
OP_F77_SUBSTR,
/* OP_STRING represents a string constant.
Its format is the same as that of a STRUCTOP, but the string
data is just made into a string constant when the operation
@ -342,6 +330,28 @@ extern struct expression *parse_exp_1 PARAMS ((char **, struct block *, int));
parse_<whatever>, then look at it. */
extern struct block *innermost_block;
/* From eval.c */
/* Values of NOSIDE argument to eval_subexp. */
enum noside
{
EVAL_NORMAL,
EVAL_SKIP, /* Only effect is to increment pos. */
EVAL_AVOID_SIDE_EFFECTS /* Don't modify any variables or
call any functions. The value
returned will have the correct
type, and will have an
approximately correct lvalue
type (inaccuracy: anything that is
listed as being in a register in
the function in which it was
declared will be lval_register). */
};
extern struct value* evaluate_subexp_standard
PARAMS ((struct type *, struct expression *, int*, enum noside));
/* From expprint.c */
extern void print_expression PARAMS ((struct expression *, GDB_FILE *));

View File

@ -423,6 +423,7 @@ const struct language_defn f_language_defn = {
type_check_on,
f_parse, /* parser */
f_error, /* parser error function */
evaluate_subexp_standard,
f_printchar, /* Print character constant */
f_printstr, /* function to print string constant */
f_create_fundamental_type, /* Create fundamental type in this language */

View File

@ -1189,6 +1189,7 @@ const struct language_defn unknown_language_defn = {
type_check_off,
unk_lang_parser,
unk_lang_error,
evaluate_subexp_standard,
unk_lang_printchar, /* Print character constant */
unk_lang_printstr,
unk_lang_create_fundamental_type,
@ -1215,6 +1216,7 @@ const struct language_defn auto_language_defn = {
type_check_off,
unk_lang_parser,
unk_lang_error,
evaluate_subexp_standard,
unk_lang_printchar, /* Print character constant */
unk_lang_printstr,
unk_lang_create_fundamental_type,
@ -1240,6 +1242,7 @@ const struct language_defn local_language_defn = {
type_check_off,
unk_lang_parser,
unk_lang_error,
evaluate_subexp_standard,
unk_lang_printchar, /* Print character constant */
unk_lang_printstr,
unk_lang_create_fundamental_type,

View File

@ -25,6 +25,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifdef __STDC__ /* Forward decls for prototypes */
struct value;
struct objfile;
struct expression;
/* enum exp_opcode; ANSI's `wisdom' didn't include forward enum decls. */
#endif
@ -132,6 +133,10 @@ struct language_defn
void (*la_error) PARAMS ((char *));
/* Evaluate an expression. */
struct value * (*evaluate_exp) PARAMS ((struct type*, struct expression *,
int *, enum noside));
void (*la_printchar) PARAMS ((int, GDB_FILE *));
void (*la_printstr) PARAMS ((GDB_FILE *, char *, unsigned int, int));

View File

@ -407,6 +407,7 @@ const struct language_defn m2_language_defn = {
type_check_on,
m2_parse, /* parser */
m2_error, /* parser error function */
evaluate_subexp_standard,
m2_printchar, /* Print character constant */
m2_printstr, /* function to print string constant */
m2_create_fundamental_type, /* Create fundamental type in this language */