about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-08-30 19:34:27 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-08-30 19:34:27 -0700
commitfc0212a63bf888008cffe256663317e3472fbab4 (patch)
tree6b3d4412dae64bbfb33b6c83eca23bcf7e225bf3
parentc6a47e4087c226bf61964fe1105b47328553a8aa (diff)
rt: Override the character interpretation of u8/i8 values when logging
-rw-r--r--src/rt/rust_shape.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/rt/rust_shape.h b/src/rt/rust_shape.h
index e871900d65f..769c4981ef9 100644
--- a/src/rt/rust_shape.h
+++ b/src/rt/rust_shape.h
@@ -168,6 +168,24 @@ get_u16_bump(const uint8_t *&addr) {
     return result;
 }
 
+template<typename T>
+inline void
+fmt_number(std::ostream &out, T n) {
+    out << n;
+}
+
+// Override the character interpretation for these two.
+template<>
+inline void
+fmt_number<uint8_t>(std::ostream &out, uint8_t n) {
+    out << (int)n;
+}
+template<>
+inline void
+fmt_number<int8_t>(std::ostream &out, int8_t n) {
+    out << (int)n;
+}
+
 
 // Contexts
 
@@ -1015,7 +1033,7 @@ private:
                   const type_param *params, const uint8_t *end_sp, bool live);
 
     template<typename T>
-    void walk_number() { out << get_dp<T>(dp); }
+    inline void walk_number() { fmt_number(out, get_dp<T>(dp)); }
 
 public:
     log(rust_task *in_task,