/* Evaluate expressions for GDB.
- Copyright (C) 1986-2003, 2005-2012 Free Software Foundation, Inc.
+ Copyright (C) 1986-2013 Free Software Foundation, Inc.
This file is part of GDB.
and return the result as a number. */
CORE_ADDR
-parse_and_eval_address (char *exp)
+parse_and_eval_address (const char *exp)
{
struct expression *expr = parse_expression (exp);
CORE_ADDR addr;
}
struct value *
-parse_and_eval (char *exp)
+parse_and_eval (const char *exp)
{
struct expression *expr = parse_expression (exp);
struct value *val;
EXPP is advanced to point to the comma. */
struct value *
-parse_to_comma_and_eval (char **expp)
+parse_to_comma_and_eval (const char **expp)
{
struct expression *expr = parse_exp_1 (expp, 0, (struct block *) 0, 1);
struct value *val;
if (noside == EVAL_AVOID_SIDE_EFFECTS)
return value_zero (SYMBOL_TYPE (sym), not_lval);
- if (SYMBOL_CLASS (sym) != LOC_COMPUTED
+ if (SYMBOL_COMPUTED_OPS (sym) == NULL
|| SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry == NULL)
error (_("Symbol \"%s\" does not have any specific entry value"),
SYMBOL_PRINT_NAME (sym));
alloca (sizeof (struct value *) * (nargs + 3));
if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
{
- nargs++;
/* First, evaluate the structure into arg2. */
pc2 = (*pos)++;
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
- if (TYPE_CODE (check_typedef (value_type (arg1)))
- != TYPE_CODE_METHODPTR)
- error (_("Non-pointer-to-member value used in pointer-to-member "
- "construct"));
+ type = check_typedef (value_type (arg1));
+ if (TYPE_CODE (type) == TYPE_CODE_METHODPTR)
+ {
+ if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ arg1 = value_zero (TYPE_TARGET_TYPE (type), not_lval);
+ else
+ arg1 = cplus_method_ptr_to_value (&arg2, arg1);
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ /* Now, say which argument to start evaluating from. */
+ nargs++;
+ tem = 2;
+ argvec[1] = arg2;
+ }
+ else if (TYPE_CODE (type) == TYPE_CODE_MEMBERPTR)
{
- struct type *method_type = check_typedef (value_type (arg1));
+ struct type *type_ptr
+ = lookup_pointer_type (TYPE_DOMAIN_TYPE (type));
+ struct type *target_type_ptr
+ = lookup_pointer_type (TYPE_TARGET_TYPE (type));
- arg1 = value_zero (method_type, not_lval);
+ /* Now, convert these values to an address. */
+ arg2 = value_cast (type_ptr, arg2);
+
+ mem_offset = value_as_long (arg1);
+
+ arg1 = value_from_pointer (target_type_ptr,
+ value_as_long (arg2) + mem_offset);
+ arg1 = value_ind (arg1);
+ tem = 1;
}
else
- arg1 = cplus_method_ptr_to_value (&arg2, arg1);
-
- /* Now, say which argument to start evaluating from. */
- tem = 2;
+ error (_("Non-pointer-to-member value used in pointer-to-member "
+ "construct"));
}
else if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR)
{
find_overload_match (&argvec[1], nargs, func_name,
NON_METHOD, /* not method */
- 0, /* strict match */
NULL, NULL, /* pass NULL symbol since
symbol is unknown */
NULL, &symp, NULL, 0);
(void) find_overload_match (&argvec[1], nargs, tstr,
METHOD, /* method */
- 0, /* strict match */
&arg2, /* the object */
NULL, &valp, NULL,
&static_memfuncp, 0);
}
else if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
{
- argvec[1] = arg2;
+ /* Pointer to member. argvec[1] is already set up. */
argvec[0] = arg1;
}
else if (op == OP_VAR_VALUE || (op == OP_SCOPE && function != NULL))
(void) find_overload_match (&argvec[1], nargs,
NULL, /* no need for name */
NON_METHOD, /* not method */
- 0, /* strict match */
NULL, function, /* the function */
NULL, &symp, NULL, no_adl);
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
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,
- 0),
- lval_memory);
- else
- {
- struct value *temp = arg1;
-
- return value_struct_elt (&temp, NULL, &exp->elts[pc + 2].string,
- NULL, "structure");
- }
+ /* Also handle EVAL_AVOID_SIDE_EFFECTS. */
+ return value_struct_elt (&arg1, NULL, &exp->elts[pc + 2].string,
+ NULL, "structure");
case STRUCTOP_PTR:
tem = longest_to_int (exp->elts[pc + 1].longconst);
}
}
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value_zero (lookup_struct_elt_type (value_type (arg1),
- &exp->elts[pc + 2].string,
- 0),
- lval_memory);
- else
- {
- struct value *temp = arg1;
-
- return value_struct_elt (&temp, NULL, &exp->elts[pc + 2].string,
- NULL, "structure pointer");
- }
+ /* Also handle EVAL_AVOID_SIDE_EFFECTS. */
+ return value_struct_elt (&arg1, NULL, &exp->elts[pc + 2].string,
+ NULL, "structure pointer");
case STRUCTOP_MEMBER:
case STRUCTOP_MPTR:
{
struct type *type = check_typedef (value_type (x));
- if (VALUE_LVAL (x) == lval_memory || value_must_coerce_to_target (x))
- return value_zero (lookup_pointer_type (value_type (x)),
- not_lval);
- else if (TYPE_CODE (type) == TYPE_CODE_REF)
+ if (TYPE_CODE (type) == TYPE_CODE_REF)
return value_zero (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
not_lval);
+ else if (VALUE_LVAL (x) == lval_memory || value_must_coerce_to_target (x))
+ return value_zero (lookup_pointer_type (value_type (x)),
+ not_lval);
else
error (_("Attempt to take address of "
"value not located in memory."));