* expression.h (struct expression): New member GDBARCH.

* parse.c (parse_exp_in_context): Initialize it.
	* parser-def.h (parse_gdbarch, parse_language): New macros.

	* ada-exp.y (parse_type): New macro.
	Replace builtin_type_ macros by using parse_type.
	Replace current_language by parse_language.
	* ada-lex.l (processInt): Replace current_gdbarch by parse_gdbarch.
	Replace builtin_type_ macros.

	* c-exp.y (parse_type): New macro.
	Replace builtin_type_ macros by using parse_type.
	(parse_number): Replace current_gdbarch by parse_gdbarch.
	(yylex): Replace current_language by parse_language.

	* f-exp.y (parse_type, parse_f_type): New macros.
	Replace builtin_type_ macros by using parse_{f_,}type.
	(parse_number): Replace current_gdbarch by parse_gdbarch.
	(yylex): Replace current_language by parse_language.

	* jv-exp.y (parse_type): New macro.
	(parse_number): Replace builtin_type_ macros by using parse_type.

	* m2-exp.y (parse_type, parse_m2_type): New macros.
	Replace builtin_type_ macros by using parse_{m2_,}type.

	* objc-exp.y (parse_type): New macro.
	Replace builtin_type_ macros by using parse_type.
	(parse_number): Replace current_gdbarch by parse_gdbarch.
	(yylex): Replace current_language by parse_language.

	* p-exp.y (parse_type): New macro.
	Replace builtin_type_ macros by using parse_type.
	(parse_number): Replace current_gdbarch by parse_gdbarch.
	(yylex): Replace current_language by parse_language.
This commit is contained in:
Ulrich Weigand 2008-09-11 14:09:37 +00:00
parent c841afd52a
commit 3e79cecf02
12 changed files with 255 additions and 195 deletions

View file

@ -1,3 +1,41 @@
2008-09-11 Ulrich Weigand <uweigand@de.ibm.com>
* expression.h (struct expression): New member GDBARCH.
* parse.c (parse_exp_in_context): Initialize it.
* parser-def.h (parse_gdbarch, parse_language): New macros.
* ada-exp.y (parse_type): New macro.
Replace builtin_type_ macros by using parse_type.
Replace current_language by parse_language.
* ada-lex.l (processInt): Replace current_gdbarch by parse_gdbarch.
Replace builtin_type_ macros.
* c-exp.y (parse_type): New macro.
Replace builtin_type_ macros by using parse_type.
(parse_number): Replace current_gdbarch by parse_gdbarch.
(yylex): Replace current_language by parse_language.
* f-exp.y (parse_type, parse_f_type): New macros.
Replace builtin_type_ macros by using parse_{f_,}type.
(parse_number): Replace current_gdbarch by parse_gdbarch.
(yylex): Replace current_language by parse_language.
* jv-exp.y (parse_type): New macro.
(parse_number): Replace builtin_type_ macros by using parse_type.
* m2-exp.y (parse_type, parse_m2_type): New macros.
Replace builtin_type_ macros by using parse_{m2_,}type.
* objc-exp.y (parse_type): New macro.
Replace builtin_type_ macros by using parse_type.
(parse_number): Replace current_gdbarch by parse_gdbarch.
(yylex): Replace current_language by parse_language.
* p-exp.y (parse_type): New macro.
Replace builtin_type_ macros by using parse_type.
(parse_number): Replace current_gdbarch by parse_gdbarch.
(yylex): Replace current_language by parse_language.
2008-09-11 Ulrich Weigand <uweigand@de.ibm.com> 2008-09-11 Ulrich Weigand <uweigand@de.ibm.com>
* parser-defs.h (write_exp_msymbol): Remove TEXT_SYMBOL_TYPE * parser-defs.h (write_exp_msymbol): Remove TEXT_SYMBOL_TYPE

View file

@ -52,6 +52,8 @@ Boston, MA 02110-1301, USA. */
#include "frame.h" #include "frame.h"
#include "block.h" #include "block.h"
#define parse_type builtin_type (parse_gdbarch)
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple as well as gratuitiously global symbol names, so we can have multiple
yacc generated parsers in gdb. These are only the variables yacc generated parsers in gdb. These are only the variables
@ -571,7 +573,7 @@ opt_type_prefix :
type_prefix type_prefix
| /* EMPTY */ | /* EMPTY */
{ write_exp_elt_opcode (OP_TYPE); { write_exp_elt_opcode (OP_TYPE);
write_exp_elt_type (builtin_type_void); write_exp_elt_type (parse_type->builtin_void);
write_exp_elt_opcode (OP_TYPE); } write_exp_elt_opcode (OP_TYPE); }
; ;
@ -1081,8 +1083,8 @@ static struct type*
find_primitive_type (char *name) find_primitive_type (char *name)
{ {
struct type *type; struct type *type;
type = language_lookup_primitive_type_by_name (current_language, type = language_lookup_primitive_type_by_name (parse_language,
current_gdbarch, parse_gdbarch,
name); name);
if (type == NULL && strcmp ("system__address", name) == 0) if (type == NULL && strcmp ("system__address", name) == 0)
type = type_system_address (); type = type_system_address ();
@ -1463,59 +1465,59 @@ convert_char_literal (struct type *type, LONGEST val)
static struct type * static struct type *
type_int (void) type_int (void)
{ {
return builtin_type_int; return parse_type->builtin_int;
} }
static struct type * static struct type *
type_long (void) type_long (void)
{ {
return builtin_type_long; return parse_type->builtin_long;
} }
static struct type * static struct type *
type_long_long (void) type_long_long (void)
{ {
return builtin_type_long_long; return parse_type->builtin_long_long;
} }
static struct type * static struct type *
type_float (void) type_float (void)
{ {
return builtin_type_float; return parse_type->builtin_float;
} }
static struct type * static struct type *
type_double (void) type_double (void)
{ {
return builtin_type_double; return parse_type->builtin_double;
} }
static struct type * static struct type *
type_long_double (void) type_long_double (void)
{ {
return builtin_type_long_double; return parse_type->builtin_long_double;
} }
static struct type * static struct type *
type_char (void) type_char (void)
{ {
return language_string_char_type (current_language, current_gdbarch); return language_string_char_type (parse_language, parse_gdbarch);
} }
static struct type * static struct type *
type_boolean (void) type_boolean (void)
{ {
return builtin_type_bool; return parse_type->builtin_bool;
} }
static struct type * static struct type *
type_system_address (void) type_system_address (void)
{ {
struct type *type struct type *type
= language_lookup_primitive_type_by_name (current_language, = language_lookup_primitive_type_by_name (parse_language,
current_gdbarch, parse_gdbarch,
"system__address"); "system__address");
return type != NULL ? type : lookup_pointer_type (builtin_type_void); return type != NULL ? type : parse_type->builtin_data_ptr;
} }
void void

View file

@ -351,11 +351,11 @@ processInt (const char *base0, const char *num0, const char *exp0)
exp -= 1; exp -= 1;
} }
if ((result >> (gdbarch_int_bit (current_gdbarch)-1)) == 0) if ((result >> (gdbarch_int_bit (parse_gdbarch)-1)) == 0)
yylval.typed_val.type = type_int (); yylval.typed_val.type = type_int ();
else if ((result >> (gdbarch_long_bit (current_gdbarch)-1)) == 0) else if ((result >> (gdbarch_long_bit (parse_gdbarch)-1)) == 0)
yylval.typed_val.type = type_long (); yylval.typed_val.type = type_long ();
else if (((result >> (gdbarch_long_bit (current_gdbarch)-1)) >> 1) == 0) else if (((result >> (gdbarch_long_bit (parse_gdbarch)-1)) >> 1) == 0)
{ {
/* We have a number representable as an unsigned integer quantity. /* We have a number representable as an unsigned integer quantity.
For consistency with the C treatment, we will treat it as an For consistency with the C treatment, we will treat it as an
@ -364,7 +364,8 @@ processInt (const char *base0, const char *num0, const char *exp0)
for the mess, but C doesn't officially guarantee that a simple for the mess, but C doesn't officially guarantee that a simple
assignment does the trick (no, it doesn't; read the reference manual). assignment does the trick (no, it doesn't; read the reference manual).
*/ */
yylval.typed_val.type = builtin_type_unsigned_long; yylval.typed_val.type
= builtin_type (parse_gdbarch)->builtin_unsigned_long;
if (result & LONGEST_SIGN) if (result & LONGEST_SIGN)
yylval.typed_val.val = yylval.typed_val.val =
(LONGEST) (result & ~LONGEST_SIGN) (LONGEST) (result & ~LONGEST_SIGN)
@ -386,10 +387,10 @@ processReal (const char *num0)
sscanf (num0, "%" DOUBLEST_SCAN_FORMAT, &yylval.typed_val_float.dval); sscanf (num0, "%" DOUBLEST_SCAN_FORMAT, &yylval.typed_val_float.dval);
yylval.typed_val_float.type = type_float (); yylval.typed_val_float.type = type_float ();
if (sizeof(DOUBLEST) >= gdbarch_double_bit (current_gdbarch) if (sizeof(DOUBLEST) >= gdbarch_double_bit (parse_gdbarch)
/ TARGET_CHAR_BIT) / TARGET_CHAR_BIT)
yylval.typed_val_float.type = type_double (); yylval.typed_val_float.type = type_double ();
if (sizeof(DOUBLEST) >= gdbarch_long_double_bit (current_gdbarch) if (sizeof(DOUBLEST) >= gdbarch_long_double_bit (parse_gdbarch)
/ TARGET_CHAR_BIT) / TARGET_CHAR_BIT)
yylval.typed_val_float.type = type_long_double (); yylval.typed_val_float.type = type_long_double ();

View file

@ -55,6 +55,8 @@ Boston, MA 02110-1301, USA. */
#include "cp-support.h" #include "cp-support.h"
#include "dfp.h" #include "dfp.h"
#define parse_type builtin_type (parse_gdbarch)
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple as well as gratuitiously global symbol names, so we can have multiple
yacc generated parsers in gdb. Note that these are only the variables yacc generated parsers in gdb. Note that these are only the variables
@ -554,7 +556,7 @@ exp : VARIABLE
exp : SIZEOF '(' type ')' %prec UNARY exp : SIZEOF '(' type ')' %prec UNARY
{ write_exp_elt_opcode (OP_LONG); { write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type (current_gdbarch)->builtin_int); write_exp_elt_type (parse_type->builtin_int);
CHECK_TYPEDEF ($3); CHECK_TYPEDEF ($3);
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3)); write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
write_exp_elt_opcode (OP_LONG); } write_exp_elt_opcode (OP_LONG); }
@ -570,12 +572,12 @@ exp : STRING
while (count-- > 0) while (count-- > 0)
{ {
write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type (current_gdbarch)->builtin_char); write_exp_elt_type (parse_type->builtin_char);
write_exp_elt_longcst ((LONGEST)(*sp++)); write_exp_elt_longcst ((LONGEST)(*sp++));
write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_LONG);
} }
write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type (current_gdbarch)->builtin_char); write_exp_elt_type (parse_type->builtin_char);
write_exp_elt_longcst ((LONGEST)'\0'); write_exp_elt_longcst ((LONGEST)'\0');
write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_LONG);
write_exp_elt_opcode (OP_ARRAY); write_exp_elt_opcode (OP_ARRAY);
@ -587,14 +589,14 @@ exp : STRING
/* C++. */ /* C++. */
exp : TRUEKEYWORD exp : TRUEKEYWORD
{ write_exp_elt_opcode (OP_LONG); { write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type (current_gdbarch)->builtin_bool); write_exp_elt_type (parse_type->builtin_bool);
write_exp_elt_longcst ((LONGEST) 1); write_exp_elt_longcst ((LONGEST) 1);
write_exp_elt_opcode (OP_LONG); } write_exp_elt_opcode (OP_LONG); }
; ;
exp : FALSEKEYWORD exp : FALSEKEYWORD
{ write_exp_elt_opcode (OP_LONG); { write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type (current_gdbarch)->builtin_bool); write_exp_elt_type (parse_type->builtin_bool);
write_exp_elt_longcst ((LONGEST) 0); write_exp_elt_longcst ((LONGEST) 0);
write_exp_elt_opcode (OP_LONG); } write_exp_elt_opcode (OP_LONG); }
; ;
@ -841,61 +843,61 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */
: TYPENAME : TYPENAME
{ $$ = $1.type; } { $$ = $1.type; }
| INT_KEYWORD | INT_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_int; } { $$ = parse_type->builtin_int; }
| LONG | LONG
{ $$ = builtin_type (current_gdbarch)->builtin_long; } { $$ = parse_type->builtin_long; }
| SHORT | SHORT
{ $$ = builtin_type (current_gdbarch)->builtin_short; } { $$ = parse_type->builtin_short; }
| LONG INT_KEYWORD | LONG INT_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_long; } { $$ = parse_type->builtin_long; }
| LONG SIGNED_KEYWORD INT_KEYWORD | LONG SIGNED_KEYWORD INT_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_long; } { $$ = parse_type->builtin_long; }
| LONG SIGNED_KEYWORD | LONG SIGNED_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_long; } { $$ = parse_type->builtin_long; }
| SIGNED_KEYWORD LONG INT_KEYWORD | SIGNED_KEYWORD LONG INT_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_long; } { $$ = parse_type->builtin_long; }
| UNSIGNED LONG INT_KEYWORD | UNSIGNED LONG INT_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_long; } { $$ = parse_type->builtin_unsigned_long; }
| LONG UNSIGNED INT_KEYWORD | LONG UNSIGNED INT_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_long; } { $$ = parse_type->builtin_unsigned_long; }
| LONG UNSIGNED | LONG UNSIGNED
{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_long; } { $$ = parse_type->builtin_unsigned_long; }
| LONG LONG | LONG LONG
{ $$ = builtin_type (current_gdbarch)->builtin_long_long; } { $$ = parse_type->builtin_long_long; }
| LONG LONG INT_KEYWORD | LONG LONG INT_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_long_long; } { $$ = parse_type->builtin_long_long; }
| LONG LONG SIGNED_KEYWORD INT_KEYWORD | LONG LONG SIGNED_KEYWORD INT_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_long_long; } { $$ = parse_type->builtin_long_long; }
| LONG LONG SIGNED_KEYWORD | LONG LONG SIGNED_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_long_long; } { $$ = parse_type->builtin_long_long; }
| SIGNED_KEYWORD LONG LONG | SIGNED_KEYWORD LONG LONG
{ $$ = builtin_type (current_gdbarch)->builtin_long_long; } { $$ = parse_type->builtin_long_long; }
| SIGNED_KEYWORD LONG LONG INT_KEYWORD | SIGNED_KEYWORD LONG LONG INT_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_long_long; } { $$ = parse_type->builtin_long_long; }
| UNSIGNED LONG LONG | UNSIGNED LONG LONG
{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; } { $$ = parse_type->builtin_unsigned_long_long; }
| UNSIGNED LONG LONG INT_KEYWORD | UNSIGNED LONG LONG INT_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; } { $$ = parse_type->builtin_unsigned_long_long; }
| LONG LONG UNSIGNED | LONG LONG UNSIGNED
{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; } { $$ = parse_type->builtin_unsigned_long_long; }
| LONG LONG UNSIGNED INT_KEYWORD | LONG LONG UNSIGNED INT_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; } { $$ = parse_type->builtin_unsigned_long_long; }
| SHORT INT_KEYWORD | SHORT INT_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_short; } { $$ = parse_type->builtin_short; }
| SHORT SIGNED_KEYWORD INT_KEYWORD | SHORT SIGNED_KEYWORD INT_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_short; } { $$ = parse_type->builtin_short; }
| SHORT SIGNED_KEYWORD | SHORT SIGNED_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_short; } { $$ = parse_type->builtin_short; }
| UNSIGNED SHORT INT_KEYWORD | UNSIGNED SHORT INT_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_short; } { $$ = parse_type->builtin_unsigned_short; }
| SHORT UNSIGNED | SHORT UNSIGNED
{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_short; } { $$ = parse_type->builtin_unsigned_short; }
| SHORT UNSIGNED INT_KEYWORD | SHORT UNSIGNED INT_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_short; } { $$ = parse_type->builtin_unsigned_short; }
| DOUBLE_KEYWORD | DOUBLE_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_double; } { $$ = parse_type->builtin_double; }
| LONG DOUBLE_KEYWORD | LONG DOUBLE_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_long_double; } { $$ = parse_type->builtin_long_double; }
| STRUCT name | STRUCT name
{ $$ = lookup_struct (copy_name ($2), { $$ = lookup_struct (copy_name ($2),
expression_context_block); } expression_context_block); }
@ -911,11 +913,11 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */
| UNSIGNED typename | UNSIGNED typename
{ $$ = lookup_unsigned_typename (TYPE_NAME($2.type)); } { $$ = lookup_unsigned_typename (TYPE_NAME($2.type)); }
| UNSIGNED | UNSIGNED
{ $$ = builtin_type (current_gdbarch)->builtin_unsigned_int; } { $$ = parse_type->builtin_unsigned_int; }
| SIGNED_KEYWORD typename | SIGNED_KEYWORD typename
{ $$ = lookup_signed_typename (TYPE_NAME($2.type)); } { $$ = lookup_signed_typename (TYPE_NAME($2.type)); }
| SIGNED_KEYWORD | SIGNED_KEYWORD
{ $$ = builtin_type (current_gdbarch)->builtin_int; } { $$ = parse_type->builtin_int; }
/* It appears that this rule for templates is never /* It appears that this rule for templates is never
reduced; template recognition happens by lookahead reduced; template recognition happens by lookahead
in the token processing code in yylex. */ in the token processing code in yylex. */
@ -1005,19 +1007,19 @@ typename: TYPENAME
{ {
$$.stoken.ptr = "int"; $$.stoken.ptr = "int";
$$.stoken.length = 3; $$.stoken.length = 3;
$$.type = builtin_type (current_gdbarch)->builtin_int; $$.type = parse_type->builtin_int;
} }
| LONG | LONG
{ {
$$.stoken.ptr = "long"; $$.stoken.ptr = "long";
$$.stoken.length = 4; $$.stoken.length = 4;
$$.type = builtin_type (current_gdbarch)->builtin_long; $$.type = parse_type->builtin_long;
} }
| SHORT | SHORT
{ {
$$.stoken.ptr = "short"; $$.stoken.ptr = "short";
$$.stoken.length = 5; $$.stoken.length = 5;
$$.type = builtin_type (current_gdbarch)->builtin_short; $$.type = parse_type->builtin_short;
} }
; ;
@ -1120,7 +1122,7 @@ parse_number (p, len, parsed_float, putithere)
{ {
p[len - 2] = '\0'; p[len - 2] = '\0';
putithere->typed_val_decfloat.type putithere->typed_val_decfloat.type
= builtin_type (current_gdbarch)->builtin_decfloat; = parse_type->builtin_decfloat;
decimal_from_string (putithere->typed_val_decfloat.val, 4, p); decimal_from_string (putithere->typed_val_decfloat.val, 4, p);
p[len - 2] = 'd'; p[len - 2] = 'd';
return DECFLOAT; return DECFLOAT;
@ -1130,7 +1132,7 @@ parse_number (p, len, parsed_float, putithere)
{ {
p[len - 2] = '\0'; p[len - 2] = '\0';
putithere->typed_val_decfloat.type putithere->typed_val_decfloat.type
= builtin_type (current_gdbarch)->builtin_decdouble; = parse_type->builtin_decdouble;
decimal_from_string (putithere->typed_val_decfloat.val, 8, p); decimal_from_string (putithere->typed_val_decfloat.val, 8, p);
p[len - 2] = 'd'; p[len - 2] = 'd';
return DECFLOAT; return DECFLOAT;
@ -1140,7 +1142,7 @@ parse_number (p, len, parsed_float, putithere)
{ {
p[len - 2] = '\0'; p[len - 2] = '\0';
putithere->typed_val_decfloat.type putithere->typed_val_decfloat.type
= builtin_type (current_gdbarch)->builtin_declong; = parse_type->builtin_declong;
decimal_from_string (putithere->typed_val_decfloat.val, 16, p); decimal_from_string (putithere->typed_val_decfloat.val, 16, p);
p[len - 2] = 'd'; p[len - 2] = 'd';
return DECFLOAT; return DECFLOAT;
@ -1155,7 +1157,7 @@ parse_number (p, len, parsed_float, putithere)
if (num == 1) if (num == 1)
putithere->typed_val_float.type = putithere->typed_val_float.type =
builtin_type (current_gdbarch)->builtin_double; parse_type->builtin_double;
if (num == 2 ) if (num == 2 )
{ {
@ -1163,10 +1165,10 @@ parse_number (p, len, parsed_float, putithere)
double. */ double. */
if (!strcasecmp (s, "f")) if (!strcasecmp (s, "f"))
putithere->typed_val_float.type = putithere->typed_val_float.type =
builtin_type (current_gdbarch)->builtin_float; parse_type->builtin_float;
else if (!strcasecmp (s, "l")) else if (!strcasecmp (s, "l"))
putithere->typed_val_float.type = putithere->typed_val_float.type =
builtin_type (current_gdbarch)->builtin_long_double; parse_type->builtin_long_double;
else else
{ {
free (s); free (s);
@ -1277,9 +1279,9 @@ parse_number (p, len, parsed_float, putithere)
un = (ULONGEST)n >> 2; un = (ULONGEST)n >> 2;
if (long_p == 0 if (long_p == 0
&& (un >> (gdbarch_int_bit (current_gdbarch) - 2)) == 0) && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
{ {
high_bit = ((ULONGEST)1) << (gdbarch_int_bit (current_gdbarch) - 1); high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
/* A large decimal (not hex or octal) constant (between INT_MAX /* A large decimal (not hex or octal) constant (between INT_MAX
and UINT_MAX) is a long or unsigned long, according to ANSI, and UINT_MAX) is a long or unsigned long, according to ANSI,
@ -1287,28 +1289,28 @@ parse_number (p, len, parsed_float, putithere)
int. This probably should be fixed. GCC gives a warning on int. This probably should be fixed. GCC gives a warning on
such constants. */ such constants. */
unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_int; unsigned_type = parse_type->builtin_unsigned_int;
signed_type = builtin_type (current_gdbarch)->builtin_int; signed_type = parse_type->builtin_int;
} }
else if (long_p <= 1 else if (long_p <= 1
&& (un >> (gdbarch_long_bit (current_gdbarch) - 2)) == 0) && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
{ {
high_bit = ((ULONGEST)1) << (gdbarch_long_bit (current_gdbarch) - 1); high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_long; unsigned_type = parse_type->builtin_unsigned_long;
signed_type = builtin_type (current_gdbarch)->builtin_long; signed_type = parse_type->builtin_long;
} }
else else
{ {
int shift; int shift;
if (sizeof (ULONGEST) * HOST_CHAR_BIT if (sizeof (ULONGEST) * HOST_CHAR_BIT
< gdbarch_long_long_bit (current_gdbarch)) < gdbarch_long_long_bit (parse_gdbarch))
/* A long long does not fit in a LONGEST. */ /* A long long does not fit in a LONGEST. */
shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1); shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
else else
shift = (gdbarch_long_long_bit (current_gdbarch) - 1); shift = (gdbarch_long_long_bit (parse_gdbarch) - 1);
high_bit = (ULONGEST) 1 << shift; high_bit = (ULONGEST) 1 << shift;
unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_long_long; unsigned_type = parse_type->builtin_unsigned_long_long;
signed_type = builtin_type (current_gdbarch)->builtin_long_long; signed_type = parse_type->builtin_long_long;
} }
putithere->typed_val_int.val = n; putithere->typed_val_int.val = n;
@ -1481,7 +1483,7 @@ yylex ()
} }
yylval.typed_val_int.val = c; yylval.typed_val_int.val = c;
yylval.typed_val_int.type = builtin_type (current_gdbarch)->builtin_char; yylval.typed_val_int.type = parse_type->builtin_char;
c = *lexptr++; c = *lexptr++;
if (c != '\'') if (c != '\'')
@ -1733,7 +1735,7 @@ yylex ()
case 8: case 8:
if (strncmp (tokstart, "unsigned", 8) == 0) if (strncmp (tokstart, "unsigned", 8) == 0)
return UNSIGNED; return UNSIGNED;
if (current_language->la_language == language_cplus if (parse_language->la_language == language_cplus
&& strncmp (tokstart, "template", 8) == 0) && strncmp (tokstart, "template", 8) == 0)
return TEMPLATE; return TEMPLATE;
if (strncmp (tokstart, "volatile", 8) == 0) if (strncmp (tokstart, "volatile", 8) == 0)
@ -1750,7 +1752,7 @@ yylex ()
return DOUBLE_KEYWORD; return DOUBLE_KEYWORD;
break; break;
case 5: case 5:
if (current_language->la_language == language_cplus) if (parse_language->la_language == language_cplus)
{ {
if (strncmp (tokstart, "false", 5) == 0) if (strncmp (tokstart, "false", 5) == 0)
return FALSEKEYWORD; return FALSEKEYWORD;
@ -1769,7 +1771,7 @@ yylex ()
return ENUM; return ENUM;
if (strncmp (tokstart, "long", 4) == 0) if (strncmp (tokstart, "long", 4) == 0)
return LONG; return LONG;
if (current_language->la_language == language_cplus) if (parse_language->la_language == language_cplus)
{ {
if (strncmp (tokstart, "true", 4) == 0) if (strncmp (tokstart, "true", 4) == 0)
return TRUEKEYWORD; return TRUEKEYWORD;
@ -1805,7 +1807,7 @@ yylex ()
sym = lookup_symbol (tmp, expression_context_block, sym = lookup_symbol (tmp, expression_context_block,
VAR_DOMAIN, VAR_DOMAIN,
current_language->la_language == language_cplus parse_language->la_language == language_cplus
? &is_a_field_of_this : (int *) NULL); ? &is_a_field_of_this : (int *) NULL);
/* Call lookup_symtab, not lookup_partial_symtab, in case there are /* Call lookup_symtab, not lookup_partial_symtab, in case there are
no psymtabs (coff, xcoff, or some future change to blow away the no psymtabs (coff, xcoff, or some future change to blow away the
@ -1838,8 +1840,8 @@ yylex ()
return TYPENAME; return TYPENAME;
} }
yylval.tsym.type yylval.tsym.type
= language_lookup_primitive_type_by_name (current_language, = language_lookup_primitive_type_by_name (parse_language,
current_gdbarch, tmp); parse_gdbarch, tmp);
if (yylval.tsym.type != NULL) if (yylval.tsym.type != NULL)
return TYPENAME; return TYPENAME;

View file

@ -373,6 +373,7 @@ union exp_element
struct expression struct expression
{ {
const struct language_defn *language_defn; /* language it was entered in */ const struct language_defn *language_defn; /* language it was entered in */
struct gdbarch *gdbarch; /* architecture it was parsed in */
int nelts; int nelts;
union exp_element elts[1]; union exp_element elts[1];
}; };

View file

@ -57,6 +57,9 @@ Boston, MA 02110-1301, USA. */
#include "block.h" #include "block.h"
#include <ctype.h> #include <ctype.h>
#define parse_type builtin_type (parse_gdbarch)
#define parse_f_type builtin_f_type (parse_gdbarch)
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple as well as gratuitiously global symbol names, so we can have multiple
yacc generated parsers in gdb. Note that these are only the variables yacc generated parsers in gdb. Note that these are only the variables
@ -447,7 +450,7 @@ exp : NAME_OR_INT
exp : FLOAT exp : FLOAT
{ write_exp_elt_opcode (OP_DOUBLE); { write_exp_elt_opcode (OP_DOUBLE);
write_exp_elt_type (builtin_type_f_real_s8); write_exp_elt_type (parse_f_type->builtin_real_s8);
write_exp_elt_dblcst ($1); write_exp_elt_dblcst ($1);
write_exp_elt_opcode (OP_DOUBLE); } write_exp_elt_opcode (OP_DOUBLE); }
; ;
@ -460,7 +463,7 @@ exp : VARIABLE
exp : SIZEOF '(' type ')' %prec UNARY exp : SIZEOF '(' type ')' %prec UNARY
{ write_exp_elt_opcode (OP_LONG); { write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_f_integer); write_exp_elt_type (parse_f_type->builtin_integer);
CHECK_TYPEDEF ($3); CHECK_TYPEDEF ($3);
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3)); write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
write_exp_elt_opcode (OP_LONG); } write_exp_elt_opcode (OP_LONG); }
@ -551,8 +554,8 @@ ptype : typebase
{ {
range_type = range_type =
create_range_type ((struct type *) NULL, create_range_type ((struct type *) NULL,
builtin_type_f_integer, 0, parse_f_type->builtin_integer,
array_size - 1); 0, array_size - 1);
follow_type = follow_type =
create_array_type ((struct type *) NULL, create_array_type ((struct type *) NULL,
follow_type, range_type); follow_type, range_type);
@ -597,29 +600,29 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */
: TYPENAME : TYPENAME
{ $$ = $1.type; } { $$ = $1.type; }
| INT_KEYWORD | INT_KEYWORD
{ $$ = builtin_type_f_integer; } { $$ = parse_f_type->builtin_integer; }
| INT_S2_KEYWORD | INT_S2_KEYWORD
{ $$ = builtin_type_f_integer_s2; } { $$ = parse_f_type->builtin_integer_s2; }
| CHARACTER | CHARACTER
{ $$ = builtin_type_f_character; } { $$ = parse_f_type->builtin_character; }
| LOGICAL_KEYWORD | LOGICAL_KEYWORD
{ $$ = builtin_type_f_logical;} { $$ = parse_f_type->builtin_logical; }
| LOGICAL_S2_KEYWORD | LOGICAL_S2_KEYWORD
{ $$ = builtin_type_f_logical_s2;} { $$ = parse_f_type->builtin_logical_s2; }
| LOGICAL_S1_KEYWORD | LOGICAL_S1_KEYWORD
{ $$ = builtin_type_f_logical_s1;} { $$ = parse_f_type->builtin_logical_s1; }
| REAL_KEYWORD | REAL_KEYWORD
{ $$ = builtin_type_f_real;} { $$ = parse_f_type->builtin_real; }
| REAL_S8_KEYWORD | REAL_S8_KEYWORD
{ $$ = builtin_type_f_real_s8;} { $$ = parse_f_type->builtin_real_s8; }
| REAL_S16_KEYWORD | REAL_S16_KEYWORD
{ $$ = builtin_type_f_real_s16;} { $$ = parse_f_type->builtin_real_s16; }
| COMPLEX_S8_KEYWORD | COMPLEX_S8_KEYWORD
{ $$ = builtin_type_f_complex_s8;} { $$ = parse_f_type->builtin_complex_s8; }
| COMPLEX_S16_KEYWORD | COMPLEX_S16_KEYWORD
{ $$ = builtin_type_f_complex_s16;} { $$ = parse_f_type->builtin_complex_s16; }
| COMPLEX_S32_KEYWORD | COMPLEX_S32_KEYWORD
{ $$ = builtin_type_f_complex_s32;} { $$ = parse_f_type->builtin_complex_s32; }
; ;
nonempty_typelist nonempty_typelist
@ -762,26 +765,26 @@ parse_number (p, len, parsed_float, putithere)
target int size is different to the target long size. target int size is different to the target long size.
In the expression below, we could have tested In the expression below, we could have tested
(n >> gdbarch_int_bit (current_gdbarch)) (n >> gdbarch_int_bit (parse_gdbarch))
to see if it was zero, to see if it was zero,
but too many compilers warn about that, when ints and longs but too many compilers warn about that, when ints and longs
are the same size. So we shift it twice, with fewer bits are the same size. So we shift it twice, with fewer bits
each time, for the same result. */ each time, for the same result. */
if ((gdbarch_int_bit (current_gdbarch) != gdbarch_long_bit (current_gdbarch) if ((gdbarch_int_bit (parse_gdbarch) != gdbarch_long_bit (parse_gdbarch)
&& ((n >> 2) && ((n >> 2)
>> (gdbarch_int_bit (current_gdbarch)-2))) /* Avoid shift warning */ >> (gdbarch_int_bit (parse_gdbarch)-2))) /* Avoid shift warning */
|| long_p) || long_p)
{ {
high_bit = ((ULONGEST)1) << (gdbarch_long_bit (current_gdbarch)-1); high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch)-1);
unsigned_type = builtin_type_unsigned_long; unsigned_type = parse_type->builtin_unsigned_long;
signed_type = builtin_type_long; signed_type = parse_type->builtin_long;
} }
else else
{ {
high_bit = ((ULONGEST)1) << (gdbarch_int_bit (current_gdbarch)-1); high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch)-1);
unsigned_type = builtin_type_unsigned_int; unsigned_type = parse_type->builtin_unsigned_int;
signed_type = builtin_type_int; signed_type = parse_type->builtin_int;
} }
putithere->typed_val.val = n; putithere->typed_val.val = n;
@ -1170,7 +1173,7 @@ yylex ()
sym = lookup_symbol (tmp, expression_context_block, sym = lookup_symbol (tmp, expression_context_block,
VAR_DOMAIN, VAR_DOMAIN,
current_language->la_language == language_cplus parse_language->la_language == language_cplus
? &is_a_field_of_this : NULL); ? &is_a_field_of_this : NULL);
if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF) if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
{ {
@ -1178,8 +1181,8 @@ yylex ()
return TYPENAME; return TYPENAME;
} }
yylval.tsym.type yylval.tsym.type
= language_lookup_primitive_type_by_name (current_language, = language_lookup_primitive_type_by_name (parse_language,
current_gdbarch, tmp); parse_gdbarch, tmp);
if (yylval.tsym.type != NULL) if (yylval.tsym.type != NULL)
return TYPENAME; return TYPENAME;

View file

@ -51,6 +51,8 @@ Boston, MA 02110-1301, USA. */
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */ #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
#include "block.h" #include "block.h"
#define parse_type builtin_type (parse_gdbarch)
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple as well as gratuitiously global symbol names, so we can have multiple
yacc generated parsers in gdb. Note that these are only the variables yacc generated parsers in gdb. Note that these are only the variables
@ -723,9 +725,9 @@ parse_number (p, len, parsed_float, putithere)
c = tolower (p[len - 1]); c = tolower (p[len - 1]);
if (c == 'f' || c == 'F') if (c == 'f' || c == 'F')
putithere->typed_val_float.type = builtin_type_float; putithere->typed_val_float.type = parse_type->builtin_float;
else if (isdigit (c) || c == '.' || c == 'd' || c == 'D') else if (isdigit (c) || c == '.' || c == 'd' || c == 'D')
putithere->typed_val_float.type = builtin_type_double; putithere->typed_val_float.type = parse_type->builtin_double;
else else
return ERROR; return ERROR;

View file

@ -52,6 +52,9 @@ Boston, MA 02110-1301, USA. */
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */ #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
#include "block.h" #include "block.h"
#define parse_type builtin_type (parse_gdbarch)
#define parse_m2_type builtin_m2_type (parse_gdbarch)
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple as well as gratuitiously global symbol names, so we can have multiple
yacc generated parsers in gdb. Note that these are only the variables yacc generated parsers in gdb. Note that these are only the variables
@ -497,7 +500,7 @@ exp : M2_FALSE
exp : INT exp : INT
{ write_exp_elt_opcode (OP_LONG); { write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_m2_int); write_exp_elt_type (parse_m2_type->builtin_int);
write_exp_elt_longcst ((LONGEST) $1); write_exp_elt_longcst ((LONGEST) $1);
write_exp_elt_opcode (OP_LONG); } write_exp_elt_opcode (OP_LONG); }
; ;
@ -505,7 +508,7 @@ exp : INT
exp : UINT exp : UINT
{ {
write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_m2_card); write_exp_elt_type (parse_m2_type->builtin_card);
write_exp_elt_longcst ((LONGEST) $1); write_exp_elt_longcst ((LONGEST) $1);
write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_LONG);
} }
@ -513,7 +516,7 @@ exp : UINT
exp : CHAR exp : CHAR
{ write_exp_elt_opcode (OP_LONG); { write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_m2_char); write_exp_elt_type (parse_m2_type->builtin_char);
write_exp_elt_longcst ((LONGEST) $1); write_exp_elt_longcst ((LONGEST) $1);
write_exp_elt_opcode (OP_LONG); } write_exp_elt_opcode (OP_LONG); }
; ;
@ -521,7 +524,7 @@ exp : CHAR
exp : FLOAT exp : FLOAT
{ write_exp_elt_opcode (OP_DOUBLE); { write_exp_elt_opcode (OP_DOUBLE);
write_exp_elt_type (builtin_type_m2_real); write_exp_elt_type (parse_m2_type->builtin_real);
write_exp_elt_dblcst ($1); write_exp_elt_dblcst ($1);
write_exp_elt_opcode (OP_DOUBLE); } write_exp_elt_opcode (OP_DOUBLE); }
; ;
@ -531,7 +534,7 @@ exp : variable
exp : SIZE '(' type ')' %prec UNARY exp : SIZE '(' type ')' %prec UNARY
{ write_exp_elt_opcode (OP_LONG); { write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_int); write_exp_elt_type (parse_type->builtin_int);
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3)); write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
write_exp_elt_opcode (OP_LONG); } write_exp_elt_opcode (OP_LONG); }
; ;
@ -654,14 +657,14 @@ int
overflow(a,b) overflow(a,b)
long a,b; long a,b;
{ {
return (MAX_OF_TYPE(builtin_type_m2_int) - b) < a; return (MAX_OF_TYPE(parse_m2_type->builtin_int) - b) < a;
} }
int int
uoverflow(a,b) uoverflow(a,b)
unsigned long a,b; unsigned long a,b;
{ {
return (MAX_OF_TYPE(builtin_type_m2_card) - b) < a; return (MAX_OF_TYPE(parse_m2_type->builtin_card) - b) < a;
} }
#endif /* FIXME */ #endif /* FIXME */

View file

@ -54,6 +54,8 @@
#include "completer.h" /* For skip_quoted(). */ #include "completer.h" /* For skip_quoted(). */
#include "block.h" #include "block.h"
#define parse_type builtin_type (parse_gdbarch)
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, /* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
etc), as well as gratuitiously global symbol names, so we can have etc), as well as gratuitiously global symbol names, so we can have
multiple yacc generated parsers in gdb. Note that these are only multiple yacc generated parsers in gdb. Note that these are only
@ -338,7 +340,7 @@ exp : '[' TYPENAME
error ("%s is not an ObjC Class", error ("%s is not an ObjC Class",
copy_name ($2.stoken)); copy_name ($2.stoken));
write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_int); write_exp_elt_type (parse_type->builtin_int);
write_exp_elt_longcst ((LONGEST) class); write_exp_elt_longcst ((LONGEST) class);
write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_LONG);
start_msglist(); start_msglist();
@ -353,7 +355,7 @@ exp : '[' TYPENAME
exp : '[' CLASSNAME exp : '[' CLASSNAME
{ {
write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_int); write_exp_elt_type (parse_type->builtin_int);
write_exp_elt_longcst ((LONGEST) $2.class); write_exp_elt_longcst ((LONGEST) $2.class);
write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_LONG);
start_msglist(); start_msglist();
@ -575,7 +577,7 @@ exp : SELECTOR
exp : SIZEOF '(' type ')' %prec UNARY exp : SIZEOF '(' type ')' %prec UNARY
{ write_exp_elt_opcode (OP_LONG); { write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_int); write_exp_elt_type (parse_type->builtin_int);
CHECK_TYPEDEF ($3); CHECK_TYPEDEF ($3);
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3)); write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
write_exp_elt_opcode (OP_LONG); } write_exp_elt_opcode (OP_LONG); }
@ -592,12 +594,12 @@ exp : STRING
while (count-- > 0) while (count-- > 0)
{ {
write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_char); write_exp_elt_type (parse_type->builtin_char);
write_exp_elt_longcst ((LONGEST)(*sp++)); write_exp_elt_longcst ((LONGEST)(*sp++));
write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_LONG);
} }
write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_char); write_exp_elt_type (parse_type->builtin_char);
write_exp_elt_longcst ((LONGEST)'\0'); write_exp_elt_longcst ((LONGEST)'\0');
write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_LONG);
write_exp_elt_opcode (OP_ARRAY); write_exp_elt_opcode (OP_ARRAY);
@ -860,31 +862,31 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier. */
$$ = $1.type; $$ = $1.type;
} }
| INT_KEYWORD | INT_KEYWORD
{ $$ = builtin_type_int; } { $$ = parse_type->builtin_int; }
| LONG | LONG
{ $$ = builtin_type_long; } { $$ = parse_type->builtin_long; }
| SHORT | SHORT
{ $$ = builtin_type_short; } { $$ = parse_type->builtin_short; }
| LONG INT_KEYWORD | LONG INT_KEYWORD
{ $$ = builtin_type_long; } { $$ = parse_type->builtin_long; }
| UNSIGNED LONG INT_KEYWORD | UNSIGNED LONG INT_KEYWORD
{ $$ = builtin_type_unsigned_long; } { $$ = parse_type->builtin_unsigned_long; }
| LONG LONG | LONG LONG
{ $$ = builtin_type_long_long; } { $$ = parse_type->builtin_long_long; }
| LONG LONG INT_KEYWORD | LONG LONG INT_KEYWORD
{ $$ = builtin_type_long_long; } { $$ = parse_type->builtin_long_long; }
| UNSIGNED LONG LONG | UNSIGNED LONG LONG
{ $$ = builtin_type_unsigned_long_long; } { $$ = parse_type->builtin_unsigned_long_long; }
| UNSIGNED LONG LONG INT_KEYWORD | UNSIGNED LONG LONG INT_KEYWORD
{ $$ = builtin_type_unsigned_long_long; } { $$ = parse_type->builtin_unsigned_long_long; }
| SHORT INT_KEYWORD | SHORT INT_KEYWORD
{ $$ = builtin_type_short; } { $$ = parse_type->builtin_short; }
| UNSIGNED SHORT INT_KEYWORD | UNSIGNED SHORT INT_KEYWORD
{ $$ = builtin_type_unsigned_short; } { $$ = parse_type->builtin_unsigned_short; }
| DOUBLE_KEYWORD | DOUBLE_KEYWORD
{ $$ = builtin_type_double; } { $$ = parse_type->builtin_double; }
| LONG DOUBLE_KEYWORD | LONG DOUBLE_KEYWORD
{ $$ = builtin_type_long_double; } { $$ = parse_type->builtin_long_double; }
| STRUCT name | STRUCT name
{ $$ = lookup_struct (copy_name ($2), { $$ = lookup_struct (copy_name ($2),
expression_context_block); } expression_context_block); }
@ -900,11 +902,11 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier. */
| UNSIGNED typename | UNSIGNED typename
{ $$ = lookup_unsigned_typename (TYPE_NAME($2.type)); } { $$ = lookup_unsigned_typename (TYPE_NAME($2.type)); }
| UNSIGNED | UNSIGNED
{ $$ = builtin_type_unsigned_int; } { $$ = parse_type->builtin_unsigned_int; }
| SIGNED_KEYWORD typename | SIGNED_KEYWORD typename
{ $$ = lookup_signed_typename (TYPE_NAME($2.type)); } { $$ = lookup_signed_typename (TYPE_NAME($2.type)); }
| SIGNED_KEYWORD | SIGNED_KEYWORD
{ $$ = builtin_type_int; } { $$ = parse_type->builtin_int; }
| TEMPLATE name '<' type '>' | TEMPLATE name '<' type '>'
{ $$ = lookup_template_type(copy_name($2), $4, { $$ = lookup_template_type(copy_name($2), $4,
expression_context_block); expression_context_block);
@ -921,19 +923,19 @@ typename: TYPENAME
{ {
$$.stoken.ptr = "int"; $$.stoken.ptr = "int";
$$.stoken.length = 3; $$.stoken.length = 3;
$$.type = builtin_type_int; $$.type = parse_type->builtin_int;
} }
| LONG | LONG
{ {
$$.stoken.ptr = "long"; $$.stoken.ptr = "long";
$$.stoken.length = 4; $$.stoken.length = 4;
$$.type = builtin_type_long; $$.type = parse_type->builtin_long;
} }
| SHORT | SHORT
{ {
$$.stoken.ptr = "short"; $$.stoken.ptr = "short";
$$.stoken.length = 5; $$.stoken.length = 5;
$$.type = builtin_type_short; $$.type = parse_type->builtin_short;
} }
; ;
@ -1019,11 +1021,11 @@ parse_number (p, len, parsed_float, putithere)
c = tolower (p[len - 1]); c = tolower (p[len - 1]);
if (c == 'f') if (c == 'f')
putithere->typed_val_float.type = builtin_type_float; putithere->typed_val_float.type = parse_type->builtin_float;
else if (c == 'l') else if (c == 'l')
putithere->typed_val_float.type = builtin_type_long_double; putithere->typed_val_float.type = parse_type->builtin_long_double;
else if (isdigit (c) || c == '.') else if (isdigit (c) || c == '.')
putithere->typed_val_float.type = builtin_type_double; putithere->typed_val_float.type = parse_type->builtin_double;
else else
return ERROR; return ERROR;
@ -1129,9 +1131,9 @@ parse_number (p, len, parsed_float, putithere)
un = (unsigned LONGEST)n >> 2; un = (unsigned LONGEST)n >> 2;
if (long_p == 0 if (long_p == 0
&& (un >> (gdbarch_int_bit (current_gdbarch) - 2)) == 0) && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
{ {
high_bit = ((unsigned LONGEST)1) << (gdbarch_int_bit (current_gdbarch) - 1); high_bit = ((unsigned LONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
/* A large decimal (not hex or octal) constant (between INT_MAX /* A large decimal (not hex or octal) constant (between INT_MAX
and UINT_MAX) is a long or unsigned long, according to ANSI, and UINT_MAX) is a long or unsigned long, according to ANSI,
@ -1139,28 +1141,28 @@ parse_number (p, len, parsed_float, putithere)
int. This probably should be fixed. GCC gives a warning on int. This probably should be fixed. GCC gives a warning on
such constants. */ such constants. */
unsigned_type = builtin_type_unsigned_int; unsigned_type = parse_type->builtin_unsigned_int;
signed_type = builtin_type_int; signed_type = parse_type->builtin_int;
} }
else if (long_p <= 1 else if (long_p <= 1
&& (un >> (gdbarch_long_bit (current_gdbarch) - 2)) == 0) && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
{ {
high_bit = ((unsigned LONGEST)1) << (gdbarch_long_bit (current_gdbarch) - 1); high_bit = ((unsigned LONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
unsigned_type = builtin_type_unsigned_long; unsigned_type = parse_type->builtin_unsigned_long;
signed_type = builtin_type_long; signed_type = parse_type->builtin_long;
} }
else else
{ {
high_bit = (((unsigned LONGEST)1) high_bit = (((unsigned LONGEST)1)
<< (gdbarch_long_long_bit (current_gdbarch) - 32 - 1) << (gdbarch_long_long_bit (parse_gdbarch) - 32 - 1)
<< 16 << 16
<< 16); << 16);
if (high_bit == 0) if (high_bit == 0)
/* A long long does not fit in a LONGEST. */ /* A long long does not fit in a LONGEST. */
high_bit = high_bit =
(unsigned LONGEST)1 << (sizeof (LONGEST) * HOST_CHAR_BIT - 1); (unsigned LONGEST)1 << (sizeof (LONGEST) * HOST_CHAR_BIT - 1);
unsigned_type = builtin_type_unsigned_long_long; unsigned_type = parse_type->builtin_unsigned_long_long;
signed_type = builtin_type_long_long; signed_type = parse_type->builtin_long_long;
} }
putithere->typed_val_int.val = n; putithere->typed_val_int.val = n;
@ -1276,7 +1278,7 @@ yylex ()
error ("Empty character constant."); error ("Empty character constant.");
yylval.typed_val_int.val = c; yylval.typed_val_int.val = c;
yylval.typed_val_int.type = builtin_type_char; yylval.typed_val_int.type = parse_type->builtin_char;
c = *lexptr++; c = *lexptr++;
if (c != '\'') if (c != '\'')
@ -1562,7 +1564,7 @@ yylex ()
case 8: case 8:
if (strncmp (tokstart, "unsigned", 8) == 0) if (strncmp (tokstart, "unsigned", 8) == 0)
return UNSIGNED; return UNSIGNED;
if (current_language->la_language == language_cplus if (parse_language->la_language == language_cplus
&& strncmp (tokstart, "template", 8) == 0) && strncmp (tokstart, "template", 8) == 0)
return TEMPLATE; return TEMPLATE;
if (strncmp (tokstart, "volatile", 8) == 0) if (strncmp (tokstart, "volatile", 8) == 0)
@ -1579,7 +1581,7 @@ yylex ()
return DOUBLE_KEYWORD; return DOUBLE_KEYWORD;
break; break;
case 5: case 5:
if ((current_language->la_language == language_cplus) if ((parse_language->la_language == language_cplus)
&& strncmp (tokstart, "class", 5) == 0) && strncmp (tokstart, "class", 5) == 0)
return CLASS; return CLASS;
if (strncmp (tokstart, "union", 5) == 0) if (strncmp (tokstart, "union", 5) == 0)
@ -1623,8 +1625,8 @@ yylex ()
int is_a_field_of_this = 0, *need_this; int is_a_field_of_this = 0, *need_this;
int hextype; int hextype;
if (current_language->la_language == language_cplus || if (parse_language->la_language == language_cplus ||
current_language->la_language == language_objc) parse_language->la_language == language_objc)
need_this = &is_a_field_of_this; need_this = &is_a_field_of_this;
else else
need_this = (int *) NULL; need_this = (int *) NULL;
@ -1736,8 +1738,8 @@ yylex ()
return TYPENAME; return TYPENAME;
} }
yylval.tsym.type yylval.tsym.type
= language_lookup_primitive_type_by_name (current_language, = language_lookup_primitive_type_by_name (parse_language,
current_gdbarch, tmp); parse_gdbarch, tmp);
if (yylval.tsym.type != NULL) if (yylval.tsym.type != NULL)
return TYPENAME; return TYPENAME;

View file

@ -58,6 +58,8 @@ Boston, MA 02110-1301, USA. */
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */ #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
#include "block.h" #include "block.h"
#define parse_type builtin_type (parse_gdbarch)
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple as well as gratuitiously global symbol names, so we can have multiple
yacc generated parsers in gdb. Note that these are only the variables yacc generated parsers in gdb. Note that these are only the variables
@ -381,8 +383,8 @@ exp : exp '/' {
&& is_integral_type (current_type)) && is_integral_type (current_type))
{ {
write_exp_elt_opcode (UNOP_CAST); write_exp_elt_opcode (UNOP_CAST);
write_exp_elt_type (builtin_type_long_double); write_exp_elt_type (parse_type->builtin_long_double);
current_type = builtin_type_long_double; current_type = parse_type->builtin_long_double;
write_exp_elt_opcode (UNOP_CAST); write_exp_elt_opcode (UNOP_CAST);
leftdiv_is_integer = 0; leftdiv_is_integer = 0;
} }
@ -417,37 +419,37 @@ exp : exp RSH exp
exp : exp '=' exp exp : exp '=' exp
{ write_exp_elt_opcode (BINOP_EQUAL); { write_exp_elt_opcode (BINOP_EQUAL);
current_type = builtin_type_bool; current_type = parse_type->builtin_bool;
} }
; ;
exp : exp NOTEQUAL exp exp : exp NOTEQUAL exp
{ write_exp_elt_opcode (BINOP_NOTEQUAL); { write_exp_elt_opcode (BINOP_NOTEQUAL);
current_type = builtin_type_bool; current_type = parse_type->builtin_bool;
} }
; ;
exp : exp LEQ exp exp : exp LEQ exp
{ write_exp_elt_opcode (BINOP_LEQ); { write_exp_elt_opcode (BINOP_LEQ);
current_type = builtin_type_bool; current_type = parse_type->builtin_bool;
} }
; ;
exp : exp GEQ exp exp : exp GEQ exp
{ write_exp_elt_opcode (BINOP_GEQ); { write_exp_elt_opcode (BINOP_GEQ);
current_type = builtin_type_bool; current_type = parse_type->builtin_bool;
} }
; ;
exp : exp '<' exp exp : exp '<' exp
{ write_exp_elt_opcode (BINOP_LESS); { write_exp_elt_opcode (BINOP_LESS);
current_type = builtin_type_bool; current_type = parse_type->builtin_bool;
} }
; ;
exp : exp '>' exp exp : exp '>' exp
{ write_exp_elt_opcode (BINOP_GTR); { write_exp_elt_opcode (BINOP_GTR);
current_type = builtin_type_bool; current_type = parse_type->builtin_bool;
} }
; ;
@ -470,14 +472,14 @@ exp : exp ASSIGN exp
exp : TRUEKEYWORD exp : TRUEKEYWORD
{ write_exp_elt_opcode (OP_BOOL); { write_exp_elt_opcode (OP_BOOL);
write_exp_elt_longcst ((LONGEST) $1); write_exp_elt_longcst ((LONGEST) $1);
current_type = builtin_type_bool; current_type = parse_type->builtin_bool;
write_exp_elt_opcode (OP_BOOL); } write_exp_elt_opcode (OP_BOOL); }
; ;
exp : FALSEKEYWORD exp : FALSEKEYWORD
{ write_exp_elt_opcode (OP_BOOL); { write_exp_elt_opcode (OP_BOOL);
write_exp_elt_longcst ((LONGEST) $1); write_exp_elt_longcst ((LONGEST) $1);
current_type = builtin_type_bool; current_type = parse_type->builtin_bool;
write_exp_elt_opcode (OP_BOOL); } write_exp_elt_opcode (OP_BOOL); }
; ;
@ -518,7 +520,7 @@ exp : VARIABLE
exp : SIZEOF '(' type ')' %prec UNARY exp : SIZEOF '(' type ')' %prec UNARY
{ write_exp_elt_opcode (OP_LONG); { write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_int); write_exp_elt_type (parse_type->builtin_int);
CHECK_TYPEDEF ($3); CHECK_TYPEDEF ($3);
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3)); write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
write_exp_elt_opcode (OP_LONG); } write_exp_elt_opcode (OP_LONG); }
@ -534,12 +536,12 @@ exp : STRING
while (count-- > 0) while (count-- > 0)
{ {
write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_char); write_exp_elt_type (parse_type->builtin_char);
write_exp_elt_longcst ((LONGEST)(*sp++)); write_exp_elt_longcst ((LONGEST)(*sp++));
write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_LONG);
} }
write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_char); write_exp_elt_type (parse_type->builtin_char);
write_exp_elt_longcst ((LONGEST)'\0'); write_exp_elt_longcst ((LONGEST)'\0');
write_exp_elt_opcode (OP_LONG); write_exp_elt_opcode (OP_LONG);
write_exp_elt_opcode (OP_ARRAY); write_exp_elt_opcode (OP_ARRAY);
@ -832,11 +834,11 @@ parse_number (p, len, parsed_float, putithere)
c = tolower (p[len - 1]); c = tolower (p[len - 1]);
if (c == 'f') if (c == 'f')
putithere->typed_val_float.type = builtin_type_float; putithere->typed_val_float.type = parse_type->builtin_float;
else if (c == 'l') else if (c == 'l')
putithere->typed_val_float.type = builtin_type_long_double; putithere->typed_val_float.type = parse_type->builtin_long_double;
else if (isdigit (c) || c == '.') else if (isdigit (c) || c == '.')
putithere->typed_val_float.type = builtin_type_double; putithere->typed_val_float.type = parse_type->builtin_double;
else else
return ERROR; return ERROR;
@ -942,9 +944,9 @@ parse_number (p, len, parsed_float, putithere)
un = (ULONGEST)n >> 2; un = (ULONGEST)n >> 2;
if (long_p == 0 if (long_p == 0
&& (un >> (gdbarch_int_bit (current_gdbarch) - 2)) == 0) && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
{ {
high_bit = ((ULONGEST)1) << (gdbarch_int_bit (current_gdbarch) - 1); high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
/* A large decimal (not hex or octal) constant (between INT_MAX /* A large decimal (not hex or octal) constant (between INT_MAX
and UINT_MAX) is a long or unsigned long, according to ANSI, and UINT_MAX) is a long or unsigned long, according to ANSI,
@ -952,28 +954,28 @@ parse_number (p, len, parsed_float, putithere)
int. This probably should be fixed. GCC gives a warning on int. This probably should be fixed. GCC gives a warning on
such constants. */ such constants. */
unsigned_type = builtin_type_unsigned_int; unsigned_type = parse_type->builtin_unsigned_int;
signed_type = builtin_type_int; signed_type = parse_type->builtin_int;
} }
else if (long_p <= 1 else if (long_p <= 1
&& (un >> (gdbarch_long_bit (current_gdbarch) - 2)) == 0) && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
{ {
high_bit = ((ULONGEST)1) << (gdbarch_long_bit (current_gdbarch) - 1); high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
unsigned_type = builtin_type_unsigned_long; unsigned_type = parse_type->builtin_unsigned_long;
signed_type = builtin_type_long; signed_type = parse_type->builtin_long;
} }
else else
{ {
int shift; int shift;
if (sizeof (ULONGEST) * HOST_CHAR_BIT if (sizeof (ULONGEST) * HOST_CHAR_BIT
< gdbarch_long_long_bit (current_gdbarch)) < gdbarch_long_long_bit (parse_gdbarch))
/* A long long does not fit in a LONGEST. */ /* A long long does not fit in a LONGEST. */
shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1); shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
else else
shift = (gdbarch_long_long_bit (current_gdbarch) - 1); shift = (gdbarch_long_long_bit (parse_gdbarch) - 1);
high_bit = (ULONGEST) 1 << shift; high_bit = (ULONGEST) 1 << shift;
unsigned_type = builtin_type_unsigned_long_long; unsigned_type = parse_type->builtin_unsigned_long_long;
signed_type = builtin_type_long_long; signed_type = parse_type->builtin_long_long;
} }
putithere->typed_val_int.val = n; putithere->typed_val_int.val = n;
@ -1142,7 +1144,7 @@ yylex ()
error ("Empty character constant."); error ("Empty character constant.");
yylval.typed_val_int.val = c; yylval.typed_val_int.val = c;
yylval.typed_val_int.type = builtin_type_char; yylval.typed_val_int.type = parse_type->builtin_char;
c = *lexptr++; c = *lexptr++;
if (c != '\'') if (c != '\'')
@ -1636,8 +1638,8 @@ yylex ()
return TYPENAME; return TYPENAME;
} }
yylval.tsym.type yylval.tsym.type
= language_lookup_primitive_type_by_name (current_language, = language_lookup_primitive_type_by_name (parse_language,
current_gdbarch, tmp); parse_gdbarch, tmp);
if (yylval.tsym.type != NULL) if (yylval.tsym.type != NULL)
{ {
free (uptokstart); free (uptokstart);

View file

@ -1027,6 +1027,7 @@ parse_exp_in_context (char **stringptr, struct block *block, int comma,
expout = (struct expression *) expout = (struct expression *)
xmalloc (sizeof (struct expression) + EXP_ELEM_TO_BYTES (expout_size)); xmalloc (sizeof (struct expression) + EXP_ELEM_TO_BYTES (expout_size));
expout->language_defn = current_language; expout->language_defn = current_language;
expout->gdbarch = current_gdbarch;
TRY_CATCH (except, RETURN_MASK_ALL) TRY_CATCH (except, RETURN_MASK_ALL)
{ {

View file

@ -32,6 +32,9 @@ extern struct expression *expout;
extern int expout_size; extern int expout_size;
extern int expout_ptr; extern int expout_ptr;
#define parse_gdbarch (expout->gdbarch)
#define parse_language (expout->language_defn)
/* If this is nonzero, this block is used as the lexical context /* If this is nonzero, this block is used as the lexical context
for symbol names. */ for symbol names. */