about summary refs log tree commit diff
path: root/src/rt/rust_shape.cpp
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-01-11 09:09:46 -0800
committerNiko Matsakis <niko@alum.mit.edu>2012-01-11 10:32:54 -0800
commitc68345e57e82e7233e0f875bd416f46e1f8859e1 (patch)
tree394fdadbb90e0eb8661e1a9475985f12629ada67 /src/rt/rust_shape.cpp
parentf3b867fd04d06c732a41e05c3abddb8e8bcbdbbb (diff)
downloadrust-c68345e57e82e7233e0f875bd416f46e1f8859e1.tar.gz
rust-c68345e57e82e7233e0f875bd416f46e1f8859e1.zip
add a log_str() function and allow '%?' in fmt strings to use it
Diffstat (limited to 'src/rt/rust_shape.cpp')
-rw-r--r--src/rt/rust_shape.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/rt/rust_shape.cpp b/src/rt/rust_shape.cpp
index 1743aaad9dd..ee7e389dc77 100644
--- a/src/rt/rust_shape.cpp
+++ b/src/rt/rust_shape.cpp
@@ -548,6 +548,24 @@ shape_cmp_type(int8_t *result, const type_desc *tydesc,
     }
 }
 
+extern "C" rust_str *
+shape_log_str(const type_desc *tydesc, uint8_t *data) {
+    rust_task *task = rust_scheduler::get_task();
+
+    shape::arena arena;
+    shape::type_param *params =
+        shape::type_param::from_tydesc_and_data(tydesc, data, arena);
+
+    std::stringstream ss;
+    shape::log log(task, true, tydesc->shape, params, tydesc->shape_tables,
+                   data, ss);
+
+    log.walk();
+
+    int len = ss.str().length();
+    return make_str(task->kernel, ss.str().c_str(), len, "log_str");
+}
+
 extern "C" void
 shape_log_type(const type_desc *tydesc, uint8_t *data, uint32_t level) {
     rust_task *task = rust_scheduler::get_task();