- case int_number:
- case character:
- offset = 16 - (get_mode_size_bits(tv->mode)/4);
- str = sc_print_hex(tv->value);
- return XPF1R("0x%s", str + offset);
-
- case float_number:
- return XPF1R("%s", fc_print_dec(tv->value));
-
- case reference:
- if (tv->value != NULL)
- if (tarval_is_entity(tv))
- if (get_entity_peculiarity((entity *)tv->value) == existent)
- return XPF1R("&(%I)", get_entity_ld_ident((entity *)tv->value));
- else
- return XPSR("NULL");
- else
- return XPMR((char*)tv->value, tv->length);
+ case irms_int_number:
+ case irms_character:
+ switch (mode_info->mode_output) {
+
+ case TVO_DECIMAL:
+ str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_DEC);
+ break;
+
+ case TVO_OCTAL:
+ str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_OCT);
+ break;
+
+ case TVO_HEX:
+ case TVO_NATIVE:
+ default:
+ str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_HEX);
+ break;
+ }
+ return snprintf(buf, len, "%s%s%s", prefix, str, suffix);
+
+ case irms_float_number:
+ switch (mode_info->mode_output) {
+ case TVO_HEX:
+ return snprintf(buf, len, "%s%s%s", prefix, fc_print(tv->value, tv_buf, sizeof(tv_buf), FC_PACKED), suffix);
+
+ case TVO_HEXFLOAT:
+ return snprintf(buf, len, "%s%s%s", prefix, fc_print(tv->value, tv_buf, sizeof(tv_buf), FC_HEX), suffix);
+
+ case TVO_FLOAT:
+ case TVO_NATIVE:
+ default:
+ return snprintf(buf, len, "%s%s%s", prefix, fc_print(tv->value, tv_buf, sizeof(tv_buf), FC_DEC), suffix);
+ }
+ break;
+
+ case irms_reference:
+ if (tv == tv->mode->null) return snprintf(buf, len, "NULL");
+ if (tv->value != NULL) {
+ if (len > tv->length) {
+ memcpy(buf, tv->value, tv->length);
+ buf[tv->length] = '\0';
+ }
+ else {
+ /* truncated */
+ memcpy(buf, tv->value, len-1);
+ buf[len-1] = '\0';
+ }
+ return tv->length;
+ }