This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: remove a couple uses of current_language


I'm checking this in.

This removes a couple uses of current_language from the expression
evaluator.  It particular it removes the uses from ptrmath_type_p and
from CAST_IS_CONVERSION.

Built and regtested on x86-64 (compile farm).

More uses of current_language remain, but they are buried in valops.c
and perhaps elsewhere, not eval.c.  Ultimately I would like to see all
these uses removed.  Ideally the expression evaluator should not depend
on any globals.

Tom

2010-05-10  Tom Tromey  <tromey@redhat.com>

	* eval.c (ptrmath_type_p): Add 'lang' argument.
	(evaluate_subexp_standard): Update.
	(evaluate_subexp_with_coercion): Update.
	* language.h (CAST_IS_CONVERSION): Add 'LANG' argument.

Index: eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.131
diff -u -r1.131 eval.c
--- eval.c	7 May 2010 14:46:26 -0000	1.131
+++ eval.c	10 May 2010 19:42:44 -0000
@@ -633,7 +633,7 @@
 }
 
 static int
-ptrmath_type_p (struct type *type)
+ptrmath_type_p (const struct language_defn *lang, struct type *type)
 {
   type = check_typedef (type);
   if (TYPE_CODE (type) == TYPE_CODE_REF)
@@ -646,7 +646,7 @@
       return 1;
 
     case TYPE_CODE_ARRAY:
-      return current_language->c_style_arrays;
+      return lang->c_style_arrays;
 
     default:
       return 0;
@@ -1906,10 +1906,12 @@
       op = exp->elts[pc + 1].opcode;
       if (binop_user_defined_p (op, arg1, arg2))
 	return value_x_binop (arg1, arg2, BINOP_ASSIGN_MODIFY, op, noside);
-      else if (op == BINOP_ADD && ptrmath_type_p (value_type (arg1))
+      else if (op == BINOP_ADD && ptrmath_type_p (exp->language_defn,
+						  value_type (arg1))
 	       && is_integral_type (value_type (arg2)))
 	arg2 = value_ptradd (arg1, value_as_long (arg2));
-      else if (op == BINOP_SUB && ptrmath_type_p (value_type (arg1))
+      else if (op == BINOP_SUB && ptrmath_type_p (exp->language_defn,
+						  value_type (arg1))
 	       && is_integral_type (value_type (arg2)))
 	arg2 = value_ptradd (arg1, - value_as_long (arg2));
       else
@@ -1935,10 +1937,10 @@
 	goto nosideret;
       if (binop_user_defined_p (op, arg1, arg2))
 	return value_x_binop (arg1, arg2, op, OP_NULL, noside);
-      else if (ptrmath_type_p (value_type (arg1))
+      else if (ptrmath_type_p (exp->language_defn, value_type (arg1))
 	       && is_integral_type (value_type (arg2)))
 	return value_ptradd (arg1, value_as_long (arg2));
-      else if (ptrmath_type_p (value_type (arg2))
+      else if (ptrmath_type_p (exp->language_defn, value_type (arg2))
 	       && is_integral_type (value_type (arg1)))
 	return value_ptradd (arg2, value_as_long (arg1));
       else
@@ -1954,14 +1956,14 @@
 	goto nosideret;
       if (binop_user_defined_p (op, arg1, arg2))
 	return value_x_binop (arg1, arg2, op, OP_NULL, noside);
-      else if (ptrmath_type_p (value_type (arg1))
-	       && ptrmath_type_p (value_type (arg2)))
+      else if (ptrmath_type_p (exp->language_defn, value_type (arg1))
+	       && ptrmath_type_p (exp->language_defn, value_type (arg2)))
 	{
 	  /* FIXME -- should be ptrdiff_t */
 	  type = builtin_type (exp->gdbarch)->builtin_long;
 	  return value_from_longest (type, value_ptrdiff (arg1, arg2));
 	}
-      else if (ptrmath_type_p (value_type (arg1))
+      else if (ptrmath_type_p (exp->language_defn, value_type (arg1))
 	       && is_integral_type (value_type (arg2)))
 	return value_ptradd (arg1, - value_as_long (arg2));
       else
@@ -2031,8 +2033,8 @@
       error (_("':' operator used in invalid context"));
 
     case BINOP_SUBSCRIPT:
-      arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
-      arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
+      arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+      arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
       if (noside == EVAL_SKIP)
 	goto nosideret;
       if (binop_user_defined_p (op, arg1, arg2))
@@ -2572,7 +2574,7 @@
 	}
       else
 	{
-	  if (ptrmath_type_p (value_type (arg1)))
+	  if (ptrmath_type_p (exp->language_defn, value_type (arg1)))
 	    arg2 = value_ptradd (arg1, 1);
 	  else
 	    {
@@ -2595,7 +2597,7 @@
 	}
       else
 	{
-	  if (ptrmath_type_p (value_type (arg1)))
+	  if (ptrmath_type_p (exp->language_defn, value_type (arg1)))
 	    arg2 = value_ptradd (arg1, -1);
 	  else
 	    {
@@ -2618,7 +2620,7 @@
 	}
       else
 	{
-	  if (ptrmath_type_p (value_type (arg1)))
+	  if (ptrmath_type_p (exp->language_defn, value_type (arg1)))
 	    arg2 = value_ptradd (arg1, 1);
 	  else
 	    {
@@ -2642,7 +2644,7 @@
 	}
       else
 	{
-	  if (ptrmath_type_p (value_type (arg1)))
+	  if (ptrmath_type_p (exp->language_defn, value_type (arg1)))
 	    arg2 = value_ptradd (arg1, -1);
 	  else
 	    {
@@ -2832,7 +2834,7 @@
       var = exp->elts[pc + 2].symbol;
       type = check_typedef (SYMBOL_TYPE (var));
       if (TYPE_CODE (type) == TYPE_CODE_ARRAY
-	  && CAST_IS_CONVERSION)
+	  && CAST_IS_CONVERSION (exp->language_defn))
 	{
 	  (*pos) += 4;
 	  val = address_of_variable (var, exp->elts[pc + 1].block);
Index: language.h
===================================================================
RCS file: /cvs/src/src/gdb/language.h,v
retrieving revision 1.65
diff -u -r1.65 language.h
--- language.h	2 May 2010 21:14:59 -0000	1.65
+++ language.h	10 May 2010 19:42:47 -0000
@@ -381,9 +381,9 @@
 
 /* "cast" really means conversion */
 /* FIXME -- should be a setting in language_defn */
-#define CAST_IS_CONVERSION (current_language->la_language == language_c  || \
-			    current_language->la_language == language_cplus || \
-			    current_language->la_language == language_objc)
+#define CAST_IS_CONVERSION(LANG) ((LANG)->la_language == language_c  || \
+				  (LANG)->la_language == language_cplus || \
+				  (LANG)->la_language == language_objc)
 
 extern void language_info (int);
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]