Introduce type_instance_operation
authorTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:27:57 +0000 (07:27 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:28:23 +0000 (07:28 -0700)
This adds class type_instance_operation, which implements
TYPE_INSTANCE.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

* expop.h (class type_instance_operation): New.
* eval.c (type_instance_operation::evaluate): New method.

gdb/ChangeLog
gdb/eval.c
gdb/expop.h

index e9ba10d0899ed0c1c42d26ba820423fae2ac2d56..58ada4e328222278a0b1b7e4647ffca20d36218a 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-08  Tom Tromey  <tom@tromey.com>
+
+       * expop.h (class type_instance_operation): New.
+       * eval.c (type_instance_operation::evaluate): New method.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
        * expop.h (class op_this_operation): New.
index 2781e1d993e3e6783532d0744cb7af31125ae7f4..f0bad85e951a76ae62c9cea408e4cb3e661174c8 100644 (file)
@@ -636,6 +636,24 @@ fake_method::~fake_method ()
   xfree (m_type.fields ());
 }
 
+namespace expr
+{
+
+value *
+type_instance_operation::evaluate (struct type *expect_type,
+                                  struct expression *exp,
+                                  enum noside noside)
+{
+  type_instance_flags flags = std::get<0> (m_storage);
+  std::vector<type *> &types = std::get<1> (m_storage);
+
+  fake_method fake_expect_type (flags, types.size (), types.data ());
+  return std::get<2> (m_storage)->evaluate (fake_expect_type.type (),
+                                           exp, noside);
+}
+
+}
+
 /* Helper for evaluating an OP_VAR_VALUE.  */
 
 value *
index 7c0768ca6c1784eb1a50c1598be766073eb36ba0..b196de52d0b7047692499a16b7034b66db00d68b 100644 (file)
@@ -1740,6 +1740,23 @@ protected:
     override;
 };
 
+/* Implement the "type instance" operation.  */
+class type_instance_operation
+  : public tuple_holding_operation<type_instance_flags, std::vector<type *>,
+                                  operation_up>
+{
+public:
+
+  using tuple_holding_operation::tuple_holding_operation;
+
+  value *evaluate (struct type *expect_type,
+                  struct expression *exp,
+                  enum noside noside) override;
+
+  enum exp_opcode opcode () const override
+  { return TYPE_INSTANCE; }
+};
+
 } /* namespace expr */
 
 #endif /* EXPOP_H */