This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [rfc][05/37] Eliminate builtin_type_ macros: Replace LA_BOOL_TYPE macro


>        * language.c (lang_bool_type): Remove.
>        (language_bool_type): New function.

I was hoping we could cache the boolean type, but I guess it can get
stale every time we load or unload a symbol file...

>          case TYPE_CODE_RANGE:
>            arg2 = value_from_longest (builtin_type_int, TYPE_LOW_BOUND (type));
>            arg3 = value_from_longest (builtin_type_int,
>                                       TYPE_HIGH_BOUND (type));
> +          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)

Nice improvement - the returning of a boolean type instead of an int :).
It should transform:

    (gdb) print 2 in 1 .. 3
    $1 = 1

Hopefully into:`

    (gdb) print 2 in 1 .. 3
    $1 = true

Thanks!

Your patch also allowed me to notice something else: I also think that
I'll explore the idea of using value_in() instead of the combination of
value_less/value_equal/[...]. Separate patch, though.

No further comment, your honor...
-- 
Joel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]