UNOP_IND, UNOP_CAST, UNOP_ADDR, STRUCOP_STRUCT, OP_TYPE.
* ch-typeprint.c (chill_print_type): Move support
for TYPE_CODE_ARRAY and TYPE_CODE_STRING from here ...
* ch-typeprint.c (chill_type_print_base): ... here.
* ch-typeprint.c (chill_type_print_base): Improve
support for PTR, REF, and FUNC types.
* ch-valprint.c: Prefer H'%x format to 0x%s.
* ch-valprint.c (chill_val_print): Add support for printing
TYPE_CODE_REF (return for LOC parameters and variables).
Use c_val_print to print random types (including ENUM).
* ch-valprint,c (chill_print_value_fields): Make
output look more like Chill tuples.
* stabsread.c (read_struct_type): Factor common code.
+Tue Apr 6 00:24:32 1993 Per Bothner (bothner@rtl.cygnus.com)
+
+ * ch-exp.y: Remove ambiguities. Fix or add support for
+ UNOP_IND, UNOP_CAST, UNOP_ADDR, STRUCOP_STRUCT, OP_TYPE.
+ * ch-typeprint.c (chill_print_type): Move support
+ for TYPE_CODE_ARRAY and TYPE_CODE_STRING from here ...
+ * ch-typeprint.c (chill_type_print_base): ... here.
+ * ch-typeprint.c (chill_type_print_base): Improve
+ support for PTR, REF, and FUNC types.
+ * ch-valprint.c: Prefer H'%x format to 0x%s.
+ * ch-valprint.c (chill_val_print): Add support for printing
+ TYPE_CODE_REF (return for LOC parameters and variables).
+ Use c_val_print to print random types (including ENUM).
+ * ch-valprint,c (chill_print_value_fields): Make
+ output look more like Chill tuples.
+ * stabsread.c (read_struct_type): Factor common code.
+
Wed Apr 7 11:22:43 1993 Fred Fish (fnf@cygnus.com)
* sparclite/Makefile.in: Add dummy mostlyclean, clean,
%token <voidval> EMPTINESS_LITERAL
%token <sval> CHARACTER_STRING_LITERAL
%token <sval> BIT_STRING_LITERAL
+%token <tsym> TYPENAME
+%token <sval> FIELD_NAME
%token <voidval> '.'
%token <voidval> ';'
%type <voidval> upper_element
%type <voidval> first_element
%type <voidval> structure_primitive_value
-%type <voidval> field_name
%type <voidval> mode_argument
%type <voidval> upper_lower_argument
%type <voidval> length_argument
-%type <voidval> mode_name
%type <voidval> array_mode_name
%type <voidval> string_mode_name
%type <voidval> variant_structure_mode_name
%type <voidval> subexpression
%type <voidval> case_label_specification
%type <voidval> buffer_location
-
%type <voidval> single_assignment_action
+%type <tsym> mode_name
%%
/* Z.200, 5.3.1 */
+start : value
+ | mode_name
+ { write_exp_elt_opcode(OP_TYPE);
+ write_exp_elt_type($1.type);
+ write_exp_elt_opcode(OP_TYPE);}
+ ;
+
value : expression
{
$$ = 0; /* FIXME */
{
$$ = 0; /* FIXME */
}
- | FIXME_02
+ | primitive_value POINTER
{
- $$ = 0; /* FIXME */
+ write_exp_elt_opcode (UNOP_IND);
}
;
/* Z.200, 5.2.10 */
-value_structure_field: structure_primitive_value '.' field_name
- {
- $$ = 0; /* FIXME */
+value_structure_field: primitive_value FIELD_NAME
+ { write_exp_elt_opcode (STRUCTOP_STRUCT);
+ write_exp_string ($2);
+ write_exp_elt_opcode (STRUCTOP_STRUCT);
}
;
expression_conversion: mode_name parenthesised_expression
{
- $$ = 0; /* FIXME */
+ write_exp_elt_opcode (UNOP_CAST);
+ write_exp_elt_type ($1.type);
+ write_exp_elt_opcode (UNOP_CAST);
}
;
{
$$ = 0; /* FIXME */
}
+ | single_assignment_action
+ {
+ $$ = 0; /* FIXME */
+ }
| conditional_expression
{
$$ = 0; /* FIXME */
{
write_exp_elt_opcode (BINOP_BITWISE_XOR);
}
- | single_assignment_action
- {
- $$ = 0; /* FIXME */
- }
;
/* Z.200, 5.3.4 */
;
/* Z.200, 5.3.8 */
-/* Note that we accept any expression for BINOP_CONCAT, not just
- integer literal expressions. (FIXME?) */
operand_5 : operand_6
{
{
write_exp_elt_opcode (UNOP_LOGICAL_NOT);
}
- | parenthesised_expression operand_6
+ | parenthesised_expression CHARACTER_STRING_LITERAL
+/* We require the string operand to be a literal, to avoid some
+ nasty parsing ambiguities. */
{
write_exp_elt_opcode (BINOP_CONCAT);
}
operand_6 : POINTER location
{
- $$ = 0; /* FIXME */
+ write_exp_elt_opcode (UNOP_ADDR);
}
| RECEIVE buffer_location
{
}
;
-upper_lower_argument : location
- {
- $$ = 0; /* FIXME */
- }
- | expression
+mode_name : TYPENAME
+ ;
+
+upper_lower_argument : expression
{
$$ = 0; /* FIXME */
}
}
;
-length_argument : location
- {
- $$ = 0; /* FIXME */
- }
- | expression
+length_argument : expression
{
$$ = 0; /* FIXME */
}
upper_element : FIXME_21 { $$ = 0; }
first_element : FIXME_22 { $$ = 0; }
structure_primitive_value: FIXME_23 { $$ = 0; }
-field_name : FIXME_24 { $$ = 0; }
-mode_name : FIXME_25 { $$ = 0; }
boolean_expression : FIXME_26 { $$ = 0; }
case_selector_list : FIXME_27 { $$ = 0; }
subexpression : FIXME_28 { $$ = 0; }
{
{ ":=", GDB_ASSIGNMENT },
{ "//", SLASH_SLASH },
+ { "->", POINTER },
{ "/=", NOTEQUAL },
{ "<=", LEQ },
{ ">=", GTR },
case ';':
case '!':
case '+':
- case '-':
case '*':
case '(':
case ')':
would already have found it. */
switch (*lexptr)
{
+ case '-':
case ':':
case '/':
case '<':
case LOC_LABEL:
return (LOCATION_NAME);
break;
- case LOC_UNDEF:
case LOC_TYPEDEF:
+ yylval.tsym.type = SYMBOL_TYPE (sym);
+ return TYPENAME;
+ case LOC_UNDEF:
case LOC_CONST_BYTES:
case LOC_OPTIMIZED_OUT:
error ("Symbol \"%s\" names no location.", simplename);
switch (*lexptr)
{
case '.': /* Not float for example. */
- return (*lexptr++);
+ lexptr++;
+ while (isspace (*lexptr)) lexptr++;
+ simplename = match_simple_name_string ();
+ if (!simplename)
+ return '.';
+ return FIELD_NAME;
}
return (ILLEGAL_TOKEN);
int show;
int level;
{
- struct type *index_type;
- struct type *range_type;
- LONGEST low_bound;
- LONGEST high_bound;
-
if (varstring != NULL && *varstring != '\0')
{
fputs_filtered (varstring, stream);
fputs_filtered (" ", stream);
}
- switch (TYPE_CODE (type))
- {
- case TYPE_CODE_ARRAY:
- range_type = TYPE_FIELD_TYPE (type, 0);
- index_type = TYPE_TARGET_TYPE (range_type);
- low_bound = TYPE_FIELD_BITPOS (range_type, 0);
- high_bound = TYPE_FIELD_BITPOS (range_type, 1);
- fputs_filtered ("array (", stream);
- print_type_scalar (index_type, low_bound, stream);
- fputs_filtered (":", stream);
- print_type_scalar (index_type, high_bound, stream);
- fputs_filtered (") ", stream);
- chill_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level);
- break;
-
- case TYPE_CODE_STRING:
- range_type = TYPE_FIELD_TYPE (type, 0);
- index_type = TYPE_TARGET_TYPE (range_type);
- high_bound = TYPE_FIELD_BITPOS (range_type, 1);
- fputs_filtered ("CHAR (", stream);
- print_type_scalar (index_type, high_bound + 1, stream);
- fputs_filtered (")", stream);
- break;
-
- default:
- chill_type_print_base (type, stream, show, level);
- break;
- }
+ chill_type_print_base (type, stream, show, level);
}
/* Print the name of the type (or the ultimate pointer target,
char *name;
register int len;
register int i;
+ struct type *index_type;
+ struct type *range_type;
+ LONGEST low_bound;
+ LONGEST high_bound;
QUIT;
switch (TYPE_CODE (type))
{
- case TYPE_CODE_ARRAY:
case TYPE_CODE_PTR:
+ if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID)
+ {
+ fprintf_filtered (stream, "PTR");
+ break;
+ }
+ fprintf_filtered (stream, "REF ");
+ chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
+ break;
+
+ case TYPE_CODE_ARRAY:
+ range_type = TYPE_FIELD_TYPE (type, 0);
+ index_type = TYPE_TARGET_TYPE (range_type);
+ low_bound = TYPE_FIELD_BITPOS (range_type, 0);
+ high_bound = TYPE_FIELD_BITPOS (range_type, 1);
+ fputs_filtered ("ARRAY (", stream);
+ print_type_scalar (index_type, low_bound, stream);
+ fputs_filtered (":", stream);
+ print_type_scalar (index_type, high_bound, stream);
+ fputs_filtered (") ", stream);
+ chill_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level);
+ break;
+
+ case TYPE_CODE_STRING:
+ range_type = TYPE_FIELD_TYPE (type, 0);
+ index_type = TYPE_TARGET_TYPE (range_type);
+ high_bound = TYPE_FIELD_BITPOS (range_type, 1);
+ fputs_filtered ("CHAR (", stream);
+ print_type_scalar (index_type, high_bound + 1, stream);
+ fputs_filtered (")", stream);
+ break;
+
case TYPE_CODE_MEMBER:
+ fprintf_filtered (stream, "MEMBER ");
+ chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
+ break;
case TYPE_CODE_REF:
+ fprintf_filtered (stream, "/*LOC*/ ");
+ chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
+ break;
case TYPE_CODE_FUNC:
+ fprintf_filtered (stream, "PROC (?)");
chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
break;
}
if (addressprint && format != 's')
{
- fprintf_filtered (stream, "0x%x", addr);
+ fprintf_filtered (stream, "H'%x", addr);
}
/* For a pointer to char or unsigned char, also print the string
}
if (addressprint && format != 's')
{
- fprintf_filtered (stream, "0x%x ", addr);
+ fprintf_filtered (stream, "H'%x ", addr);
}
i = TYPE_LENGTH (type);
LA_PRINT_STRING (stream, valaddr, i, 0);
0);
break;
- case TYPE_CODE_MEMBER:
case TYPE_CODE_REF:
- case TYPE_CODE_UNION:
+ if (addressprint)
+ {
+ fprintf_filtered (stream, "LOC(H'%lx)",
+ unpack_long (builtin_type_int, valaddr));
+ if (deref_ref)
+ fputs_filtered (": ", stream);
+ }
+ /* De-reference the reference. */
+ if (deref_ref)
+ {
+ if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_UNDEF)
+ {
+ value deref_val =
+ value_at
+ (TYPE_TARGET_TYPE (type),
+ unpack_pointer (lookup_pointer_type (builtin_type_void),
+ valaddr));
+ val_print (VALUE_TYPE (deref_val),
+ VALUE_CONTENTS (deref_val),
+ VALUE_ADDRESS (deref_val), stream, format,
+ deref_ref, recurse + 1, pretty);
+ }
+ else
+ fputs_filtered ("???", stream);
+ }
+ break;
+
case TYPE_CODE_ENUM:
+ c_val_print (type, valaddr, address, stream, format,
+ deref_ref, recurse, pretty);
+ break;
+
+ case TYPE_CODE_MEMBER:
+ case TYPE_CODE_UNION:
case TYPE_CODE_FUNC:
case TYPE_CODE_VOID:
case TYPE_CODE_ERROR:
case TYPE_CODE_RANGE:
- error ("Unimplemented chill_val_print support for type %d",
- TYPE_CODE (type));
- break;
-
default:
- error ("Invalid Chill type code %d in symbol table.", TYPE_CODE (type));
+ /* Let's derfer printing to the C printer, rather than
+ print an error message. FIXME! */
+ c_val_print (type, valaddr, address, stream, format,
+ deref_ref, recurse, pretty);
}
fflush (stream);
return (0);
check_stub_type (type);
- fprintf_filtered (stream, "(");
+ fprintf_filtered (stream, "[");
len = TYPE_NFIELDS (type);
if (len == 0)
{
{
wrap_here (n_spaces (2 + 2 * recurse));
}
+ fputs_filtered (".", stream);
fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i),
language_chill, DMGL_NO_OPTS);
- fputs_filtered (" = ", stream);
+ fputs_filtered (": ", stream);
if (TYPE_FIELD_PACKED (type, i))
{
value v;
print_spaces_filtered (2 * recurse, stream);
}
}
- fprintf_filtered (stream, ")");
+ fprintf_filtered (stream, "]");
}
member functions, attach them to the type, and then read any tilde
field (baseclass specifier for the class holding the main vtable). */
- if (!read_baseclasses (&fi, pp, type, objfile))
- {
- do_cleanups (back_to);
- return (error_type (pp));
- }
- if (!read_struct_fields (&fi, pp, type, objfile))
- {
- do_cleanups (back_to);
- return (error_type (pp));
- }
- if (!attach_fields_to_type (&fi, type, objfile))
- {
- do_cleanups (back_to);
- return (error_type (pp));
- }
- if (!read_member_functions (&fi, pp, type, objfile))
- {
- do_cleanups (back_to);
- return (error_type (pp));
- }
- if (!attach_fn_fields_to_type (&fi, type))
- {
- do_cleanups (back_to);
- return (error_type (pp));
- }
- if (!read_tilde_fields (&fi, pp, type, objfile))
+ if (!read_baseclasses (&fi, pp, type, objfile)
+ || !read_struct_fields (&fi, pp, type, objfile)
+ || !attach_fields_to_type (&fi, type, objfile)
+ || !read_member_functions (&fi, pp, type, objfile)
+ || !attach_fn_fields_to_type (&fi, type)
+ || !read_tilde_fields (&fi, pp, type, objfile))
{
do_cleanups (back_to);
return (error_type (pp));