Generate drop glue correctly for classes with destructors
This commit is contained in:
parent
5d625af9f9
commit
fa5cc5bcd0
11 changed files with 171 additions and 30 deletions
|
|
@ -95,6 +95,7 @@ const tag_mod_impl_iface: uint = 0x47u;
|
|||
different tags.
|
||||
*/
|
||||
const tag_item_impl_method: uint = 0x48u;
|
||||
const tag_item_dtor: uint = 0x49u;
|
||||
|
||||
// used to encode crate_ctxt side tables
|
||||
enum astencode_tag { // Reserves 0x50 -- 0x6f
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import driver::session::expect;
|
|||
import common::*;
|
||||
import std::map::hashmap;
|
||||
|
||||
export class_dtor;
|
||||
export get_symbol;
|
||||
export get_class_fields;
|
||||
export get_class_method;
|
||||
|
|
@ -185,6 +186,12 @@ fn get_class_method(cstore: cstore::cstore, def: ast::def_id, mname: str)
|
|||
decoder::get_class_method(cdata, def.node, mname)
|
||||
}
|
||||
|
||||
/* If def names a class with a dtor, return it. Otherwise, return none. */
|
||||
fn class_dtor(cstore: cstore::cstore, def: ast::def_id)
|
||||
-> option<ast::def_id> {
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
decoder::class_dtor(cdata, def.node)
|
||||
}
|
||||
// Local Variables:
|
||||
// mode: rust
|
||||
// fill-column: 78;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import util::ppaux::ty_to_str;
|
|||
import ebml::deserializer;
|
||||
import syntax::diagnostic::span_handler;
|
||||
|
||||
export class_dtor;
|
||||
export get_class_fields;
|
||||
export get_symbol;
|
||||
export get_enum_variants;
|
||||
|
|
@ -331,6 +332,19 @@ fn get_class_method(cdata: cmd, id: ast::node_id, name: str) -> ast::def_id {
|
|||
}
|
||||
}
|
||||
|
||||
fn class_dtor(cdata: cmd, id: ast::node_id) -> option<ast::def_id> {
|
||||
let items = ebml::get_doc(ebml::doc(cdata.data), tag_items);
|
||||
let cls_items = alt maybe_find_item(id, items) {
|
||||
some(it) { it }
|
||||
none { ret none; }};
|
||||
let mut rslt = none;
|
||||
ebml::tagged_docs(cls_items, tag_item_dtor) {|f|
|
||||
let did = parse_def_id(ebml::doc_data(f));
|
||||
rslt = some(translate_def_id(cdata, did));
|
||||
}
|
||||
rslt
|
||||
}
|
||||
|
||||
fn get_symbol(data: @[u8], id: ast::node_id) -> str {
|
||||
ret item_symbol(lookup_item(id, data));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,8 +201,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
|
|||
encode_def_id(ebml_w, local_def(it.id));
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
// FIXME: I don't *think* dtor needs to be serialized?
|
||||
item_class(_, _, items, ctor, _dtor, _) {
|
||||
item_class(_, _, items, ctor, m_dtor, _) {
|
||||
add_to_index(ebml_w, path, index, it.ident);
|
||||
ebml_w.start_tag(tag_paths_data_item);
|
||||
encode_name(ebml_w, it.ident);
|
||||
|
|
@ -212,6 +211,12 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
|
|||
add_to_index(ebml_w, path, index, it.ident);
|
||||
#debug("ctor id: %d", ctor.node.id);
|
||||
encode_named_def_id(ebml_w, it.ident, local_def(ctor.node.id));
|
||||
/* Encode id for dtor */
|
||||
option::iter(m_dtor) {|dtor|
|
||||
ebml_w.start_tag(tag_item_dtor);
|
||||
encode_def_id(ebml_w, local_def(dtor.node.id));
|
||||
ebml_w.end_tag();
|
||||
};
|
||||
encode_class_item_paths(ebml_w, items, path + [it.ident],
|
||||
index);
|
||||
ebml_w.end_tag();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue