Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "auto merge of #8745 : brson/rust/metadata, r=cmr" #8751

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,7 @@ opt mingw-cross 0 "cross-compile for win32 using mingw"
opt clang 0 "prefer clang to gcc for building the runtime"
opt ccache 0 "invoke gcc/clang via ccache to reuse object files between builds"
opt local-rust 0 "use an installed rustc rather than downloading a snapshot"
opt pax-flags 0 "apply PaX flags to rustc binaries (required for GRSecurity/PaX-patched
kernels)"
opt pax-flags 0 "apply PaX flags to rustc binaries (required for GRSecurity/PaX-patched kernels)"
valopt prefix "/usr/local" "set installation prefix"
valopt local-rust-root "/usr/local" "set prefix for local rust binary"
valopt llvm-root "" "set LLVM root"
Expand Down
77 changes: 20 additions & 57 deletions src/libextra/ebml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@


use std::str;
use std::cast;
use std::vec;

// Simple Extensible Binary Markup Language (ebml) reader and writer on a
// cursor model. See the specification here:
Expand All @@ -31,42 +29,9 @@ struct EbmlState {
data_pos: uint,
}

#[deriving(Clone)]
pub enum EbmlData {
SafeData(@~[u8]),
UnsafeData(*u8, uint)
}

impl EbmlData {
#[inline]
pub fn slice<'a>(&'a self, start: uint, end: uint) -> &'a [u8] {
match *self {
SafeData(@ref v) => v.slice(start, end),
UnsafeData(buf, len) => unsafe {
do vec::raw::buf_as_slice(buf, len) |s| {
cast::transmute(s.slice(start, end))
}
}
}
}

#[inline]
pub fn as_slice<'a>(&'a self) -> &'a [u8] {
self.slice(0, self.len())
}

#[inline]
pub fn len(&self) -> uint {
match *self {
SafeData(@ref v) => v.len(),
UnsafeData(_, len) => len
}
}
}

#[deriving(Clone)]
pub struct Doc {
data: EbmlData,
data: @~[u8],
start: uint,
end: uint,
}
Expand Down Expand Up @@ -220,28 +185,24 @@ pub mod reader {
}

pub fn Doc(data: @~[u8]) -> Doc {
Doc { data: SafeData(data), start: 0u, end: data.len() }
}

pub fn unsafe_Doc(buf: *u8, len: uint) -> Doc {
Doc { data: UnsafeData(buf, len), start: 0u, end: len }
Doc { data: data, start: 0u, end: data.len() }
}

pub fn doc_at(data: &EbmlData, start: uint) -> TaggedDoc {
let elt_tag = vuint_at(data.as_slice(), start);
let elt_size = vuint_at(data.as_slice(), elt_tag.next);
pub fn doc_at(data: @~[u8], start: uint) -> TaggedDoc {
let elt_tag = vuint_at(*data, start);
let elt_size = vuint_at(*data, elt_tag.next);
let end = elt_size.next + elt_size.val;
TaggedDoc {
tag: elt_tag.val,
doc: Doc { data: data.clone(), start: elt_size.next, end: end }
doc: Doc { data: data, start: elt_size.next, end: end }
}
}

pub fn maybe_get_doc(d: Doc, tg: uint) -> Option<Doc> {
let mut pos = d.start;
while pos < d.end {
let elt_tag = vuint_at(d.data.as_slice(), pos);
let elt_size = vuint_at(d.data.as_slice(), elt_tag.next);
let elt_tag = vuint_at(*d.data, pos);
let elt_size = vuint_at(*d.data, elt_tag.next);
pos = elt_size.next + elt_size.val;
if elt_tag.val == tg {
return Some(Doc { data: d.data, start: elt_size.next,
Expand All @@ -264,8 +225,8 @@ pub mod reader {
pub fn docs(d: Doc, it: &fn(uint, Doc) -> bool) -> bool {
let mut pos = d.start;
while pos < d.end {
let elt_tag = vuint_at(d.data.as_slice(), pos);
let elt_size = vuint_at(d.data.as_slice(), elt_tag.next);
let elt_tag = vuint_at(*d.data, pos);
let elt_size = vuint_at(*d.data, elt_tag.next);
pos = elt_size.next + elt_size.val;
let doc = Doc { data: d.data, start: elt_size.next, end: pos };
if !it(elt_tag.val, doc) {
Expand All @@ -278,8 +239,8 @@ pub mod reader {
pub fn tagged_docs(d: Doc, tg: uint, it: &fn(Doc) -> bool) -> bool {
let mut pos = d.start;
while pos < d.end {
let elt_tag = vuint_at(d.data.as_slice(), pos);
let elt_size = vuint_at(d.data.as_slice(), elt_tag.next);
let elt_tag = vuint_at(*d.data, pos);
let elt_size = vuint_at(*d.data, elt_tag.next);
pos = elt_size.next + elt_size.val;
if elt_tag.val == tg {
let doc = Doc { data: d.data, start: elt_size.next,
Expand All @@ -299,22 +260,22 @@ pub mod reader {

pub fn doc_as_u8(d: Doc) -> u8 {
assert_eq!(d.end, d.start + 1u);
d.data.as_slice()[d.start]
(*d.data)[d.start]
}

pub fn doc_as_u16(d: Doc) -> u16 {
assert_eq!(d.end, d.start + 2u);
io::u64_from_be_bytes(d.data.as_slice(), d.start, 2u) as u16
io::u64_from_be_bytes(*d.data, d.start, 2u) as u16
}

pub fn doc_as_u32(d: Doc) -> u32 {
assert_eq!(d.end, d.start + 4u);
io::u64_from_be_bytes(d.data.as_slice(), d.start, 4u) as u32
io::u64_from_be_bytes(*d.data, d.start, 4u) as u32
}

pub fn doc_as_u64(d: Doc) -> u64 {
assert_eq!(d.end, d.start + 8u);
io::u64_from_be_bytes(d.data.as_slice(), d.start, 8u)
io::u64_from_be_bytes(*d.data, d.start, 8u)
}

pub fn doc_as_i8(d: Doc) -> i8 { doc_as_u8(d) as i8 }
Expand All @@ -337,7 +298,8 @@ pub mod reader {
impl Decoder {
fn _check_label(&mut self, lbl: &str) {
if self.pos < self.parent.end {
let TaggedDoc { tag: r_tag, doc: r_doc } = doc_at(&self.parent.data, self.pos);
let TaggedDoc { tag: r_tag, doc: r_doc } =
doc_at(self.parent.data, self.pos);

if r_tag == (EsLabel as uint) {
self.pos = r_doc.end;
Expand All @@ -354,7 +316,8 @@ pub mod reader {
if self.pos >= self.parent.end {
fail!("no more documents in current node!");
}
let TaggedDoc { tag: r_tag, doc: r_doc } = doc_at(&self.parent.data, self.pos);
let TaggedDoc { tag: r_tag, doc: r_doc } =
doc_at(self.parent.data, self.pos);
debug!("self.parent=%?-%? self.pos=%? r_tag=%? r_doc=%?-%?",
self.parent.start,
self.parent.end,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ pub fn build_session_options(binary: @str,
parse_only: parse_only,
no_trans: no_trans,
debugging_opts: debugging_opts,
android_cross_path: android_cross_path,
android_cross_path: android_cross_path
};
return sopts;
}
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use metadata::cstore;
use metadata::decoder;
use metadata::filesearch::FileSearch;
use metadata::loader;
use metadata::loader::MetadataSection;

use std::hashmap::HashMap;
use syntax::ast;
Expand Down Expand Up @@ -309,7 +308,7 @@ fn resolve_crate(e: @mut Env,
}

// Go through the crate metadata and load any crates that it references
fn resolve_crate_deps(e: @mut Env, cdata: MetadataSection) -> cstore::cnum_map {
fn resolve_crate_deps(e: @mut Env, cdata: @~[u8]) -> cstore::cnum_map {
debug!("resolving deps of external crate");
// The map from crate numbers in the crate we're resolving to local crate
// numbers
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/csearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ pub fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id,
def: ast::def_id) -> ty::ty_param_bounds_and_ty {
let cstore = tcx.cstore;
let cdata = cstore::get_crate_data(cstore, class_id.crate);
let all_items = reader::get_doc(decoder::section_to_ebml_doc(cdata.data), tag_items);
let all_items = reader::get_doc(reader::Doc(cdata.data), tag_items);
debug!("Looking up %?", class_id);
let class_doc = expect(tcx.diag,
decoder::maybe_find_item(class_id.node, all_items),
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/metadata/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

use metadata::cstore;
use metadata::decoder;
use metadata::loader::MetadataSection;

use std::hashmap::HashMap;
use extra;
Expand All @@ -30,7 +29,7 @@ pub type cnum_map = @mut HashMap<ast::CrateNum, ast::CrateNum>;

pub struct crate_metadata {
name: @str,
data: MetadataSection,
data: @~[u8],
cnum_map: cnum_map,
cnum: ast::CrateNum
}
Expand Down
Loading