auto merge of #8455 : nikomatsakis/rust/issue-5762-objects-dralston-d, r=graydon

Fix #5762 and various other aspects of object invocation.

r? @graydon
This commit is contained in:
bors 2013-08-11 14:17:09 -07:00
commit b285f1e6c9
65 changed files with 1154 additions and 559 deletions

View file

@ -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"]
@ -310,8 +328,12 @@ extern "rust-intrinsic" {
/// Returns `true` if a type is managed (will be allocated on the local heap)
pub fn contains_managed<T>() -> bool;
#[cfg(stage0)]
pub fn visit_tydesc(td: *TyDesc, tv: @TyVisitor);
#[cfg(not(stage0))]
pub fn visit_tydesc(td: *TyDesc, tv: &TyVisitor);
pub fn frame_address(f: &once fn(*u8));
/// Get the address of the `__morestack` stack growth function.