[PATCH 2/4] factor code

Yao Qi
2012-11-22T07:32:45Z

This is a code refactor to pave the way for the following patches.
Functionality of GDB is not affected.

gdb:

2012-11-22 Daniel Jacobowitz <dan@codesourcery.com>
Yao Qi <yao@codesourcery.com>

* eval.c (evaluate_subexp_standard): Code factor.
---
gdb/eval.c | 27 +++++++++++++--------------
1 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/gdb/eval.c b/gdb/eval.c
index f655957..9957d02 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1364,7 +1364,6 @@ evaluate_subexp_standard (struct type *expect_type,
alloca (sizeof (struct value *) * (nargs + 3));
if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
{
- nargs++;
/* First, evaluate the structure into arg2. */
pc2 = (*pos)++;

@@ -1388,22 +1387,22 @@ evaluate_subexp_standard (struct type *expect_type,

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"));
-
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ type = check_typedef (value_type (arg1));
+ if (TYPE_CODE (type) == TYPE_CODE_METHODPTR)
{
- struct type *method_type = check_typedef (value_type (arg1));
+ if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ arg1 = value_zero (type, not_lval);
+ else
+ arg1 = cplus_method_ptr_to_value (&arg2, arg1);

- arg1 = value_zero (method_type, not_lval);
+ /* Now, say which argument to start evaluating from. */
+ nargs++;
+ tem = 2;
+ argvec[1] = arg2;
}
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)
{
@@ -1654,7 +1653,7 @@ evaluate_subexp_standard (struct type *expect_type,
}
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))
--
1.7.7.6