aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:25 -0700
commit42fecb6183f4cce4e85473b8c43d90ec0ea562e7 (patch)
tree13c67a36281440d28aeb76162c7ffd57d9855505
parent03070ee9c77877655051c073cf060585f7cb2ff2 (diff)
downloadbinutils-42fecb6183f4cce4e85473b8c43d90ec0ea562e7.zip
binutils-42fecb6183f4cce4e85473b8c43d90ec0ea562e7.tar.gz
binutils-42fecb6183f4cce4e85473b8c43d90ec0ea562e7.tar.bz2
Introduce ada_string_operation
This adds class ada_string_operation, which implements string constants for Ada. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * ada-lang.c (ada_string_operation::evaluate): New method. * ada-exp.h (class ada_string_operation): New.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/ada-exp.h13
-rw-r--r--gdb/ada-lang.c13
3 files changed, 31 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ff5862e..816f5a8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * ada-lang.c (ada_string_operation::evaluate): New method.
+ * ada-exp.h (class ada_string_operation): New.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* ada-lang.c (ada_wrapped_operation::evaluate): New method.
* ada-exp.h: New file.
diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h
index 3f780dc..88ed0c5 100644
--- a/gdb/ada-exp.h
+++ b/gdb/ada-exp.h
@@ -42,6 +42,19 @@ public:
{ return std::get<0> (m_storage)->opcode (); }
};
+/* An Ada string constant. */
+class ada_string_operation
+ : public string_operation
+{
+public:
+
+ using string_operation::string_operation;
+
+ value *evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside) override;
+};
+
} /* namespace expr */
#endif /* ADA_EXP_H */
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 4db5823..0666302 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10414,6 +10414,19 @@ ada_wrapped_operation::evaluate (struct type *expect_type,
return result;
}
+value *
+ada_string_operation::evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside)
+{
+ value *result = string_operation::evaluate (expect_type, exp, noside);
+ /* The result type will have code OP_STRING, bashed there from
+ OP_ARRAY. Bash it back. */
+ if (value_type (result)->code () == TYPE_CODE_STRING)
+ value_type (result)->set_code (TYPE_CODE_ARRAY);
+ return result;
+}
+
}
/* Implement the evaluate_exp routine in the exp_descriptor structure