m2-lang.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /* Modula 2 language support definitions for GDB, the GNU debugger.
  2. Copyright (C) 1992-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef M2_LANG_H
  15. #define M2_LANG_H
  16. struct type_print_options;
  17. struct parser_state;
  18. /* Defined in m2-typeprint.c */
  19. extern void m2_print_type (struct type *, const char *, struct ui_file *, int,
  20. int, const struct type_print_options *);
  21. extern int m2_is_long_set (struct type *type);
  22. extern int m2_is_unbounded_array (struct type *type);
  23. extern int get_long_set_bounds (struct type *type, LONGEST *low,
  24. LONGEST *high);
  25. /* Modula-2 types */
  26. struct builtin_m2_type
  27. {
  28. struct type *builtin_char;
  29. struct type *builtin_int;
  30. struct type *builtin_card;
  31. struct type *builtin_real;
  32. struct type *builtin_bool;
  33. };
  34. /* Return the Modula-2 type table for the specified architecture. */
  35. extern const struct builtin_m2_type *builtin_m2_type (struct gdbarch *gdbarch);
  36. /* Class representing the M2 language. */
  37. class m2_language : public language_defn
  38. {
  39. public:
  40. m2_language ()
  41. : language_defn (language_m2)
  42. { /* Nothing. */ }
  43. /* See language.h. */
  44. const char *name () const override
  45. { return "modula-2"; }
  46. /* See language.h. */
  47. const char *natural_name () const override
  48. { return "Modula-2"; }
  49. /* See language.h. */
  50. void language_arch_info (struct gdbarch *gdbarch,
  51. struct language_arch_info *lai) const override;
  52. /* See language.h. */
  53. void print_type (struct type *type, const char *varstring,
  54. struct ui_file *stream, int show, int level,
  55. const struct type_print_options *flags) const override
  56. {
  57. m2_print_type (type, varstring, stream, show, level, flags);
  58. }
  59. /* See language.h. */
  60. void value_print_inner (struct value *val, struct ui_file *stream,
  61. int recurse,
  62. const struct value_print_options *options) const override;
  63. /* See language.h. */
  64. int parser (struct parser_state *ps) const override;
  65. /* See language.h. */
  66. void emitchar (int ch, struct type *chtype,
  67. struct ui_file *stream, int quoter) const override;
  68. /* See language.h. */
  69. void printchar (int ch, struct type *chtype,
  70. struct ui_file *stream) const override;
  71. /* See language.h. */
  72. void printstr (struct ui_file *stream, struct type *elttype,
  73. const gdb_byte *string, unsigned int length,
  74. const char *encoding, int force_ellipses,
  75. const struct value_print_options *options) const override;
  76. /* See language.h. */
  77. void print_typedef (struct type *type, struct symbol *new_symbol,
  78. struct ui_file *stream) const override;
  79. /* See language.h. */
  80. bool is_string_type_p (struct type *type) const override
  81. {
  82. type = check_typedef (type);
  83. if (type->code () == TYPE_CODE_ARRAY
  84. && TYPE_LENGTH (type) > 0
  85. && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
  86. {
  87. struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
  88. if (TYPE_LENGTH (elttype) == 1
  89. && (elttype->code () == TYPE_CODE_INT
  90. || elttype->code () == TYPE_CODE_CHAR))
  91. return true;
  92. }
  93. return false;
  94. }
  95. /* See language.h. */
  96. bool c_style_arrays_p () const override
  97. { return false; }
  98. /* See language.h. Despite not having C-style arrays, Modula-2 uses 0
  99. for its string lower bounds. */
  100. char string_lower_bound () const override
  101. { return 0; }
  102. /* See language.h. */
  103. bool range_checking_on_by_default () const override
  104. { return true; }
  105. };
  106. #endif /* M2_LANG_H */