aboutsummaryrefslogtreecommitdiff
path: root/gdb/m2-lang.c
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2020-06-18 22:01:33 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2020-06-23 13:34:11 +0100
commit39e7eccae602562368438c955b31f1d0e37feaa5 (patch)
tree3236e9c2818f16148ab08612b7a4ee8e3ec84540 /gdb/m2-lang.c
parent4ffc13fb0e4a1c5158cdf00f2751378653101207 (diff)
downloadgdb-39e7eccae602562368438c955b31f1d0e37feaa5.zip
gdb-39e7eccae602562368438c955b31f1d0e37feaa5.tar.gz
gdb-39e7eccae602562368438c955b31f1d0e37feaa5.tar.bz2
gdb: Convert language la_is_string_type_p field to a method
This commit changes the language_data::la_is_string_type_p function pointer member variable into a member function of language_defn. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_language_data): Delete la_is_string_type_p initializer. (ada_language::is_string_type_p): New member function. * c-lang.c (c_language_data): Delete la_is_string_type_p initializer. (cplus_language_data): Likewise. (asm_language_data): Likewise. (minimal_language_data): Likewise. * d-lang.c (d_language_data): Likewise. * f-lang.c (f_is_string_type_p): Delete function, implementation moved to f_language::is_string_type_p. (f_language_data): Delete la_is_string_type_p initializer. (f_language::is_string_type_p): New member function, implementation from f_is_string_type_p. * go-lang.c (go_is_string_type_p): Delete function, implementation moved to go_language::is_string_type_p. (go_language_data): Delete la_is_string_type_p initializer. (go_language::is_string_type_p): New member function, implementation from go_is_string_type_p. * language.c (language_defn::is_string_type_p): Define new member function. (default_is_string_type_p): Make static, add comment copied from header file. (unknown_language_data): Delete la_is_string_type_p initializer. (unknown_language::is_string_type_p): New member function. (auto_language_data): Delete la_is_string_type_p initializer. (auto_language::is_string_type_p): New member function. * language.h (language_data): Delete la_is_string_type_p field. (language_defn::is_string_type_p): Declare new function. (default_is_string_type_p): Delete desclaration, move comment to definition. * m2-lang.c (m2_is_string_type_p): Delete function, implementation moved to m2_language::is_string_type_p. (m2_language_data): Delete la_is_string_type_p initializer. (m2_language::is_string_type_p): New member function, implementation from m2_is_string_type_p. * objc-lang.c (objc_language_data): Delete la_is_string_type_p initializer. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_is_string_type_p): Delete function, implementation moved to pascal_language::is_string_type_p. (pascal_language_data): Delete la_is_string_type_p initializer. (pascal_language::is_string_type_p): New member function, implementation from pascal_is_string_type_p. * rust-lang.c (rust_is_string_type_p): Delete function, implementation moved to rust_language::is_string_type_p. (rust_language_data): Delete la_is_string_type_p initializer. (rust_language::is_string_type_p): New member function, implementation from rust_is_string_type_p. * valprint.c (val_print_scalar_or_string_type_p): Update call to is_string_type_p.
Diffstat (limited to 'gdb/m2-lang.c')
-rw-r--r--gdb/m2-lang.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index f0f7c22..2c39359 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -42,27 +42,6 @@ m2_printchar (int c, struct type *type, struct ui_file *stream)
fputs_filtered ("'", stream);
}
-/* Return true if TYPE is a string. */
-
-static bool
-m2_is_string_type_p (struct type *type)
-{
- type = check_typedef (type);
- if (type->code () == TYPE_CODE_ARRAY
- && TYPE_LENGTH (type) > 0
- && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
- {
- struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
-
- if (TYPE_LENGTH (elttype) == 1
- && (elttype->code () == TYPE_CODE_INT
- || elttype->code () == TYPE_CODE_CHAR))
- return true;
- }
-
- return false;
-}
-
static struct value *
evaluate_subexp_modula2 (struct type *expect_type, struct expression *exp,
int *pos, enum noside noside)
@@ -235,7 +214,6 @@ extern const struct language_data m2_language_data =
0, /* arrays are first-class (not c-style) */
0, /* String lower bound */
&default_varobj_ops,
- m2_is_string_type_p,
"{...}" /* la_struct_too_deep_ellipsis */
};
@@ -435,6 +413,25 @@ public:
m2_print_typedef (type, new_symbol, stream);
}
+ /* See language.h. */
+
+ bool is_string_type_p (struct type *type) const override
+ {
+ type = check_typedef (type);
+ if (type->code () == TYPE_CODE_ARRAY
+ && TYPE_LENGTH (type) > 0
+ && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
+ {
+ struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
+
+ if (TYPE_LENGTH (elttype) == 1
+ && (elttype->code () == TYPE_CODE_INT
+ || elttype->code () == TYPE_CODE_CHAR))
+ return true;
+ }
+
+ return false;
+ }
};
/* Single instance of the M2 language. */