From c68345e57e82e7233e0f875bd416f46e1f8859e1 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 11 Jan 2012 09:09:46 -0800 Subject: add a log_str() function and allow '%?' in fmt strings to use it --- src/rt/rust_shape.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/rt/rust_shape.cpp') 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(); -- cgit 1.4.1-3-g733a5