Skip to content

Commit 3859af8

Browse files
committed
---
yaml --- r: 16266 b: refs/heads/try c: ebde938 h: refs/heads/master v: v3
1 parent cc690ee commit 3859af8

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: aabf84cdd81351cc63ebdc9e2427203621d19950
5+
refs/heads/try: ebde93861fc004aec9d1fdac528cca9aad9a7612
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rustc/middle/trans/base.rs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,7 +2252,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t],
22522252
dtor"); }
22532253
};
22542254
trans_class_dtor(ccx, *pt, dtor.node.body,
2255-
dtor.node.id, psubsts, some(hash_id), parent_id, s)
2255+
dtor.node.id, psubsts, some(hash_id), parent_id)
22562256
}
22572257
// Ugh -- but this ensures any new variants won't be forgotten
22582258
ast_map::node_expr(*) { ccx.tcx.sess.bug("Can't monomorphize an expr") }
@@ -4887,9 +4887,8 @@ fn trans_class_ctor(ccx: @crate_ctxt, path: path, decl: ast::fn_decl,
48874887
fn trans_class_dtor(ccx: @crate_ctxt, path: path,
48884888
body: ast::blk,
48894889
dtor_id: ast::node_id, substs: option<param_substs>,
4890-
hash_id: option<mono_id>, parent_id: ast::def_id,
4891-
// mangled exported name for dtor
4892-
s: str) -> ValueRef {
4890+
hash_id: option<mono_id>, parent_id: ast::def_id)
4891+
-> ValueRef {
48934892
let tcx = ccx.tcx;
48944893
/* Look up the parent class's def_id */
48954894
let mut class_ty = ty::lookup_item_type(tcx, parent_id).ty;
@@ -4903,6 +4902,7 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path,
49034902
let lldty = T_fn([T_ptr(type_of(ccx, ty::mk_nil(tcx))),
49044903
T_ptr(type_of(ccx, class_ty))],
49054904
llvm::LLVMVoidType());
4905+
let s = get_dtor_symbol(ccx, path, dtor_id);
49064906
/* Register the dtor as a function. It has external linkage */
49074907
let lldecl = decl_internal_cdecl_fn(ccx.llmod, s, lldty);
49084908
lib::llvm::SetLinkage(lldecl, lib::llvm::ExternalLinkage);
@@ -4912,9 +4912,7 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path,
49124912
option::iter(hash_id) {|h_id|
49134913
ccx.monomorphized.insert(h_id, lldecl);
49144914
}
4915-
/* Register the symbol for the dtor, and generate the code for its
4916-
body */
4917-
ccx.item_symbols.insert(dtor_id, s);
4915+
/* Translate the dtor body */
49184916
trans_fn(ccx, path, ast_util::dtor_dec(),
49194917
body, lldecl, impl_self(class_ty), substs, dtor_id);
49204918
lldecl
@@ -4997,11 +4995,8 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
49974995
get_item_val(ccx, ctor.node.id), psubsts,
49984996
ctor.node.id, local_def(item.id), ctor.span);
49994997
option::iter(m_dtor) {|dtor|
5000-
let s = mangle_exported_name(ccx, *path +
5001-
[path_name(ccx.names("dtor"))],
5002-
ty::node_id_to_type(ccx.tcx, dtor.node.id));
50034998
trans_class_dtor(ccx, *path, dtor.node.body,
5004-
dtor.node.id, none, none, local_def(item.id), s);
4999+
dtor.node.id, none, none, local_def(item.id));
50055000
};
50065001
}
50075002
// If there are ty params, the ctor will get monomorphized
@@ -5162,8 +5157,21 @@ fn item_path(ccx: @crate_ctxt, i: @ast::item) -> path {
51625157
} + [path_name(i.ident)]
51635158
}
51645159

5160+
/* If there's already a symbol for the dtor with <id>, return it;
5161+
otherwise, create one and register it, returning it as well */
5162+
fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id) -> str {
5163+
alt ccx.item_symbols.find(id) {
5164+
some(s) { s }
5165+
none {
5166+
let s = mangle_exported_name(ccx, path +
5167+
[path_name(ccx.names("dtor"))], ty::node_id_to_type(ccx.tcx, id));
5168+
ccx.item_symbols.insert(id, s);
5169+
s
5170+
}
5171+
}
5172+
}
5173+
51655174
fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
5166-
#debug("get_item_val: %d", id);
51675175
let tcx = ccx.tcx;
51685176
alt ccx.item_vals.find(id) {
51695177
some(v) { v }
@@ -5242,11 +5250,8 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
52425250
let lldty = T_fn([T_ptr(type_of(ccx, ty::mk_nil(tcx))),
52435251
T_ptr(type_of(ccx, class_ty))],
52445252
llvm::LLVMVoidType());
5245-
/* The symbol for the dtor should have already been registered */
5246-
let s: str = alt ccx.item_symbols.find(id) {
5247-
some(s) { s }
5248-
none { ccx.sess.bug("in get_item_val, dtor is unbound"); }
5249-
};
5253+
let s = get_dtor_symbol(ccx, *pt, dt.node.id);
5254+
52505255
/* Make the declaration for the dtor */
52515256
let llfn = decl_internal_cdecl_fn(ccx.llmod, s, lldty);
52525257
lib::llvm::SetLinkage(llfn, lib::llvm::ExternalLinkage);

0 commit comments

Comments
 (0)