aboutsummaryrefslogtreecommitdiff
path: root/gdb/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/eval.c')
-rw-r--r--gdb/eval.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index 0694d15..110a129 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1,5 +1,5 @@
/* Evaluate expressions for GDB.
- Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
+ Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
This file is part of GDB.
@@ -19,7 +19,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "value.h"
#include "expression.h"
@@ -96,7 +95,7 @@ parse_to_comma_and_eval (expp)
}
/* Evaluate an expression in internal prefix form
- such as is constructed by expread.y.
+ such as is constructed by parse.y.
See expression.h for info on the format of an expression. */
@@ -109,7 +108,7 @@ static value evaluate_subexp_with_coercion ();
enum noside
{ EVAL_NORMAL,
EVAL_SKIP, /* Only effect is to increment pos. */
- EVAL_AVOID_SIDE_EFFECTS, /* Don't modify any variables or
+ 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
@@ -966,7 +965,7 @@ evaluate_subexp_for_address (exp, pos, noside)
{
value x = evaluate_subexp (NULL_TYPE, exp, pos, noside);
if (VALUE_LVAL (x) == lval_memory)
- return value_zero (TYPE_POINTER_TYPE (VALUE_TYPE (x)),
+ return value_zero (lookup_pointer_type (VALUE_TYPE (x)),
not_lval);
else
error ("Attempt to take address of non-lval");
@@ -1052,3 +1051,23 @@ evaluate_subexp_for_sizeof (exp, pos)
(LONGEST) TYPE_LENGTH (VALUE_TYPE (val)));
}
}
+
+/* Parse a type expression in the string [P..P+LENGTH). */
+
+struct type *
+parse_and_eval_type (p, length)
+ char *p;
+ int length;
+{
+ char *tmp = (char *)alloca (length + 4);
+ struct expression *expr;
+ tmp[0] = '(';
+ bcopy (p, tmp+1, length);
+ tmp[length+1] = ')';
+ tmp[length+2] = '0';
+ tmp[length+3] = '\0';
+ expr = parse_expression (tmp);
+ if (expr->elts[0].opcode != UNOP_CAST)
+ error ("Internal error in eval_type.");
+ return expr->elts[1].type;
+}