gdb: Convert language_data::string_lower_bound to a method
authorAndrew Burgess <andrew.burgess@embecosm.com>
Sun, 5 Jul 2020 08:29:34 +0000 (09:29 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 16 Sep 2020 09:16:48 +0000 (10:16 +0100)
commit22c12a6c70a0bf1c292478436f12df0a2d84c2a2
treeeb8f23e76fedac0151280623ebe9d055819b34d3
parent1c236ddd45b182b6f4895b276183cdd8382d3e1b
gdb: Convert language_data::string_lower_bound to a method

Convert language_data::string_lower_bound member variable to a virtual
method language_defn::string_lower_bound.

Over all of the languages we currently support there are currently
only two values for the lower bound, 0 or 1.  I noticed that in all
cases, if a language has C style arrays then the lower bound is 0,
otherwise the lower bound is 1.  So the default for the virtual method
in language.h makes use of this, which means languages don't have to
worry about providing a string_lower_bound method at all.

Except for Modula2.  This language is defined to not have C style
arrays, but has a string_lower_bound index of 0, this behaviour is
maintained after this commit by having Modula2 be the only language
that overrides the string_lower_bound method.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove string_lower_bound
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Remove string_lower_bound field.
(language_defn::string_lower_bound): New member function.
* m2-lang.c (m2_language_data): Remove string_lower_bound
initializer.
(m2_language::string_lower_bound): New member function.
* objc-lang.c (objc_language_data): Remove string_lower_bound
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
* valops.c (value_cstring): Update call to string_lower_bound.
(value_string): Likewise.
* value.c (allocate_repeated_value): Likewise.
15 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/c-lang.c
gdb/d-lang.c
gdb/f-lang.c
gdb/go-lang.c
gdb/language.c
gdb/language.h
gdb/m2-lang.c
gdb/objc-lang.c
gdb/opencl-lang.c
gdb/p-lang.c
gdb/rust-lang.c
gdb/valops.c
gdb/value.c
This page took 0.042268 seconds and 4 git commands to generate.