+/* Base class from which all other language classes derive. */
+
+struct language_defn : language_data
+{
+ language_defn (enum language lang, const language_data &init_data)
+ : language_data (init_data)
+ {
+ /* We should only ever create one instance of each language. */
+ gdb_assert (languages[lang] == nullptr);
+ languages[lang] = this;
+ }
+
+ /* Print the index of an element of an array. This default
+ implementation prints using C99 syntax. */
+
+ virtual void print_array_index (struct type *index_type,
+ LONGEST index_value,
+ struct ui_file *stream,
+ const value_print_options *options) const;
+
+ /* Given a symbol VAR, the corresponding block VAR_BLOCK (if any) and a
+ stack frame id FRAME, read the value of the variable and return (pointer
+ to a) struct value containing the value.
+
+ VAR_BLOCK is needed if there's a possibility for VAR to be outside
+ FRAME. This is what happens if FRAME correspond to a nested function
+ and VAR is defined in the outer function. If callers know that VAR is
+ located in FRAME or is global/static, NULL can be passed as VAR_BLOCK.
+
+ Throw an error if the variable cannot be found. */
+
+ virtual struct value *read_var_value (struct symbol *var,
+ const struct block *var_block,
+ struct frame_info *frame) const;
+
+ /* Return information about whether TYPE should be passed
+ (and returned) by reference at the language level. The default
+ implementation returns a LANGUAGE_PASS_BY_REF_INFO initialised in its
+ default state. */
+
+ virtual struct language_pass_by_ref_info pass_by_reference_info
+ (struct type *type) const
+ {
+ return {};
+ }
+
+ /* The per-architecture (OS/ABI) language information. */
+
+ virtual void language_arch_info (struct gdbarch *,
+ struct language_arch_info *) const = 0;
+
+ /* Find the definition of the type with the given name. */
+
+ virtual struct type *lookup_transparent_type (const char *name) const
+ {
+ return basic_lookup_transparent_type (name);
+ }
+
+ /* Find all symbols in the current program space matching NAME in
+ DOMAIN, according to this language's rules.
+
+ The search is done in BLOCK only.
+ The caller is responsible for iterating up through superblocks
+ if desired.
+
+ For each one, call CALLBACK with the symbol. If CALLBACK
+ returns false, the iteration ends at that point.
+
+ This field may not be NULL. If the language does not need any
+ special processing here, 'iterate_over_symbols' should be
+ used as the definition. */
+ virtual bool iterate_over_symbols
+ (const struct block *block, const lookup_name_info &name,
+ domain_enum domain,
+ gdb::function_view<symbol_found_callback_ftype> callback) const
+ {
+ return ::iterate_over_symbols (block, name, domain, callback);
+ }
+
+ /* If this language allows compilation from the gdb command line, then
+ this method will return an instance of struct gcc_context appropriate
+ to the language. If compilation for this language is generally
+ supported, but something goes wrong then an exception is thrown. The
+ returned compiler instance is owned by its caller and must be
+ deallocated by the caller. If compilation is not supported for this
+ language then this method returns NULL. */
+
+ virtual compile_instance *get_compile_instance () const
+ {
+ return nullptr;
+ }
+
+ /* Hash the given symbol search name. */
+ virtual unsigned int search_name_hash (const char *name) const;
+
+ /* Demangle a symbol according to this language's rules. Unlike
+ la_demangle, this does not take any options.
+
+ *DEMANGLED will be set by this function.
+
+ If this function returns false, then *DEMANGLED must always be set
+ to NULL.
+
+ If this function returns true, the implementation may set this to
+ a xmalloc'd string holding the demangled form. However, it is
+ not required to. The string, if any, is owned by the caller.
+
+ The resulting string should be of the form that will be
+ installed into a symbol. */
+ virtual bool sniff_from_mangled_name (const char *mangled,
+ char **demangled) const
+ {
+ *demangled = nullptr;
+ return false;
+ }
+
+ /* Return demangled language symbol version of MANGLED, or NULL. */
+ virtual char *demangle (const char *mangled, int options) const
+ {
+ return nullptr;
+ }
+
+ /* Print a type using syntax appropriate for this language. */
+
+ virtual void print_type (struct type *, const char *, struct ui_file *, int,
+ int, const struct type_print_options *) const = 0;
+
+ /* PC is possibly an unknown languages trampoline.
+ If that PC falls in a trampoline belonging to this language, return
+ the address of the first pc in the real function, or 0 if it isn't a
+ language tramp for this language. */
+ virtual CORE_ADDR skip_trampoline (struct frame_info *fi, CORE_ADDR pc) const
+ {
+ return (CORE_ADDR) 0;
+ }
+
+ /* List of all known languages. */
+ static const struct language_defn *languages[nr_languages];
+};