This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
FYI: consolidate value_of_this and value_of_local
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 17 Jun 2011 14:29:17 -0600
- Subject: FYI: consolidate value_of_this and value_of_local
I'm checking this in on the trunk.
There's no reason to have both value_of_this and value_of_local; one
will do. This patch removes the latter. This also removes a use of
current_language from the value code -- always a good thing.
Built and regtested by the buildbot.
Tom
2011-06-17 Tom Tromey <tromey@redhat.com>
* value.h (value_of_this): Update.
(value_of_local): Remove.
* valops.c (value_of_this): Rename from value_of_local. Change
parameters.
* p-exp.y (exp): Update.
(variable): Likewise.
* eval.c (evaluate_subexp_standard) <OP_THIS>: Use value_of_this.
Index: eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.150
diff -u -r1.150 eval.c
--- eval.c 17 Jun 2011 20:24:22 -0000 1.150
+++ eval.c 17 Jun 2011 20:27:19 -0000
@@ -2830,7 +2830,7 @@
case OP_THIS:
(*pos) += 1;
- return value_of_local (exp->language_defn->la_name_of_this, 1);
+ return value_of_this (exp->language_defn, 1);
case OP_TYPE:
/* The value is not supposed to be used. This is here to make it
Index: p-exp.y
===================================================================
RCS file: /cvs/src/src/gdb/p-exp.y,v
retrieving revision 1.58
diff -u -r1.58 p-exp.y
--- p-exp.y 18 Mar 2011 13:51:41 -0000 1.58
+++ p-exp.y 17 Jun 2011 20:27:19 -0000
@@ -612,7 +612,7 @@
write_exp_elt_opcode (OP_THIS);
write_exp_elt_opcode (OP_THIS);
/* We need type of this. */
- this_val = value_of_this (0);
+ this_val = value_of_this (parse_language, 0);
if (this_val)
this_type = value_type (this_val);
else
@@ -760,7 +760,7 @@
write_exp_string ($1.stoken);
write_exp_elt_opcode (STRUCTOP_PTR);
/* We need type of this. */
- this_val = value_of_this (0);
+ this_val = value_of_this (parse_language, 0);
if (this_val)
this_type = value_type (this_val);
else
Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.277
diff -u -r1.277 valops.c
--- valops.c 17 Jun 2011 20:24:22 -0000 1.277
+++ valops.c 17 Jun 2011 20:27:20 -0000
@@ -3601,12 +3601,13 @@
inappropriate context. */
struct value *
-value_of_local (const char *name, int complain)
+value_of_this (const struct language_defn *lang, int complain)
{
struct symbol *func, *sym;
struct block *b;
struct value * ret;
struct frame_info *frame;
+ const char *name = lang->la_name_of_this;
if (!name)
{
@@ -3660,18 +3661,6 @@
return ret;
}
-/* C++/Objective-C: return the value of the class instance variable,
- if one exists. Flag COMPLAIN signals an error if the request is
- made in an inappropriate context. */
-
-struct value *
-value_of_this (int complain)
-{
- if (!current_language->la_name_of_this)
- return 0;
- return value_of_local (current_language->la_name_of_this, complain);
-}
-
/* Create a slice (sub-string, sub-array) of ARRAY, that is LENGTH
elements long, starting at LOWBOUND. The result has the same lower
bound as the original ARRAY. */
Index: value.h
===================================================================
RCS file: /cvs/src/src/gdb/value.h,v
retrieving revision 1.180
diff -u -r1.180 value.h
--- value.h 12 May 2011 17:40:54 -0000 1.180
+++ value.h 17 Jun 2011 20:27:21 -0000
@@ -715,7 +715,8 @@
/* C++ */
-extern struct value *value_of_this (int complain);
+extern struct value *value_of_this (const struct language_defn *lang,
+ int complain);
extern struct value *value_x_binop (struct value *arg1, struct value *arg2,
enum exp_opcode op,
@@ -835,8 +836,6 @@
extern struct value *value_allocate_space_in_inferior (int);
-extern struct value *value_of_local (const char *name, int complain);
-
extern struct value *value_subscripted_rvalue (struct value *array,
LONGEST index, int lowerbound);