/****************************************************************************
* private variables
****************************************************************************/
-static struct set *tarvals; /* container for tarval structs */
-static struct set *values; /* container for values */
+static struct set *tarvals = NULL; /* container for tarval structs */
+static struct set *values = NULL; /* container for values */
static tarval_int_overflow_mode_t int_overflow_mode = TV_OVERFLOW_WRAP;
/****************************************************************************
}
#endif /* NDEBUG */
-static int hash_tv(tarval *tv)
-{
+/** Hash a tarval. */
+static int hash_tv(tarval *tv) {
return (PTR_TO_INT(tv->value) ^ PTR_TO_INT(tv->mode)) + tv->length;
}
-static int hash_val(const void *value, unsigned int length)
-{
+/** Hash a value. Treat it as a byte array. */
+static int hash_val(const void *value, unsigned int length) {
unsigned int i;
unsigned int hash = 0;
char *temp = alloca(sc_get_buffer_length());
sc_val_from_ulong(-1, temp);
sc_and(temp, value, temp);
+ /* the sc_ module expects that all bits are set ... */
+ sign_extend(temp, mode);
return get_tarval(temp, length, mode);
}
case TV_OVERFLOW_BAD:
switch (get_mode_sort(m)) {
case irms_int_number:
case irms_character:
- return get_tarval_overflow(src->value, src->length, m);
+ buffer = alloca(sc_get_buffer_length());
+ memcpy(buffer, src->value, sc_get_buffer_length());
+ sign_extend(buffer, src->mode);
+ return get_tarval_overflow(buffer, src->length, m);
case irms_internal_boolean:
/* XXX C semantics */
/* decimal string representation because hexadecimal output is
* interpreted unsigned by fc_val_from_str, so this is a HACK */
snprintf(buffer, 100, "%s",
- sc_print(src->value, get_mode_size_bits(src->mode), SC_DEC));
+ sc_print(src->value, get_mode_size_bits(src->mode), SC_DEC, mode_is_signed(src->mode)));
+ buffer[100 - 1] = '\0';
switch (get_mode_size_bits(m))
{
case 32:
switch (mode_info->mode_output) {
case TVO_DECIMAL:
- str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_DEC);
+ str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_DEC, mode_is_signed(tv->mode));
break;
case TVO_OCTAL:
- str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_OCT);
+ str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_OCT, 0);
break;
case TVO_HEX:
case TVO_NATIVE:
default:
- str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_HEX);
+ str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_HEX, 0);
break;
}
return snprintf(buf, len, "%s%s%s", prefix, str, suffix);