PARAMS elimination.
[deliverable/binutils-gdb.git] / gdb / eval.c
index d054ac7ffbd3cfb996d91f01f4d64f5cc156072f..9cfac7b2eb6da5c7d97108613c95d7fe5e13a872 100644 (file)
@@ -37,27 +37,29 @@ extern int hp_som_som_object_present;
 /* 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 value_ptr evaluate_subexp_for_sizeof PARAMS ((struct expression *,
-                                                    int *));
+static value_ptr evaluate_subexp_for_sizeof (struct expression *, int *);
 
-static value_ptr evaluate_subexp_for_address PARAMS ((struct expression *,
-                                                     int *, enum noside));
+static value_ptr evaluate_subexp_for_address (struct expression *,
+                                             int *, enum noside);
 
-static value_ptr evaluate_subexp PARAMS ((struct type *, struct expression *,
-                                         int *, enum noside));
+static value_ptr evaluate_subexp (struct type *, struct expression *,
+                                 int *, enum noside);
 
-static char *get_label PARAMS ((struct expression *, int *));
+static char *get_label (struct expression *, int *);
 
 static value_ptr
-  evaluate_struct_tuple PARAMS ((value_ptr, struct expression *, int *,
-                                enum noside, int));
+evaluate_struct_tuple (value_ptr, struct expression *, int *,
+                      enum noside, int);
 
 static LONGEST
-  init_array_element PARAMS ((value_ptr, value_ptr, struct expression *,
-                             int *, enum noside, LONGEST, LONGEST));
+init_array_element (value_ptr, value_ptr, struct expression *,
+                   int *, enum noside, LONGEST, LONGEST);
 
 #if defined (__GNUC__) && !__STDC__
 inline
@@ -82,7 +84,7 @@ parse_and_eval_address (exp)
   struct expression *expr = parse_expression (exp);
   register CORE_ADDR addr;
   register struct cleanup *old_chain =
-  make_cleanup ((make_cleanup_func) free_current_contents, &expr);
+  make_cleanup (free_current_contents, &expr);
 
   addr = value_as_pointer (evaluate_expression (expr));
   do_cleanups (old_chain);
@@ -99,7 +101,7 @@ parse_and_eval_address_1 (expptr)
   struct expression *expr = parse_exp_1 (expptr, (struct block *) 0, 0);
   register CORE_ADDR addr;
   register struct cleanup *old_chain =
-  make_cleanup ((make_cleanup_func) free_current_contents, &expr);
+  make_cleanup (free_current_contents, &expr);
 
   addr = value_as_pointer (evaluate_expression (expr));
   do_cleanups (old_chain);
@@ -113,7 +115,7 @@ parse_and_eval (exp)
   struct expression *expr = parse_expression (exp);
   register value_ptr val;
   register struct cleanup *old_chain
-  = make_cleanup ((make_cleanup_func) free_current_contents, &expr);
+  = make_cleanup (free_current_contents, &expr);
 
   val = evaluate_expression (expr);
   do_cleanups (old_chain);
@@ -131,7 +133,7 @@ parse_to_comma_and_eval (expp)
   struct expression *expr = parse_exp_1 (expp, (struct block *) 0, 1);
   register value_ptr val;
   register struct cleanup *old_chain
-  = make_cleanup ((make_cleanup_func) free_current_contents, &expr);
+  = make_cleanup (free_current_contents, &expr);
 
   val = evaluate_expression (expr);
   do_cleanups (old_chain);
@@ -428,32 +430,16 @@ evaluate_subexp_standard (expect_type, exp, pos, noside)
       (*pos) += 3;
       if (noside == EVAL_SKIP)
        goto nosideret;
-      if (noside == EVAL_AVOID_SIDE_EFFECTS)
-       {
-         struct symbol *sym = exp->elts[pc + 2].symbol;
-         enum lval_type lv;
 
-         switch (SYMBOL_CLASS (sym))
-           {
-           case LOC_CONST:
-           case LOC_LABEL:
-           case LOC_CONST_BYTES:
-             lv = not_lval;
-             break;
-
-           case LOC_REGISTER:
-           case LOC_REGPARM:
-             lv = lval_register;
-             break;
-
-           default:
-             lv = lval_memory;
-             break;
-           }
+      /* JYG: We used to just return value_zero of the symbol type
+        if we're asked to avoid side effects.  Otherwise we return
+        value_of_variable (...).  However I'm not sure if
+        value_of_variable () has any side effect.
+        We need a full value object returned here for whatis_exp ()
+        to call evaluate_type () and then pass the full value to
+        value_rtti_target_type () if we are dealing with a pointer
+        or reference to a base class and print object is on. */
 
-         return value_zero (SYMBOL_TYPE (sym), lv);
-       }
-      else
        return value_of_variable (exp->elts[pc + 2].symbol,
                                  exp->elts[pc + 1].block);
 
@@ -845,8 +831,9 @@ evaluate_subexp_standard (expect_type, exp, pos, noside)
          /* Method invocation : stuff "this" as first parameter */
          /* pai: this used to have lookup_pointer_type for some reason,
           * but temp is already a pointer to the object */
-         argvec[1] = value_from_longest (VALUE_TYPE (temp),
-                               VALUE_ADDRESS (temp) + VALUE_OFFSET (temp));
+         argvec[1]
+           = value_from_pointer (VALUE_TYPE (temp),
+                                 VALUE_ADDRESS (temp) + VALUE_OFFSET (temp));
          /* Name of method from expression */
          strcpy (tstr, &exp->elts[pc2 + 2].string);
 
@@ -1051,6 +1038,31 @@ evaluate_subexp_standard (expect_type, exp, pos, noside)
       arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
       if (noside == EVAL_SKIP)
        goto nosideret;
+
+      /* JYG: if print object is on we need to replace the base type
+        with rtti type in order to continue on with successful
+        lookup of member / method only available in the rtti type. */
+      {
+        struct type *type = VALUE_TYPE (arg1);
+        struct type *real_type;
+        int full, top, using_enc;
+        
+        if (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);
+            if (real_type)
+              {
+                if (TYPE_CODE (type) == TYPE_CODE_PTR)
+                  real_type = lookup_pointer_type (real_type);
+                else
+                  real_type = lookup_reference_type (real_type);
+
+                arg1 = value_cast (real_type, arg1);
+              }
+          }
+      }
+
       if (noside == EVAL_AVOID_SIDE_EFFECTS)
        return value_zero (lookup_struct_elt_type (VALUE_TYPE (arg1),
                                                   &exp->elts[pc + 2].string,
@@ -1110,7 +1122,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside)
       /* Now, convert these values to an address.  */
       arg1 = value_cast (lookup_pointer_type (TYPE_DOMAIN_TYPE (type)),
                         arg1);
-      arg3 = value_from_longest (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
+      arg3 = value_from_pointer (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
                                 value_as_long (arg1) + mem_offset);
       return value_ind (arg3);
     bad_pointer_to_member:
@@ -1875,7 +1887,7 @@ evaluate_subexp_with_coercion (exp, pos, noside)
          val =
            locate_var_value
            (var, block_innermost_frame (exp->elts[pc + 1].block));
-         return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (SYMBOL_TYPE (var))),
+         return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (check_typedef (SYMBOL_TYPE (var)))),
                             val);
        }
       /* FALLTHROUGH */
This page took 0.026356 seconds and 4 git commands to generate.