15796c8dcSSimon Schubert /* Modula 2 language support routines for GDB, the GNU debugger.
25796c8dcSSimon Schubert
3*ef5ccd6cSJohn Marino Copyright (C) 1992-2013 Free Software Foundation, Inc.
45796c8dcSSimon Schubert
55796c8dcSSimon Schubert This file is part of GDB.
65796c8dcSSimon Schubert
75796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify
85796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by
95796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or
105796c8dcSSimon Schubert (at your option) any later version.
115796c8dcSSimon Schubert
125796c8dcSSimon Schubert This program is distributed in the hope that it will be useful,
135796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of
145796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
155796c8dcSSimon Schubert GNU General Public License for more details.
165796c8dcSSimon Schubert
175796c8dcSSimon Schubert You should have received a copy of the GNU General Public License
185796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */
195796c8dcSSimon Schubert
205796c8dcSSimon Schubert #include "defs.h"
215796c8dcSSimon Schubert #include "symtab.h"
225796c8dcSSimon Schubert #include "gdbtypes.h"
235796c8dcSSimon Schubert #include "expression.h"
245796c8dcSSimon Schubert #include "parser-defs.h"
255796c8dcSSimon Schubert #include "language.h"
265796c8dcSSimon Schubert #include "m2-lang.h"
275796c8dcSSimon Schubert #include "c-lang.h"
285796c8dcSSimon Schubert #include "valprint.h"
295796c8dcSSimon Schubert
305796c8dcSSimon Schubert extern void _initialize_m2_language (void);
315796c8dcSSimon Schubert static void m2_printchar (int, struct type *, struct ui_file *);
325796c8dcSSimon Schubert static void m2_emit_char (int, struct type *, struct ui_file *, int);
335796c8dcSSimon Schubert
345796c8dcSSimon Schubert /* Print the character C on STREAM as part of the contents of a literal
355796c8dcSSimon Schubert string whose delimiter is QUOTER. Note that that format for printing
365796c8dcSSimon Schubert characters and strings is language specific.
375796c8dcSSimon Schubert FIXME: This is a copy of the same function from c-exp.y. It should
385796c8dcSSimon Schubert be replaced with a true Modula version. */
395796c8dcSSimon Schubert
405796c8dcSSimon Schubert static void
m2_emit_char(int c,struct type * type,struct ui_file * stream,int quoter)415796c8dcSSimon Schubert m2_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
425796c8dcSSimon Schubert {
435796c8dcSSimon Schubert
44c50c785cSJohn Marino c &= 0xFF; /* Avoid sign bit follies. */
455796c8dcSSimon Schubert
465796c8dcSSimon Schubert if (PRINT_LITERAL_FORM (c))
475796c8dcSSimon Schubert {
485796c8dcSSimon Schubert if (c == '\\' || c == quoter)
495796c8dcSSimon Schubert {
505796c8dcSSimon Schubert fputs_filtered ("\\", stream);
515796c8dcSSimon Schubert }
525796c8dcSSimon Schubert fprintf_filtered (stream, "%c", c);
535796c8dcSSimon Schubert }
545796c8dcSSimon Schubert else
555796c8dcSSimon Schubert {
565796c8dcSSimon Schubert switch (c)
575796c8dcSSimon Schubert {
585796c8dcSSimon Schubert case '\n':
595796c8dcSSimon Schubert fputs_filtered ("\\n", stream);
605796c8dcSSimon Schubert break;
615796c8dcSSimon Schubert case '\b':
625796c8dcSSimon Schubert fputs_filtered ("\\b", stream);
635796c8dcSSimon Schubert break;
645796c8dcSSimon Schubert case '\t':
655796c8dcSSimon Schubert fputs_filtered ("\\t", stream);
665796c8dcSSimon Schubert break;
675796c8dcSSimon Schubert case '\f':
685796c8dcSSimon Schubert fputs_filtered ("\\f", stream);
695796c8dcSSimon Schubert break;
705796c8dcSSimon Schubert case '\r':
715796c8dcSSimon Schubert fputs_filtered ("\\r", stream);
725796c8dcSSimon Schubert break;
735796c8dcSSimon Schubert case '\033':
745796c8dcSSimon Schubert fputs_filtered ("\\e", stream);
755796c8dcSSimon Schubert break;
765796c8dcSSimon Schubert case '\007':
775796c8dcSSimon Schubert fputs_filtered ("\\a", stream);
785796c8dcSSimon Schubert break;
795796c8dcSSimon Schubert default:
805796c8dcSSimon Schubert fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
815796c8dcSSimon Schubert break;
825796c8dcSSimon Schubert }
835796c8dcSSimon Schubert }
845796c8dcSSimon Schubert }
855796c8dcSSimon Schubert
865796c8dcSSimon Schubert /* FIXME: This is a copy of the same function from c-exp.y. It should
875796c8dcSSimon Schubert be replaced with a true Modula version. */
885796c8dcSSimon Schubert
895796c8dcSSimon Schubert static void
m2_printchar(int c,struct type * type,struct ui_file * stream)905796c8dcSSimon Schubert m2_printchar (int c, struct type *type, struct ui_file *stream)
915796c8dcSSimon Schubert {
925796c8dcSSimon Schubert fputs_filtered ("'", stream);
935796c8dcSSimon Schubert LA_EMIT_CHAR (c, type, stream, '\'');
945796c8dcSSimon Schubert fputs_filtered ("'", stream);
955796c8dcSSimon Schubert }
965796c8dcSSimon Schubert
975796c8dcSSimon Schubert /* Print the character string STRING, printing at most LENGTH characters.
985796c8dcSSimon Schubert Printing stops early if the number hits print_max; repeat counts
995796c8dcSSimon Schubert are printed as appropriate. Print ellipses at the end if we
1005796c8dcSSimon Schubert had to stop before printing LENGTH characters, or if FORCE_ELLIPSES.
1015796c8dcSSimon Schubert FIXME: This is a copy of the same function from c-exp.y. It should
1025796c8dcSSimon Schubert be replaced with a true Modula version. */
1035796c8dcSSimon Schubert
1045796c8dcSSimon Schubert static void
m2_printstr(struct ui_file * stream,struct type * type,const gdb_byte * string,unsigned int length,const char * encoding,int force_ellipses,const struct value_print_options * options)1055796c8dcSSimon Schubert m2_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
106cf7f2e2dSJohn Marino unsigned int length, const char *encoding, int force_ellipses,
1075796c8dcSSimon Schubert const struct value_print_options *options)
1085796c8dcSSimon Schubert {
1095796c8dcSSimon Schubert unsigned int i;
1105796c8dcSSimon Schubert unsigned int things_printed = 0;
1115796c8dcSSimon Schubert int in_quotes = 0;
1125796c8dcSSimon Schubert int need_comma = 0;
1135796c8dcSSimon Schubert
1145796c8dcSSimon Schubert if (length == 0)
1155796c8dcSSimon Schubert {
1165796c8dcSSimon Schubert fputs_filtered ("\"\"", gdb_stdout);
1175796c8dcSSimon Schubert return;
1185796c8dcSSimon Schubert }
1195796c8dcSSimon Schubert
1205796c8dcSSimon Schubert for (i = 0; i < length && things_printed < options->print_max; ++i)
1215796c8dcSSimon Schubert {
1225796c8dcSSimon Schubert /* Position of the character we are examining
1235796c8dcSSimon Schubert to see whether it is repeated. */
1245796c8dcSSimon Schubert unsigned int rep1;
1255796c8dcSSimon Schubert /* Number of repetitions we have detected so far. */
1265796c8dcSSimon Schubert unsigned int reps;
1275796c8dcSSimon Schubert
1285796c8dcSSimon Schubert QUIT;
1295796c8dcSSimon Schubert
1305796c8dcSSimon Schubert if (need_comma)
1315796c8dcSSimon Schubert {
1325796c8dcSSimon Schubert fputs_filtered (", ", stream);
1335796c8dcSSimon Schubert need_comma = 0;
1345796c8dcSSimon Schubert }
1355796c8dcSSimon Schubert
1365796c8dcSSimon Schubert rep1 = i + 1;
1375796c8dcSSimon Schubert reps = 1;
1385796c8dcSSimon Schubert while (rep1 < length && string[rep1] == string[i])
1395796c8dcSSimon Schubert {
1405796c8dcSSimon Schubert ++rep1;
1415796c8dcSSimon Schubert ++reps;
1425796c8dcSSimon Schubert }
1435796c8dcSSimon Schubert
1445796c8dcSSimon Schubert if (reps > options->repeat_count_threshold)
1455796c8dcSSimon Schubert {
1465796c8dcSSimon Schubert if (in_quotes)
1475796c8dcSSimon Schubert {
1485796c8dcSSimon Schubert fputs_filtered ("\", ", stream);
1495796c8dcSSimon Schubert in_quotes = 0;
1505796c8dcSSimon Schubert }
1515796c8dcSSimon Schubert m2_printchar (string[i], type, stream);
1525796c8dcSSimon Schubert fprintf_filtered (stream, " <repeats %u times>", reps);
1535796c8dcSSimon Schubert i = rep1 - 1;
1545796c8dcSSimon Schubert things_printed += options->repeat_count_threshold;
1555796c8dcSSimon Schubert need_comma = 1;
1565796c8dcSSimon Schubert }
1575796c8dcSSimon Schubert else
1585796c8dcSSimon Schubert {
1595796c8dcSSimon Schubert if (!in_quotes)
1605796c8dcSSimon Schubert {
1615796c8dcSSimon Schubert fputs_filtered ("\"", stream);
1625796c8dcSSimon Schubert in_quotes = 1;
1635796c8dcSSimon Schubert }
1645796c8dcSSimon Schubert LA_EMIT_CHAR (string[i], type, stream, '"');
1655796c8dcSSimon Schubert ++things_printed;
1665796c8dcSSimon Schubert }
1675796c8dcSSimon Schubert }
1685796c8dcSSimon Schubert
1695796c8dcSSimon Schubert /* Terminate the quotes if necessary. */
1705796c8dcSSimon Schubert if (in_quotes)
1715796c8dcSSimon Schubert fputs_filtered ("\"", stream);
1725796c8dcSSimon Schubert
1735796c8dcSSimon Schubert if (force_ellipses || i < length)
1745796c8dcSSimon Schubert fputs_filtered ("...", stream);
1755796c8dcSSimon Schubert }
1765796c8dcSSimon Schubert
1775796c8dcSSimon Schubert static struct value *
evaluate_subexp_modula2(struct type * expect_type,struct expression * exp,int * pos,enum noside noside)1785796c8dcSSimon Schubert evaluate_subexp_modula2 (struct type *expect_type, struct expression *exp,
1795796c8dcSSimon Schubert int *pos, enum noside noside)
1805796c8dcSSimon Schubert {
1815796c8dcSSimon Schubert enum exp_opcode op = exp->elts[*pos].opcode;
1825796c8dcSSimon Schubert struct value *arg1;
1835796c8dcSSimon Schubert struct value *arg2;
1845796c8dcSSimon Schubert struct type *type;
185cf7f2e2dSJohn Marino
1865796c8dcSSimon Schubert switch (op)
1875796c8dcSSimon Schubert {
1885796c8dcSSimon Schubert case UNOP_HIGH:
1895796c8dcSSimon Schubert (*pos)++;
1905796c8dcSSimon Schubert arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
1915796c8dcSSimon Schubert
1925796c8dcSSimon Schubert if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
1935796c8dcSSimon Schubert return arg1;
1945796c8dcSSimon Schubert else
1955796c8dcSSimon Schubert {
1965796c8dcSSimon Schubert arg1 = coerce_ref (arg1);
1975796c8dcSSimon Schubert type = check_typedef (value_type (arg1));
1985796c8dcSSimon Schubert
1995796c8dcSSimon Schubert if (m2_is_unbounded_array (type))
2005796c8dcSSimon Schubert {
2015796c8dcSSimon Schubert struct value *temp = arg1;
202cf7f2e2dSJohn Marino
2035796c8dcSSimon Schubert type = TYPE_FIELD_TYPE (type, 1);
2045796c8dcSSimon Schubert /* i18n: Do not translate the "_m2_high" part! */
2055796c8dcSSimon Schubert arg1 = value_struct_elt (&temp, NULL, "_m2_high", NULL,
2065796c8dcSSimon Schubert _("unbounded structure "
2075796c8dcSSimon Schubert "missing _m2_high field"));
2085796c8dcSSimon Schubert
2095796c8dcSSimon Schubert if (value_type (arg1) != type)
2105796c8dcSSimon Schubert arg1 = value_cast (type, arg1);
2115796c8dcSSimon Schubert }
2125796c8dcSSimon Schubert }
2135796c8dcSSimon Schubert return arg1;
2145796c8dcSSimon Schubert
2155796c8dcSSimon Schubert case BINOP_SUBSCRIPT:
2165796c8dcSSimon Schubert (*pos)++;
2175796c8dcSSimon Schubert arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
2185796c8dcSSimon Schubert arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
2195796c8dcSSimon Schubert if (noside == EVAL_SKIP)
2205796c8dcSSimon Schubert goto nosideret;
2215796c8dcSSimon Schubert /* If the user attempts to subscript something that is not an
2225796c8dcSSimon Schubert array or pointer type (like a plain int variable for example),
2235796c8dcSSimon Schubert then report this as an error. */
2245796c8dcSSimon Schubert
2255796c8dcSSimon Schubert arg1 = coerce_ref (arg1);
2265796c8dcSSimon Schubert type = check_typedef (value_type (arg1));
2275796c8dcSSimon Schubert
2285796c8dcSSimon Schubert if (m2_is_unbounded_array (type))
2295796c8dcSSimon Schubert {
2305796c8dcSSimon Schubert struct value *temp = arg1;
2315796c8dcSSimon Schubert type = TYPE_FIELD_TYPE (type, 0);
232cf7f2e2dSJohn Marino if (type == NULL || (TYPE_CODE (type) != TYPE_CODE_PTR))
233cf7f2e2dSJohn Marino {
234c50c785cSJohn Marino warning (_("internal error: unbounded "
235c50c785cSJohn Marino "array structure is unknown"));
2365796c8dcSSimon Schubert return evaluate_subexp_standard (expect_type, exp, pos, noside);
2375796c8dcSSimon Schubert }
2385796c8dcSSimon Schubert /* i18n: Do not translate the "_m2_contents" part! */
2395796c8dcSSimon Schubert arg1 = value_struct_elt (&temp, NULL, "_m2_contents", NULL,
2405796c8dcSSimon Schubert _("unbounded structure "
2415796c8dcSSimon Schubert "missing _m2_contents field"));
2425796c8dcSSimon Schubert
2435796c8dcSSimon Schubert if (value_type (arg1) != type)
2445796c8dcSSimon Schubert arg1 = value_cast (type, arg1);
2455796c8dcSSimon Schubert
246c50c785cSJohn Marino check_typedef (value_type (arg1));
2475796c8dcSSimon Schubert return value_ind (value_ptradd (arg1, value_as_long (arg2)));
2485796c8dcSSimon Schubert }
2495796c8dcSSimon Schubert else
2505796c8dcSSimon Schubert if (TYPE_CODE (type) != TYPE_CODE_ARRAY)
2515796c8dcSSimon Schubert {
2525796c8dcSSimon Schubert if (TYPE_NAME (type))
2535796c8dcSSimon Schubert error (_("cannot subscript something of type `%s'"),
2545796c8dcSSimon Schubert TYPE_NAME (type));
2555796c8dcSSimon Schubert else
2565796c8dcSSimon Schubert error (_("cannot subscript requested type"));
2575796c8dcSSimon Schubert }
2585796c8dcSSimon Schubert
2595796c8dcSSimon Schubert if (noside == EVAL_AVOID_SIDE_EFFECTS)
2605796c8dcSSimon Schubert return value_zero (TYPE_TARGET_TYPE (type), VALUE_LVAL (arg1));
2615796c8dcSSimon Schubert else
2625796c8dcSSimon Schubert return value_subscript (arg1, value_as_long (arg2));
2635796c8dcSSimon Schubert
2645796c8dcSSimon Schubert default:
2655796c8dcSSimon Schubert return evaluate_subexp_standard (expect_type, exp, pos, noside);
2665796c8dcSSimon Schubert }
2675796c8dcSSimon Schubert
2685796c8dcSSimon Schubert nosideret:
2695796c8dcSSimon Schubert return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, 1);
2705796c8dcSSimon Schubert }
2715796c8dcSSimon Schubert
2725796c8dcSSimon Schubert
2735796c8dcSSimon Schubert /* Table of operators and their precedences for printing expressions. */
2745796c8dcSSimon Schubert
2755796c8dcSSimon Schubert static const struct op_print m2_op_print_tab[] =
2765796c8dcSSimon Schubert {
2775796c8dcSSimon Schubert {"+", BINOP_ADD, PREC_ADD, 0},
2785796c8dcSSimon Schubert {"+", UNOP_PLUS, PREC_PREFIX, 0},
2795796c8dcSSimon Schubert {"-", BINOP_SUB, PREC_ADD, 0},
2805796c8dcSSimon Schubert {"-", UNOP_NEG, PREC_PREFIX, 0},
2815796c8dcSSimon Schubert {"*", BINOP_MUL, PREC_MUL, 0},
2825796c8dcSSimon Schubert {"/", BINOP_DIV, PREC_MUL, 0},
2835796c8dcSSimon Schubert {"DIV", BINOP_INTDIV, PREC_MUL, 0},
2845796c8dcSSimon Schubert {"MOD", BINOP_REM, PREC_MUL, 0},
2855796c8dcSSimon Schubert {":=", BINOP_ASSIGN, PREC_ASSIGN, 1},
2865796c8dcSSimon Schubert {"OR", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0},
2875796c8dcSSimon Schubert {"AND", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0},
2885796c8dcSSimon Schubert {"NOT", UNOP_LOGICAL_NOT, PREC_PREFIX, 0},
2895796c8dcSSimon Schubert {"=", BINOP_EQUAL, PREC_EQUAL, 0},
2905796c8dcSSimon Schubert {"<>", BINOP_NOTEQUAL, PREC_EQUAL, 0},
2915796c8dcSSimon Schubert {"<=", BINOP_LEQ, PREC_ORDER, 0},
2925796c8dcSSimon Schubert {">=", BINOP_GEQ, PREC_ORDER, 0},
2935796c8dcSSimon Schubert {">", BINOP_GTR, PREC_ORDER, 0},
2945796c8dcSSimon Schubert {"<", BINOP_LESS, PREC_ORDER, 0},
2955796c8dcSSimon Schubert {"^", UNOP_IND, PREC_PREFIX, 0},
2965796c8dcSSimon Schubert {"@", BINOP_REPEAT, PREC_REPEAT, 0},
2975796c8dcSSimon Schubert {"CAP", UNOP_CAP, PREC_BUILTIN_FUNCTION, 0},
2985796c8dcSSimon Schubert {"CHR", UNOP_CHR, PREC_BUILTIN_FUNCTION, 0},
2995796c8dcSSimon Schubert {"ORD", UNOP_ORD, PREC_BUILTIN_FUNCTION, 0},
3005796c8dcSSimon Schubert {"FLOAT", UNOP_FLOAT, PREC_BUILTIN_FUNCTION, 0},
3015796c8dcSSimon Schubert {"HIGH", UNOP_HIGH, PREC_BUILTIN_FUNCTION, 0},
3025796c8dcSSimon Schubert {"MAX", UNOP_MAX, PREC_BUILTIN_FUNCTION, 0},
3035796c8dcSSimon Schubert {"MIN", UNOP_MIN, PREC_BUILTIN_FUNCTION, 0},
3045796c8dcSSimon Schubert {"ODD", UNOP_ODD, PREC_BUILTIN_FUNCTION, 0},
3055796c8dcSSimon Schubert {"TRUNC", UNOP_TRUNC, PREC_BUILTIN_FUNCTION, 0},
3065796c8dcSSimon Schubert {NULL, 0, 0, 0}
3075796c8dcSSimon Schubert };
3085796c8dcSSimon Schubert
3095796c8dcSSimon Schubert /* The built-in types of Modula-2. */
3105796c8dcSSimon Schubert
3115796c8dcSSimon Schubert enum m2_primitive_types {
3125796c8dcSSimon Schubert m2_primitive_type_char,
3135796c8dcSSimon Schubert m2_primitive_type_int,
3145796c8dcSSimon Schubert m2_primitive_type_card,
3155796c8dcSSimon Schubert m2_primitive_type_real,
3165796c8dcSSimon Schubert m2_primitive_type_bool,
3175796c8dcSSimon Schubert nr_m2_primitive_types
3185796c8dcSSimon Schubert };
3195796c8dcSSimon Schubert
3205796c8dcSSimon Schubert static void
m2_language_arch_info(struct gdbarch * gdbarch,struct language_arch_info * lai)3215796c8dcSSimon Schubert m2_language_arch_info (struct gdbarch *gdbarch,
3225796c8dcSSimon Schubert struct language_arch_info *lai)
3235796c8dcSSimon Schubert {
3245796c8dcSSimon Schubert const struct builtin_m2_type *builtin = builtin_m2_type (gdbarch);
3255796c8dcSSimon Schubert
3265796c8dcSSimon Schubert lai->string_char_type = builtin->builtin_char;
3275796c8dcSSimon Schubert lai->primitive_type_vector
3285796c8dcSSimon Schubert = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_m2_primitive_types + 1,
3295796c8dcSSimon Schubert struct type *);
3305796c8dcSSimon Schubert
3315796c8dcSSimon Schubert lai->primitive_type_vector [m2_primitive_type_char]
3325796c8dcSSimon Schubert = builtin->builtin_char;
3335796c8dcSSimon Schubert lai->primitive_type_vector [m2_primitive_type_int]
3345796c8dcSSimon Schubert = builtin->builtin_int;
3355796c8dcSSimon Schubert lai->primitive_type_vector [m2_primitive_type_card]
3365796c8dcSSimon Schubert = builtin->builtin_card;
3375796c8dcSSimon Schubert lai->primitive_type_vector [m2_primitive_type_real]
3385796c8dcSSimon Schubert = builtin->builtin_real;
3395796c8dcSSimon Schubert lai->primitive_type_vector [m2_primitive_type_bool]
3405796c8dcSSimon Schubert = builtin->builtin_bool;
3415796c8dcSSimon Schubert
3425796c8dcSSimon Schubert lai->bool_type_symbol = "BOOLEAN";
3435796c8dcSSimon Schubert lai->bool_type_default = builtin->builtin_bool;
3445796c8dcSSimon Schubert }
3455796c8dcSSimon Schubert
3465796c8dcSSimon Schubert const struct exp_descriptor exp_descriptor_modula2 =
3475796c8dcSSimon Schubert {
3485796c8dcSSimon Schubert print_subexp_standard,
3495796c8dcSSimon Schubert operator_length_standard,
350cf7f2e2dSJohn Marino operator_check_standard,
3515796c8dcSSimon Schubert op_name_standard,
3525796c8dcSSimon Schubert dump_subexp_body_standard,
3535796c8dcSSimon Schubert evaluate_subexp_modula2
3545796c8dcSSimon Schubert };
3555796c8dcSSimon Schubert
3565796c8dcSSimon Schubert const struct language_defn m2_language_defn =
3575796c8dcSSimon Schubert {
3585796c8dcSSimon Schubert "modula-2",
3595796c8dcSSimon Schubert language_m2,
3605796c8dcSSimon Schubert range_check_on,
3615796c8dcSSimon Schubert case_sensitive_on,
3625796c8dcSSimon Schubert array_row_major,
3635796c8dcSSimon Schubert macro_expansion_no,
3645796c8dcSSimon Schubert &exp_descriptor_modula2,
3655796c8dcSSimon Schubert m2_parse, /* parser */
3665796c8dcSSimon Schubert m2_error, /* parser error function */
3675796c8dcSSimon Schubert null_post_parser,
3685796c8dcSSimon Schubert m2_printchar, /* Print character constant */
3695796c8dcSSimon Schubert m2_printstr, /* function to print string constant */
3705796c8dcSSimon Schubert m2_emit_char, /* Function to print a single character */
3715796c8dcSSimon Schubert m2_print_type, /* Print a type using appropriate syntax */
3725796c8dcSSimon Schubert m2_print_typedef, /* Print a typedef using appropriate syntax */
3735796c8dcSSimon Schubert m2_val_print, /* Print a value using appropriate syntax */
3745796c8dcSSimon Schubert c_value_print, /* Print a top-level value */
375*ef5ccd6cSJohn Marino default_read_var_value, /* la_read_var_value */
3765796c8dcSSimon Schubert NULL, /* Language specific skip_trampoline */
3775796c8dcSSimon Schubert NULL, /* name_of_this */
3785796c8dcSSimon Schubert basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
3795796c8dcSSimon Schubert basic_lookup_transparent_type,/* lookup_transparent_type */
3805796c8dcSSimon Schubert NULL, /* Language specific symbol demangler */
381c50c785cSJohn Marino NULL, /* Language specific
382c50c785cSJohn Marino class_name_from_physname */
3835796c8dcSSimon Schubert m2_op_print_tab, /* expression operators for printing */
3845796c8dcSSimon Schubert 0, /* arrays are first-class (not c-style) */
3855796c8dcSSimon Schubert 0, /* String lower bound */
3865796c8dcSSimon Schubert default_word_break_characters,
3875796c8dcSSimon Schubert default_make_symbol_completion_list,
3885796c8dcSSimon Schubert m2_language_arch_info,
3895796c8dcSSimon Schubert default_print_array_index,
3905796c8dcSSimon Schubert default_pass_by_reference,
3915796c8dcSSimon Schubert default_get_string,
392*ef5ccd6cSJohn Marino NULL, /* la_get_symbol_name_cmp */
393a45ae5f8SJohn Marino iterate_over_symbols,
3945796c8dcSSimon Schubert LANG_MAGIC
3955796c8dcSSimon Schubert };
3965796c8dcSSimon Schubert
3975796c8dcSSimon Schubert static void *
build_m2_types(struct gdbarch * gdbarch)3985796c8dcSSimon Schubert build_m2_types (struct gdbarch *gdbarch)
3995796c8dcSSimon Schubert {
4005796c8dcSSimon Schubert struct builtin_m2_type *builtin_m2_type
4015796c8dcSSimon Schubert = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_m2_type);
4025796c8dcSSimon Schubert
4035796c8dcSSimon Schubert /* Modula-2 "pervasive" types. NOTE: these can be redefined!!! */
4045796c8dcSSimon Schubert builtin_m2_type->builtin_int
4055796c8dcSSimon Schubert = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 0, "INTEGER");
4065796c8dcSSimon Schubert builtin_m2_type->builtin_card
4075796c8dcSSimon Schubert = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 1, "CARDINAL");
4085796c8dcSSimon Schubert builtin_m2_type->builtin_real
4095796c8dcSSimon Schubert = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), "REAL", NULL);
4105796c8dcSSimon Schubert builtin_m2_type->builtin_char
4115796c8dcSSimon Schubert = arch_character_type (gdbarch, TARGET_CHAR_BIT, 1, "CHAR");
4125796c8dcSSimon Schubert builtin_m2_type->builtin_bool
4135796c8dcSSimon Schubert = arch_boolean_type (gdbarch, gdbarch_int_bit (gdbarch), 1, "BOOLEAN");
4145796c8dcSSimon Schubert
4155796c8dcSSimon Schubert return builtin_m2_type;
4165796c8dcSSimon Schubert }
4175796c8dcSSimon Schubert
4185796c8dcSSimon Schubert static struct gdbarch_data *m2_type_data;
4195796c8dcSSimon Schubert
4205796c8dcSSimon Schubert const struct builtin_m2_type *
builtin_m2_type(struct gdbarch * gdbarch)4215796c8dcSSimon Schubert builtin_m2_type (struct gdbarch *gdbarch)
4225796c8dcSSimon Schubert {
4235796c8dcSSimon Schubert return gdbarch_data (gdbarch, m2_type_data);
4245796c8dcSSimon Schubert }
4255796c8dcSSimon Schubert
4265796c8dcSSimon Schubert
4275796c8dcSSimon Schubert /* Initialization for Modula-2 */
4285796c8dcSSimon Schubert
4295796c8dcSSimon Schubert void
_initialize_m2_language(void)4305796c8dcSSimon Schubert _initialize_m2_language (void)
4315796c8dcSSimon Schubert {
4325796c8dcSSimon Schubert m2_type_data = gdbarch_data_register_post_init (build_m2_types);
4335796c8dcSSimon Schubert
4345796c8dcSSimon Schubert add_language (&m2_language_defn);
4355796c8dcSSimon Schubert }
436