aboutsummaryrefslogtreecommitdiff
path: root/gdb/ch-lang.c
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>1995-02-12 19:21:04 +0000
committerPer Bothner <per@bothner.com>1995-02-12 19:21:04 +0000
commit7398958c7d7356235a818cca7da57d9377ee0556 (patch)
treec024f941aea7b6d4eb7ae6ca15fa7403aa3c4edc /gdb/ch-lang.c
parent60438e8e3e963c5d06ffb85d30ec74d680b06f24 (diff)
downloadgdb-7398958c7d7356235a818cca7da57d9377ee0556.zip
gdb-7398958c7d7356235a818cca7da57d9377ee0556.tar.gz
gdb-7398958c7d7356235a818cca7da57d9377ee0556.tar.bz2
* 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.
Diffstat (limited to 'gdb/ch-lang.c')
-rw-r--r--gdb/ch-lang.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/gdb/ch-lang.c b/gdb/ch-lang.c
index 7060ce1..9bce588 100644
--- a/gdb/ch-lang.c
+++ b/gdb/ch-lang.c
@@ -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 */