Skip to content

Commit cf62b54

Browse files
committed
Add a little pointer-cast helper to dbg.
1 parent 974092c commit cf62b54

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/lib/dbg.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ native "rust" mod rustrt {
1414
fn debug_tag[T](&T x);
1515
fn debug_obj[T](&T x, uint nmethods, uint nbytes);
1616
fn debug_fn[T](&T x);
17+
fn debug_ptrcast[T, U](@T x) -> @U;
1718
}
1819

1920
fn debug_vec[T](vec[T] v) {
@@ -52,3 +53,7 @@ fn debug_obj[T](&T x, uint nmethods, uint nbytes) {
5253
fn debug_fn[T](&T x) {
5354
rustrt.debug_fn[T](x);
5455
}
56+
57+
fn ptr_cast[T, U](@T x) -> @U {
58+
ret rustrt.debug_ptrcast[T, U](x);
59+
}

src/rt/rust_builtin.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,19 @@ debug_fn(rust_task *task, type_desc *t, rust_fn *fn)
340340
task->log(rust_log::STDLIB, " closure at 0x%" PRIxPTR, fn->closure);
341341
}
342342

343+
extern "C" CDECL void *
344+
debug_ptrcast(rust_task *task,
345+
type_desc *from_ty,
346+
type_desc *to_ty,
347+
void *ptr)
348+
{
349+
task->log(rust_log::STDLIB, "debug_ptrcast from");
350+
debug_tydesc_helper(task, from_ty);
351+
task->log(rust_log::STDLIB, "to");
352+
debug_tydesc_helper(task, to_ty);
353+
return ptr;
354+
}
355+
343356

344357
//
345358
// Local Variables:

0 commit comments

Comments
 (0)