* language.c (lang_bool_type), language.h: New function.
authorPer Bothner <per@bothner.com>
Fri, 1 Dec 1995 08:08:41 +0000 (08:08 +0000)
committerPer Bothner <per@bothner.com>
Fri, 1 Dec 1995 08:08:41 +0000 (08:08 +0000)
* 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.

gdb/ChangeLog
gdb/eval.c
gdb/language.c
gdb/language.h

index ebbcc68485a0c510176138dbde6a401f9de3084d..247d8bb6487e2ea71a7ecbeb74ae508ce14dacdb 100644 (file)
@@ -1,5 +1,11 @@
 Thu Nov 30 23:54:17 1995  Per Bothner  <bothner@kalessin.cygnus.com>
 
+       * 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 "<incomplete type>" - Chill has zero-length (string) types.
index b45c3c880cd0ad50b3978be1da1b51d4e349bf29..c3918481d8591c2aba5c4558610c5eff481990a1 100644 (file)
@@ -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:
index 2504f8630903966f1657b8d7490dee6dbe12e596..0ce74feb4ed716dd794c33fcbf1df9d57371e61f 100644 (file)
@@ -773,6 +773,29 @@ structured_type(type)
 }
 #endif
 \f
+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;
+    }
+}
+\f
 /* This page contains functions that return info about
    (struct value) values used in GDB. */
 
index 9542d72c8f86117e015797b0d1d1e3362b985e1a..cb9d709a29908eaa69636260ac20db5ef966784e 100644 (file)
@@ -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 *
This page took 0.042798 seconds and 4 git commands to generate.