Implement Fortran associated operations
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:30 +0000 (07:28 -0700)
This implements the Fortran 1- and 2-argument "associated" operations.

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

* f-lang.c (eval_op_f_associated): New functions.
* f-exp.h (fortran_associated_1arg, fortran_associated_2arg): New
typedefs.

gdb/ChangeLog
gdb/f-exp.h
gdb/f-lang.c

index 6f3037c8c2804a35e40f228a4f2f858e26c23b49..d92f16b12d5dece6c5ebe6309cc09604a3fb8eed 100644 (file)
@@ -1,3 +1,9 @@
+2021-03-08  Tom Tromey  <tom@tromey.com>
+
+       * f-lang.c (eval_op_f_associated): New functions.
+       * f-exp.h (fortran_associated_1arg, fortran_associated_2arg): New
+       typedefs.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
        * f-lang.c (fortran_bound_1arg::evaluate)
index e1d351a2bb421c915ac754bba9447eca3a91a0a0..11f403d13ca67ad3776d98f00e1b6f58a0e096c8 100644 (file)
@@ -57,6 +57,17 @@ extern struct value *eval_op_f_kind (struct type *expect_type,
                                     enum noside noside,
                                     enum exp_opcode opcode,
                                     struct value *arg1);
+extern struct value *eval_op_f_associated (struct type *expect_type,
+                                          struct expression *exp,
+                                          enum noside noside,
+                                          enum exp_opcode opcode,
+                                          struct value *arg1);
+extern struct value *eval_op_f_associated (struct type *expect_type,
+                                          struct expression *exp,
+                                          enum noside noside,
+                                          enum exp_opcode opcode,
+                                          struct value *arg1,
+                                          struct value *arg2);
 
 namespace expr
 {
@@ -72,6 +83,10 @@ using fortran_kind_operation = unop_operation<UNOP_FORTRAN_KIND,
 using fortran_mod_operation = binop_operation<BINOP_MOD, eval_op_f_mod>;
 using fortran_modulo_operation = binop_operation<BINOP_FORTRAN_MODULO,
                                                 eval_op_f_modulo>;
+using fortran_associated_1arg = unop_operation<FORTRAN_ASSOCIATED,
+                                              eval_op_f_associated>;
+using fortran_associated_2arg = binop_operation<FORTRAN_ASSOCIATED,
+                                               eval_op_f_associated>;
 
 /* The Fortran "complex" operation.  */
 class fortran_cmplx_operation
index dcd7c48bbcfec4b6a4395ad69017f3bfbdc874b6..1a49b6bdb2f81ce5c84f09b469902e794b305ac7 100644 (file)
@@ -995,6 +995,26 @@ fortran_associated (struct gdbarch *gdbarch, const language_defn *lang,
   return value_from_longest (result_type, is_associated ? 1 : 0);
 }
 
+struct value *
+eval_op_f_associated (struct type *expect_type,
+                     struct expression *exp,
+                     enum noside noside,
+                     enum exp_opcode opcode,
+                     struct value *arg1)
+{
+  return fortran_associated (exp->gdbarch, exp->language_defn, arg1);
+}
+
+struct value *
+eval_op_f_associated (struct type *expect_type,
+                     struct expression *exp,
+                     enum noside noside,
+                     enum exp_opcode opcode,
+                     struct value *arg1,
+                     struct value *arg2)
+{
+  return fortran_associated (exp->gdbarch, exp->language_defn, arg1, arg2);
+}
 
 /* A helper function for UNOP_ABS.  */