gdb/testsuite: some additional tests in gdb.tui/scroll.exp
[binutils-gdb.git] / gdb / eval.c
index 713f977bc77d550ff4677349cd1878673d6d016b..1211930a377c712a239ff70a25f4029c02540dc3 100644 (file)
@@ -564,7 +564,7 @@ evaluate_var_value (enum noside noside, const block *blk, symbol *var)
       if (noside != EVAL_AVOID_SIDE_EFFECTS)
        throw;
 
-      ret = value_zero (SYMBOL_TYPE (var), not_lval);
+      ret = value_zero (var->type (), not_lval);
     }
 
   return ret;
@@ -580,7 +580,7 @@ var_value_operation::evaluate (struct type *expect_type,
                               enum noside noside)
 {
   symbol *var = std::get<0> (m_storage).symbol;
-  if (SYMBOL_TYPE (var)->code () == TYPE_CODE_ERROR)
+  if (var->type ()->code () == TYPE_CODE_ERROR)
     error_unknown_type (var->print_name ());
   return evaluate_var_value (noside, std::get<0> (m_storage).block, var);
 }
@@ -722,7 +722,7 @@ var_value_operation::evaluate_funcall (struct type *expect_type,
                       NULL, std::get<0> (m_storage).symbol,
                       NULL, &symp, NULL, 0, noside);
 
-  if (SYMBOL_TYPE (symp)->code () == TYPE_CODE_ERROR)
+  if (symp->type ()->code () == TYPE_CODE_ERROR)
     error_unknown_type (symp->print_name ());
   value *callee = evaluate_var_value (noside, std::get<0> (m_storage).block,
                                      symp);
@@ -1005,7 +1005,7 @@ eval_op_var_entry_value (struct type *expect_type, struct expression *exp,
                         enum noside noside, symbol *sym)
 {
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
-    return value_zero (SYMBOL_TYPE (sym), not_lval);
+    return value_zero (sym->type (), not_lval);
 
   if (SYMBOL_COMPUTED_OPS (sym) == NULL
       || SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry == NULL)
@@ -1078,17 +1078,22 @@ eval_op_register (struct type *expect_type, struct expression *exp,
     return val;
 }
 
-/* Helper function that implements the body of OP_STRING.  */
+namespace expr
+{
 
-struct value *
-eval_op_string (struct type *expect_type, struct expression *exp,
-               enum noside noside, int len, const char *string)
+value *
+string_operation::evaluate (struct type *expect_type,
+                           struct expression *exp,
+                           enum noside noside)
 {
+  const std::string &str = std::get<0> (m_storage);
   struct type *type = language_string_char_type (exp->language_defn,
                                                 exp->gdbarch);
-  return value_string (string, len, type);
+  return value_string (str.c_str (), str.size (), type);
 }
 
+} /* namespace expr */
+
 /* Helper function that implements the body of OP_OBJC_SELECTOR.  */
 
 struct value *
@@ -1101,18 +1106,6 @@ eval_op_objc_selector (struct type *expect_type, struct expression *exp,
                             lookup_child_selector (exp->gdbarch, sel));
 }
 
-/* Helper function that implements the body of BINOP_CONCAT.  */
-
-struct value *
-eval_op_concat (struct type *expect_type, struct expression *exp,
-               enum noside noside, struct value *arg1, struct value *arg2)
-{
-  if (binop_user_defined_p (BINOP_CONCAT, arg1, arg2))
-    return value_x_binop (arg1, arg2, BINOP_CONCAT, OP_NULL, noside);
-  else
-    return value_concat (arg1, arg2);
-}
-
 /* A helper function for TERNOP_SLICE.  */
 
 struct value *
@@ -2261,7 +2254,7 @@ adl_func_operation::evaluate (struct type *expect_type,
                       NON_METHOD,
                       nullptr, nullptr,
                       nullptr, &symp, nullptr, 0, noside);
-  if (SYMBOL_TYPE (symp)->code () == TYPE_CODE_ERROR)
+  if (symp->type ()->code () == TYPE_CODE_ERROR)
     error_unknown_type (symp->print_name ());
   value *callee = evaluate_var_value (noside, std::get<1> (m_storage), symp);
   return evaluate_subexp_do_call (exp, noside, callee, args,
@@ -2467,6 +2460,22 @@ array_operation::evaluate (struct type *expect_type,
   return value_array (tem2, tem3, argvec);
 }
 
+value *
+unop_extract_operation::evaluate (struct type *expect_type,
+                                 struct expression *exp,
+                                 enum noside noside)
+{
+  value *old_value = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
+  struct type *type = get_type ();
+
+  if (TYPE_LENGTH (type) > TYPE_LENGTH (value_type (old_value)))
+    error (_("length type is larger than the value type"));
+
+  struct value *result = allocate_value (type);
+  value_contents_copy (result, 0, old_value, 0, TYPE_LENGTH (type));
+  return result;
+}
+
 }
 
 \f
@@ -2582,13 +2591,13 @@ var_value_operation::evaluate_for_address (struct expression *exp,
 
   /* C++: The "address" of a reference should yield the address
    * of the object pointed to.  Let value_addr() deal with it.  */
-  if (TYPE_IS_REFERENCE (SYMBOL_TYPE (var)))
+  if (TYPE_IS_REFERENCE (var->type ()))
     return operation::evaluate_for_address (exp, noside);
 
   if (noside == EVAL_AVOID_SIDE_EFFECTS)
     {
-      struct type *type = lookup_pointer_type (SYMBOL_TYPE (var));
-      enum address_class sym_class = SYMBOL_CLASS (var);
+      struct type *type = lookup_pointer_type (var->type ());
+      enum address_class sym_class = var->aclass ();
 
       if (sym_class == LOC_CONST
          || sym_class == LOC_CONST_BYTES
@@ -2606,7 +2615,7 @@ var_value_operation::evaluate_with_coercion (struct expression *exp,
                                             enum noside noside)
 {
   struct symbol *var = std::get<0> (m_storage).symbol;
-  struct type *type = check_typedef (SYMBOL_TYPE (var));
+  struct type *type = check_typedef (var->type ());
   if (type->code () == TYPE_CODE_ARRAY
       && !type->is_vector ()
       && CAST_IS_CONVERSION (exp->language_defn))
@@ -2735,7 +2744,7 @@ value *
 var_value_operation::evaluate_for_sizeof (struct expression *exp,
                                          enum noside noside)
 {
-  struct type *type = SYMBOL_TYPE (std::get<0> (m_storage).symbol);
+  struct type *type = std::get<0> (m_storage).symbol->type ();
   if (is_dynamic_type (type))
     {
       value *val = evaluate (nullptr, exp, EVAL_NORMAL);