mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-01 13:18:54 +01:00
Encode both private and public class fields in metadata
This is necessary to calculate the correct offsets for field references. Simple cross-crate class tests (still with fields only) now pass.
This commit is contained in:
parent
16dd6c4756
commit
e3a1c5c96a
@ -405,12 +405,8 @@ fn get_iface_methods(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
|
||||
@result
|
||||
}
|
||||
|
||||
/*
|
||||
FIXME
|
||||
This is not working. metadata is broken -- fields get encoded correctly,
|
||||
but not decoded. look at this code, see what it's actually writing out
|
||||
also see what "data" is
|
||||
*/
|
||||
/* Take a node ID for a class, return a vector of the class's
|
||||
member types */
|
||||
fn get_class_items(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
|
||||
-> [@ty::class_item_ty] {
|
||||
let data = cdata.data;
|
||||
|
@ -358,9 +358,9 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
encode_name(ebml_w, name);
|
||||
|
||||
for ci in items {
|
||||
alt ci.node.privacy {
|
||||
pub {
|
||||
ebml_w.start_tag(tag_items_class_member); // ???
|
||||
/* We encode both private and public fields -- need to include
|
||||
private fields to get the offsets right */
|
||||
ebml_w.start_tag(tag_items_class_member);
|
||||
alt ci.node.decl {
|
||||
instance_var(nm, _, _, id) {
|
||||
#debug("encode_info_for_class: doing %s %d", nm, id);
|
||||
@ -383,11 +383,6 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
}
|
||||
}
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
priv {
|
||||
/* don't export it, then! */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4128,7 +4128,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
|
||||
// Register a type for obj
|
||||
smallintmap::insert(*ccx.tcx.node_types,
|
||||
rslt_loc_.id as uint, rslt_ty);
|
||||
// Create the decl statement that initializers obj
|
||||
// Create the decl statement that initializes obj
|
||||
let rslt_loc : @ast::local =
|
||||
@{node: rslt_loc_, span: ctor.node.body.span};
|
||||
let rslt_decl_ : ast::decl_ = ast::decl_local([rslt_loc]);
|
||||
|
@ -2437,11 +2437,7 @@ fn lookup_item_type(cx: ctxt, did: ast::def_id) -> ty_param_bounds_and_ty {
|
||||
// Look up the list of item types for a given class
|
||||
// Fails if the id is not bound to a class.
|
||||
fn lookup_class_item_tys(cx: ctxt, did: ast::def_id) -> [@class_item_ty] {
|
||||
/*
|
||||
TODO: Check whether this is a local id or not; use csearch / tcache
|
||||
if it's external
|
||||
*/
|
||||
if did.crate == ast::local_crate {
|
||||
if did.crate == ast::local_crate {
|
||||
alt cx.items.find(did.node) {
|
||||
some(ast_map::node_item(i,_)) {
|
||||
alt i.node {
|
||||
@ -2454,7 +2450,7 @@ fn lookup_class_item_tys(cx: ctxt, did: ast::def_id) -> [@class_item_ty] {
|
||||
_ { cx.sess.bug("class ID not bound to an item"); }
|
||||
}
|
||||
}
|
||||
else {
|
||||
else {
|
||||
ret csearch::get_class_items(cx, did);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
// xfail-test
|
||||
// xfail-fast
|
||||
// aux-build:cci_class.rs
|
||||
use cci_class;
|
||||
|
@ -1,5 +1,3 @@
|
||||
// xfail-test FIXME: Needs metadata encoding
|
||||
|
||||
class cat {
|
||||
priv {
|
||||
let mutable meows : uint;
|
||||
|
Loading…
Reference in New Issue
Block a user