public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-swagiaal-using-directive: Recommit: Added support for ADL function lookup. Patch 2.
@ 2009-04-29 15:53 swagiaal
  0 siblings, 0 replies; only message in thread
From: swagiaal @ 2009-04-29 15:53 UTC (permalink / raw)
  To: archer-commits

The branch, archer-swagiaal-using-directive has been updated
       via  7d1e49d1b6be54d563280f13fd69672faa98ef6f (commit)
       via  4456fc97dbe1c9bcd6de19b73100962829a7962f (commit)
       via  8766e4cc15d35573ee3780fc24a56110666ee9f4 (commit)
       via  24b05d02163fcceab0676aa1eb0bce2becf3fa9f (commit)
       via  759518daa029fd492d2a4bfac65bda5de6ce7a7a (commit)
      from  a95add1ecf6d2e6fa4074617d2ae61ab863fdb8a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 7d1e49d1b6be54d563280f13fd69672faa98ef6f
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Wed Apr 29 11:28:57 2009 -0400

    Recommit: Added support for ADL function lookup. Patch 2.
    
    2009-04-28  Sami Wagiaalla  <swagiaal@redhat.com>
    
       * valops.c (find_overload_match): Added adl argument.
       Perform argument defined lookup when requested.
       * parse.c (operator_length_standard): Added length information for
       OP_ADL_FUNC.
       * expression.h: Added OP_ADL_FUNC.
       * c-exp.y: Created token UNKOWN_NAME.
       Created grammer rules for UNKOWN_NAME, and adl_function.
       * eval.c (evaluate_subexp_standard): Added handling for for OP_ADL_FUNC.

commit 4456fc97dbe1c9bcd6de19b73100962829a7962f
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Wed Apr 29 11:01:04 2009 -0400

    Revert "Added support for ADL function lookup. Patch 2."
    
    This reverts commit 8766e4cc15d35573ee3780fc24a56110666ee9f4.

commit 8766e4cc15d35573ee3780fc24a56110666ee9f4
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Tue Apr 28 14:25:22 2009 -0400

    Added support for ADL function lookup. Patch 2.
    
    +2009-04-28  Sami Wagiaalla  <swagiaal@redhat.com>
    +
    +	* valops.c (find_overload_match): Added adl argument.
    +	Perform argument defined lookup when requested.
    +	* parse.c (operator_length_standard): Added length information for
    +        OP_ADL_FUNC.
    +        * expression.h: Added OP_ADL_FUNC.
    +        * c-exp.y: Created token UNKOWN_NAME.
    +        Created grammer rules for UNKOWN_NAME, and adl_function.
    +        * eval.c (evaluate_subexp_standard): Added handling for for OP_ADL_FUNC.
    +
     2009-03-12  Sami Wagiaalla  <swagiaal@redhat.com>
    
     	* valops.c (find_overload_match): Creates its own list of argument

commit 24b05d02163fcceab0676aa1eb0bce2becf3fa9f
Merge: 759518daa029fd492d2a4bfac65bda5de6ce7a7a a95add1ecf6d2e6fa4074617d2ae61ab863fdb8a
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Tue Apr 28 14:21:43 2009 -0400

    Merge branch 'archer-swagiaal-using-directive' of ssh://sourceware.org/git/archer into archer-swagiaal-using-directive

commit 759518daa029fd492d2a4bfac65bda5de6ce7a7a
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Tue Apr 28 11:02:13 2009 -0400

    Revert "Add support for argument dependent lookup functions."
    
    This reverts commit e1178d9880da2cae617ef30f1644cb2c5e04cc0c.

-----------------------------------------------------------------------

Summary of changes:
 gdb/c-exp.y  |    3 +-
 gdb/eval.c   |  576 +++++++++++++++++++++++++--------------------------------
 gdb/parse.c  |    4 +-
 gdb/valops.c |   35 ++++-
 gdb/value.h  |    2 +-
 5 files changed, 290 insertions(+), 330 deletions(-)

First 500 lines of diff:
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 7b0b299..7e12e0c 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -820,8 +820,7 @@ variable:	name_not_typename
 			}
 	;
 
-space_identifier : '@' NAME
-		|  '@' UNKNOWN_NAME
+space_identifier : '@' UNKNOWN_NAME
 		{ push_type_address_space (copy_name ($2.stoken));
 		  push_type (tp_space_identifier);
 		}
diff --git a/gdb/eval.c b/gdb/eval.c
index 13760da..0fa10c7 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -672,9 +672,6 @@ evaluate_subexp_standard (struct type *expect_type,
   struct type **arg_types;
   int save_pos1;
 
-  static char** prefix_array = NULL;
-  static int    prefix_array_size = 0;
-
   pc = (*pos)++;
   op = exp->elts[pc].opcode;
 
@@ -708,56 +705,6 @@ evaluate_subexp_standard (struct type *expect_type,
 				  exp->elts[pc + 2].decfloatconst);
 
     case OP_ADL_FUNC:
-      {
-        char *func_name;
-        char *prefix;
-        char *concatenated_name;
-        struct symbol *sym = NULL;
-        int string_length;
-        int i = 0;
-        int string_pc = pc + 3;
-
-        string_length = longest_to_int (exp->elts[string_pc].longconst);
-
-        func_name = (char*) alloca(string_length+1);
-        strcpy (func_name, &exp->elts[string_pc + 1].string);
-        sym = exp->elts[pc + 2].symbol;
-        if (sym == NULL)
-          { /* Symbol has not been resolved yet. */
-            for (i = 0; sym == NULL && i < prefix_array_size; i++)
-              {
-                prefix = prefix_array[i];
-                concatenated_name = alloca (strlen (prefix) + 1 + strlen (func_name) + 1);
-                strcpy(concatenated_name, prefix);
-                strcat(concatenated_name, "::");
-                strcat(concatenated_name, func_name);
-
-                sym = lookup_symbol(concatenated_name,
-                    exp->elts[pc + 1].block, VAR_DOMAIN, (int *) NULL);
-
-                if (sym)
-                  {
-                    exp->elts[pc + 2].symbol = sym;
-                    break;
-                  }
-              }
-
-            /* free prefix_array */
-            for (i = 0; i < prefix_array_size; ++i)
-              {
-                xfree(prefix_array[i]);
-              }
-            xfree(prefix_array);
-            prefix_array = NULL;
-            prefix_array_size = 0;
-          }
-
-        if (sym == NULL)
-          {
-            error("No function \"%s\" in specified context.", func_name);
-          }
-      }
-      /* Now fall through for normal symbol evaluation  */
     case OP_VAR_VALUE:
       (*pos) += 3;
       if (noside == EVAL_SKIP)
@@ -1330,283 +1277,266 @@ evaluate_subexp_standard (struct type *expect_type,
       break;
 
     case OP_FUNCALL:
-      {
-        int adl_func_pos = 0;
-        int adl_func = 0;
-
-        (*pos) += 2;
-        op = exp->elts[*pos].opcode;
-        nargs = longest_to_int (exp->elts[pc + 1].longconst);
-        /* Allocate arg vector, including space for the function to be
-           called in argvec[0] and a terminating NULL */
-        argvec = (struct value **) alloca (sizeof (struct value *) * (nargs + 3));
-        if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
-          {
-            nargs++;
-            /* First, evaluate the structure into arg2 */
-            pc2 = (*pos)++;
+      (*pos) += 2;
+      op = exp->elts[*pos].opcode;
+      nargs = longest_to_int (exp->elts[pc + 1].longconst);
+      /* Allocate arg vector, including space for the function to be
+         called in argvec[0] and a terminating NULL */
+      argvec = (struct value **) alloca (sizeof (struct value *) * (nargs + 3));
+      if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
+	{
+	  nargs++;
+	  /* First, evaluate the structure into arg2 */
+	  pc2 = (*pos)++;
 
-            if (noside == EVAL_SKIP)
-              goto nosideret;
+	  if (noside == EVAL_SKIP)
+	    goto nosideret;
 
-            if (op == STRUCTOP_MEMBER)
-              {
-                arg2 = evaluate_subexp_for_address (exp, pos, noside);
-              }
-            else
-              {
-                arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
-              }
+	  if (op == STRUCTOP_MEMBER)
+	    {
+	      arg2 = evaluate_subexp_for_address (exp, pos, noside);
+	    }
+	  else
+	    {
+	      arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	    }
 
-            /* If the function is a virtual function, then the
-	       aggregate value (providing the structure) plays
-	       its part by providing the vtable.  Otherwise,
-	       it is just along for the ride: call the function
-	       directly.  */
+	  /* If the function is a virtual function, then the
+	     aggregate value (providing the structure) plays
+	     its part by providing the vtable.  Otherwise,
+	     it is just along for the ride: call the function
+	     directly.  */
 
-            arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	  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 (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)
-              {
-                struct type *method_type = check_typedef (value_type (arg1));
-                arg1 = value_zero (method_type, not_lval);
-              }
-            else
-              arg1 = cplus_method_ptr_to_value (&arg2, arg1);
+	  if (noside == EVAL_AVOID_SIDE_EFFECTS)
+	    {
+	      struct type *method_type = check_typedef (value_type (arg1));
+	      arg1 = value_zero (method_type, not_lval);
+	    }
+	  else
+	    arg1 = cplus_method_ptr_to_value (&arg2, arg1);
 
-            /* Now, say which argument to start evaluating from */
-            tem = 2;
-          }
-        else if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR)
-          {
-            /* Hair for method invocations */
-            int tem2;
-
-            nargs++;
-            /* First, evaluate the structure into arg2 */
-            pc2 = (*pos)++;
-            tem2 = longest_to_int (exp->elts[pc2 + 1].longconst);
-            *pos += 3 + BYTES_TO_EXP_ELEM (tem2 + 1);
-            if (noside == EVAL_SKIP)
-              goto nosideret;
-
-            if (op == STRUCTOP_STRUCT)
-              {
-                /* If v is a variable in a register, and the user types
-	           v.method (), this will produce an error, because v has
-	           no address.
-
-  	           A possible way around this would be to allocate a
-	           copy of the variable on the stack, copy in the
-	           contents, call the function, and copy out the
-	           contents.  I.e. convert this from call by reference
-	           to call by copy-return (or whatever it's called).
-	           However, this does not work because it is not the
-	           same: the method being called could stash a copy of
-	           the address, and then future uses through that address
-	           (after the method returns) would be expected to
-	           use the variable itself, not some copy of it.  */
-                arg2 = evaluate_subexp_for_address (exp, pos, noside);
-              }
-            else
-              {
-                arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
-              }
-            /* Now, say which argument to start evaluating from */
-            tem = 2;
-          }
-        else if ( op == OP_ADL_FUNC )
-          {
-            int temp;
-            adl_func_pos = *pos;
-            tem = 1;
-            adl_func = 1;
-
-            prefix_array = xzalloc (sizeof(char*) * nargs);
-            temp = longest_to_int (exp->elts[adl_func_pos + 3].longconst);
-            (*pos)++; // block
-            (*pos)++; // symbol
-            (*pos)++; // strlng
-            (*pos) += 3 + BYTES_TO_EXP_ELEM (temp + 1); // string + a null terminator
-          }
-        else{
-          /* Non-method function call */
+	  /* Now, say which argument to start evaluating from */
+	  tem = 2;
+	}
+      else if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR)
+	{
+	  /* Hair for method invocations */
+	  int tem2;
+
+	  nargs++;
+	  /* First, evaluate the structure into arg2 */
+	  pc2 = (*pos)++;
+	  tem2 = longest_to_int (exp->elts[pc2 + 1].longconst);
+	  *pos += 3 + BYTES_TO_EXP_ELEM (tem2 + 1);
+	  if (noside == EVAL_SKIP)
+	    goto nosideret;
+
+	  if (op == STRUCTOP_STRUCT)
+	    {
+	      /* If v is a variable in a register, and the user types
+	         v.method (), this will produce an error, because v has
+	         no address.
+
+	         A possible way around this would be to allocate a
+	         copy of the variable on the stack, copy in the
+	         contents, call the function, and copy out the
+	         contents.  I.e. convert this from call by reference
+	         to call by copy-return (or whatever it's called).
+	         However, this does not work because it is not the
+	         same: the method being called could stash a copy of
+	         the address, and then future uses through that address
+	         (after the method returns) would be expected to
+	         use the variable itself, not some copy of it.  */
+	      arg2 = evaluate_subexp_for_address (exp, pos, noside);
+	    }
+	  else
+	    {
+	      arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+	    }
+	  /* Now, say which argument to start evaluating from */
+	  tem = 2;
+	}
+      else if ( op == OP_ADL_FUNC )
+        {
+          /* Save the function position and move pos so that the arguments
+             can be evaluated. */
+          int func_name_len;
           save_pos1 = *pos;
-          argvec[0] = evaluate_subexp_with_coercion (exp, pos, noside);
           tem = 1;
-          type = value_type (argvec[0]);
-          if (type && TYPE_CODE (type) == TYPE_CODE_PTR)
-            type = TYPE_TARGET_TYPE (type);
-          if (type && TYPE_CODE (type) == TYPE_CODE_FUNC)
-            {
-              for (; tem <= nargs && tem <= TYPE_NFIELDS (type); tem++)
-                {
-                  /* pai: FIXME This seems to be coercing arguments before
-                   * overload resolution has been done! */
-                  argvec[tem] = evaluate_subexp (TYPE_FIELD_TYPE (type, tem - 1),
-						 exp, pos, noside);
-                }
-            }
+
+          func_name_len = longest_to_int (exp->elts[save_pos1 + 3].longconst);
+          (*pos) += 6 + BYTES_TO_EXP_ELEM (func_name_len + 1);
         }
+      else
+	{
+	  /* Non-method function call */
+	  save_pos1 = *pos;
+	  argvec[0] = evaluate_subexp_with_coercion (exp, pos, noside);
+	  tem = 1;
+	  type = value_type (argvec[0]);
+	  if (type && TYPE_CODE (type) == TYPE_CODE_PTR)
+	    type = TYPE_TARGET_TYPE (type);
+	  if (type && TYPE_CODE (type) == TYPE_CODE_FUNC)
+	    {
+	      for (; tem <= nargs && tem <= TYPE_NFIELDS (type); tem++)
+		{
+		  /* pai: FIXME This seems to be coercing arguments before
+		   * overload resolution has been done! */
+		  argvec[tem] = evaluate_subexp (TYPE_FIELD_TYPE (type, tem - 1),
+						 exp, pos, noside);
+		}
+	    }
+	}
 
-        /* Evaluate arguments */
-        for (; tem <= nargs; tem++)
-          {
+      /* Evaluate arguments */
+      for (; tem <= nargs; tem++)
+	{
+	  /* Ensure that array expressions are coerced into pointer objects. */
+	  argvec[tem] = evaluate_subexp_with_coercion (exp, pos, noside);
+	}
 
-            /* Ensure that array expressions are coerced into pointer objects. */
-            argvec[tem] = evaluate_subexp_with_coercion (exp, pos, noside);
+      /* signal end of arglist */
+      argvec[tem] = 0;
 
-            if ( adl_func )
-              {
-                /* save prefixes */
-                char* cindex;
-                char* name;
-
-                name = TYPE_NAME (value_type (argvec[tem]));
-                cindex = rindex(name, ':');
-                if(cindex != NULL){
-                  prefix_array[prefix_array_size] = savestring(name, (int)(cindex - name) - 1);
-                  prefix_array_size++;
-                }
-              }
-          }
+      if ( op == OP_ADL_FUNC )
+        {
+          struct symbol *symp;
+          char *func_name;
+          int  name_len;
+          int string_pc = save_pos1 + 3;
 
-        if ( adl_func )
-          {
-            struct symbol *symp;
-            save_pos1 = adl_func_pos;
-            argvec[0] = evaluate_subexp_with_coercion (exp, &adl_func_pos, noside);
-            find_overload_match (argvec, nargs, NULL /* no need for name */ ,
-                0 /* not method */ , 0 /* strict match */ ,
-                NULL, exp->elts[save_pos1+2].symbol /* the function */ ,
-                NULL, &symp, NULL);
-
-            /* Now fix the expression being evaluated */
-            exp->elts[save_pos1+2].symbol = symp;
-            argvec[0] = evaluate_subexp_with_coercion (exp, &save_pos1, noside);
-          }
+          name_len = longest_to_int (exp->elts[string_pc].longconst);
+          func_name = (char*) alloca(name_len+1);
+          strcpy (func_name, &exp->elts[string_pc + 1].string);
+          find_overload_match (argvec, nargs, func_name,
+                               0 /* not method */ , 0 /* strict match */ ,
+                               NULL, NULL /* pass NULL symbol to signal ADL lookup */ ,
+                               NULL, &symp, NULL, 1);
 
-        /* signal end of arglist */
-        argvec[tem] = 0;
+          /* Now fix the expression being evaluated */
+          exp->elts[save_pos1+2].symbol = symp;
+          argvec[0] = evaluate_subexp_with_coercion (exp, &save_pos1, noside);
+        }
 
-        if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR)
-          {
-            int static_memfuncp;
-            char tstr[256];
+      if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR)
+	{
+	  int static_memfuncp;
+	  char tstr[256];
 
-            /* Method invocation : stuff "this" as first parameter */
-            argvec[1] = arg2;
-            /* Name of method from expression */
-            strcpy (tstr, &exp->elts[pc2 + 2].string);
+	  /* Method invocation : stuff "this" as first parameter */
+	  argvec[1] = arg2;
+	  /* Name of method from expression */
+	  strcpy (tstr, &exp->elts[pc2 + 2].string);
 
-            if (overload_resolution && (exp->language_defn->la_language == language_cplus))
-              {
-                /* Language is C++, do some overload resolution before evaluation */
-                struct value *valp = NULL;
+	  if (overload_resolution && (exp->language_defn->la_language == language_cplus))
+	    {
+	      /* Language is C++, do some overload resolution before evaluation */
+	      struct value *valp = NULL;
 
-                (void) find_overload_match (argvec, nargs, tstr,
+	      (void) find_overload_match (argvec, nargs, tstr,
 				     1 /* method */ , 0 /* strict match */ ,
 					  &arg2 /* the object */ , NULL,
-					  &valp, NULL, &static_memfuncp);
+					  &valp, NULL, &static_memfuncp, 0);
 
 
-                argvec[1] = arg2;	/* the ``this'' pointer */
-                argvec[0] = valp;	/* use the method found after overload resolution */
-              }
-            else
-              /* Non-C++ case -- or no overload resolution */
-              {
-                struct value *temp = arg2;
-                argvec[0] = value_struct_elt (&temp, argvec + 1, tstr,
-					      &static_memfuncp,
-					      op == STRUCTOP_STRUCT
-				         ? "structure" : "structure pointer");
-                /* value_struct_elt updates temp with the correct value
-	 	   of the ``this'' pointer if necessary, so modify argvec[1] to
-		   reflect any ``this'' changes.  */
-                arg2 = value_from_longest (lookup_pointer_type(value_type (temp)),
-                                           VALUE_ADDRESS (temp) + value_offset (temp)
-					   + value_embedded_offset (temp));
-                argvec[1] = arg2;	/* the ``this'' pointer */
-              }
+	      argvec[1] = arg2;	/* the ``this'' pointer */
+	      argvec[0] = valp;	/* use the method found after overload resolution */
+	    }
+	  else
+	    /* Non-C++ case -- or no overload resolution */
+	    {
+	      struct value *temp = arg2;
+	      argvec[0] = value_struct_elt (&temp, argvec + 1, tstr,
+					    &static_memfuncp,
+					    op == STRUCTOP_STRUCT
+				       ? "structure" : "structure pointer");
+	      /* value_struct_elt updates temp with the correct value
+	 	 of the ``this'' pointer if necessary, so modify argvec[1] to
+		 reflect any ``this'' changes.  */
+	      arg2 = value_from_longest (lookup_pointer_type(value_type (temp)),
+					 VALUE_ADDRESS (temp) + value_offset (temp)
+					 + value_embedded_offset (temp));
+	      argvec[1] = arg2;	/* the ``this'' pointer */
+	    }
 
-            if (static_memfuncp)
-              {
-                argvec[1] = argvec[0];
-                nargs--;
-                argvec++;
-              }
-          }
-        else if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
-          {
-            argvec[1] = arg2;
-            argvec[0] = arg1;
-          }
-        else if (op == OP_VAR_VALUE)
-          {
-            /* Non-member function being called */
-            /* fn: This can only be done for C++ functions.  A C-style function
-               in a C++ program, for instance, does not have the fields that
-               are expected here */
+	  if (static_memfuncp)
+	    {
+	      argvec[1] = argvec[0];
+	      nargs--;
+	      argvec++;
+	    }
+	}
+      else if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
+	{
+	  argvec[1] = arg2;
+	  argvec[0] = arg1;
+	}
+      else if (op == OP_VAR_VALUE)
+	{
+	  /* Non-member function being called */
+          /* fn: This can only be done for C++ functions.  A C-style function
+             in a C++ program, for instance, does not have the fields that 
+             are expected here */
 
-            if (overload_resolution && (exp->language_defn->la_language == language_cplus))
-              {
-                /* Language is C++, do some overload resolution before evaluation */
-	        struct symbol *symp;


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-04-29 15:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-29 15:53 [SCM] archer-swagiaal-using-directive: Recommit: Added support for ADL function lookup. Patch 2 swagiaal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).