Give Palmer co-credit for last patch.
[deliverable/binutils-gdb.git] / gdb / eval.c
index 24f32f887d92b014eff29d1ebf0f9effb198d092..14a3e05ade223385989446c663cd0a620058ad7b 100644 (file)
@@ -642,18 +642,33 @@ ptrmath_type_p (const struct language_defn *lang, struct type *type)
     }
 }
 
-/* Constructs a fake method with the given parameter types.  This
-   function is used by the parser to construct an "expected" type for
+/* Represents a fake method with the given parameter types.  This is
+   used by the parser to construct a temporary "expected" type for
    method overload resolution.  FLAGS is used as instance flags of the
    new type, in order to be able to make the new type represent a
    const/volatile overload.  */
 
-static struct type *
-make_params (type_instance_flags flags,
-            int num_types, struct type **param_types)
+class fake_method
 {
-  struct type *type = XCNEW (struct type);
-  TYPE_MAIN_TYPE (type) = XCNEW (struct main_type);
+public:
+  fake_method (type_instance_flags flags,
+              int num_types, struct type **param_types);
+  ~fake_method ();
+
+  /* The constructed type.  */
+  struct type *type () { return &m_type; }
+
+private:
+  struct type m_type {};
+  main_type m_main_type {};
+};
+
+fake_method::fake_method (type_instance_flags flags,
+                         int num_types, struct type **param_types)
+{
+  struct type *type = &m_type;
+
+  TYPE_MAIN_TYPE (type) = &m_main_type;
   TYPE_LENGTH (type) = 1;
   TYPE_CODE (type) = TYPE_CODE_METHOD;
   TYPE_CHAIN (type) = type;
@@ -681,13 +696,16 @@ make_params (type_instance_flags flags,
 
   while (num_types-- > 0)
     TYPE_FIELD_TYPE (type, num_types) = param_types[num_types];
+}
 
-  return type;
+fake_method::~fake_method ()
+{
+  xfree (TYPE_FIELDS (&m_type));
 }
 
 /* Helper for evaluating an OP_VAR_VALUE.  */
 
-static value *
+value *
 evaluate_var_value (enum noside noside, const block *blk, symbol *var)
 {
   /* JYG: We used to just return value_zero of the symbol type if
@@ -720,7 +738,7 @@ evaluate_var_value (enum noside noside, const block *blk, symbol *var)
 
 /* Helper for evaluating an OP_VAR_MSYM_VALUE.  */
 
-static value *
+value *
 evaluate_var_msym_value (enum noside noside,
                         struct objfile *objfile, minimal_symbol *msymbol)
 {
@@ -739,7 +757,7 @@ evaluate_var_msym_value (enum noside noside,
 
 /* Helper for returning a value when handling EVAL_SKIP.  */
 
-static value *
+value *
 eval_skip_value (expression *exp)
 {
   return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, 1);
@@ -1259,15 +1277,10 @@ evaluate_subexp_standard (struct type *expect_type,
       return value_from_longest (exp->elts[pc + 1].type,
                                 exp->elts[pc + 2].longconst);
 
-    case OP_DOUBLE:
+    case OP_FLOAT:
       (*pos) += 3;
-      return value_from_double (exp->elts[pc + 1].type,
-                               exp->elts[pc + 2].doubleconst);
-
-    case OP_DECFLOAT:
-      (*pos) += 3;
-      return value_from_decfloat (exp->elts[pc + 1].type,
-                                 exp->elts[pc + 2].decfloatconst);
+      return value_from_contents (exp->elts[pc + 1].type,
+                                 exp->elts[pc + 2].floatconst);
 
     case OP_ADL_FUNC:
     case OP_VAR_VALUE:
@@ -2076,13 +2089,9 @@ evaluate_subexp_standard (struct type *expect_type,
        for (ix = 0; ix < nargs; ++ix)
          arg_types[ix] = exp->elts[pc + 2 + ix + 1].type;
 
-       expect_type = make_params (flags, nargs, arg_types);
+       fake_method expect_type (flags, nargs, arg_types);
        *(pos) += 4 + nargs;
-       arg1 = evaluate_subexp_standard (expect_type, exp, pos, noside);
-       xfree (TYPE_FIELDS (expect_type));
-       xfree (TYPE_MAIN_TYPE (expect_type));
-       xfree (expect_type);
-       return arg1;
+       return evaluate_subexp_standard (expect_type.type (), exp, pos, noside);
       }
 
     case BINOP_CONCAT:
This page took 0.028422 seconds and 4 git commands to generate.