Automatic date update in version.in
[binutils-gdb.git] / gdb / go-typeprint.c
blob7778c71a3d24db5c6f092aa356b3dcc06018185d
1 /* Support for printing Go types for GDB, the GNU debugger.
3 Copyright (C) 2012-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* TODO:
21 - lots
22 - if the more complex types get Python pretty-printers, we'll
23 want a Python API for type printing
26 #include "gdbtypes.h"
27 #include "c-lang.h"
28 #include "go-lang.h"
30 /* Print a description of a type TYPE.
31 Output goes to STREAM (via stdio).
32 If VARSTRING is a non-empty string, print as an Ada variable/field
33 declaration.
34 SHOW+1 is the maximum number of levels of internal type structure
35 to show (this applies to record types, enumerated types, and
36 array types).
37 SHOW is the number of levels of internal type structure to show
38 when there is a type name for the SHOWth deepest level (0th is
39 outer level).
40 When SHOW<0, no inner structure is shown.
41 LEVEL indicates level of recursion (for nested definitions). */
43 void
44 go_language::print_type (struct type *type, const char *varstring,
45 struct ui_file *stream, int show, int level,
46 const struct type_print_options *flags) const
48 /* Borrowed from c-typeprint.c. */
49 if (show > 0)
50 type = check_typedef (type);
52 /* Print the type of "abc" as "string", not char[4]. */
53 if (type->code () == TYPE_CODE_ARRAY
54 && type->target_type ()->code () == TYPE_CODE_CHAR)
56 gdb_puts ("string", stream);
57 return;
60 /* Punt the rest to C for now. */
61 c_print_type (type, varstring, stream, show, level, la_language, flags);