/* 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.
#include <stdio.h>
#include "defs.h"
-#include "param.h"
#include "symtab.h"
#include "value.h"
#include "expression.h"
}
\f
/* 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. */
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
{
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");
(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;
+}