aboutsummaryrefslogtreecommitdiff
path: root/gdb/ch-exp.y
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>1995-01-23 21:20:58 +0000
committerPer Bothner <per@bothner.com>1995-01-23 21:20:58 +0000
commit6d34c23688b9d441b6daba6dff56d6a4389bc058 (patch)
treef2acf81c173f32cd8b679d92911f4298440f896d /gdb/ch-exp.y
parentce51845b10a95dc54e30c5df90706a3902d6d1ed (diff)
downloadgdb-6d34c23688b9d441b6daba6dff56d6a4389bc058.zip
gdb-6d34c23688b9d441b6daba6dff56d6a4389bc058.tar.gz
gdb-6d34c23688b9d441b6daba6dff56d6a4389bc058.tar.bz2
Add support for Chill bitstring literals (e.h. H'FF00').
* ch-exp.y (match_bitstring_literal): Fix for proper endianness. * expprint.c (print_subexp): Don't call error on OP_BITSTRING, just print B'<unimlemented>'. * gdbtypes.c (create_set_type): Fix bug in length calculation. * valops.c, value.h (value_bitstring): New function. * eval.c (evaluate_subexp): Implement support for OP_BITSTRING. * ch-typeprint.c (chill_type_print_base): For TYPE_CODE_FUNC, check that return type is non-void, and print in proper Chill syntax.
Diffstat (limited to 'gdb/ch-exp.y')
-rw-r--r--gdb/ch-exp.y35
1 files changed, 20 insertions, 15 deletions
diff --git a/gdb/ch-exp.y b/gdb/ch-exp.y
index 9bb7526..46f48da 100644
--- a/gdb/ch-exp.y
+++ b/gdb/ch-exp.y
@@ -1503,14 +1503,15 @@ match_integer_literal ()
static int
match_bitstring_literal ()
{
- char *tokptr = lexptr;
- int mask;
+ register char *tokptr = lexptr;
int bitoffset = 0;
int bitcount = 0;
- int base;
+ int bits_per_char;
int digit;
tempbufindex = 0;
+ CHECKBUF (1);
+ tempbuf[0] = 0;
/* Look for the required explicit base specifier. */
@@ -1518,21 +1519,21 @@ match_bitstring_literal ()
{
case 'b':
case 'B':
- base = 2;
+ bits_per_char = 1;
break;
case 'o':
case 'O':
- base = 8;
+ bits_per_char = 3;
break;
case 'h':
case 'H':
- base = 16;
+ bits_per_char = 4;
break;
default:
return (0);
break;
}
-
+
/* Ensure that the character after the explicit base is a single quote. */
if (*tokptr++ != '\'')
@@ -1562,29 +1563,33 @@ match_bitstring_literal ()
return (0);
break;
}
- if (digit >= base)
+ if (digit >= 1 << bits_per_char)
{
/* Found something not in domain for current base. */
return (0);
}
else
{
- /* Extract bits from digit, starting with the msbit appropriate for
- the current base, and packing them into the bitstring byte,
- starting at the lsbit. */
- for (mask = (base >> 1); mask > 0; mask >>= 1)
+ /* Extract bits from digit, packing them into the bitstring byte. */
+ int k = TARGET_BYTE_ORDER == BIG_ENDIAN ? bits_per_char - 1 : 0;
+ for (; TARGET_BYTE_ORDER == BIG_ENDIAN ? k >= 0 : k < bits_per_char;
+ TARGET_BYTE_ORDER == BIG_ENDIAN ? k-- : k++)
{
bitcount++;
- CHECKBUF (1);
- if (digit & mask)
+ if (digit & (1 << k))
{
- tempbuf[tempbufindex] |= (1 << bitoffset);
+ tempbuf[tempbufindex] |=
+ (TARGET_BYTE_ORDER == BIG_ENDIAN)
+ ? (1 << (HOST_CHAR_BIT - 1 - bitoffset))
+ : (1 << bitoffset);
}
bitoffset++;
if (bitoffset == HOST_CHAR_BIT)
{
bitoffset = 0;
tempbufindex++;
+ CHECKBUF(1);
+ tempbuf[tempbufindex] = 0;
}
}
}