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