* language.h (language_format_info): New structure to bundle

local formatting information.
	* language.h (language_defn):  Replace individual format info
	with language_format_info structs.
	* language.h (local_*_format, local_*_format_prefix,
	local_*_format_specifier, local_*_format_suffix):  New macros
	for binary/octal/decimal/hex formats to access info elements.
	* c-exp.y (c_language_defn):  Update for new format handling.
	* m2-exp.y (m2_language_defn):  Update for new format handling.
	* dbxread.c (language.h):  Include for partial-stab.h use.
	* defs.h (local_hex_format, local_hex_format_custom,
	local_hex_string, local_hex_string_custom):  Move to language.h.
	* language.c (local_hex_format_custom, local_hex_string,
	local_hex_string_custom, local_octal_format_custom):  Use new
	format handling.
	* language.c (unknown_language_defn, auto_language_defn,
	local_language_defn):  Update for new format handling.
	* printcmd.c (print_scalar_formatted):  Use new macros
	to access decimal and binary format info for printing.
	**** start-sanitize-chill ****
	* c-exp.y (chill_language_defn):  Update for new format handling.
	* ch-exp.y (CHARACTER_LITERAL):  Add support to yylex.
	* ch-exp.y (match_integer_literal):  Add function.
	* ch-exp.y (builtin_type_chill_char):  Add definition.
	* gdbtypes.h (builtin_type_chill_char):  Add declaration.
	**** end-sanitize-chill ****
This commit is contained in:
Fred Fish 1992-11-18 22:49:38 +00:00
parent e1b91f0b1a
commit 2e66cf7d6d
7 changed files with 555 additions and 263 deletions

View file

@ -1,3 +1,32 @@
Wed Nov 18 14:27:47 1992 Fred Fish (fnf@cygnus.com)
* language.h (language_format_info): New structure to bundle
local formatting information.
* language.h (language_defn): Replace individual format info
with language_format_info structs.
* language.h (local_*_format, local_*_format_prefix,
local_*_format_specifier, local_*_format_suffix): New macros
for binary/octal/decimal/hex formats to access info elements.
* c-exp.y (c_language_defn): Update for new format handling.
* m2-exp.y (m2_language_defn): Update for new format handling.
* dbxread.c (language.h): Include for partial-stab.h use.
* defs.h (local_hex_format, local_hex_format_custom,
local_hex_string, local_hex_string_custom): Move to language.h.
* language.c (local_hex_format_custom, local_hex_string,
local_hex_string_custom, local_octal_format_custom): Use new
format handling.
* language.c (unknown_language_defn, auto_language_defn,
local_language_defn): Update for new format handling.
* printcmd.c (print_scalar_formatted): Use new macros
to access decimal and binary format info for printing.
**** start-sanitize-chill ****
* c-exp.y (chill_language_defn): Update for new format handling.
* ch-exp.y (CHARACTER_LITERAL): Add support to yylex.
* ch-exp.y (match_integer_literal): Add function.
* ch-exp.y (builtin_type_chill_char): Add definition.
* gdbtypes.h (builtin_type_chill_char): Add declaration.
**** end-sanitize-chill ****
Tue Nov 17 11:17:06 1992 Ian Lance Taylor (ian@cygnus.com) Tue Nov 17 11:17:06 1992 Ian Lance Taylor (ian@cygnus.com)
* tm-rs6000.h (BELIEVE_PCC_PROMOTION): Define, since AIX cc gets * tm-rs6000.h (BELIEVE_PCC_PROMOTION): Define, since AIX cc gets

View file

@ -1564,8 +1564,10 @@ const struct language_defn c_language_defn = {
&BUILTIN_TYPE_LONGEST, /* longest signed integral type */ &BUILTIN_TYPE_LONGEST, /* longest signed integral type */
&BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */ &BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */
&builtin_type_double, /* longest floating point type */ /*FIXME*/ &builtin_type_double, /* longest floating point type */ /*FIXME*/
"0x%x", "0x%", "x", /* Hex format, prefix, suffix */ {"", "", "", ""}, /* Binary format info */
"0%o", "0%", "o", /* Octal format, prefix, suffix */ {"0%o", "0", "o", ""}, /* Octal format info */
{"%d", "", "d", ""}, /* Decimal format info */
{"0x%x", "0x", "x", ""}, /* Hex format info */
c_op_print_tab, /* expression operators for printing */ c_op_print_tab, /* expression operators for printing */
LANG_MAGIC LANG_MAGIC
}; };
@ -1581,8 +1583,10 @@ const struct language_defn cplus_language_defn = {
&BUILTIN_TYPE_LONGEST, /* longest signed integral type */ &BUILTIN_TYPE_LONGEST, /* longest signed integral type */
&BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */ &BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */
&builtin_type_double, /* longest floating point type */ /*FIXME*/ &builtin_type_double, /* longest floating point type */ /*FIXME*/
"0x%x", "0x%", "x", /* Hex format, prefix, suffix */ {"", "", "", ""}, /* Binary format info */
"0%o", "0%", "o", /* Octal format, prefix, suffix */ {"0%o", "0", "o", ""}, /* Octal format info */
{"%d", "", "d", ""}, /* Decimal format info */
{"0x%x", "0x", "x", ""}, /* Hex format info */
c_op_print_tab, /* expression operators for printing */ c_op_print_tab, /* expression operators for printing */
LANG_MAGIC LANG_MAGIC
}; };

File diff suppressed because it is too large Load diff

View file

@ -493,6 +493,7 @@ extern struct type *builtin_type_m2_bool;
/* Chill types */ /* Chill types */
extern struct type *builtin_type_chill_bool; extern struct type *builtin_type_chill_bool;
extern struct type *builtin_type_chill_char;
extern struct type *builtin_type_chill_long; extern struct type *builtin_type_chill_long;
extern struct type *builtin_type_chill_ulong; extern struct type *builtin_type_chill_ulong;
extern struct type *builtin_type_chill_real; extern struct type *builtin_type_chill_real;

View file

@ -483,9 +483,11 @@ local_hex_format_custom(pre)
{ {
static char form[50]; static char form[50];
strcpy (form, current_language->la_hex_format_pre); strcpy (form, local_hex_format_prefix ());
strcat (form, "%");
strcat (form, pre); strcat (form, pre);
strcat (form, current_language->la_hex_format_suf); strcat (form, local_hex_format_specifier ());
strcat (form, local_hex_format_suffix ());
return form; return form;
} }
@ -497,7 +499,7 @@ local_hex_string (num)
{ {
static char res[50]; static char res[50];
sprintf (res, current_language->la_hex_format, num); sprintf (res, local_hex_format(), num);
return res; return res;
} }
@ -522,9 +524,11 @@ local_octal_format_custom(pre)
{ {
static char form[50]; static char form[50];
strcpy (form, current_language->la_octal_format_pre); strcpy (form, local_octal_format_prefix ());
strcat (form, "%");
strcat (form, pre); strcat (form, pre);
strcat (form, current_language->la_octal_format_suf); strcat (form, local_octal_format_specifier ());
strcat (form, local_octal_format_suffix ());
return form; return form;
} }
@ -563,7 +567,10 @@ simple_type(type)
} }
} }
/* Returns non-zero if its argument is of an ordered type. */ /* Returns non-zero if its argument is of an ordered type.
An ordered type is one in which the elements can be tested for the
properties of "greater than", "less than", etc, or for which the
operations "increment" or "decrement" make sense. */
int int
ordered_type (type) ordered_type (type)
struct type *type; struct type *type;
@ -643,6 +650,9 @@ character_type (type)
{ {
switch(current_language->la_language) switch(current_language->la_language)
{ {
/* start-sanitize-chill */
case language_chill:
/* end-sanitize-chill */
case language_m2: case language_m2:
return TYPE_CODE(type) != TYPE_CODE_CHAR ? 0 : 1; return TYPE_CODE(type) != TYPE_CODE_CHAR ? 0 : 1;
@ -651,10 +661,6 @@ character_type (type)
return (TYPE_CODE(type) == TYPE_CODE_INT) && return (TYPE_CODE(type) == TYPE_CODE_INT) &&
TYPE_LENGTH(type) == sizeof(char) TYPE_LENGTH(type) == sizeof(char)
? 1 : 0; ? 1 : 0;
/* start-sanitize-chill */
case language_chill:
error ("Missing Chill support in function character_type."); /*FIXME*/
/* end-sanitize-chill */
default: default:
return (0); return (0);
} }
@ -1106,8 +1112,10 @@ const struct language_defn unknown_language_defn = {
&builtin_type_error, /* longest signed integral type */ &builtin_type_error, /* longest signed integral type */
&builtin_type_error, /* longest unsigned integral type */ &builtin_type_error, /* longest unsigned integral type */
&builtin_type_error, /* longest floating point type */ &builtin_type_error, /* longest floating point type */
"0x%x", "0x%", "x", /* Hex format, prefix, suffix */ {"", "", "", ""}, /* Binary format info */
"0%o", "0%", "o", /* Octal format, prefix, suffix */ {"0%o", "0", "o", ""}, /* Octal format info */
{"%d", "", "d", ""}, /* Decimal format info */
{"0x%x", "0x", "x", ""}, /* Hex format info */
unk_op_print_tab, /* expression operators for printing */ unk_op_print_tab, /* expression operators for printing */
LANG_MAGIC LANG_MAGIC
}; };
@ -1124,8 +1132,10 @@ const struct language_defn auto_language_defn = {
&builtin_type_error, /* longest signed integral type */ &builtin_type_error, /* longest signed integral type */
&builtin_type_error, /* longest unsigned integral type */ &builtin_type_error, /* longest unsigned integral type */
&builtin_type_error, /* longest floating point type */ &builtin_type_error, /* longest floating point type */
"0x%x", "0x%", "x", /* Hex format, prefix, suffix */ {"", "", "", ""}, /* Binary format info */
"0%o", "0%", "o", /* Octal format, prefix, suffix */ {"0%o", "0", "o", ""}, /* Octal format info */
{"%d", "", "d", ""}, /* Decimal format info */
{"0x%x", "0x", "x", ""}, /* Hex format info */
unk_op_print_tab, /* expression operators for printing */ unk_op_print_tab, /* expression operators for printing */
LANG_MAGIC LANG_MAGIC
}; };
@ -1141,8 +1151,10 @@ const struct language_defn local_language_defn = {
&builtin_type_error, /* longest signed integral type */ &builtin_type_error, /* longest signed integral type */
&builtin_type_error, /* longest unsigned integral type */ &builtin_type_error, /* longest unsigned integral type */
&builtin_type_error, /* longest floating point type */ &builtin_type_error, /* longest floating point type */
"0x%x", "0x%", "x", /* Hex format, prefix, suffix */ {"", "", "", ""}, /* Binary format info */
"0%o", "0%", "o", /* Octal format, prefix, suffix */ {"0%o", "0", "o", ""}, /* Octal format info */
{"%d", "", "d", ""}, /* Decimal format info */
{"0x%x", "0x", "x", ""}, /* Hex format info */
unk_op_print_tab, /* expression operators for printing */ unk_op_print_tab, /* expression operators for printing */
LANG_MAGIC LANG_MAGIC
}; };

View file

@ -64,6 +64,37 @@ extern enum type_mode {type_mode_auto, type_mode_manual} type_mode;
extern enum type_check extern enum type_check
{type_check_off, type_check_warn, type_check_on} type_check; {type_check_off, type_check_warn, type_check_on} type_check;
/* Information for doing language dependent formatting of printed values. */
struct language_format_info
{
/* The format that can be passed directly to standard C printf functions
to generate a completely formatted value in the format appropriate for
the language. */
char *la_format;
/* The prefix to be used when directly printing a value, or constructing
a standard C printf format. This generally is everything up to the
conversion specification (the part introduced by the '%' character
and terminated by the conversion specifier character). */
char *la_format_prefix;
/* The conversion specifier. This is generally everything after the
field width and precision, typically only a single character such
as 'o' for octal format or 'x' for hexadecimal format. */
char *la_format_specifier;
/* The suffix to be used when directly printing a value, or constructing
a standard C printf format. This generally is everything after the
conversion specification (the part introduced by the '%' character
and terminated by the conversion specifier character). */
char *la_format_suffix; /* Suffix for custom format string */
};
/* Structure tying together assorted information about a language. */ /* Structure tying together assorted information about a language. */
struct language_defn { struct language_defn {
@ -78,13 +109,15 @@ struct language_defn {
struct type **la_longest_int; /* Longest signed integral type */ struct type **la_longest_int; /* Longest signed integral type */
struct type **la_longest_unsigned_int; /* Longest uns integral type */ struct type **la_longest_unsigned_int; /* Longest uns integral type */
struct type **la_longest_float; /* Longest floating point type */ struct type **la_longest_float; /* Longest floating point type */
char *la_hex_format; /* Hexadecimal printf format str */ struct language_format_info
char *la_hex_format_pre; /* Prefix for custom format string */ la_binary_format; /* Base 2 (binary) formats. */
char *la_hex_format_suf; /* Suffix for custom format string */ struct language_format_info
char *la_octal_format; /* Octal printf format str */ la_octal_format; /* Base 8 (octal) formats. */
char *la_octal_format_pre; /* Prefix for custom format string */ struct language_format_info
char *la_octal_format_suf; /* Suffix for custom format string */ la_decimal_format; /* Base 10 (decimal) formats */
const struct op_print struct language_format_info
la_hex_format; /* Base 16 (hexadecimal) formats */
const struct op_print
*la_op_print_tab; /* Table for printing expressions */ *la_op_print_tab; /* Table for printing expressions */
/* Add fields above this point, so the magic number is always last. */ /* Add fields above this point, so the magic number is always last. */
long la_magic; /* Magic number for compat checking */ long la_magic; /* Magic number for compat checking */
@ -141,18 +174,73 @@ set_language PARAMS ((enum language));
#define longest_unsigned_int() (*current_language->la_longest_unsigned_int) #define longest_unsigned_int() (*current_language->la_longest_unsigned_int)
#define longest_float() (*current_language->la_longest_float) #define longest_float() (*current_language->la_longest_float)
/* Hexadecimal number formatting is in defs.h because it is so common /* Return a format string for printf that will print a number in one of
throughout GDB. */ the local (language-specific) formats. Result is static and is
overwritten by the next call. Takes printf options like "08" or "l"
(to produce e.g. %08x or %lx). */
/* Return a format string for printf that will print a number in the local #define local_binary_format() \
(language-specific) octal format. Result is static and is (current_language->la_binary_format.la_format)
overwritten by the next call. local_octal_format_custom takes printf #define local_binary_format_prefix() \
options like "08" or "l" (to produce e.g. %08x or %lx). */ (current_language->la_binary_format.la_format_prefix)
#define local_binary_format_specifier() \
(current_language->la_binary_format.la_format_specifier)
#define local_binary_format_suffix() \
(current_language->la_binary_format.la_format_suffix)
#define local_octal_format() (current_language->la_octal_format) #define local_octal_format() \
(current_language->la_octal_format.la_format)
#define local_octal_format_prefix() \
(current_language->la_octal_format.la_format_prefix)
#define local_octal_format_specifier() \
(current_language->la_octal_format.la_format_specifier)
#define local_octal_format_suffix() \
(current_language->la_octal_format.la_format_suffix)
#define local_decimal_format() \
(current_language->la_decimal_format.la_format)
#define local_decimal_format_prefix() \
(current_language->la_decimal_format.la_format_prefix)
#define local_decimal_format_specifier() \
(current_language->la_decimal_format.la_format_specifier)
#define local_decimal_format_suffix() \
(current_language->la_decimal_format.la_format_suffix)
#define local_hex_format() \
(current_language->la_hex_format.la_format)
#define local_hex_format_prefix() \
(current_language->la_hex_format.la_format_prefix)
#define local_hex_format_specifier() \
(current_language->la_hex_format.la_format_specifier)
#define local_hex_format_suffix() \
(current_language->la_hex_format.la_format_suffix)
/* Return a format string for printf that will print a number in one of
the local (language-specific) formats. Result is static and is
overwritten by the next call. Takes printf options like "08" or "l"
(to produce e.g. %08x or %lx). */
extern char * extern char *
local_octal_format_custom PARAMS ((char *)); local_octal_format_custom PARAMS ((char *)); /* language.c */
extern char *
local_hex_format_custom PARAMS ((char *)); /* language.c */
/* Return a string that contains a number formatted in one of the local
(language-specific) formats. Result is static and is overwritten by
the next call. Takes printf options like "08" or "l". */
extern char *
local_octal_string PARAMS ((int)); /* language.c */
extern char *
local_octal_string_custom PARAMS ((int, char *));/* language.c */
extern char *
local_hex_string PARAMS ((int)); /* language.c */
extern char *
local_hex_string_custom PARAMS ((int, char *)); /* language.c */
/* Type predicates */ /* Type predicates */

View file

@ -1228,10 +1228,12 @@ const struct language_defn m2_language_defn = {
m2_parse, /* parser */ m2_parse, /* parser */
m2_error, /* parser error function */ m2_error, /* parser error function */
&builtin_type_m2_int, /* longest signed integral type */ &builtin_type_m2_int, /* longest signed integral type */
&builtin_type_m2_card, /* longest unsigned integral type */ &builtin_type_m2_card, /* longest unsigned integral type */
&builtin_type_m2_real, /* longest floating point type */ &builtin_type_m2_real, /* longest floating point type */
"0%XH", "0%", "XH", /* Hex format string, prefix, suffix */ {"", "", "", ""}, /* Binary format info */
"%oB", "%", "oB", /* Octal format string, prefix, suffix */ {"%oB", "", "o", "B"}, /* Octal format info */
{"%d", "", "d", ""}, /* Decimal format info */
{"0%XH", "0", "X", "H"}, /* Hex format info */
m2_op_print_tab, /* expression operators for printing */ m2_op_print_tab, /* expression operators for printing */
LANG_MAGIC LANG_MAGIC
}; };