From: Per Bothner Date: Fri, 1 Dec 1995 08:08:41 +0000 (+0000) Subject: * language.c (lang_bool_type), language.h: New function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a366d882c09d3fb36aafca0d3f9cc7aa1aa46dfe;p=binutils-gdb.git * language.c (lang_bool_type), language.h: New function. * language.h (LA_BOOL_TYPE): New macro. * eval.c (evaluate_subexp_standard) Use LA_BOOL_TYPE instead of builtin_type_int where appropriate, * valarith.c (value_subscript): Likewise. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ebbcc68485a..247d8bb6487 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ Thu Nov 30 23:54:17 1995 Per Bothner + * language.c (lang_bool_type), language.h: New function. + * language.h (LA_BOOL_TYPE): New macro. + * eval.c (evaluate_subexp_standard) Use LA_BOOL_TYPE instead + of builtin_type_int where appropriate, + * valarith.c (value_subscript): Likewise. + * valops.c (value_slice): Implement (value) bitstring slices. * valprint.c (val_print): If TYPE_LENGTH is zero, don't automatically print "" - Chill has zero-length (string) types. diff --git a/gdb/eval.c b/gdb/eval.c index b45c3c880cd..c3918481d85 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1258,7 +1258,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside) tem = value_logical_not (arg1); arg2 = evaluate_subexp (NULL_TYPE, exp, pos, (tem ? EVAL_SKIP : noside)); - return value_from_longest (builtin_type_int, + return value_from_longest (LA_BOOL_TYPE, (LONGEST) (!tem && !value_logical_not (arg2))); } @@ -1284,7 +1284,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside) tem = value_logical_not (arg1); arg2 = evaluate_subexp (NULL_TYPE, exp, pos, (!tem ? EVAL_SKIP : noside)); - return value_from_longest (builtin_type_int, + return value_from_longest (LA_BOOL_TYPE, (LONGEST) (!tem || !value_logical_not (arg2))); } @@ -1300,7 +1300,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside) else { tem = value_equal (arg1, arg2); - return value_from_longest (builtin_type_int, (LONGEST) tem); + return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem); } case BINOP_NOTEQUAL: @@ -1315,7 +1315,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside) else { tem = value_equal (arg1, arg2); - return value_from_longest (builtin_type_int, (LONGEST) ! tem); + return value_from_longest (LA_BOOL_TYPE, (LONGEST) ! tem); } case BINOP_LESS: @@ -1330,7 +1330,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside) else { tem = value_less (arg1, arg2); - return value_from_longest (builtin_type_int, (LONGEST) tem); + return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem); } case BINOP_GTR: @@ -1345,7 +1345,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside) else { tem = value_less (arg2, arg1); - return value_from_longest (builtin_type_int, (LONGEST) tem); + return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem); } case BINOP_GEQ: @@ -1360,7 +1360,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside) else { tem = value_less (arg2, arg1) || value_equal (arg1, arg2); - return value_from_longest (builtin_type_int, (LONGEST) tem); + return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem); } case BINOP_LEQ: @@ -1375,7 +1375,7 @@ evaluate_subexp_standard (expect_type, exp, pos, noside) else { tem = value_less (arg1, arg2) || value_equal (arg1, arg2); - return value_from_longest (builtin_type_int, (LONGEST) tem); + return value_from_longest (LA_BOOL_TYPE, (LONGEST) tem); } case BINOP_REPEAT: diff --git a/gdb/language.c b/gdb/language.c index 2504f863090..0ce74feb4ed 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -773,6 +773,29 @@ structured_type(type) } #endif +struct type * +lang_bool_type () +{ + struct symbol *sym; + struct type *type; + switch(current_language->la_language) + { + case language_chill: + return builtin_type_chill_bool; + case language_cplus: + sym = lookup_symbol ("bool", NULL, VAR_NAMESPACE, NULL, NULL); + if (sym) + { + struct type *type = SYMBOL_TYPE (sym); + if (type && TYPE_CODE (type) == TYPE_CODE_BOOL) + return type; + } + /* ... else fall through ... */ + default: + return builtin_type_int; + } +} + /* This page contains functions that return info about (struct value) values used in GDB. */ diff --git a/gdb/language.h b/gdb/language.h index 9542d72c8f8..cb9d709a299 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -407,6 +407,11 @@ range_error PARAMS ((char *, ...)) extern int value_true PARAMS ((struct value *)); +extern struct type * lang_bool_type PARAMS ((void)); + +/* The type used for Boolean values in teh current language. */ +#define LA_BOOL_TYPE lang_bool_type () + /* Misc: The string representing a particular enum language. */ extern const struct language_defn *