From cf62b54028ef949298fc38a815f5f0a3e1666261 Mon Sep 17 00:00:00 2001 From: Roy Frostig Date: Mon, 6 Sep 2010 23:24:01 -0700 Subject: Add a little pointer-cast helper to dbg. --- src/lib/dbg.rs | 5 +++++ src/rt/rust_builtin.cpp | 13 +++++++++++++ 2 files changed, 18 insertions(+) (limited to 'src') diff --git a/src/lib/dbg.rs b/src/lib/dbg.rs index 11c0086c..0ea8bd08 100644 --- a/src/lib/dbg.rs +++ b/src/lib/dbg.rs @@ -14,6 +14,7 @@ native "rust" mod rustrt { fn debug_tag[T](&T x); fn debug_obj[T](&T x, uint nmethods, uint nbytes); fn debug_fn[T](&T x); + fn debug_ptrcast[T, U](@T x) -> @U; } fn debug_vec[T](vec[T] v) { @@ -52,3 +53,7 @@ fn debug_obj[T](&T x, uint nmethods, uint nbytes) { fn debug_fn[T](&T x) { rustrt.debug_fn[T](x); } + +fn ptr_cast[T, U](@T x) -> @U { + ret rustrt.debug_ptrcast[T, U](x); +} diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index e8bc9fc7..8654e050 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -340,6 +340,19 @@ debug_fn(rust_task *task, type_desc *t, rust_fn *fn) task->log(rust_log::STDLIB, " closure at 0x%" PRIxPTR, fn->closure); } +extern "C" CDECL void * +debug_ptrcast(rust_task *task, + type_desc *from_ty, + type_desc *to_ty, + void *ptr) +{ + task->log(rust_log::STDLIB, "debug_ptrcast from"); + debug_tydesc_helper(task, from_ty); + task->log(rust_log::STDLIB, "to"); + debug_tydesc_helper(task, to_ty); + return ptr; +} + // // Local Variables: -- cgit v1.2.3