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>
+
+ * 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.
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);
*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:
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)
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);
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)
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)
(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;
}
\f
/* Language vector */
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 =
= 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 =
}
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;
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;
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:
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)));
}
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)));
}
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:
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:
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:
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:
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:
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:
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)
= 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
= 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 =
}
#endif
\f
-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;
- }
-}
-\f
/* This page contains functions that return info about
(struct value) values used in GDB. */
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 *);
}
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,
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. */
}
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);
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);
= 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 =
= 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 =
return (word >> rel_index) & 1;
}
-struct value *
+int
value_in (struct value *element, struct value *set)
{
int member;
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
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);