* eval.c (evaluate_subexp_standard): Assert that there is at
[binutils-gdb.git] / gdb / eval.c
index f4ae539b52f25c3be510c1a0d700bcb829aa98e3..ccb6b742b618b6a04f8840be23a34b7fc5cf4be4 100644 (file)
 #include "exceptions.h"
 #include "regcache.h"
 #include "user-regs.h"
+#include "valprint.h"
 
 #include "gdb_assert.h"
 
 /* This is defined in valops.c */
 extern int overload_resolution;
 
-/* JYG: lookup rtti type of STRUCTOP_PTR when this is set to continue
-   on with successful lookup for member/method of the rtti type. */
-extern int objectprint;
-
 /* Prototypes for local functions. */
 
 static struct value *evaluate_subexp_for_sizeof (struct expression *, int *);
@@ -319,7 +316,8 @@ evaluate_struct_tuple (struct value *struct_val,
                  fieldno++;
                  /* Skip static fields.  */
                  while (fieldno < TYPE_NFIELDS (struct_type)
-                        && TYPE_FIELD_STATIC_KIND (struct_type, fieldno))
+                        && field_is_static (&TYPE_FIELD (struct_type,
+                                                         fieldno)))
                    fieldno++;
                  subfieldno = fieldno;
                  if (fieldno >= TYPE_NFIELDS (struct_type))
@@ -999,6 +997,7 @@ evaluate_subexp_standard (struct type *expect_type,
       {                                /* Objective C @selector operator.  */
        char *sel = &exp->elts[pc + 2].string;
        int len = longest_to_int (exp->elts[pc + 1].longconst);
+       struct type *selector_type;
 
        (*pos) += 3 + BYTES_TO_EXP_ELEM (len + 1);
        if (noside == EVAL_SKIP)
@@ -1006,8 +1005,9 @@ evaluate_subexp_standard (struct type *expect_type,
 
        if (sel[len] != 0)
          sel[len] = 0;         /* Make sure it's terminated.  */
-       return value_from_longest (lookup_pointer_type (builtin_type_void),
-                                  lookup_child_selector (sel));
+
+       selector_type = builtin_type (exp->gdbarch)->builtin_data_ptr;
+       return value_from_longest (selector_type, lookup_child_selector (sel));
       }
 
     case OP_OBJC_MSGCALL:
@@ -1030,6 +1030,7 @@ evaluate_subexp_standard (struct type *expect_type,
        struct value *called_method = NULL; 
 
        struct type *selector_type = NULL;
+       struct type *long_type;
 
        struct value *ret = NULL;
        CORE_ADDR addr = 0;
@@ -1041,7 +1042,9 @@ evaluate_subexp_standard (struct type *expect_type,
 
        (*pos) += 3;
 
-       selector_type = lookup_pointer_type (builtin_type_void);
+       long_type = builtin_type (exp->gdbarch)->builtin_long;
+       selector_type = builtin_type (exp->gdbarch)->builtin_data_ptr;
+
        if (noside == EVAL_AVOID_SIDE_EFFECTS)
          sub_no_side = EVAL_NORMAL;
        else
@@ -1050,7 +1053,7 @@ evaluate_subexp_standard (struct type *expect_type,
        target = evaluate_subexp (selector_type, exp, pos, sub_no_side);
 
        if (value_as_long (target) == 0)
-         return value_from_longest (builtin_type_long, 0);
+         return value_from_longest (long_type, 0);
        
        if (lookup_minimal_symbol ("objc_msg_lookup", 0, 0))
          gnu_runtime = 1;
@@ -1065,15 +1068,15 @@ evaluate_subexp_standard (struct type *expect_type,
           only).  */
        if (gnu_runtime)
          {
-           struct type *type;
-           type = lookup_pointer_type (builtin_type_void);
+           struct type *type = selector_type;
            type = lookup_function_type (type);
            type = lookup_pointer_type (type);
            type = lookup_function_type (type);
            type = lookup_pointer_type (type);
 
-           msg_send = find_function_in_inferior ("objc_msg_lookup");
-           msg_send_stret = find_function_in_inferior ("objc_msg_lookup");
+           msg_send = find_function_in_inferior ("objc_msg_lookup", NULL);
+           msg_send_stret
+             = find_function_in_inferior ("objc_msg_lookup", NULL);
 
            msg_send = value_from_pointer (type, value_as_address (msg_send));
            msg_send_stret = value_from_pointer (type, 
@@ -1081,9 +1084,10 @@ evaluate_subexp_standard (struct type *expect_type,
          }
        else
          {
-           msg_send = find_function_in_inferior ("objc_msgSend");
+           msg_send = find_function_in_inferior ("objc_msgSend", NULL);
            /* Special dispatcher for methods returning structs */
-           msg_send_stret = find_function_in_inferior ("objc_msgSend_stret");
+           msg_send_stret
+             = find_function_in_inferior ("objc_msgSend_stret", NULL);
          }
 
        /* Verify the target object responds to this method. The
@@ -1110,8 +1114,8 @@ evaluate_subexp_standard (struct type *expect_type,
 
        argvec[0] = msg_send;
        argvec[1] = target;
-       argvec[2] = value_from_longest (builtin_type_long, responds_selector);
-       argvec[3] = value_from_longest (builtin_type_long, selector);
+       argvec[2] = value_from_longest (long_type, responds_selector);
+       argvec[3] = value_from_longest (long_type, selector);
        argvec[4] = 0;
 
        ret = call_function_by_hand (argvec[0], 3, argvec + 1);
@@ -1132,8 +1136,8 @@ evaluate_subexp_standard (struct type *expect_type,
 
        argvec[0] = msg_send;
        argvec[1] = target;
-       argvec[2] = value_from_longest (builtin_type_long, method_selector);
-       argvec[3] = value_from_longest (builtin_type_long, selector);
+       argvec[2] = value_from_longest (long_type, method_selector);
+       argvec[3] = value_from_longest (long_type, selector);
        argvec[4] = 0;
 
        ret = call_function_by_hand (argvec[0], 3, argvec + 1);
@@ -1252,7 +1256,7 @@ evaluate_subexp_standard (struct type *expect_type,
 
        argvec[0] = called_method;
        argvec[1] = target;
-       argvec[2] = value_from_longest (builtin_type_long, selector);
+       argvec[2] = value_from_longest (long_type, selector);
        /* User-supplied arguments.  */
        for (tem = 0; tem < nargs; tem++)
          argvec[tem + 3] = evaluate_subexp_with_coercion (exp, pos, noside);
@@ -1621,8 +1625,10 @@ evaluate_subexp_standard (struct type *expect_type,
         struct type *type = value_type (arg1);
         struct type *real_type;
         int full, top, using_enc;
-        
-        if (objectprint && TYPE_TARGET_TYPE(type) &&
+       struct value_print_options opts;
+
+       get_user_print_options (&opts);
+        if (opts.objectprint && TYPE_TARGET_TYPE(type) &&
             (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
           {
             real_type = value_rtti_target_type (arg1, &full, &top, &using_enc);
@@ -1970,6 +1976,8 @@ evaluate_subexp_standard (struct type *expect_type,
        if (nargs != ndimensions)
          error (_("Wrong number of subscripts"));
 
+       gdb_assert (nargs > 0);
+
        /* Now that we know we have a legal array subscript expression 
           let us actually find out where this element exists in the array. */
 
@@ -1988,13 +1996,8 @@ evaluate_subexp_standard (struct type *expect_type,
        /* Internal type of array is arranged right to left */
        for (i = 0; i < nargs; i++)
          {
-           retcode = f77_get_dynamic_upperbound (tmp_type, &upper);
-           if (retcode == BOUND_FETCH_ERROR)
-             error (_("Cannot obtain dynamic upper bound"));
-
-           retcode = f77_get_dynamic_lowerbound (tmp_type, &lower);
-           if (retcode == BOUND_FETCH_ERROR)
-             error (_("Cannot obtain dynamic lower bound"));
+           upper = f77_get_upperbound (tmp_type);
+           lower = f77_get_lowerbound (tmp_type);
 
            array_size_array[nargs - i - 1] = upper - lower + 1;
 
@@ -2024,7 +2027,7 @@ evaluate_subexp_standard (struct type *expect_type,
 
        /* Construct a value node with the value of the offset */
 
-       arg2 = value_from_longest (builtin_type_f_integer, offset_item);
+       arg2 = value_from_longest (builtin_type_int32, offset_item);
 
        /* Let us now play a dirty trick: we will take arg1 
           which is a value node pointing to the topmost level