Skip to content

Commit fc0212a

Browse files
committed
rt: Override the character interpretation of u8/i8 values when logging
1 parent c6a47e4 commit fc0212a

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/rt/rust_shape.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,24 @@ get_u16_bump(const uint8_t *&addr) {
168168
return result;
169169
}
170170

171+
template<typename T>
172+
inline void
173+
fmt_number(std::ostream &out, T n) {
174+
out << n;
175+
}
176+
177+
// Override the character interpretation for these two.
178+
template<>
179+
inline void
180+
fmt_number<uint8_t>(std::ostream &out, uint8_t n) {
181+
out << (int)n;
182+
}
183+
template<>
184+
inline void
185+
fmt_number<int8_t>(std::ostream &out, int8_t n) {
186+
out << (int)n;
187+
}
188+
171189

172190
// Contexts
173191

@@ -1015,7 +1033,7 @@ class log : public data<log,ptr> {
10151033
const type_param *params, const uint8_t *end_sp, bool live);
10161034

10171035
template<typename T>
1018-
void walk_number() { out << get_dp<T>(dp); }
1036+
inline void walk_number() { fmt_number(out, get_dp<T>(dp)); }
10191037

10201038
public:
10211039
log(rust_task *in_task,

0 commit comments

Comments
 (0)