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.
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 */
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 */
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 */
#include "defs.h"
#include "symtab.h"
#include "gdbtypes.h"
+#include "value.h"
#include "expression.h"
#include "parser-defs.h"
#include "language.h"
{"->", UNOP_ADDR, PREC_PREFIX, 0},
{NULL, 0, 0, 0}
};
-
\f
/* The built-in types of Chill. */
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,
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 */
#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);
+}
\f
/* Parse the string EXP as a C expression, evaluate it,
and return the result as a number. */
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;
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;
}
}
- 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);
}
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:
*/
-static value_ptr
+value_ptr
evaluate_subexp_with_coercion (exp, pos, noside)
register struct expression *exp;
register int *pos;
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. */
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
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 *));
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 */
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,
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,
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,
#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
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));
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 */