librustc: Make the Drop trait use explicit self
This commit is contained in:
parent
5a282ec26f
commit
9e1c9be16f
91 changed files with 166 additions and 123 deletions
|
@ -25,7 +25,7 @@ pub trait Owned {
|
||||||
|
|
||||||
#[lang="drop"]
|
#[lang="drop"]
|
||||||
pub trait Drop {
|
pub trait Drop {
|
||||||
fn finalize(); // XXX: Rename to "drop"? --pcwalton
|
fn finalize(&self); // XXX: Rename to "drop"? --pcwalton
|
||||||
}
|
}
|
||||||
|
|
||||||
#[lang="add"]
|
#[lang="add"]
|
||||||
|
|
|
@ -888,7 +888,7 @@ fn with_field_tys<R>(tcx: ty::ctxt,
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::ty_class(did, ref substs) => {
|
ty::ty_class(did, ref substs) => {
|
||||||
let has_dtor = ty::ty_dtor(tcx, did).is_some();
|
let has_dtor = ty::ty_dtor(tcx, did).is_present();
|
||||||
op(has_dtor, class_items_as_mutable_fields(tcx, did, substs))
|
op(has_dtor, class_items_as_mutable_fields(tcx, did, substs))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -397,8 +397,14 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
|
||||||
}
|
}
|
||||||
ty::ty_class(did, ref substs) => {
|
ty::ty_class(did, ref substs) => {
|
||||||
// Call the dtor if there is one
|
// Call the dtor if there is one
|
||||||
do option::map_default(&ty::ty_dtor(bcx.tcx(), did), bcx) |dt_id| {
|
match ty::ty_dtor(bcx.tcx(), did) {
|
||||||
trans_class_drop(bcx, v, *dt_id, did, substs)
|
ty::NoDtor => bcx,
|
||||||
|
ty::LegacyDtor(ref dt_id) => {
|
||||||
|
trans_class_drop(bcx, v, *dt_id, did, substs, false)
|
||||||
|
}
|
||||||
|
ty::TraitDtor(ref dt_id) => {
|
||||||
|
trans_class_drop(bcx, v, *dt_id, did, substs, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => bcx
|
_ => bcx
|
||||||
|
@ -410,7 +416,8 @@ fn trans_class_drop(bcx: block,
|
||||||
v0: ValueRef,
|
v0: ValueRef,
|
||||||
dtor_did: ast::def_id,
|
dtor_did: ast::def_id,
|
||||||
class_did: ast::def_id,
|
class_did: ast::def_id,
|
||||||
substs: &ty::substs) -> block {
|
substs: &ty::substs,
|
||||||
|
take_ref: bool) -> block {
|
||||||
let drop_flag = GEPi(bcx, v0, struct_dtor());
|
let drop_flag = GEPi(bcx, v0, struct_dtor());
|
||||||
do with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag))) |cx| {
|
do with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag))) |cx| {
|
||||||
let mut bcx = cx;
|
let mut bcx = cx;
|
||||||
|
@ -427,7 +434,18 @@ fn trans_class_drop(bcx: block,
|
||||||
// just consist of the output pointer and the environment
|
// just consist of the output pointer and the environment
|
||||||
// (self)
|
// (self)
|
||||||
assert(params.len() == 2);
|
assert(params.len() == 2);
|
||||||
let self_arg = PointerCast(bcx, v0, params[1]);
|
|
||||||
|
// If we need to take a reference to the class (because it's using
|
||||||
|
// the Drop trait), do so now.
|
||||||
|
let llval;
|
||||||
|
if take_ref {
|
||||||
|
llval = alloca(bcx, val_ty(v0));
|
||||||
|
Store(bcx, v0, llval);
|
||||||
|
} else {
|
||||||
|
llval = v0;
|
||||||
|
}
|
||||||
|
|
||||||
|
let self_arg = PointerCast(bcx, llval, params[1]);
|
||||||
let args = ~[bcx.fcx.llretptr, self_arg];
|
let args = ~[bcx.fcx.llretptr, self_arg];
|
||||||
Call(bcx, dtor_addr, args);
|
Call(bcx, dtor_addr, args);
|
||||||
|
|
||||||
|
@ -465,10 +483,13 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
|
||||||
ty::ty_class(did, ref substs) => {
|
ty::ty_class(did, ref substs) => {
|
||||||
let tcx = bcx.tcx();
|
let tcx = bcx.tcx();
|
||||||
match ty::ty_dtor(tcx, did) {
|
match ty::ty_dtor(tcx, did) {
|
||||||
Some(dtor) => {
|
ty::TraitDtor(dtor) => {
|
||||||
trans_class_drop(bcx, v0, dtor, did, substs)
|
trans_class_drop(bcx, v0, dtor, did, substs, true)
|
||||||
}
|
}
|
||||||
None => {
|
ty::LegacyDtor(dtor) => {
|
||||||
|
trans_class_drop(bcx, v0, dtor, did, substs, false)
|
||||||
|
}
|
||||||
|
ty::NoDtor => {
|
||||||
// No dtor? Just the default case
|
// No dtor? Just the default case
|
||||||
iter_structural_ty(bcx, v0, t, drop_ty)
|
iter_structural_ty(bcx, v0, t, drop_ty)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t {
|
||||||
// Reduce a class type to a record type in which all the fields are
|
// Reduce a class type to a record type in which all the fields are
|
||||||
// simplified
|
// simplified
|
||||||
ty::ty_class(did, ref substs) => {
|
ty::ty_class(did, ref substs) => {
|
||||||
let simpl_fields = (if ty::ty_dtor(tcx, did).is_some() {
|
let simpl_fields = (if ty::ty_dtor(tcx, did).is_present() {
|
||||||
// remember the drop flag
|
// remember the drop flag
|
||||||
~[{ident: syntax::parse::token::special_idents::dtor,
|
~[{ident: syntax::parse::token::special_idents::dtor,
|
||||||
mt: {ty: ty::mk_u8(tcx),
|
mt: {ty: ty::mk_u8(tcx),
|
||||||
|
|
|
@ -199,7 +199,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
|
||||||
|
|
||||||
// include a byte flag if there is a dtor so that we know when we've
|
// include a byte flag if there is a dtor so that we know when we've
|
||||||
// been dropped
|
// been dropped
|
||||||
if ty::ty_dtor(cx.tcx, did) != None {
|
if ty::ty_dtor(cx.tcx, did).is_present() {
|
||||||
common::set_struct_body(llty, ~[T_struct(tys), T_i8()]);
|
common::set_struct_body(llty, ~[T_struct(tys), T_i8()]);
|
||||||
} else {
|
} else {
|
||||||
common::set_struct_body(llty, ~[T_struct(tys)]);
|
common::set_struct_body(llty, ~[T_struct(tys)]);
|
||||||
|
|
|
@ -75,6 +75,7 @@ export enum_variants, substd_enum_variants, enum_is_univariant;
|
||||||
export trait_methods, store_trait_methods, impl_traits;
|
export trait_methods, store_trait_methods, impl_traits;
|
||||||
export enum_variant_with_id;
|
export enum_variant_with_id;
|
||||||
export ty_dtor;
|
export ty_dtor;
|
||||||
|
export DtorKind, NoDtor, LegacyDtor, TraitDtor;
|
||||||
export ty_param_bounds_and_ty;
|
export ty_param_bounds_and_ty;
|
||||||
export ty_param_substs_and_ty;
|
export ty_param_substs_and_ty;
|
||||||
export ty_bool, mk_bool, type_is_bool;
|
export ty_bool, mk_bool, type_is_bool;
|
||||||
|
@ -1868,7 +1869,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
|
||||||
}
|
}
|
||||||
ty_class(did, ref substs) => {
|
ty_class(did, ref substs) => {
|
||||||
// Any class with a dtor needs a drop
|
// Any class with a dtor needs a drop
|
||||||
ty_dtor(cx, did).is_some() || {
|
ty_dtor(cx, did).is_present() || {
|
||||||
for vec::each(ty::class_items_as_fields(cx, did, substs)) |f| {
|
for vec::each(ty::class_items_as_fields(cx, did, substs)) |f| {
|
||||||
if type_needs_drop(cx, f.mt.ty) { accum = true; }
|
if type_needs_drop(cx, f.mt.ty) { accum = true; }
|
||||||
}
|
}
|
||||||
|
@ -3954,11 +3955,29 @@ fn item_path_str(cx: ctxt, id: ast::def_id) -> ~str {
|
||||||
ast_map::path_to_str(item_path(cx, id), cx.sess.parse_sess.interner)
|
ast_map::path_to_str(item_path(cx, id), cx.sess.parse_sess.interner)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum DtorKind {
|
||||||
|
NoDtor,
|
||||||
|
LegacyDtor(def_id),
|
||||||
|
TraitDtor(def_id)
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DtorKind {
|
||||||
|
pure fn is_not_present(&const self) -> bool {
|
||||||
|
match *self {
|
||||||
|
NoDtor => true,
|
||||||
|
_ => false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pure fn is_present(&const self) -> bool {
|
||||||
|
!self.is_not_present()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* If class_id names a class with a dtor, return Some(the dtor's id).
|
/* If class_id names a class with a dtor, return Some(the dtor's id).
|
||||||
Otherwise return none. */
|
Otherwise return none. */
|
||||||
fn ty_dtor(cx: ctxt, class_id: def_id) -> Option<def_id> {
|
fn ty_dtor(cx: ctxt, class_id: def_id) -> DtorKind {
|
||||||
match cx.destructor_for_type.find(class_id) {
|
match cx.destructor_for_type.find(class_id) {
|
||||||
Some(method_def_id) => return Some(method_def_id),
|
Some(method_def_id) => return TraitDtor(method_def_id),
|
||||||
None => {} // Continue.
|
None => {} // Continue.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3968,18 +3987,21 @@ fn ty_dtor(cx: ctxt, class_id: def_id) -> Option<def_id> {
|
||||||
node: ast::item_class(@{ dtor: Some(dtor), _ }, _),
|
node: ast::item_class(@{ dtor: Some(dtor), _ }, _),
|
||||||
_
|
_
|
||||||
}, _)) =>
|
}, _)) =>
|
||||||
Some(local_def(dtor.node.id)),
|
LegacyDtor(local_def(dtor.node.id)),
|
||||||
_ =>
|
_ =>
|
||||||
None
|
NoDtor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
csearch::class_dtor(cx.sess.cstore, class_id)
|
match csearch::class_dtor(cx.sess.cstore, class_id) {
|
||||||
|
None => NoDtor,
|
||||||
|
Some(did) => LegacyDtor(did),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_dtor(cx: ctxt, class_id: def_id) -> bool {
|
fn has_dtor(cx: ctxt, class_id: def_id) -> bool {
|
||||||
ty_dtor(cx, class_id).is_some()
|
ty_dtor(cx, class_id).is_present()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
|
fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
|
||||||
|
|
|
@ -229,7 +229,7 @@ struct PoisonOnFail {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PoisonOnFail : Drop {
|
impl PoisonOnFail : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
/* assert !*self.failed; -- might be false in case of cond.wait() */
|
/* assert !*self.failed; -- might be false in case of cond.wait() */
|
||||||
if task::failing() { *self.failed = true; }
|
if task::failing() { *self.failed = true; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ pub struct Arena {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Arena : Drop {
|
impl Arena : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
destroy_chunk(&self.head);
|
destroy_chunk(&self.head);
|
||||||
for list::each(self.chunks) |chunk| {
|
for list::each(self.chunks) |chunk| {
|
||||||
|
|
|
@ -42,7 +42,7 @@ struct DtorRes {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DtorRes : Drop {
|
impl DtorRes : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
match self.dtor {
|
match self.dtor {
|
||||||
option::None => (),
|
option::None => (),
|
||||||
option::Some(f) => f()
|
option::Some(f) => f()
|
||||||
|
|
|
@ -28,7 +28,7 @@ pub struct Future<A> {
|
||||||
// FIXME(#2829) -- futures should not be copyable, because they close
|
// FIXME(#2829) -- futures should not be copyable, because they close
|
||||||
// over fn~'s that have pipes and so forth within!
|
// over fn~'s that have pipes and so forth within!
|
||||||
impl<A> Future<A> : Drop {
|
impl<A> Future<A> : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
priv enum FutureState<A> {
|
priv enum FutureState<A> {
|
||||||
|
|
|
@ -30,7 +30,7 @@ struct TcpSocket {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TcpSocket : Drop {
|
impl TcpSocket : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
tear_down_socket_data(self.socket_data)
|
tear_down_socket_data(self.socket_data)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1137,7 +1137,7 @@ mod big_tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LVal : Drop {
|
impl LVal : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
let x = unsafe { task::local_data::local_data_get(self.key) };
|
let x = unsafe { task::local_data::local_data_get(self.key) };
|
||||||
match x {
|
match x {
|
||||||
Some(@y) => {
|
Some(@y) => {
|
||||||
|
|
|
@ -153,7 +153,7 @@ struct SemRelease {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SemRelease : Drop {
|
impl SemRelease : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
self.sem.release();
|
self.sem.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ struct SemAndSignalRelease {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SemAndSignalRelease : Drop {
|
impl SemAndSignalRelease : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
self.sem.release();
|
self.sem.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ fn SemAndSignalRelease(sem: &r/Sem<~[mut Waitqueue]>)
|
||||||
/// A mechanism for atomic-unlock-and-deschedule blocking and signalling.
|
/// A mechanism for atomic-unlock-and-deschedule blocking and signalling.
|
||||||
pub struct Condvar { priv sem: &Sem<~[mut Waitqueue]> }
|
pub struct Condvar { priv sem: &Sem<~[mut Waitqueue]> }
|
||||||
|
|
||||||
impl Condvar : Drop { fn finalize() {} }
|
impl Condvar : Drop { fn finalize(&self) {} }
|
||||||
|
|
||||||
impl &Condvar {
|
impl &Condvar {
|
||||||
/**
|
/**
|
||||||
|
@ -257,7 +257,7 @@ impl &Condvar {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SemAndSignalReacquire : Drop {
|
impl SemAndSignalReacquire : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
// Needs to succeed, instead of itself dying.
|
// Needs to succeed, instead of itself dying.
|
||||||
do task::unkillable {
|
do task::unkillable {
|
||||||
|
@ -607,7 +607,7 @@ struct RWlockReleaseRead {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RWlockReleaseRead : Drop {
|
impl RWlockReleaseRead : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
do task::unkillable {
|
do task::unkillable {
|
||||||
let mut last_reader = false;
|
let mut last_reader = false;
|
||||||
|
@ -641,7 +641,7 @@ struct RWlockReleaseDowngrade {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RWlockReleaseDowngrade : Drop {
|
impl RWlockReleaseDowngrade : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
do task::unkillable {
|
do task::unkillable {
|
||||||
let mut writer_or_last_reader = false;
|
let mut writer_or_last_reader = false;
|
||||||
|
@ -678,10 +678,10 @@ fn RWlockReleaseDowngrade(lock: &r/RWlock) -> RWlockReleaseDowngrade/&r {
|
||||||
|
|
||||||
/// The "write permission" token used for rwlock.write_downgrade().
|
/// The "write permission" token used for rwlock.write_downgrade().
|
||||||
pub struct RWlockWriteMode { /* priv */ lock: &RWlock }
|
pub struct RWlockWriteMode { /* priv */ lock: &RWlock }
|
||||||
impl RWlockWriteMode : Drop { fn finalize() {} }
|
impl RWlockWriteMode : Drop { fn finalize(&self) {} }
|
||||||
/// The "read permission" token used for rwlock.write_downgrade().
|
/// The "read permission" token used for rwlock.write_downgrade().
|
||||||
pub struct RWlockReadMode { priv lock: &RWlock }
|
pub struct RWlockReadMode { priv lock: &RWlock }
|
||||||
impl RWlockReadMode : Drop { fn finalize() {} }
|
impl RWlockReadMode : Drop { fn finalize(&self) {} }
|
||||||
|
|
||||||
impl &RWlockWriteMode {
|
impl &RWlockWriteMode {
|
||||||
/// Access the pre-downgrade rwlock in write mode.
|
/// Access the pre-downgrade rwlock in write mode.
|
||||||
|
@ -993,7 +993,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SendOnFailure : Drop {
|
impl SendOnFailure : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
self.c.send(());
|
self.c.send(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ struct arc_destruct<T:Const> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T:Const> arc_destruct<T> : Drop {
|
impl<T:Const> arc_destruct<T> : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn arc_destruct<T: Const>(data: int) -> arc_destruct<T> {
|
fn arc_destruct<T: Const>(data: int) -> arc_destruct<T> {
|
||||||
|
@ -34,7 +34,7 @@ struct context_res {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl context_res : Drop {
|
impl context_res : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn context_res() -> context_res {
|
fn context_res() -> context_res {
|
||||||
|
|
|
@ -12,7 +12,7 @@ struct socket_handle {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl socket_handle : Drop {
|
impl socket_handle : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
/* c::close(self.sockfd); */
|
/* c::close(self.sockfd); */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ struct rsrc {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl rsrc : Drop {
|
impl rsrc : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
foo(self.x);
|
foo(self.x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ struct port_ptr<T:Send> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T:Send> port_ptr<T> : Drop {
|
impl<T:Send> port_ptr<T> : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
debug!("in the port_ptr destructor");
|
debug!("in the port_ptr destructor");
|
||||||
do task::unkillable {
|
do task::unkillable {
|
||||||
|
|
|
@ -45,7 +45,7 @@ struct r {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl r : Drop {
|
impl r : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn r(l: @nillist) -> r {
|
fn r(l: @nillist) -> r {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
struct X { x: () }
|
struct X { x: () }
|
||||||
|
|
||||||
impl X : Drop {
|
impl X : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
error!("destructor runs");
|
error!("destructor runs");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
struct X { x: (), }
|
struct X { x: (), }
|
||||||
|
|
||||||
impl X : Drop {
|
impl X : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
error!("destructor runs");
|
error!("destructor runs");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
struct X { x: (), }
|
struct X { x: (), }
|
||||||
|
|
||||||
impl X : Drop {
|
impl X : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
error!("destructor runs");
|
error!("destructor runs");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
struct X { x: (), }
|
struct X { x: (), }
|
||||||
|
|
||||||
impl X : Drop {
|
impl X : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
error!("destructor runs");
|
error!("destructor runs");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
struct X { x: (), }
|
struct X { x: (), }
|
||||||
|
|
||||||
impl X : Drop {
|
impl X : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
error!("destructor runs");
|
error!("destructor runs");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
struct X { x: (), }
|
struct X { x: (), }
|
||||||
|
|
||||||
impl X : Drop {
|
impl X : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
error!("destructor runs");
|
error!("destructor runs");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
struct X { x: (), }
|
struct X { x: (), }
|
||||||
|
|
||||||
impl X : Drop {
|
impl X : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
error!("destructor runs");
|
error!("destructor runs");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
struct r {}
|
struct r {}
|
||||||
|
|
||||||
impl r : Drop {
|
impl r : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ struct defer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl defer : Drop {
|
impl defer : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
error!("%?", self.x);
|
error!("%?", self.x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ struct noncopyable {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl noncopyable : Drop {
|
impl noncopyable : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
error!("dropped");
|
error!("dropped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
struct foo { x: int, }
|
struct foo { x: int, }
|
||||||
|
|
||||||
impl foo : Drop {
|
impl foo : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo(x: int) -> foo {
|
fn foo(x: int) -> foo {
|
||||||
|
|
|
@ -5,7 +5,7 @@ struct foo {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl foo : Drop {
|
impl foo : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo(i:int) -> foo {
|
fn foo(i:int) -> foo {
|
||||||
|
|
|
@ -3,7 +3,7 @@ struct X {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl X : Drop {
|
impl X : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
error!("value: %s", self.x);
|
error!("value: %s", self.x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
type Foo = @[u8];
|
type Foo = @[u8];
|
||||||
|
|
||||||
impl Foo : Drop { //~ ERROR the Drop trait may only be implemented
|
impl Foo : Drop { //~ ERROR the Drop trait may only be implemented
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
io::println("kaboom");
|
io::println("kaboom");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ struct Foo {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Foo : Drop {
|
impl Foo : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
io::println("kaboom");
|
io::println("kaboom");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ trait Bar : Drop {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Foo : Drop {
|
impl Foo : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
io::println("kaboom");
|
io::println("kaboom");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ struct Bar {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Bar : Drop {
|
impl Bar : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
io::println("Goodbye, cruel world");
|
io::println("Goodbye, cruel world");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ struct socket {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl socket : Drop {
|
impl socket : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl socket {
|
impl socket {
|
||||||
|
|
|
@ -7,7 +7,7 @@ struct foo {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl foo : Drop {
|
impl foo : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
io::println("Goodbye, World!");
|
io::println("Goodbye, World!");
|
||||||
*self.x += 1;
|
*self.x += 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ struct S {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl S : Drop {
|
impl S : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn S(x: int) -> S { S { x: x } }
|
fn S(x: int) -> S { S { x: x } }
|
||||||
|
|
|
@ -3,7 +3,7 @@ struct C {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl C : Drop {
|
impl C : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
error!("dropping: %?", self.x);
|
error!("dropping: %?", self.x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ fn foo<T>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> foo<T> : Drop {
|
impl<T> foo<T> : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn main() { }
|
fn main() { }
|
||||||
|
|
|
@ -53,7 +53,7 @@ struct r {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl r : Drop {
|
impl r : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -4,7 +4,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl foo : Drop {
|
impl foo : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo(x: comm::Port<()>) -> foo {
|
fn foo(x: comm::Port<()>) -> foo {
|
||||||
|
|
|
@ -7,7 +7,7 @@ struct r {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl r : Drop {
|
impl r : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn r(x:int) -> r {
|
fn r(x:int) -> r {
|
||||||
|
@ -21,7 +21,7 @@ struct r2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl r2 : Drop {
|
impl r2 : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn r2(x:@mut int) -> r2 {
|
fn r2(x:@mut int) -> r2 {
|
||||||
|
|
|
@ -7,7 +7,7 @@ struct bar {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl bar : Drop {
|
impl bar : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bar(x:int) -> bar {
|
fn bar(x:int) -> bar {
|
||||||
|
|
|
@ -5,7 +5,7 @@ struct r {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl r : Drop {
|
impl r : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
*(self.i) = *(self.i) + 1;
|
*(self.i) = *(self.i) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ struct my_resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl my_resource : Drop {
|
impl my_resource : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
log(error, self.x);
|
log(error, self.x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ struct yes0 {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl yes0 : Drop {
|
impl yes0 : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct yes1 {
|
struct yes1 {
|
||||||
|
@ -11,7 +11,7 @@ struct yes1 {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl yes1 : Drop {
|
impl yes1 : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct yes2 {
|
struct yes2 {
|
||||||
|
@ -19,7 +19,7 @@ struct yes2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl yes2 : Drop {
|
impl yes2 : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -7,7 +7,7 @@ struct Foo {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Foo : Drop {
|
impl Foo : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
io::println("Goodbye!");
|
io::println("Goodbye!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ struct Bar {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Bar : Drop {
|
impl Bar : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Bar : Foo {
|
impl Bar : Foo {
|
||||||
|
|
|
@ -5,7 +5,7 @@ struct r {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl r : Drop {
|
impl r : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -5,7 +5,7 @@ struct r {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl r : Drop {
|
impl r : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
*(self.i) = *(self.i) + 1;
|
*(self.i) = *(self.i) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ struct r {
|
||||||
fn r(i:int) -> r { r { i: i } }
|
fn r(i:int) -> r { r { i: i } }
|
||||||
|
|
||||||
impl r : Drop {
|
impl r : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -5,7 +5,7 @@ struct R {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl R : Drop {
|
impl R : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
let _y = R { b: self.b };
|
let _y = R { b: self.b };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ struct and_then_get_big_again {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl and_then_get_big_again : Drop {
|
impl and_then_get_big_again : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
fn getbig(i: int) {
|
fn getbig(i: int) {
|
||||||
if i != 0 {
|
if i != 0 {
|
||||||
getbig(i - 1);
|
getbig(i - 1);
|
||||||
|
|
|
@ -18,7 +18,7 @@ struct and_then_get_big_again {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl and_then_get_big_again : Drop {
|
impl and_then_get_big_again : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
fn getbig(i: int) {
|
fn getbig(i: int) {
|
||||||
if i != 0 {
|
if i != 0 {
|
||||||
getbig(i - 1);
|
getbig(i - 1);
|
||||||
|
|
|
@ -18,7 +18,7 @@ struct and_then_get_big_again {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl and_then_get_big_again : Drop {
|
impl and_then_get_big_again : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn and_then_get_big_again(x:int) -> and_then_get_big_again {
|
fn and_then_get_big_again(x:int) -> and_then_get_big_again {
|
||||||
|
|
|
@ -8,7 +8,7 @@ struct r {
|
||||||
// failed has no effect and the process exits with the
|
// failed has no effect and the process exits with the
|
||||||
// runtime's exit code
|
// runtime's exit code
|
||||||
impl r : Drop {
|
impl r : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
os::set_exit_status(50);
|
os::set_exit_status(50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ struct r {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl r : Drop {
|
impl r : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let _v2: ~int = cast::reinterpret_cast(&self.v);
|
let _v2: ~int = cast::reinterpret_cast(&self.v);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ struct faily_box {
|
||||||
fn faily_box(i: @int) -> faily_box { faily_box { i: i } }
|
fn faily_box(i: @int) -> faily_box { faily_box { i: i } }
|
||||||
|
|
||||||
impl faily_box : Drop {
|
impl faily_box : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
fail ~"quux";
|
fail ~"quux";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ struct cat {
|
||||||
|
|
||||||
impl cat: Drop {
|
impl cat: Drop {
|
||||||
#[cat_dropper]
|
#[cat_dropper]
|
||||||
fn finalize() { error!("%s landed on hir feet",self.name); }
|
fn finalize(&self) { error!("%s landed on hir feet",self.name); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ impl cat : Drop {
|
||||||
/**
|
/**
|
||||||
Actually, cats don't always land on their feet when you drop them.
|
Actually, cats don't always land on their feet when you drop them.
|
||||||
*/
|
*/
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
error!("%s landed on hir feet", self.name);
|
error!("%s landed on hir feet", self.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ struct cat {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl cat : Drop {
|
impl cat : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
self.done(self.meows);
|
self.done(self.meows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ struct S<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> S<T> : core::ops::Drop {
|
impl<T> S<T> : core::ops::Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
io::println("bye");
|
io::println("bye");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ struct Foo {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Foo : Drop {
|
impl Foo : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
io::println("bye");
|
io::println("bye");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ struct r {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl r : Drop {
|
impl r : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
*(self.i) = *(self.i) + 1;
|
*(self.i) = *(self.i) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ struct socket {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl socket : Drop {
|
impl socket : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl socket {
|
impl socket {
|
||||||
|
|
|
@ -6,7 +6,7 @@ struct Font {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Font : Drop {
|
impl Font : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Font() -> Font {
|
fn Font() -> Font {
|
||||||
|
|
|
@ -144,7 +144,7 @@ mod pipes {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Send> send_packet<T> : Drop {
|
impl<T: Send> send_packet<T> : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
if self.p != None {
|
if self.p != None {
|
||||||
let mut p = None;
|
let mut p = None;
|
||||||
p <-> self.p;
|
p <-> self.p;
|
||||||
|
@ -172,7 +172,7 @@ mod pipes {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Send> recv_packet<T> : Drop {
|
impl<T: Send> recv_packet<T> : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
if self.p != None {
|
if self.p != None {
|
||||||
let mut p = None;
|
let mut p = None;
|
||||||
p <-> self.p;
|
p <-> self.p;
|
||||||
|
|
|
@ -4,7 +4,7 @@ struct defer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl defer : Drop {
|
impl defer : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
*(self.b) = true;
|
*(self.b) = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ struct defer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl defer : Drop {
|
impl defer : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
*(self.b) = true;
|
*(self.b) = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ struct Kitty {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Kitty : Drop {
|
impl Kitty : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
struct thing { x: int, }
|
struct thing { x: int, }
|
||||||
|
|
||||||
impl thing : Drop {
|
impl thing : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn thing() -> thing {
|
fn thing() -> thing {
|
||||||
|
|
|
@ -3,7 +3,7 @@ struct r {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl r : Drop {
|
impl r : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
*(self.b) += 1;
|
*(self.b) += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ struct dtor {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl dtor : Drop {
|
impl dtor : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
// abuse access to shared mutable state to write this code
|
// abuse access to shared mutable state to write this code
|
||||||
*self.x -= 1;
|
*self.x -= 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ struct Buffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Buffer : Drop {
|
impl Buffer : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
proto! double_buffer (
|
proto! double_buffer (
|
||||||
|
|
|
@ -3,7 +3,7 @@ struct r {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl r : Drop {
|
impl r : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
*(self.i) += 1;
|
*(self.i) += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ struct r {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl r : Drop {
|
impl r : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
debug!("r's dtor: self = %x, self.v = %x, self.v's value = %x",
|
debug!("r's dtor: self = %x, self.v = %x, self.v's value = %x",
|
||||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&self)),
|
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&self)),
|
||||||
|
|
|
@ -11,7 +11,7 @@ struct r {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl r : Drop {
|
impl r : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let v2: ~int = cast::reinterpret_cast(&self.v.c);
|
let v2: ~int = cast::reinterpret_cast(&self.v.c);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ struct r {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl r : Drop {
|
impl r : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let _v2: ~int = cast::reinterpret_cast(&self.v.c);
|
let _v2: ~int = cast::reinterpret_cast(&self.v.c);
|
||||||
// let _v3: ~int = unsafe::reinterpret_cast(self.x);
|
// let _v3: ~int = unsafe::reinterpret_cast(self.x);
|
||||||
|
|
|
@ -3,7 +3,7 @@ struct shrinky_pointer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl shrinky_pointer : Drop {
|
impl shrinky_pointer : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
log(error, ~"Hello!"); **(self.i) -= 1;
|
log(error, ~"Hello!"); **(self.i) -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ struct finish<T: Copy> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Copy> finish<T> : Drop {
|
impl<T: Copy> finish<T> : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
self.arg.fin(self.arg.val);
|
self.arg.fin(self.arg.val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ struct close_res {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl close_res : Drop {
|
impl close_res : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
*(self.i) = false;
|
*(self.i) = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ struct test {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl test : Drop {
|
impl test : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test(f: int) -> test {
|
fn test(f: int) -> test {
|
||||||
|
|
|
@ -3,7 +3,7 @@ struct foo {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl foo : Drop {
|
impl foo : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
error!("%s", self.x);
|
error!("%s", self.x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ struct notify {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl notify : Drop {
|
impl notify : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
error!("notify: task=%? v=%x unwinding=%b b=%b",
|
error!("notify: task=%? v=%x unwinding=%b b=%b",
|
||||||
task::get_task(),
|
task::get_task(),
|
||||||
ptr::addr_of(&(*(self.v))) as uint,
|
ptr::addr_of(&(*(self.v))) as uint,
|
||||||
|
|
|
@ -10,7 +10,7 @@ struct notify {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl notify : Drop {
|
impl notify : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
error!("notify: task=%? v=%x unwinding=%b b=%b",
|
error!("notify: task=%? v=%x unwinding=%b b=%b",
|
||||||
task::get_task(),
|
task::get_task(),
|
||||||
ptr::addr_of(&(*(self.v))) as uint,
|
ptr::addr_of(&(*(self.v))) as uint,
|
||||||
|
|
|
@ -10,7 +10,7 @@ struct r {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl r : Drop {
|
impl r : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn r(i:int) -> r {
|
fn r(i:int) -> r {
|
||||||
|
|
|
@ -3,7 +3,7 @@ struct r {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl r : Drop {
|
impl r : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
*(self.i) = *(self.i) + 1;
|
*(self.i) = *(self.i) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ struct complainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl complainer : Drop {
|
impl complainer : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
error!("About to send!");
|
error!("About to send!");
|
||||||
comm::send(self.c, true);
|
comm::send(self.c, true);
|
||||||
error!("Sent!");
|
error!("Sent!");
|
||||||
|
|
|
@ -6,7 +6,7 @@ struct complainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl complainer : Drop {
|
impl complainer : Drop {
|
||||||
fn finalize() {}
|
fn finalize(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn complainer(c: @int) -> complainer {
|
fn complainer(c: @int) -> complainer {
|
||||||
|
|
|
@ -4,7 +4,7 @@ struct foo {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl foo : Drop {
|
impl foo : Drop {
|
||||||
fn finalize() {
|
fn finalize(&self) {
|
||||||
*self.x += 1;
|
*self.x += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue