* configure.tgt (sparc64-*-solaris2*): New configuration.
[deliverable/binutils-gdb.git] / gdb / eval.c
index b45c3c880cd0ad50b3978be1da1b51d4e349bf29..87417f34eb9f94695cbd4ccf7404f29da16b3fea 100644 (file)
@@ -283,7 +283,7 @@ evaluate_struct_tuple (struct_val, exp, pos, noside, nargs)
 
          field_type = TYPE_FIELD_TYPE (substruct_type, subfieldno);
          if (val == 0)
-           val = evaluate_subexp (substruct_type, exp, pos, noside);
+           val = evaluate_subexp (field_type, exp, pos, noside);
 
          /* Now actually set the field in struct_val. */
 
@@ -647,11 +647,15 @@ evaluate_subexp_standard (expect_type, exp, pos, noside)
     case OP_FUNCALL:
       (*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 = (value_ptr *) alloca (sizeof (value_ptr) * (nargs + 3));
       if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
        {
          LONGEST fnptr;
 
-         nargs = longest_to_int (exp->elts[pc + 1].longconst) + 1;
+         nargs++;
          /* First, evaluate the structure into arg2 */
          pc2 = (*pos)++;
 
@@ -719,7 +723,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside)
          /* Hair for method invocations */
          int tem2;
 
-         nargs = longest_to_int (exp->elts[pc + 1].longconst) + 1;
+         nargs++;
          /* First, evaluate the structure into arg2 */
          pc2 = (*pos)++;
          tem2 = longest_to_int (exp->elts[pc2 + 1].longconst);
@@ -754,15 +758,27 @@ evaluate_subexp_standard (expect_type, exp, pos, noside)
        }
       else
        {
-         nargs = longest_to_int (exp->elts[pc + 1].longconst);
-         tem = 0;
+         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++)
+               {
+                 argvec[tem] = evaluate_subexp (TYPE_FIELD_TYPE (type, tem-1),
+                                                exp, pos, noside);
+               }
+           }
        }
-      /* Allocate arg vector, including space for the function to be
-        called in argvec[0] and a terminating NULL */
-      argvec = (value_ptr *) alloca (sizeof (value_ptr) * (nargs + 2));
+
       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;
@@ -884,7 +900,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside)
         goto nosideret;
       
       tem2 = value_as_long (arg2);
-      tem2 = value_as_long (arg3);
+      tem3 = value_as_long (arg3);
       
       return value_slice (arg1, tem2, tem3 - tem2 + 1);
 
@@ -1258,7 +1274,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside)
          tem = value_logical_not (arg1);
          arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
                                  (tem ? EVAL_SKIP : noside));
-         return value_from_longest (builtin_type_int,
+         return value_from_longest (LA_BOOL_TYPE,
                                  (LONGEST) (!tem && !value_logical_not (arg2)));
        }
 
@@ -1284,7 +1300,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside)
          tem = value_logical_not (arg1);
          arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
                                  (!tem ? EVAL_SKIP : noside));
-         return value_from_longest (builtin_type_int,
+         return value_from_longest (LA_BOOL_TYPE,
                                  (LONGEST) (!tem || !value_logical_not (arg2)));
        }
 
@@ -1300,7 +1316,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside)
       else
        {
          tem = value_equal (arg1, arg2);
-         return value_from_longest (builtin_type_int, (LONGEST) tem);
+         return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
        }
 
     case BINOP_NOTEQUAL:
@@ -1315,7 +1331,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside)
       else
        {
          tem = value_equal (arg1, arg2);
-         return value_from_longest (builtin_type_int, (LONGEST) ! tem);
+         return value_from_longest (LA_BOOL_TYPE, (LONGEST) ! tem);
        }
 
     case BINOP_LESS:
@@ -1330,7 +1346,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside)
       else
        {
          tem = value_less (arg1, arg2);
-         return value_from_longest (builtin_type_int, (LONGEST) tem);
+         return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
        }
 
     case BINOP_GTR:
@@ -1345,7 +1361,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside)
       else
        {
          tem = value_less (arg2, arg1);
-         return value_from_longest (builtin_type_int, (LONGEST) tem);
+         return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
        }
 
     case BINOP_GEQ:
@@ -1360,7 +1376,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside)
       else
        {
          tem = value_less (arg2, arg1) || value_equal (arg1, arg2);
-         return value_from_longest (builtin_type_int, (LONGEST) tem);
+         return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
        }
 
     case BINOP_LEQ:
@@ -1375,7 +1391,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside)
       else 
        {
          tem = value_less (arg1, arg2) || value_equal (arg1, arg2);
-         return value_from_longest (builtin_type_int, (LONGEST) tem);
+         return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
        }
 
     case BINOP_REPEAT:
This page took 0.025735 seconds and 4 git commands to generate.