* language.h (struct language_arch_info): New members

bool_type_default and bool_type_symbol.
	(lang_bool_type): Remove prototype.
	(LA_BOOL_TYPE): Remove macro.
	(language_bool_type): Add prototype.
	* language.c (lang_bool_type): Remove.
	(language_bool_type): New function.

	* value.h (value_in): Change return value to int.
	* value.c (value_in): Return int instead of struct value *.

	* eval.c (evaluate_subexp_standard): Call language_bool_type instead
	of using LA_BOOL_TYPE.  Update call to value_in.
	* ada-lang.c (ada_evaluate_subexp): Call language_bool_type instead
	of using LA_BOOL_TYPE or builtin_type_int for boolean values.

	* language.c (unknown_language_arch_info): Set bool_type_default member
	of struct language_arch_info.
	* ada-lang.c (ada_language_arch_info): Set bool_type_symbol and
	bool_type_default members of struct language_arch_info.
	* c-lang.c (c_language_arch_info): Set bool_type_default member
	of struct language_arch_info.
	(cplus_language_arch_info): Set bool_type_symbol and bool_type_default
	members of struct language_arch_info.
	* f-lang.c (f_language_arch_info): Set bool_type_symbol and
	bool_type_default members of struct language_arch_info.
	* jv-lang.c (java_language_arch_info): Set bool_type_symbol and
	bool_type_default members of struct language_arch_info.
	* m2-lang.c (m2_language_arch_info): Set bool_type_symbol and
	bool_type_default members of struct language_arch_info.
	* p-lang.c (p_language_arch_info): Set bool_type_symbol and
	bool_type_default members of struct language_arch_info.
This commit is contained in:
Ulrich Weigand 2008-09-11 14:11:40 +00:00
parent de7b6b4701
commit fbb06eb1ba
12 changed files with 133 additions and 75 deletions

View File

@ -1,3 +1,38 @@
2008-09-11 Ulrich Weigand <uweigand@de.ibm.com>
* language.h (struct language_arch_info): New members
bool_type_default and bool_type_symbol.
(lang_bool_type): Remove prototype.
(LA_BOOL_TYPE): Remove macro.
(language_bool_type): Add prototype.
* language.c (lang_bool_type): Remove.
(language_bool_type): New function.
* value.h (value_in): Change return value to int.
* value.c (value_in): Return int instead of struct value *.
* eval.c (evaluate_subexp_standard): Call language_bool_type instead
of using LA_BOOL_TYPE. Update call to value_in.
* ada-lang.c (ada_evaluate_subexp): Call language_bool_type instead
of using LA_BOOL_TYPE or builtin_type_int for boolean values.
* language.c (unknown_language_arch_info): Set bool_type_default member
of struct language_arch_info.
* ada-lang.c (ada_language_arch_info): Set bool_type_symbol and
bool_type_default members of struct language_arch_info.
* c-lang.c (c_language_arch_info): Set bool_type_default member
of struct language_arch_info.
(cplus_language_arch_info): Set bool_type_symbol and bool_type_default
members of struct language_arch_info.
* f-lang.c (f_language_arch_info): Set bool_type_symbol and
bool_type_default members of struct language_arch_info.
* jv-lang.c (java_language_arch_info): Set bool_type_symbol and
bool_type_default members of struct language_arch_info.
* m2-lang.c (m2_language_arch_info): Set bool_type_symbol and
bool_type_default members of struct language_arch_info.
* p-lang.c (p_language_arch_info): Set bool_type_symbol and
bool_type_default members of struct language_arch_info.
2008-09-11 Ulrich Weigand <uweigand@de.ibm.com>
* jv-lang.c (enum java_primitive_types): New type.

View File

@ -8525,7 +8525,8 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
tem = ada_value_equal (arg1, arg2);
if (op == BINOP_NOTEQUAL)
tem = !tem;
return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type, (LONGEST) tem);
case UNOP_NEG:
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
@ -8544,7 +8545,8 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
*pos -= 1;
val = evaluate_subexp_standard (expect_type, exp, pos, noside);
return value_cast (LA_BOOL_TYPE, val);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_cast (type, val);
}
case BINOP_BITWISE_AND:
@ -8812,13 +8814,15 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
default:
lim_warning (_("Membership test incompletely implemented; "
"always returns true"));
return value_from_longest (builtin_type_int, (LONGEST) 1);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type, (LONGEST) 1);
case TYPE_CODE_RANGE:
arg2 = value_from_longest (type, TYPE_LOW_BOUND (type));
arg3 = value_from_longest (type, TYPE_HIGH_BOUND (type));
return
value_from_longest (builtin_type_int,
type = language_bool_type (exp->language_defn, exp->gdbarch);
return
value_from_longest (type,
(value_less (arg1, arg3)
|| value_equal (arg1, arg3))
&& (value_less (arg2, arg1)
@ -8834,7 +8838,10 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
goto nosideret;
if (noside == EVAL_AVOID_SIDE_EFFECTS)
return value_zero (builtin_type_int, not_lval);
{
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_zero (type, not_lval);
}
tem = longest_to_int (exp->elts[pc + 1].longconst);
@ -8844,8 +8851,9 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
arg3 = ada_array_bound (arg2, tem, 1);
arg2 = ada_array_bound (arg2, tem, 0);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return
value_from_longest (builtin_type_int,
value_from_longest (type,
(value_less (arg1, arg3)
|| value_equal (arg1, arg3))
&& (value_less (arg2, arg1)
@ -8859,8 +8867,9 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
if (noside == EVAL_SKIP)
goto nosideret;
type = language_bool_type (exp->language_defn, exp->gdbarch);
return
value_from_longest (builtin_type_int,
value_from_longest (type,
(value_less (arg1, arg3)
|| value_equal (arg1, arg3))
&& (value_less (arg2, arg1)
@ -10872,6 +10881,9 @@ ada_language_arch_info (struct gdbarch *gdbarch,
(struct objfile *) NULL));
TYPE_NAME (lai->primitive_type_vector [ada_primitive_type_system_address])
= "system__address";
lai->bool_type_symbol = "boolean";
lai->bool_type_default = builtin->builtin_bool;
}
/* Language vector */

View File

@ -380,6 +380,8 @@ c_language_arch_info (struct gdbarch *gdbarch,
lai->primitive_type_vector [c_primitive_type_decfloat] = builtin->builtin_decfloat;
lai->primitive_type_vector [c_primitive_type_decdouble] = builtin->builtin_decdouble;
lai->primitive_type_vector [c_primitive_type_declong] = builtin->builtin_declong;
lai->bool_type_default = builtin->builtin_int;
}
const struct language_defn c_language_defn =
@ -493,6 +495,9 @@ cplus_language_arch_info (struct gdbarch *gdbarch,
= builtin->builtin_decdouble;
lai->primitive_type_vector [cplus_primitive_type_declong]
= builtin->builtin_declong;
lai->bool_type_symbol = "bool";
lai->bool_type_default = builtin->builtin_bool;
}
const struct language_defn cplus_language_defn =

View File

@ -562,8 +562,8 @@ evaluate_subexp_standard (struct type *expect_type,
}
case OP_BOOL:
(*pos) += 2;
return value_from_longest (LA_BOOL_TYPE,
exp->elts[pc + 1].longconst);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type, exp->elts[pc + 1].longconst);
case OP_INTERNALVAR:
(*pos) += 2;
@ -1618,7 +1618,8 @@ evaluate_subexp_standard (struct type *expect_type,
arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
if (noside == EVAL_SKIP)
goto nosideret;
return value_in (arg1, arg2);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type, (LONGEST) value_in (arg1, arg2));
case MULTI_SUBSCRIPT:
(*pos) += 2;
@ -1678,7 +1679,8 @@ evaluate_subexp_standard (struct type *expect_type,
break;
case TYPE_CODE_BITSTRING:
arg1 = value_bitstring_subscript (LA_BOOL_TYPE, arg1, arg2);
type = language_bool_type (exp->language_defn, exp->gdbarch);
arg1 = value_bitstring_subscript (type, arg1, arg2);
break;
default:
@ -1798,7 +1800,8 @@ evaluate_subexp_standard (struct type *expect_type,
tem = value_logical_not (arg1);
arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
(tem ? EVAL_SKIP : noside));
return value_from_longest (LA_BOOL_TYPE,
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type,
(LONGEST) (!tem && !value_logical_not (arg2)));
}
@ -1824,7 +1827,8 @@ evaluate_subexp_standard (struct type *expect_type,
tem = value_logical_not (arg1);
arg2 = evaluate_subexp (NULL_TYPE, exp, pos,
(!tem ? EVAL_SKIP : noside));
return value_from_longest (LA_BOOL_TYPE,
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type,
(LONGEST) (!tem || !value_logical_not (arg2)));
}
@ -1840,7 +1844,8 @@ evaluate_subexp_standard (struct type *expect_type,
else
{
tem = value_equal (arg1, arg2);
return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type, (LONGEST) tem);
}
case BINOP_NOTEQUAL:
@ -1855,7 +1860,8 @@ evaluate_subexp_standard (struct type *expect_type,
else
{
tem = value_equal (arg1, arg2);
return value_from_longest (LA_BOOL_TYPE, (LONGEST) ! tem);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type, (LONGEST) ! tem);
}
case BINOP_LESS:
@ -1870,7 +1876,8 @@ evaluate_subexp_standard (struct type *expect_type,
else
{
tem = value_less (arg1, arg2);
return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type, (LONGEST) tem);
}
case BINOP_GTR:
@ -1885,7 +1892,8 @@ evaluate_subexp_standard (struct type *expect_type,
else
{
tem = value_less (arg2, arg1);
return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type, (LONGEST) tem);
}
case BINOP_GEQ:
@ -1900,7 +1908,8 @@ evaluate_subexp_standard (struct type *expect_type,
else
{
tem = value_less (arg2, arg1) || value_equal (arg1, arg2);
return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type, (LONGEST) tem);
}
case BINOP_LEQ:
@ -1915,7 +1924,8 @@ evaluate_subexp_standard (struct type *expect_type,
else
{
tem = value_less (arg1, arg2) || value_equal (arg1, arg2);
return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem);
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type, (LONGEST) tem);
}
case BINOP_REPEAT:
@ -1975,8 +1985,10 @@ evaluate_subexp_standard (struct type *expect_type,
if (unop_user_defined_p (op, arg1))
return value_x_unop (arg1, op, noside);
else
return value_from_longest (LA_BOOL_TYPE,
(LONGEST) value_logical_not (arg1));
{
type = language_bool_type (exp->language_defn, exp->gdbarch);
return value_from_longest (type, (LONGEST) value_logical_not (arg1));
}
case UNOP_IND:
if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR)

View File

@ -298,6 +298,9 @@ f_language_arch_info (struct gdbarch *gdbarch,
= builtin->builtin_complex_s16;
lai->primitive_type_vector [f_primitive_type_void]
= builtin->builtin_void;
lai->bool_type_symbol = "logical";
lai->bool_type_default = builtin->builtin_logical_s2;
}
/* This is declared in c-lang.h but it is silly to import that file for what

View File

@ -1080,6 +1080,9 @@ java_language_arch_info (struct gdbarch *gdbarch,
= java_double_type;
lai->primitive_type_vector [java_primitive_type_void]
= java_void_type;
lai->bool_type_symbol = "boolean";
lai->bool_type_default = java_boolean_type;
}
const struct exp_descriptor exp_descriptor_java =

View File

@ -787,51 +787,6 @@ structured_type (struct type *type)
}
#endif
struct type *
lang_bool_type (void)
{
struct symbol *sym;
struct type *type;
switch (current_language->la_language)
{
case language_fortran:
sym = lookup_symbol ("logical", NULL, VAR_DOMAIN, NULL);
if (sym)
{
type = SYMBOL_TYPE (sym);
if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
return type;
}
return builtin_type_f_logical_s2;
case language_cplus:
case language_pascal:
case language_ada:
if (current_language->la_language==language_cplus)
{sym = lookup_symbol ("bool", NULL, VAR_DOMAIN, NULL);}
else
{sym = lookup_symbol ("boolean", NULL, VAR_DOMAIN, NULL);}
if (sym)
{
type = SYMBOL_TYPE (sym);
if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
return type;
}
return builtin_type_bool;
case language_java:
sym = lookup_symbol ("boolean", NULL, VAR_DOMAIN, NULL);
if (sym)
{
type = SYMBOL_TYPE (sym);
if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
return type;
}
return java_boolean_type;
default:
return builtin_type_int;
}
}
/* This page contains functions that return info about
(struct value) values used in GDB. */
@ -1169,6 +1124,7 @@ unknown_language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai)
{
lai->string_char_type = builtin_type (gdbarch)->builtin_char;
lai->bool_type_default = builtin_type (gdbarch)->builtin_int;
lai->primitive_type_vector = GDBARCH_OBSTACK_CALLOC (gdbarch, 1,
struct type *);
}
@ -1316,6 +1272,29 @@ language_string_char_type (const struct language_defn *la,
return ld->arch_info[la->la_language].string_char_type;
}
struct type *
language_bool_type (const struct language_defn *la,
struct gdbarch *gdbarch)
{
struct language_gdbarch *ld = gdbarch_data (gdbarch,
language_gdbarch_data);
if (ld->arch_info[la->la_language].bool_type_symbol)
{
struct symbol *sym;
sym = lookup_symbol (ld->arch_info[la->la_language].bool_type_symbol,
NULL, VAR_DOMAIN, NULL);
if (sym)
{
struct type *type = SYMBOL_TYPE (sym);
if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
return type;
}
}
return ld->arch_info[la->la_language].bool_type_default;
}
struct type *
language_lookup_primitive_type_by_name (const struct language_defn *la,
struct gdbarch *gdbarch,

View File

@ -125,6 +125,11 @@ struct language_arch_info
struct type **primitive_type_vector;
/* Type of elements of strings. */
struct type *string_char_type;
/* Symbol name of type to use as boolean type, if defined. */
const char *bool_type_symbol;
/* Otherwise, this is the default boolean builtin type. */
struct type *bool_type_default;
};
/* Structure tying together assorted information about a language. */
@ -306,6 +311,9 @@ extern enum language_mode
}
language_mode;
struct type *language_bool_type (const struct language_defn *l,
struct gdbarch *gdbarch);
struct type *language_string_char_type (const struct language_defn *l,
struct gdbarch *gdbarch);
@ -416,11 +424,6 @@ extern void range_error (const char *, ...) ATTR_FORMAT (printf, 1, 2);
extern int value_true (struct value *);
extern struct type *lang_bool_type (void);
/* The type used for Boolean values in the current language. */
#define LA_BOOL_TYPE lang_bool_type ()
/* Misc: The string representing a particular enum language. */
extern enum language language_enum (char *str);

View File

@ -345,6 +345,9 @@ m2_language_arch_info (struct gdbarch *gdbarch,
= builtin->builtin_real;
lai->primitive_type_vector [m2_primitive_type_bool]
= builtin->builtin_bool;
lai->bool_type_symbol = "BOOLEAN";
lai->bool_type_default = builtin->builtin_bool;
}
const struct exp_descriptor exp_descriptor_modula2 =

View File

@ -393,6 +393,9 @@ pascal_language_arch_info (struct gdbarch *gdbarch,
= builtin->builtin_complex;
lai->primitive_type_vector [pascal_primitive_type_double_complex]
= builtin->builtin_double_complex;
lai->bool_type_symbol = "boolean";
lai->bool_type_default = builtin->builtin_bool;
}
const struct language_defn pascal_language_defn =

View File

@ -1851,7 +1851,7 @@ value_bit_index (struct type *type, const gdb_byte *valaddr, int index)
return (word >> rel_index) & 1;
}
struct value *
int
value_in (struct value *element, struct value *set)
{
int member;
@ -1870,7 +1870,7 @@ value_in (struct value *element, struct value *set)
value_as_long (element));
if (member < 0)
error (_("First argument of 'IN' not in range"));
return value_from_longest (LA_BOOL_TYPE, member);
return member;
}
void

View File

@ -412,7 +412,7 @@ extern struct value *value_bitstring_subscript (struct type *type,
extern struct value *register_value_being_returned (struct type *valtype,
struct regcache *retbuf);
extern struct value *value_in (struct value *element, struct value *set);
extern int value_in (struct value *element, struct value *set);
extern int value_bit_index (struct type *type, const gdb_byte *addr,
int index);