aboutsummaryrefslogtreecommitdiff
path: root/gdb/eval.c
diff options
context:
space:
mode:
authorFred Fish <fnf@specifix.com>1992-11-15 17:28:02 +0000
committerFred Fish <fnf@specifix.com>1992-11-15 17:28:02 +0000
commite58de8a23021ce9bbdee715ac79745ebb93437a8 (patch)
tree008503bb278b756abfe43212bf412ab003eb6e7c /gdb/eval.c
parentc1878f87886dd7ae9af9d2aafe8dcf075ecfaa9c (diff)
downloadgdb-e58de8a23021ce9bbdee715ac79745ebb93437a8.zip
gdb-e58de8a23021ce9bbdee715ac79745ebb93437a8.tar.gz
gdb-e58de8a23021ce9bbdee715ac79745ebb93437a8.tar.bz2
* Makefile.in (SFILES_MAINDIR): Add ch-exp.y.
* Makefile.in (YYFILES): Add ch-exp.tab.c. * Makefile.in (YYOBJ): Add ch-exp.tab.o. * Makefile.in (saber_gdb): Add unload of ch-exp.y and load of ch-exp.tab.c. * Makefile.in (distclean): Add target ch-exp.tab.c. * Makefile.in (realclean): Add rm of ch-exp.tab.c. * Makefile.in (c-exp.tab.c, m2-exp.tab.c): Add dependency on Makefile since it contains sed patterns used in generation. Add sed pattern to also delete #include of any malloc.h. * Makefile.in (ch-exp.tab.o, ch-exp.tab.c): New targets. * ch-exp.y: New expression parser, for GNU-Chill. * c-exp.y, expr.c, expression.h, language.c, m2-exp.y, parser-defs.h, valarith.c, valops.c, value.h: Remap macros and function names to conform to K&R terminology with respect to logical and bitwise operators: UNOP_ZEROP => UNOP_LOGICAL_NOT UNOP_LOGNOT => UNOP_COMPLEMENT BINOP_LOGAND => BINOP_BITWISE_AND BINOP_LOGXOR => BINOP_BITWISE_XOR BINOP_LOGIOR => BINOP_BITWISE_IOR BINOP_AND => BINOP_LOGICAL_AND BINOP_OR => BINOP_LOGICAL_OR PREC_OR => PREC_LOGICAL_OR PREC_AND => PREC_LOGICAL_AND PREC_LOGIOR => PREC_BITWISE_IOR PREC_LOGXOR => PREC_BITWISE_XOR PREC_LOGAND => PREC_BITWISE_AND value_zerop() => value_logical_not() value_lognot() => value_complement() * c-exp.y (c_op_print_tab): Add explicit empty terminator. * m2-exp.y (m2_op_print_tab): Add explicit empty terminator. * defs.h (enum language): Add language_chill. * dwarfread.c (set_cu_language): Add LANG_CHILL case and make LANG_MODULA2 a recognized language. * eval.c (evaluate_subexp): Add OP_BOOL case. * expprint.c (print_subexp): Add OP_BOOL case. * gdbtypes.h (enum_typecode): Note TYPE_CODE_BOOL used for Chill as well as Modula-2. * gdbtypes.y (builtin_type_chill_bool, builtin_type_chill_long, builtin_type_chill_ulong, builtin_type_chill_real): Add. * i387-tdep.c (sys/dir.h): Remove, appears to be unnecessary and is nonexistant in some SVR4 based systems. * language.c (DEFAULT_ALLOCSIZE): Change from 3 => 4. * language.c (set_language_command): Add chill. * language.c (binop_result_type, integral_type, character_type, boolean_type, structured_type, value_true, binop_type_check): Add language_chill cases. * language.h (_LANG_chill): Define. * m2-exp.y (number_sign, modblock): Make static, #ifdef out unused modblock. * m2-exp.y (ANDAND): Rename to LOGICAL_AND. * source.c (source_info): Fix minor nits, print "1 line" rather than "1 lines", and "language is <lang>". * symfile.c (deduce_language_from_filename): Recognize the filename extensions ".chill", ".c186", and ".c286" for Chill. * valarith.c (value_binop): Handle TYPE_CODE_BOOL as well as TYPE_CODE_INT and TYPE_CODE_FLOAT. * valprint.c (val_print): Print TYPE_CODE_BOOL type values as "TRUE" or "FALSE". * valprint.c (typedef_print): Add case for language_chill. * values.c (value_from_longest): Handle TYPE_CODE_BOOL.
Diffstat (limited to 'gdb/eval.c')
-rw-r--r--gdb/eval.c74
1 files changed, 32 insertions, 42 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index 55fca20..82e02ce 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -237,6 +237,11 @@ evaluate_subexp (expect_type, exp, pos, noside)
(*pos) += 2;
return value_of_register (longest_to_int (exp->elts[pc + 1].longconst));
+ case OP_BOOL:
+ (*pos) += 2;
+ return value_from_longest (builtin_type_chill_bool,
+ exp->elts[pc + 1].longconst);
+
case OP_INTERNALVAR:
(*pos) += 2;
return value_of_internalvar (exp->elts[pc + 1].internalvar);
@@ -252,7 +257,7 @@ evaluate_subexp (expect_type, exp, pos, noside)
case TERNOP_COND:
/* Skip third and second args to evaluate the first one. */
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
- if (value_zerop (arg1))
+ if (value_logical_not (arg1))
{
evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
return evaluate_subexp (NULL_TYPE, exp, pos, noside);
@@ -342,9 +347,8 @@ evaluate_subexp (expect_type, exp, pos, noside)
nargs = longest_to_int (exp->elts[pc + 1].longconst) + 1;
/* First, evaluate the structure into arg2 */
pc2 = (*pos)++;
- /* type = exp->elts[pc2 + 1].type; */
- tem2 = strlen (&exp->elts[pc2 + 2].string);
- *pos += 3 + (tem2 + sizeof (union exp_element)) / sizeof (union exp_element);
+ tem2 = strlen (&exp->elts[pc2 + 1].string);
+ *pos += 2 + (tem2 + sizeof (union exp_element)) / sizeof (union exp_element);
if (noside == EVAL_SKIP)
goto nosideret;
@@ -377,13 +381,9 @@ evaluate_subexp (expect_type, exp, pos, noside)
int static_memfuncp;
value temp = arg2;
- /* argvec[0] gets the method;
- argvec[1] gets the 'this' pointer (unless static) (from arg2);
- the remaining args go into the rest of argvec. */
-
argvec[1] = arg2;
argvec[0] =
- value_struct_elt (&temp, argvec+1, &exp->elts[pc2 + 2].string,
+ value_struct_elt (&temp, argvec+1, &exp->elts[pc2 + 1].string,
&static_memfuncp,
op == STRUCTOP_STRUCT
? "structure" : "structure pointer");
@@ -428,50 +428,40 @@ evaluate_subexp (expect_type, exp, pos, noside)
return call_function_by_hand (argvec[0], nargs, argvec + 1);
case STRUCTOP_STRUCT:
- tem = strlen (&exp->elts[pc + 2].string);
- (*pos) += 3 + ((tem + sizeof (union exp_element))
+ tem = strlen (&exp->elts[pc + 1].string);
+ (*pos) += 2 + ((tem + sizeof (union exp_element))
/ sizeof (union exp_element));
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
- if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR)
- goto handle_structop_ptr;
- type = exp->elts[pc + 1].type;
- if (type)
- arg1 = value_ind (value_cast (lookup_pointer_type (type),
- value_addr (arg1)));
if (noside == EVAL_SKIP)
goto nosideret;
if (noside == EVAL_AVOID_SIDE_EFFECTS)
return value_zero (lookup_struct_elt_type (VALUE_TYPE (arg1),
- &exp->elts[pc + 2].string,
+ &exp->elts[pc + 1].string,
0),
lval_memory);
else
{
value temp = arg1;
- return value_struct_elt (&temp, (value *)0, &exp->elts[pc + 2].string,
+ return value_struct_elt (&temp, (value *)0, &exp->elts[pc + 1].string,
(int *) 0, "structure");
}
case STRUCTOP_PTR:
- tem = strlen (&exp->elts[pc + 2].string);
- (*pos) += 3 + (tem + sizeof (union exp_element)) / sizeof (union exp_element);
+ tem = strlen (&exp->elts[pc + 1].string);
+ (*pos) += 2 + (tem + sizeof (union exp_element)) / sizeof (union exp_element);
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
- handle_structop_ptr:
- type = exp->elts[pc + 1].type;
- if (type)
- arg1 = value_cast (lookup_pointer_type (type), arg1);
if (noside == EVAL_SKIP)
goto nosideret;
if (noside == EVAL_AVOID_SIDE_EFFECTS)
return value_zero (lookup_struct_elt_type (TYPE_TARGET_TYPE
(VALUE_TYPE (arg1)),
- &exp->elts[pc + 2].string,
+ &exp->elts[pc + 1].string,
0),
lval_memory);
else
{
value temp = arg1;
- return value_struct_elt (&temp, (value *)0, &exp->elts[pc + 2].string,
+ return value_struct_elt (&temp, (value *)0, &exp->elts[pc + 1].string,
(int *) 0, "structure pointer");
}
@@ -552,9 +542,9 @@ evaluate_subexp (expect_type, exp, pos, noside)
case BINOP_REM:
case BINOP_LSH:
case BINOP_RSH:
- case BINOP_LOGAND:
- case BINOP_LOGIOR:
- case BINOP_LOGXOR:
+ case BINOP_BITWISE_AND:
+ case BINOP_BITWISE_IOR:
+ case BINOP_BITWISE_XOR:
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
if (noside == EVAL_SKIP)
@@ -592,7 +582,7 @@ evaluate_subexp (expect_type, exp, pos, noside)
else
return value_subscript (arg1, arg2);
- case BINOP_AND:
+ case BINOP_LOGICAL_AND:
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
if (noside == EVAL_SKIP)
{
@@ -611,14 +601,14 @@ evaluate_subexp (expect_type, exp, pos, noside)
}
else
{
- tem = value_zerop (arg1);
+ tem = value_logical_not (arg1);
arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
(tem ? EVAL_SKIP : noside));
return value_from_longest (builtin_type_int,
- (LONGEST) (!tem && !value_zerop (arg2)));
+ (LONGEST) (!tem && !value_logical_not (arg2)));
}
- case BINOP_OR:
+ case BINOP_LOGICAL_OR:
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
if (noside == EVAL_SKIP)
{
@@ -637,11 +627,11 @@ evaluate_subexp (expect_type, exp, pos, noside)
}
else
{
- tem = value_zerop (arg1);
+ tem = value_logical_not (arg1);
arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
(!tem ? EVAL_SKIP : noside));
return value_from_longest (builtin_type_int,
- (LONGEST) (!tem || !value_zerop (arg2)));
+ (LONGEST) (!tem || !value_logical_not (arg2)));
}
case BINOP_EQUAL:
@@ -760,19 +750,19 @@ evaluate_subexp (expect_type, exp, pos, noside)
else
return value_neg (arg1);
- case UNOP_LOGNOT:
+ case UNOP_COMPLEMENT:
/* C++: check for and handle destructor names. */
op = exp->elts[*pos].opcode;
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
- if (unop_user_defined_p (UNOP_LOGNOT, arg1))
- return value_x_unop (arg1, UNOP_LOGNOT);
+ if (unop_user_defined_p (UNOP_COMPLEMENT, arg1))
+ return value_x_unop (arg1, UNOP_COMPLEMENT);
else
- return value_lognot (arg1);
+ return value_complement (arg1);
- case UNOP_ZEROP:
+ case UNOP_LOGICAL_NOT:
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
@@ -780,7 +770,7 @@ evaluate_subexp (expect_type, exp, pos, noside)
return value_x_unop (arg1, op);
else
return value_from_longest (builtin_type_int,
- (LONGEST) value_zerop (arg1));
+ (LONGEST) value_logical_not (arg1));
case UNOP_IND:
if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR)