about summary refs log tree commit diff
path: root/src/rt/rust_shape.cpp
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-08-09 19:01:15 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-08-09 19:01:15 -0700
commit6fbb7ffdbdfc3ea45eb913f9d6644fe5020f21d7 (patch)
tree1c9cc24d542beb9547f3a6c981d544c7760f50f9 /src/rt/rust_shape.cpp
parent8e6e6f5f896e1dbc2fb124e7dad8750d8b9112ef (diff)
downloadrust-6fbb7ffdbdfc3ea45eb913f9d6644fe5020f21d7.tar.gz
rust-6fbb7ffdbdfc3ea45eb913f9d6644fe5020f21d7.zip
rt: Stub code for polymorphic log
Diffstat (limited to 'src/rt/rust_shape.cpp')
-rw-r--r--src/rt/rust_shape.cpp47
1 files changed, 45 insertions, 2 deletions
diff --git a/src/rt/rust_shape.cpp b/src/rt/rust_shape.cpp
index 3e927b0f393..d7d5d500817 100644
--- a/src/rt/rust_shape.cpp
+++ b/src/rt/rust_shape.cpp
@@ -2,6 +2,7 @@
 // actions, such as copying, freeing, comparing, and so on.
 
 #include <algorithm>
+#include <iostream>
 #include <utility>
 #include <cassert>
 #include <cstdio>
@@ -1085,11 +1086,11 @@ public:
       result(0) {}
 
     void walk_evec(bool align, bool is_pod, uint16_t sp_size) {
-        return walk_vec(align, is_pod, get_evec_data_range(dp));
+        walk_vec(align, is_pod, get_evec_data_range(dp));
     }
 
     void walk_ivec(bool align, bool is_pod, size_align &elem_sa) {
-        return walk_vec(align, is_pod, get_ivec_data_range(dp));
+        walk_vec(align, is_pod, get_ivec_data_range(dp));
     }
 
     void walk_fn(bool align) { return cmp_two_pointers(align); }
@@ -1183,6 +1184,48 @@ cmp::walk_variant(bool align, tag_info &tinfo, uint32_t variant_id,
     }
 }
 
+
+// Polymorphic logging, for convenience
+
+class log : public data<log,uint8_t *> {
+    friend class data<log,uint8_t *>;
+
+private:
+    std::ostream &out;
+    bool in_string;
+
+    void walk_evec(bool align, bool is_pod, uint16_t sp_size) {
+        walk_vec(align, is_pod, get_evec_data_range(dp));
+    }
+
+    void walk_ivec(bool align, bool is_pod, size_align &elem_sa) {
+        walk_vec(align, is_pod, get_ivec_data_range(dp));
+    }
+
+    void walk_vec(bool align, bool is_pod,
+                  const std::pair<uint8_t *,uint8_t *> &data);
+
+    template<typename T>
+    void walk_number() { out << get_dp<T>(dp); }
+
+public:
+    log(rust_task *in_task,
+        const uint8_t *in_sp,
+        const type_param *in_params,
+        const rust_shape_tables *in_tables,
+        uint8_t *in_data,
+        std::ostream &in_out)
+    : data<log,uint8_t *>(in_task, in_sp, in_params, in_tables, in_data),
+      out(in_out) {}
+};
+
+void
+log::walk_vec(bool align, bool is_pod,
+              const std::pair<uint8_t *,uint8_t *> &data) {
+    // TODO: Check to see whether this is a string (contains u8). If so,
+    // write the vector ""-style; otherwise [ ... , ... ] style.
+}
+
 } // end namespace shape
 
 extern "C" void