15796c8dcSSimon Schubert /* Pascal language support routines for GDB, the GNU debugger.
25796c8dcSSimon Schubert
3*ef5ccd6cSJohn Marino Copyright (C) 2000-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 /* This file is derived from c-lang.c */
215796c8dcSSimon Schubert
225796c8dcSSimon Schubert #include "defs.h"
235796c8dcSSimon Schubert #include "gdb_string.h"
245796c8dcSSimon Schubert #include "symtab.h"
255796c8dcSSimon Schubert #include "gdbtypes.h"
265796c8dcSSimon Schubert #include "expression.h"
275796c8dcSSimon Schubert #include "parser-defs.h"
285796c8dcSSimon Schubert #include "language.h"
295796c8dcSSimon Schubert #include "p-lang.h"
305796c8dcSSimon Schubert #include "valprint.h"
315796c8dcSSimon Schubert #include "value.h"
325796c8dcSSimon Schubert #include <ctype.h>
335796c8dcSSimon Schubert
345796c8dcSSimon Schubert extern void _initialize_pascal_language (void);
355796c8dcSSimon Schubert
365796c8dcSSimon Schubert
375796c8dcSSimon Schubert /* All GPC versions until now (2007-09-27) also define a symbol called
385796c8dcSSimon Schubert '_p_initialize'. Check for the presence of this symbol first. */
395796c8dcSSimon Schubert static const char GPC_P_INITIALIZE[] = "_p_initialize";
405796c8dcSSimon Schubert
415796c8dcSSimon Schubert /* The name of the symbol that GPC uses as the name of the main
425796c8dcSSimon Schubert procedure (since version 20050212). */
435796c8dcSSimon Schubert static const char GPC_MAIN_PROGRAM_NAME_1[] = "_p__M0_main_program";
445796c8dcSSimon Schubert
455796c8dcSSimon Schubert /* Older versions of GPC (versions older than 20050212) were using
465796c8dcSSimon Schubert a different name for the main procedure. */
475796c8dcSSimon Schubert static const char GPC_MAIN_PROGRAM_NAME_2[] = "pascal_main_program";
485796c8dcSSimon Schubert
495796c8dcSSimon Schubert /* Function returning the special symbol name used
505796c8dcSSimon Schubert by GPC for the main procedure in the main program
515796c8dcSSimon Schubert if it is found in minimal symbol list.
525796c8dcSSimon Schubert This function tries to find minimal symbols generated by GPC
535796c8dcSSimon Schubert so that it finds the even if the program was compiled
545796c8dcSSimon Schubert without debugging information.
555796c8dcSSimon Schubert According to information supplied by Waldeck Hebisch,
565796c8dcSSimon Schubert this should work for all versions posterior to June 2000. */
575796c8dcSSimon Schubert
585796c8dcSSimon Schubert const char *
pascal_main_name(void)595796c8dcSSimon Schubert pascal_main_name (void)
605796c8dcSSimon Schubert {
615796c8dcSSimon Schubert struct minimal_symbol *msym;
625796c8dcSSimon Schubert
635796c8dcSSimon Schubert msym = lookup_minimal_symbol (GPC_P_INITIALIZE, NULL, NULL);
645796c8dcSSimon Schubert
655796c8dcSSimon Schubert /* If '_p_initialize' was not found, the main program is likely not
665796c8dcSSimon Schubert written in Pascal. */
675796c8dcSSimon Schubert if (msym == NULL)
685796c8dcSSimon Schubert return NULL;
695796c8dcSSimon Schubert
705796c8dcSSimon Schubert msym = lookup_minimal_symbol (GPC_MAIN_PROGRAM_NAME_1, NULL, NULL);
715796c8dcSSimon Schubert if (msym != NULL)
725796c8dcSSimon Schubert {
735796c8dcSSimon Schubert return GPC_MAIN_PROGRAM_NAME_1;
745796c8dcSSimon Schubert }
755796c8dcSSimon Schubert
765796c8dcSSimon Schubert msym = lookup_minimal_symbol (GPC_MAIN_PROGRAM_NAME_2, NULL, NULL);
775796c8dcSSimon Schubert if (msym != NULL)
785796c8dcSSimon Schubert {
795796c8dcSSimon Schubert return GPC_MAIN_PROGRAM_NAME_2;
805796c8dcSSimon Schubert }
815796c8dcSSimon Schubert
825796c8dcSSimon Schubert /* No known entry procedure found, the main program is probably
835796c8dcSSimon Schubert not compiled with GPC. */
845796c8dcSSimon Schubert return NULL;
855796c8dcSSimon Schubert }
865796c8dcSSimon Schubert
875796c8dcSSimon Schubert /* Determines if type TYPE is a pascal string type.
885796c8dcSSimon Schubert Returns a positive value if the type is a known pascal string type.
895796c8dcSSimon Schubert This function is used by p-valprint.c code to allow better string display.
905796c8dcSSimon Schubert If it is a pascal string type, then it also sets info needed
915796c8dcSSimon Schubert to get the length and the data of the string
925796c8dcSSimon Schubert length_pos, length_size and string_pos are given in bytes.
935796c8dcSSimon Schubert char_size gives the element size in bytes.
945796c8dcSSimon Schubert FIXME: if the position or the size of these fields
955796c8dcSSimon Schubert are not multiple of TARGET_CHAR_BIT then the results are wrong
965796c8dcSSimon Schubert but this does not happen for Free Pascal nor for GPC. */
975796c8dcSSimon Schubert int
is_pascal_string_type(struct type * type,int * length_pos,int * length_size,int * string_pos,struct type ** char_type,const char ** arrayname)985796c8dcSSimon Schubert is_pascal_string_type (struct type *type,int *length_pos,
995796c8dcSSimon Schubert int *length_size, int *string_pos,
1005796c8dcSSimon Schubert struct type **char_type,
101*ef5ccd6cSJohn Marino const char **arrayname)
1025796c8dcSSimon Schubert {
103cf7f2e2dSJohn Marino if (type != NULL && TYPE_CODE (type) == TYPE_CODE_STRUCT)
1045796c8dcSSimon Schubert {
1055796c8dcSSimon Schubert /* Old Borland type pascal strings from Free Pascal Compiler. */
1065796c8dcSSimon Schubert /* Two fields: length and st. */
1075796c8dcSSimon Schubert if (TYPE_NFIELDS (type) == 2
108c50c785cSJohn Marino && TYPE_FIELD_NAME (type, 0)
109c50c785cSJohn Marino && strcmp (TYPE_FIELD_NAME (type, 0), "length") == 0
110c50c785cSJohn Marino && TYPE_FIELD_NAME (type, 1)
111c50c785cSJohn Marino && strcmp (TYPE_FIELD_NAME (type, 1), "st") == 0)
1125796c8dcSSimon Schubert {
1135796c8dcSSimon Schubert if (length_pos)
1145796c8dcSSimon Schubert *length_pos = TYPE_FIELD_BITPOS (type, 0) / TARGET_CHAR_BIT;
1155796c8dcSSimon Schubert if (length_size)
1165796c8dcSSimon Schubert *length_size = TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0));
1175796c8dcSSimon Schubert if (string_pos)
1185796c8dcSSimon Schubert *string_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
1195796c8dcSSimon Schubert if (char_type)
1205796c8dcSSimon Schubert *char_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 1));
1215796c8dcSSimon Schubert if (arrayname)
122c50c785cSJohn Marino *arrayname = TYPE_FIELD_NAME (type, 1);
1235796c8dcSSimon Schubert return 2;
1245796c8dcSSimon Schubert };
1255796c8dcSSimon Schubert /* GNU pascal strings. */
1265796c8dcSSimon Schubert /* Three fields: Capacity, length and schema$ or _p_schema. */
1275796c8dcSSimon Schubert if (TYPE_NFIELDS (type) == 3
128c50c785cSJohn Marino && TYPE_FIELD_NAME (type, 0)
129c50c785cSJohn Marino && strcmp (TYPE_FIELD_NAME (type, 0), "Capacity") == 0
130c50c785cSJohn Marino && TYPE_FIELD_NAME (type, 1)
131c50c785cSJohn Marino && strcmp (TYPE_FIELD_NAME (type, 1), "length") == 0)
1325796c8dcSSimon Schubert {
1335796c8dcSSimon Schubert if (length_pos)
1345796c8dcSSimon Schubert *length_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
1355796c8dcSSimon Schubert if (length_size)
1365796c8dcSSimon Schubert *length_size = TYPE_LENGTH (TYPE_FIELD_TYPE (type, 1));
1375796c8dcSSimon Schubert if (string_pos)
1385796c8dcSSimon Schubert *string_pos = TYPE_FIELD_BITPOS (type, 2) / TARGET_CHAR_BIT;
1395796c8dcSSimon Schubert /* FIXME: how can I detect wide chars in GPC ?? */
1405796c8dcSSimon Schubert if (char_type)
1415796c8dcSSimon Schubert {
1425796c8dcSSimon Schubert *char_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 2));
143cf7f2e2dSJohn Marino
1445796c8dcSSimon Schubert if (TYPE_CODE (*char_type) == TYPE_CODE_ARRAY)
1455796c8dcSSimon Schubert *char_type = TYPE_TARGET_TYPE (*char_type);
1465796c8dcSSimon Schubert }
1475796c8dcSSimon Schubert if (arrayname)
148c50c785cSJohn Marino *arrayname = TYPE_FIELD_NAME (type, 2);
1495796c8dcSSimon Schubert return 3;
1505796c8dcSSimon Schubert };
1515796c8dcSSimon Schubert }
1525796c8dcSSimon Schubert return 0;
1535796c8dcSSimon Schubert }
1545796c8dcSSimon Schubert
1555796c8dcSSimon Schubert static void pascal_one_char (int, struct ui_file *, int *);
1565796c8dcSSimon Schubert
1575796c8dcSSimon Schubert /* Print the character C on STREAM as part of the contents of a literal
1585796c8dcSSimon Schubert string.
159c50c785cSJohn Marino In_quotes is reset to 0 if a char is written with #4 notation. */
1605796c8dcSSimon Schubert
1615796c8dcSSimon Schubert static void
pascal_one_char(int c,struct ui_file * stream,int * in_quotes)1625796c8dcSSimon Schubert pascal_one_char (int c, struct ui_file *stream, int *in_quotes)
1635796c8dcSSimon Schubert {
164cf7f2e2dSJohn Marino if (c == '\'' || ((unsigned int) c <= 0xff && (PRINT_LITERAL_FORM (c))))
1655796c8dcSSimon Schubert {
1665796c8dcSSimon Schubert if (!(*in_quotes))
1675796c8dcSSimon Schubert fputs_filtered ("'", stream);
1685796c8dcSSimon Schubert *in_quotes = 1;
1695796c8dcSSimon Schubert if (c == '\'')
1705796c8dcSSimon Schubert {
1715796c8dcSSimon Schubert fputs_filtered ("''", stream);
1725796c8dcSSimon Schubert }
1735796c8dcSSimon Schubert else
1745796c8dcSSimon Schubert fprintf_filtered (stream, "%c", c);
1755796c8dcSSimon Schubert }
1765796c8dcSSimon Schubert else
1775796c8dcSSimon Schubert {
1785796c8dcSSimon Schubert if (*in_quotes)
1795796c8dcSSimon Schubert fputs_filtered ("'", stream);
1805796c8dcSSimon Schubert *in_quotes = 0;
1815796c8dcSSimon Schubert fprintf_filtered (stream, "#%d", (unsigned int) c);
1825796c8dcSSimon Schubert }
1835796c8dcSSimon Schubert }
1845796c8dcSSimon Schubert
1855796c8dcSSimon Schubert static void pascal_emit_char (int c, struct type *type,
1865796c8dcSSimon Schubert struct ui_file *stream, int quoter);
1875796c8dcSSimon Schubert
1885796c8dcSSimon Schubert /* Print the character C on STREAM as part of the contents of a literal
1895796c8dcSSimon Schubert string whose delimiter is QUOTER. Note that that format for printing
1905796c8dcSSimon Schubert characters and strings is language specific. */
1915796c8dcSSimon Schubert
1925796c8dcSSimon Schubert static void
pascal_emit_char(int c,struct type * type,struct ui_file * stream,int quoter)1935796c8dcSSimon Schubert pascal_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
1945796c8dcSSimon Schubert {
1955796c8dcSSimon Schubert int in_quotes = 0;
196cf7f2e2dSJohn Marino
1975796c8dcSSimon Schubert pascal_one_char (c, stream, &in_quotes);
1985796c8dcSSimon Schubert if (in_quotes)
1995796c8dcSSimon Schubert fputs_filtered ("'", stream);
2005796c8dcSSimon Schubert }
2015796c8dcSSimon Schubert
2025796c8dcSSimon Schubert void
pascal_printchar(int c,struct type * type,struct ui_file * stream)2035796c8dcSSimon Schubert pascal_printchar (int c, struct type *type, struct ui_file *stream)
2045796c8dcSSimon Schubert {
2055796c8dcSSimon Schubert int in_quotes = 0;
206cf7f2e2dSJohn Marino
2075796c8dcSSimon Schubert pascal_one_char (c, stream, &in_quotes);
2085796c8dcSSimon Schubert if (in_quotes)
2095796c8dcSSimon Schubert fputs_filtered ("'", stream);
2105796c8dcSSimon Schubert }
2115796c8dcSSimon Schubert
2125796c8dcSSimon Schubert /* Print the character string STRING, printing at most LENGTH characters.
2135796c8dcSSimon Schubert Printing stops early if the number hits print_max; repeat counts
2145796c8dcSSimon Schubert are printed as appropriate. Print ellipses at the end if we
2155796c8dcSSimon Schubert had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. */
2165796c8dcSSimon Schubert
2175796c8dcSSimon Schubert void
pascal_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)2185796c8dcSSimon Schubert pascal_printstr (struct ui_file *stream, struct type *type,
2195796c8dcSSimon Schubert const gdb_byte *string, unsigned int length,
220cf7f2e2dSJohn Marino const char *encoding, int force_ellipses,
2215796c8dcSSimon Schubert const struct value_print_options *options)
2225796c8dcSSimon Schubert {
2235796c8dcSSimon Schubert enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
2245796c8dcSSimon Schubert unsigned int i;
2255796c8dcSSimon Schubert unsigned int things_printed = 0;
2265796c8dcSSimon Schubert int in_quotes = 0;
2275796c8dcSSimon Schubert int need_comma = 0;
228c50c785cSJohn Marino int width;
229c50c785cSJohn Marino
230c50c785cSJohn Marino /* Preserve TYPE's original type, just set its LENGTH. */
231c50c785cSJohn Marino check_typedef (type);
232c50c785cSJohn Marino width = TYPE_LENGTH (type);
2335796c8dcSSimon Schubert
2345796c8dcSSimon Schubert /* If the string was not truncated due to `set print elements', and
2355796c8dcSSimon Schubert the last byte of it is a null, we don't print that, in traditional C
2365796c8dcSSimon Schubert style. */
2375796c8dcSSimon Schubert if ((!force_ellipses) && length > 0
2385796c8dcSSimon Schubert && extract_unsigned_integer (string + (length - 1) * width, width,
2395796c8dcSSimon Schubert byte_order) == 0)
2405796c8dcSSimon Schubert length--;
2415796c8dcSSimon Schubert
2425796c8dcSSimon Schubert if (length == 0)
2435796c8dcSSimon Schubert {
2445796c8dcSSimon Schubert fputs_filtered ("''", stream);
2455796c8dcSSimon Schubert return;
2465796c8dcSSimon Schubert }
2475796c8dcSSimon Schubert
2485796c8dcSSimon Schubert for (i = 0; i < length && things_printed < options->print_max; ++i)
2495796c8dcSSimon Schubert {
2505796c8dcSSimon Schubert /* Position of the character we are examining
2515796c8dcSSimon Schubert to see whether it is repeated. */
2525796c8dcSSimon Schubert unsigned int rep1;
2535796c8dcSSimon Schubert /* Number of repetitions we have detected so far. */
2545796c8dcSSimon Schubert unsigned int reps;
2555796c8dcSSimon Schubert unsigned long int current_char;
2565796c8dcSSimon Schubert
2575796c8dcSSimon Schubert QUIT;
2585796c8dcSSimon Schubert
2595796c8dcSSimon Schubert if (need_comma)
2605796c8dcSSimon Schubert {
2615796c8dcSSimon Schubert fputs_filtered (", ", stream);
2625796c8dcSSimon Schubert need_comma = 0;
2635796c8dcSSimon Schubert }
2645796c8dcSSimon Schubert
2655796c8dcSSimon Schubert current_char = extract_unsigned_integer (string + i * width, width,
2665796c8dcSSimon Schubert byte_order);
2675796c8dcSSimon Schubert
2685796c8dcSSimon Schubert rep1 = i + 1;
2695796c8dcSSimon Schubert reps = 1;
2705796c8dcSSimon Schubert while (rep1 < length
2715796c8dcSSimon Schubert && extract_unsigned_integer (string + rep1 * width, width,
2725796c8dcSSimon Schubert byte_order) == current_char)
2735796c8dcSSimon Schubert {
2745796c8dcSSimon Schubert ++rep1;
2755796c8dcSSimon Schubert ++reps;
2765796c8dcSSimon Schubert }
2775796c8dcSSimon Schubert
2785796c8dcSSimon Schubert if (reps > options->repeat_count_threshold)
2795796c8dcSSimon Schubert {
2805796c8dcSSimon Schubert if (in_quotes)
2815796c8dcSSimon Schubert {
2825796c8dcSSimon Schubert fputs_filtered ("', ", stream);
2835796c8dcSSimon Schubert in_quotes = 0;
2845796c8dcSSimon Schubert }
2855796c8dcSSimon Schubert pascal_printchar (current_char, type, stream);
2865796c8dcSSimon Schubert fprintf_filtered (stream, " <repeats %u times>", reps);
2875796c8dcSSimon Schubert i = rep1 - 1;
2885796c8dcSSimon Schubert things_printed += options->repeat_count_threshold;
2895796c8dcSSimon Schubert need_comma = 1;
2905796c8dcSSimon Schubert }
2915796c8dcSSimon Schubert else
2925796c8dcSSimon Schubert {
2935796c8dcSSimon Schubert if ((!in_quotes) && (PRINT_LITERAL_FORM (current_char)))
2945796c8dcSSimon Schubert {
2955796c8dcSSimon Schubert fputs_filtered ("'", stream);
2965796c8dcSSimon Schubert in_quotes = 1;
2975796c8dcSSimon Schubert }
2985796c8dcSSimon Schubert pascal_one_char (current_char, stream, &in_quotes);
2995796c8dcSSimon Schubert ++things_printed;
3005796c8dcSSimon Schubert }
3015796c8dcSSimon Schubert }
3025796c8dcSSimon Schubert
3035796c8dcSSimon Schubert /* Terminate the quotes if necessary. */
3045796c8dcSSimon Schubert if (in_quotes)
3055796c8dcSSimon Schubert fputs_filtered ("'", stream);
3065796c8dcSSimon Schubert
3075796c8dcSSimon Schubert if (force_ellipses || i < length)
3085796c8dcSSimon Schubert fputs_filtered ("...", stream);
3095796c8dcSSimon Schubert }
3105796c8dcSSimon Schubert
3115796c8dcSSimon Schubert
3125796c8dcSSimon Schubert /* Table mapping opcodes into strings for printing operators
3135796c8dcSSimon Schubert and precedences of the operators. */
3145796c8dcSSimon Schubert
3155796c8dcSSimon Schubert const struct op_print pascal_op_print_tab[] =
3165796c8dcSSimon Schubert {
3175796c8dcSSimon Schubert {",", BINOP_COMMA, PREC_COMMA, 0},
3185796c8dcSSimon Schubert {":=", BINOP_ASSIGN, PREC_ASSIGN, 1},
3195796c8dcSSimon Schubert {"or", BINOP_BITWISE_IOR, PREC_BITWISE_IOR, 0},
3205796c8dcSSimon Schubert {"xor", BINOP_BITWISE_XOR, PREC_BITWISE_XOR, 0},
3215796c8dcSSimon Schubert {"and", BINOP_BITWISE_AND, PREC_BITWISE_AND, 0},
3225796c8dcSSimon Schubert {"=", BINOP_EQUAL, PREC_EQUAL, 0},
3235796c8dcSSimon Schubert {"<>", BINOP_NOTEQUAL, PREC_EQUAL, 0},
3245796c8dcSSimon Schubert {"<=", BINOP_LEQ, PREC_ORDER, 0},
3255796c8dcSSimon Schubert {">=", BINOP_GEQ, PREC_ORDER, 0},
3265796c8dcSSimon Schubert {">", BINOP_GTR, PREC_ORDER, 0},
3275796c8dcSSimon Schubert {"<", BINOP_LESS, PREC_ORDER, 0},
3285796c8dcSSimon Schubert {"shr", BINOP_RSH, PREC_SHIFT, 0},
3295796c8dcSSimon Schubert {"shl", BINOP_LSH, PREC_SHIFT, 0},
3305796c8dcSSimon Schubert {"+", BINOP_ADD, PREC_ADD, 0},
3315796c8dcSSimon Schubert {"-", BINOP_SUB, PREC_ADD, 0},
3325796c8dcSSimon Schubert {"*", BINOP_MUL, PREC_MUL, 0},
3335796c8dcSSimon Schubert {"/", BINOP_DIV, PREC_MUL, 0},
3345796c8dcSSimon Schubert {"div", BINOP_INTDIV, PREC_MUL, 0},
3355796c8dcSSimon Schubert {"mod", BINOP_REM, PREC_MUL, 0},
3365796c8dcSSimon Schubert {"@", BINOP_REPEAT, PREC_REPEAT, 0},
3375796c8dcSSimon Schubert {"-", UNOP_NEG, PREC_PREFIX, 0},
3385796c8dcSSimon Schubert {"not", UNOP_LOGICAL_NOT, PREC_PREFIX, 0},
3395796c8dcSSimon Schubert {"^", UNOP_IND, PREC_SUFFIX, 1},
3405796c8dcSSimon Schubert {"@", UNOP_ADDR, PREC_PREFIX, 0},
3415796c8dcSSimon Schubert {"sizeof", UNOP_SIZEOF, PREC_PREFIX, 0},
3425796c8dcSSimon Schubert {NULL, 0, 0, 0}
3435796c8dcSSimon Schubert };
3445796c8dcSSimon Schubert
3455796c8dcSSimon Schubert enum pascal_primitive_types {
3465796c8dcSSimon Schubert pascal_primitive_type_int,
3475796c8dcSSimon Schubert pascal_primitive_type_long,
3485796c8dcSSimon Schubert pascal_primitive_type_short,
3495796c8dcSSimon Schubert pascal_primitive_type_char,
3505796c8dcSSimon Schubert pascal_primitive_type_float,
3515796c8dcSSimon Schubert pascal_primitive_type_double,
3525796c8dcSSimon Schubert pascal_primitive_type_void,
3535796c8dcSSimon Schubert pascal_primitive_type_long_long,
3545796c8dcSSimon Schubert pascal_primitive_type_signed_char,
3555796c8dcSSimon Schubert pascal_primitive_type_unsigned_char,
3565796c8dcSSimon Schubert pascal_primitive_type_unsigned_short,
3575796c8dcSSimon Schubert pascal_primitive_type_unsigned_int,
3585796c8dcSSimon Schubert pascal_primitive_type_unsigned_long,
3595796c8dcSSimon Schubert pascal_primitive_type_unsigned_long_long,
3605796c8dcSSimon Schubert pascal_primitive_type_long_double,
3615796c8dcSSimon Schubert pascal_primitive_type_complex,
3625796c8dcSSimon Schubert pascal_primitive_type_double_complex,
3635796c8dcSSimon Schubert nr_pascal_primitive_types
3645796c8dcSSimon Schubert };
3655796c8dcSSimon Schubert
3665796c8dcSSimon Schubert static void
pascal_language_arch_info(struct gdbarch * gdbarch,struct language_arch_info * lai)3675796c8dcSSimon Schubert pascal_language_arch_info (struct gdbarch *gdbarch,
3685796c8dcSSimon Schubert struct language_arch_info *lai)
3695796c8dcSSimon Schubert {
3705796c8dcSSimon Schubert const struct builtin_type *builtin = builtin_type (gdbarch);
371cf7f2e2dSJohn Marino
3725796c8dcSSimon Schubert lai->string_char_type = builtin->builtin_char;
3735796c8dcSSimon Schubert lai->primitive_type_vector
3745796c8dcSSimon Schubert = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_pascal_primitive_types + 1,
3755796c8dcSSimon Schubert struct type *);
3765796c8dcSSimon Schubert lai->primitive_type_vector [pascal_primitive_type_int]
3775796c8dcSSimon Schubert = builtin->builtin_int;
3785796c8dcSSimon Schubert lai->primitive_type_vector [pascal_primitive_type_long]
3795796c8dcSSimon Schubert = builtin->builtin_long;
3805796c8dcSSimon Schubert lai->primitive_type_vector [pascal_primitive_type_short]
3815796c8dcSSimon Schubert = builtin->builtin_short;
3825796c8dcSSimon Schubert lai->primitive_type_vector [pascal_primitive_type_char]
3835796c8dcSSimon Schubert = builtin->builtin_char;
3845796c8dcSSimon Schubert lai->primitive_type_vector [pascal_primitive_type_float]
3855796c8dcSSimon Schubert = builtin->builtin_float;
3865796c8dcSSimon Schubert lai->primitive_type_vector [pascal_primitive_type_double]
3875796c8dcSSimon Schubert = builtin->builtin_double;
3885796c8dcSSimon Schubert lai->primitive_type_vector [pascal_primitive_type_void]
3895796c8dcSSimon Schubert = builtin->builtin_void;
3905796c8dcSSimon Schubert lai->primitive_type_vector [pascal_primitive_type_long_long]
3915796c8dcSSimon Schubert = builtin->builtin_long_long;
3925796c8dcSSimon Schubert lai->primitive_type_vector [pascal_primitive_type_signed_char]
3935796c8dcSSimon Schubert = builtin->builtin_signed_char;
3945796c8dcSSimon Schubert lai->primitive_type_vector [pascal_primitive_type_unsigned_char]
3955796c8dcSSimon Schubert = builtin->builtin_unsigned_char;
3965796c8dcSSimon Schubert lai->primitive_type_vector [pascal_primitive_type_unsigned_short]
3975796c8dcSSimon Schubert = builtin->builtin_unsigned_short;
3985796c8dcSSimon Schubert lai->primitive_type_vector [pascal_primitive_type_unsigned_int]
3995796c8dcSSimon Schubert = builtin->builtin_unsigned_int;
4005796c8dcSSimon Schubert lai->primitive_type_vector [pascal_primitive_type_unsigned_long]
4015796c8dcSSimon Schubert = builtin->builtin_unsigned_long;
4025796c8dcSSimon Schubert lai->primitive_type_vector [pascal_primitive_type_unsigned_long_long]
4035796c8dcSSimon Schubert = builtin->builtin_unsigned_long_long;
4045796c8dcSSimon Schubert lai->primitive_type_vector [pascal_primitive_type_long_double]
4055796c8dcSSimon Schubert = builtin->builtin_long_double;
4065796c8dcSSimon Schubert lai->primitive_type_vector [pascal_primitive_type_complex]
4075796c8dcSSimon Schubert = builtin->builtin_complex;
4085796c8dcSSimon Schubert lai->primitive_type_vector [pascal_primitive_type_double_complex]
4095796c8dcSSimon Schubert = builtin->builtin_double_complex;
4105796c8dcSSimon Schubert
4115796c8dcSSimon Schubert lai->bool_type_symbol = "boolean";
4125796c8dcSSimon Schubert lai->bool_type_default = builtin->builtin_bool;
4135796c8dcSSimon Schubert }
4145796c8dcSSimon Schubert
4155796c8dcSSimon Schubert const struct language_defn pascal_language_defn =
4165796c8dcSSimon Schubert {
4175796c8dcSSimon Schubert "pascal", /* Language name */
4185796c8dcSSimon Schubert language_pascal,
4195796c8dcSSimon Schubert range_check_on,
4205796c8dcSSimon Schubert case_sensitive_on,
4215796c8dcSSimon Schubert array_row_major,
4225796c8dcSSimon Schubert macro_expansion_no,
4235796c8dcSSimon Schubert &exp_descriptor_standard,
4245796c8dcSSimon Schubert pascal_parse,
4255796c8dcSSimon Schubert pascal_error,
4265796c8dcSSimon Schubert null_post_parser,
4275796c8dcSSimon Schubert pascal_printchar, /* Print a character constant */
4285796c8dcSSimon Schubert pascal_printstr, /* Function to print string constant */
4295796c8dcSSimon Schubert pascal_emit_char, /* Print a single char */
4305796c8dcSSimon Schubert pascal_print_type, /* Print a type using appropriate syntax */
4315796c8dcSSimon Schubert pascal_print_typedef, /* Print a typedef using appropriate syntax */
4325796c8dcSSimon Schubert pascal_val_print, /* Print a value using appropriate syntax */
4335796c8dcSSimon Schubert pascal_value_print, /* Print a top-level value */
434*ef5ccd6cSJohn Marino default_read_var_value, /* la_read_var_value */
4355796c8dcSSimon Schubert NULL, /* Language specific skip_trampoline */
4365796c8dcSSimon Schubert "this", /* name_of_this */
4375796c8dcSSimon Schubert basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
4385796c8dcSSimon Schubert basic_lookup_transparent_type,/* lookup_transparent_type */
4395796c8dcSSimon Schubert NULL, /* Language specific symbol demangler */
4405796c8dcSSimon Schubert NULL, /* Language specific class_name_from_physname */
4415796c8dcSSimon Schubert pascal_op_print_tab, /* expression operators for printing */
4425796c8dcSSimon Schubert 1, /* c-style arrays */
4435796c8dcSSimon Schubert 0, /* String lower bound */
4445796c8dcSSimon Schubert default_word_break_characters,
4455796c8dcSSimon Schubert default_make_symbol_completion_list,
4465796c8dcSSimon Schubert pascal_language_arch_info,
4475796c8dcSSimon Schubert default_print_array_index,
4485796c8dcSSimon Schubert default_pass_by_reference,
4495796c8dcSSimon Schubert default_get_string,
450*ef5ccd6cSJohn Marino NULL, /* la_get_symbol_name_cmp */
451a45ae5f8SJohn Marino iterate_over_symbols,
4525796c8dcSSimon Schubert LANG_MAGIC
4535796c8dcSSimon Schubert };
4545796c8dcSSimon Schubert
4555796c8dcSSimon Schubert void
_initialize_pascal_language(void)4565796c8dcSSimon Schubert _initialize_pascal_language (void)
4575796c8dcSSimon Schubert {
4585796c8dcSSimon Schubert add_language (&pascal_language_defn);
4595796c8dcSSimon Schubert }
460