Skip to content

Commit

Permalink
Add a little pointer-cast helper to dbg.
Browse files Browse the repository at this point in the history
  • Loading branch information
froystig committed Sep 7, 2010
1 parent 974092c commit cf62b54
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/dbg.rs
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
13 changes: 13 additions & 0 deletions src/rt/rust_builtin.cpp
Expand Up @@ -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:
Expand Down

0 comments on commit cf62b54

Please sign in to comment.