diff options
author | Jim Kingdon <jkingdon@engr.sgi.com> | 1994-02-02 17:20:45 +0000 |
---|---|---|
committer | Jim Kingdon <jkingdon@engr.sgi.com> | 1994-02-02 17:20:45 +0000 |
commit | 61932a8ee900c0368eef3b101fa9a04050aa7c56 (patch) | |
tree | e0a50d67f3e5ef8de7283822ecacc3d4d93fee3c /gdb/language.c | |
parent | 1051c97f630bf96febe9e0029ba8df161d3a4db1 (diff) | |
download | fsf-binutils-gdb-61932a8ee900c0368eef3b101fa9a04050aa7c56.zip fsf-binutils-gdb-61932a8ee900c0368eef3b101fa9a04050aa7c56.tar.gz fsf-binutils-gdb-61932a8ee900c0368eef3b101fa9a04050aa7c56.tar.bz2 |
* gdbtypes.h, ch-typeprint.c, ch-valprint.c:
Change comments regarding TYPE_CODE_BOOL.
* language.c (boolean_type): Always return 1 for TYPE_CODE_BOOL,
regardless of the language.
(value_true): Just call value_logical_not regardless of language.
* coffread.c (coff_read_enum_type), stabsread.c (read_enum_type):
Remove #if 0'd code which makes some enums TYPE_CODE_BOOL.
* language.h: Improve comment for la_builtin_type_vector.
* m2-lang.c (_initialize_m2_language): Don't add any fields to
builtin_type_m2_bool.
Diffstat (limited to 'gdb/language.c')
-rw-r--r-- | gdb/language.c | 68 |
1 files changed, 20 insertions, 48 deletions
diff --git a/gdb/language.c b/gdb/language.c index b74e428..03cf667 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -698,18 +698,20 @@ int boolean_type (type) struct type *type; { - switch(current_language->la_language) - { - case language_chill: - case language_m2: - return TYPE_CODE(type) != TYPE_CODE_BOOL ? 0 : 1; - - case language_c: - case language_cplus: - return TYPE_CODE(type) != TYPE_CODE_INT ? 0 : 1; + if (TYPE_CODE (type) == TYPE_CODE_BOOL) + return 1; + switch(current_language->la_language) + { + case language_c: + case language_cplus: + /* Might be more cleanly handled by having a TYPE_CODE_INT_NOT_BOOL + for CHILL and such languages, or a TYPE_CODE_INT_OR_BOOL for C. */ + if (TYPE_CODE (type) == TYPE_CODE_INT) + return 1; default: - return (0); + break; } + return 0; } /* Returns non-zero if the value is a floating-point type */ @@ -757,46 +759,16 @@ structured_type(type) /* Returns non-zero if the value VAL represents a true value. */ int -value_true(val) +value_true (val) value val; { - int len, i; - struct type *type; - LONGEST v; - - switch (current_language->la_language) { - - case language_c: - case language_cplus: - return !value_logical_not (val); - - case language_m2: - type = VALUE_TYPE(val); - if (TYPE_CODE (type) != TYPE_CODE_BOOL) - return 0; /* Not a BOOLEAN at all */ - /* Search the fields for one that matches the current value. */ - len = TYPE_NFIELDS (type); - v = value_as_long (val); - for (i = 0; i < len; i++) - { - QUIT; - if (v == TYPE_FIELD_BITPOS (type, i)) - break; - } - if (i >= len) - return 0; /* Not a valid BOOLEAN value */ - if (STREQ ("TRUE", TYPE_FIELD_NAME(VALUE_TYPE(val), i))) - return 1; /* BOOLEAN with value TRUE */ - else - return 0; /* BOOLEAN with value FALSE */ - break; - - case language_chill: - error ("Missing Chill support in function value_type."); /*FIXME*/ - - default: - error ("Language not supported."); - } + /* It is possible that we should have some sort of error if a non-boolean + value is used in this context. Possibly dependent on some kind of + "boolean-checking" option like range checking. But it should probably + not depend on the language except insofar as is necessary to identify + a "boolean" value (i.e. in C using a float, pointer, etc., as a boolean + should be an error, probably). */ + return !value_logical_not (val); } /* Returns non-zero if the operator OP is defined on |