diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2013-08-11 13:29:14 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2013-08-11 13:59:45 -0400 |
| commit | 6fe59bf8776f8913aacfb00a2281c94a117b95d1 (patch) | |
| tree | c149a22cd433599e96bd44250533351826888525 /src/libstd/unstable | |
| parent | 3aefb9649d15c16acef4eb465b06b598b3a1f179 (diff) | |
| download | rust-6fe59bf8776f8913aacfb00a2281c94a117b95d1.tar.gz rust-6fe59bf8776f8913aacfb00a2281c94a117b95d1.zip | |
Add a field `borrow_offset` to the type descriptor indicating
what amount a T* pointer must be adjusted to reach the contents of the box. For `~T` types, this requires knowing the type `T`, which is not known in the case of objects.
Diffstat (limited to 'src/libstd/unstable')
| -rw-r--r-- | src/libstd/unstable/intrinsics.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/libstd/unstable/intrinsics.rs b/src/libstd/unstable/intrinsics.rs index c60edad3dbd..d2807303fb2 100644 --- a/src/libstd/unstable/intrinsics.rs +++ b/src/libstd/unstable/intrinsics.rs @@ -38,16 +38,34 @@ pub use realstd::unstable::intrinsics::{TyDesc, Opaque, TyVisitor}; pub type GlueFn = extern "Rust" fn(*i8); -// NB: this has to be kept in sync with the Rust ABI. +// NB: this has to be kept in sync with `type_desc` in `rt` #[lang="ty_desc"] #[cfg(not(test))] pub struct TyDesc { + // sizeof(T) size: uint, + + // alignof(T) align: uint, + + // Called on a copy of a value of type `T` *after* memcpy take_glue: GlueFn, + + // Called when a value of type `T` is no longer needed drop_glue: GlueFn, + + // Called by drop glue when a value of type `T` can be freed free_glue: GlueFn, + + // Called by reflection visitor to visit a value of type `T` visit_glue: GlueFn, + + // If T represents a box pointer (`@U` or `~U`), then + // `borrow_offset` is the amount that the pointer must be adjusted + // to find the payload. This is always derivable from the type + // `U`, but in the case of `@Trait` or `~Trait` objects, the type + // `U` is unknown. + borrow_offset: uint, } #[lang="opaque"] |
