CamelCasify lots of std
This commit is contained in:
committed by
Brian Anderson
parent
ecb646477b
commit
a605fd0cad
@@ -421,7 +421,7 @@ fn host_triple() -> ~str {
|
||||
};
|
||||
}
|
||||
|
||||
fn build_session_options(matches: getopts::matches,
|
||||
fn build_session_options(matches: getopts::Matches,
|
||||
demitter: diagnostic::emitter) -> @session::options {
|
||||
let crate_type = if opt_present(matches, ~"lib") {
|
||||
session::lib_crate
|
||||
@@ -605,7 +605,7 @@ fn parse_pretty(sess: session, &&name: ~str) -> pp_mode {
|
||||
}
|
||||
}
|
||||
|
||||
fn opts() -> ~[getopts::opt] {
|
||||
fn opts() -> ~[getopts::Opt] {
|
||||
return ~[optflag(~"h"), optflag(~"help"),
|
||||
optflag(~"v"), optflag(~"version"),
|
||||
optflag(~"emit-llvm"), optflagopt(~"pretty"),
|
||||
|
||||
@@ -63,8 +63,8 @@ export translate_def_id;
|
||||
// what crate that's in and give us a def_id that makes sense for the current
|
||||
// build.
|
||||
|
||||
fn lookup_hash(d: ebml::doc, eq_fn: fn(x:&[u8]) -> bool, hash: uint) ->
|
||||
Option<ebml::doc> {
|
||||
fn lookup_hash(d: ebml::Doc, eq_fn: fn(x:&[u8]) -> bool, hash: uint) ->
|
||||
Option<ebml::Doc> {
|
||||
let index = ebml::get_doc(d, tag_index);
|
||||
let table = ebml::get_doc(index, tag_index_table);
|
||||
let hash_pos = table.start + hash % 256u * 4u;
|
||||
@@ -81,7 +81,7 @@ fn lookup_hash(d: ebml::doc, eq_fn: fn(x:&[u8]) -> bool, hash: uint) ->
|
||||
None
|
||||
}
|
||||
|
||||
fn maybe_find_item(item_id: int, items: ebml::doc) -> Option<ebml::doc> {
|
||||
fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option<ebml::Doc> {
|
||||
fn eq_item(bytes: &[u8], item_id: int) -> bool {
|
||||
return io::u64_from_be_bytes(vec::view(bytes, 0u, 4u), 0u, 4u) as int
|
||||
== item_id;
|
||||
@@ -91,13 +91,13 @@ fn maybe_find_item(item_id: int, items: ebml::doc) -> Option<ebml::doc> {
|
||||
hash_node_id(item_id))
|
||||
}
|
||||
|
||||
fn find_item(item_id: int, items: ebml::doc) -> ebml::doc {
|
||||
fn find_item(item_id: int, items: ebml::Doc) -> ebml::Doc {
|
||||
return option::get(maybe_find_item(item_id, items));
|
||||
}
|
||||
|
||||
// Looks up an item in the given metadata and returns an ebml doc pointing
|
||||
// to the item data.
|
||||
fn lookup_item(item_id: int, data: @~[u8]) -> ebml::doc {
|
||||
fn lookup_item(item_id: int, data: @~[u8]) -> ebml::Doc {
|
||||
let items = ebml::get_doc(ebml::doc(data), tag_items);
|
||||
match maybe_find_item(item_id, items) {
|
||||
None => fail(fmt!("lookup_item: id not found: %d", item_id)),
|
||||
@@ -129,7 +129,7 @@ enum Family {
|
||||
InheritedField // N
|
||||
}
|
||||
|
||||
fn item_family(item: ebml::doc) -> Family {
|
||||
fn item_family(item: ebml::Doc) -> Family {
|
||||
let fam = ebml::get_doc(item, tag_items_data_item_family);
|
||||
match ebml::doc_as_u8(fam) as char {
|
||||
'c' => Const,
|
||||
@@ -157,25 +157,25 @@ fn item_family(item: ebml::doc) -> Family {
|
||||
}
|
||||
}
|
||||
|
||||
fn item_symbol(item: ebml::doc) -> ~str {
|
||||
fn item_symbol(item: ebml::Doc) -> ~str {
|
||||
let sym = ebml::get_doc(item, tag_items_data_item_symbol);
|
||||
return str::from_bytes(ebml::doc_data(sym));
|
||||
}
|
||||
|
||||
fn item_parent_item(d: ebml::doc) -> Option<ast::def_id> {
|
||||
fn item_parent_item(d: ebml::Doc) -> Option<ast::def_id> {
|
||||
for ebml::tagged_docs(d, tag_items_data_parent_item) |did| {
|
||||
return Some(ebml::with_doc_data(did, |d| parse_def_id(d)));
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn item_def_id(d: ebml::doc, cdata: cmd) -> ast::def_id {
|
||||
fn item_def_id(d: ebml::Doc, cdata: cmd) -> ast::def_id {
|
||||
let tagdoc = ebml::get_doc(d, tag_def_id);
|
||||
return translate_def_id(cdata, ebml::with_doc_data(tagdoc,
|
||||
|d| parse_def_id(d)));
|
||||
}
|
||||
|
||||
fn each_reexport(d: ebml::doc, f: fn(ebml::doc) -> bool) {
|
||||
fn each_reexport(d: ebml::Doc, f: fn(ebml::Doc) -> bool) {
|
||||
for ebml::tagged_docs(d, tag_items_data_item_reexport) |reexport_doc| {
|
||||
if !f(reexport_doc) {
|
||||
return;
|
||||
@@ -183,7 +183,7 @@ fn each_reexport(d: ebml::doc, f: fn(ebml::doc) -> bool) {
|
||||
}
|
||||
}
|
||||
|
||||
fn field_mutability(d: ebml::doc) -> ast::class_mutability {
|
||||
fn field_mutability(d: ebml::Doc) -> ast::class_mutability {
|
||||
// Use maybe_get_doc in case it's a method
|
||||
option::map_default(
|
||||
ebml::maybe_get_doc(d, tag_class_mut),
|
||||
@@ -196,20 +196,20 @@ fn field_mutability(d: ebml::doc) -> ast::class_mutability {
|
||||
})
|
||||
}
|
||||
|
||||
fn variant_disr_val(d: ebml::doc) -> Option<int> {
|
||||
fn variant_disr_val(d: ebml::Doc) -> Option<int> {
|
||||
do option::chain(ebml::maybe_get_doc(d, tag_disr_val)) |val_doc| {
|
||||
int::parse_buf(ebml::doc_data(val_doc), 10u)
|
||||
}
|
||||
}
|
||||
|
||||
fn doc_type(doc: ebml::doc, tcx: ty::ctxt, cdata: cmd) -> ty::t {
|
||||
fn doc_type(doc: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ty::t {
|
||||
let tp = ebml::get_doc(doc, tag_items_data_item_type);
|
||||
parse_ty_data(tp.data, cdata.cnum, tp.start, tcx, |did| {
|
||||
translate_def_id(cdata, did)
|
||||
})
|
||||
}
|
||||
|
||||
fn item_type(item_id: ast::def_id, item: ebml::doc,
|
||||
fn item_type(item_id: ast::def_id, item: ebml::Doc,
|
||||
tcx: ty::ctxt, cdata: cmd) -> ty::t {
|
||||
let t = doc_type(item, tcx, cdata);
|
||||
if family_names_type(item_family(item)) {
|
||||
@@ -217,7 +217,7 @@ fn item_type(item_id: ast::def_id, item: ebml::doc,
|
||||
} else { t }
|
||||
}
|
||||
|
||||
fn item_impl_traits(item: ebml::doc, tcx: ty::ctxt, cdata: cmd) -> ~[ty::t] {
|
||||
fn item_impl_traits(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd) -> ~[ty::t] {
|
||||
let mut results = ~[];
|
||||
for ebml::tagged_docs(item, tag_impl_trait) |ity| {
|
||||
vec::push(results, doc_type(ity, tcx, cdata));
|
||||
@@ -225,7 +225,7 @@ fn item_impl_traits(item: ebml::doc, tcx: ty::ctxt, cdata: cmd) -> ~[ty::t] {
|
||||
results
|
||||
}
|
||||
|
||||
fn item_ty_param_bounds(item: ebml::doc, tcx: ty::ctxt, cdata: cmd)
|
||||
fn item_ty_param_bounds(item: ebml::Doc, tcx: ty::ctxt, cdata: cmd)
|
||||
-> @~[ty::param_bounds] {
|
||||
let mut bounds = ~[];
|
||||
for ebml::tagged_docs(item, tag_items_data_item_ty_param_bounds) |p| {
|
||||
@@ -237,21 +237,21 @@ fn item_ty_param_bounds(item: ebml::doc, tcx: ty::ctxt, cdata: cmd)
|
||||
@bounds
|
||||
}
|
||||
|
||||
fn item_ty_region_param(item: ebml::doc) -> Option<ty::region_variance> {
|
||||
fn item_ty_region_param(item: ebml::Doc) -> Option<ty::region_variance> {
|
||||
ebml::maybe_get_doc(item, tag_region_param).map(|doc| {
|
||||
let d = ebml::ebml_deserializer(doc);
|
||||
ty::deserialize_region_variance(d)
|
||||
})
|
||||
}
|
||||
|
||||
fn item_ty_param_count(item: ebml::doc) -> uint {
|
||||
fn item_ty_param_count(item: ebml::Doc) -> uint {
|
||||
let mut n = 0u;
|
||||
ebml::tagged_docs(item, tag_items_data_item_ty_param_bounds,
|
||||
|_p| { n += 1u; true } );
|
||||
n
|
||||
}
|
||||
|
||||
fn enum_variant_ids(item: ebml::doc, cdata: cmd) -> ~[ast::def_id] {
|
||||
fn enum_variant_ids(item: ebml::Doc, cdata: cmd) -> ~[ast::def_id] {
|
||||
let mut ids: ~[ast::def_id] = ~[];
|
||||
let v = tag_items_data_item_variant;
|
||||
for ebml::tagged_docs(item, v) |p| {
|
||||
@@ -261,7 +261,7 @@ fn enum_variant_ids(item: ebml::doc, cdata: cmd) -> ~[ast::def_id] {
|
||||
return ids;
|
||||
}
|
||||
|
||||
fn item_path(intr: ident_interner, item_doc: ebml::doc) -> ast_map::path {
|
||||
fn item_path(intr: ident_interner, item_doc: ebml::Doc) -> ast_map::path {
|
||||
let path_doc = ebml::get_doc(item_doc, tag_path);
|
||||
|
||||
let len_doc = ebml::get_doc(path_doc, tag_path_len);
|
||||
@@ -285,12 +285,12 @@ fn item_path(intr: ident_interner, item_doc: ebml::doc) -> ast_map::path {
|
||||
return result;
|
||||
}
|
||||
|
||||
fn item_name(intr: ident_interner, item: ebml::doc) -> ast::ident {
|
||||
fn item_name(intr: ident_interner, item: ebml::Doc) -> ast::ident {
|
||||
let name = ebml::get_doc(item, tag_paths_data_name);
|
||||
intr.intern(@str::from_bytes(ebml::doc_data(name)))
|
||||
}
|
||||
|
||||
fn item_to_def_like(item: ebml::doc, did: ast::def_id, cnum: ast::crate_num)
|
||||
fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::crate_num)
|
||||
-> def_like {
|
||||
let fam = item_family(item);
|
||||
match fam {
|
||||
@@ -533,7 +533,7 @@ type decode_inlined_item = fn(
|
||||
cdata: cstore::crate_metadata,
|
||||
tcx: ty::ctxt,
|
||||
path: ast_map::path,
|
||||
par_doc: ebml::doc) -> Option<ast::inlined_item>;
|
||||
par_doc: ebml::Doc) -> Option<ast::inlined_item>;
|
||||
|
||||
fn maybe_get_item_ast(intr: ident_interner, cdata: cmd, tcx: ty::ctxt,
|
||||
id: ast::node_id,
|
||||
@@ -602,7 +602,7 @@ type method_info = {
|
||||
|
||||
type _impl = {did: ast::def_id, ident: ast::ident, methods: ~[@method_info]};
|
||||
|
||||
fn get_self_ty(item: ebml::doc) -> ast::self_ty_ {
|
||||
fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ {
|
||||
fn get_mutability(ch: u8) -> ast::mutability {
|
||||
match ch as char {
|
||||
'i' => { ast::m_imm }
|
||||
@@ -631,7 +631,7 @@ fn get_self_ty(item: ebml::doc) -> ast::self_ty_ {
|
||||
}
|
||||
}
|
||||
|
||||
fn item_impl_methods(intr: ident_interner, cdata: cmd, item: ebml::doc,
|
||||
fn item_impl_methods(intr: ident_interner, cdata: cmd, item: ebml::Doc,
|
||||
base_tps: uint) -> ~[@method_info] {
|
||||
let mut rslt = ~[];
|
||||
for ebml::tagged_docs(item, tag_item_impl_method) |doc| {
|
||||
@@ -780,7 +780,7 @@ fn family_names_type(fam: Family) -> bool {
|
||||
match fam { Type | Mod | Trait => true, _ => false }
|
||||
}
|
||||
|
||||
fn read_path(d: ebml::doc) -> {path: ~str, pos: uint} {
|
||||
fn read_path(d: ebml::Doc) -> {path: ~str, pos: uint} {
|
||||
let desc = ebml::doc_data(d);
|
||||
let pos = io::u64_from_be_bytes(desc, 0u, 4u) as uint;
|
||||
let pathbytes = vec::slice::<u8>(desc, 4u, vec::len::<u8>(desc));
|
||||
@@ -788,7 +788,7 @@ fn read_path(d: ebml::doc) -> {path: ~str, pos: uint} {
|
||||
return {path: path, pos: pos};
|
||||
}
|
||||
|
||||
fn describe_def(items: ebml::doc, id: ast::def_id) -> ~str {
|
||||
fn describe_def(items: ebml::Doc, id: ast::def_id) -> ~str {
|
||||
if id.crate != ast::local_crate { return ~"external"; }
|
||||
let it = match maybe_find_item(id.node, items) {
|
||||
Some(it) => it,
|
||||
@@ -823,7 +823,7 @@ fn item_family_to_str(fam: Family) -> ~str {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_meta_items(md: ebml::doc) -> ~[@ast::meta_item] {
|
||||
fn get_meta_items(md: ebml::Doc) -> ~[@ast::meta_item] {
|
||||
let mut items: ~[@ast::meta_item] = ~[];
|
||||
for ebml::tagged_docs(md, tag_meta_item_word) |meta_item_doc| {
|
||||
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
|
||||
@@ -848,7 +848,7 @@ fn get_meta_items(md: ebml::doc) -> ~[@ast::meta_item] {
|
||||
return items;
|
||||
}
|
||||
|
||||
fn get_attributes(md: ebml::doc) -> ~[ast::attribute] {
|
||||
fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] {
|
||||
let mut attrs: ~[ast::attribute] = ~[];
|
||||
match ebml::maybe_get_doc(md, tag_attributes) {
|
||||
option::Some(attrs_d) => {
|
||||
@@ -870,13 +870,13 @@ fn get_attributes(md: ebml::doc) -> ~[ast::attribute] {
|
||||
}
|
||||
|
||||
fn list_meta_items(intr: ident_interner,
|
||||
meta_items: ebml::doc, out: io::Writer) {
|
||||
meta_items: ebml::Doc, out: io::Writer) {
|
||||
for get_meta_items(meta_items).each |mi| {
|
||||
out.write_str(fmt!("%s\n", pprust::meta_item_to_str(mi, intr)));
|
||||
}
|
||||
}
|
||||
|
||||
fn list_crate_attributes(intr: ident_interner, md: ebml::doc, hash: ~str,
|
||||
fn list_crate_attributes(intr: ident_interner, md: ebml::Doc, hash: ~str,
|
||||
out: io::Writer) {
|
||||
out.write_str(fmt!("=Crate Attributes (%s)=\n", hash));
|
||||
|
||||
@@ -899,7 +899,7 @@ fn get_crate_deps(intr: ident_interner, data: @~[u8]) -> ~[crate_dep] {
|
||||
let cratedoc = ebml::doc(data);
|
||||
let depsdoc = ebml::get_doc(cratedoc, tag_crate_deps);
|
||||
let mut crate_num = 1;
|
||||
fn docstr(doc: ebml::doc, tag_: uint) -> ~str {
|
||||
fn docstr(doc: ebml::Doc, tag_: uint) -> ~str {
|
||||
str::from_bytes(ebml::doc_data(ebml::get_doc(doc, tag_)))
|
||||
}
|
||||
for ebml::tagged_docs(depsdoc, tag_crate_dep) |depdoc| {
|
||||
|
||||
@@ -5,7 +5,7 @@ import util::ppaux::ty_to_str;
|
||||
import std::{ebml, map};
|
||||
import std::map::hashmap;
|
||||
import io::WriterUtil;
|
||||
import ebml::writer;
|
||||
import ebml::Writer;
|
||||
import syntax::ast::*;
|
||||
import syntax::print::pprust;
|
||||
import syntax::{ast_util, visit};
|
||||
@@ -37,7 +37,7 @@ export encode_def_id;
|
||||
type abbrev_map = map::hashmap<ty::t, tyencode::ty_abbrev>;
|
||||
|
||||
type encode_inlined_item = fn@(ecx: @encode_ctxt,
|
||||
ebml_w: ebml::writer,
|
||||
ebml_w: ebml::Writer,
|
||||
path: ast_map::path,
|
||||
ii: ast::inlined_item);
|
||||
|
||||
@@ -86,15 +86,15 @@ fn reachable(ecx: @encode_ctxt, id: node_id) -> bool {
|
||||
ecx.reachable.contains_key(id)
|
||||
}
|
||||
|
||||
fn encode_name(ecx: @encode_ctxt, ebml_w: ebml::writer, name: ident) {
|
||||
fn encode_name(ecx: @encode_ctxt, ebml_w: ebml::Writer, name: ident) {
|
||||
ebml_w.wr_tagged_str(tag_paths_data_name, ecx.tcx.sess.str_of(name));
|
||||
}
|
||||
|
||||
fn encode_def_id(ebml_w: ebml::writer, id: def_id) {
|
||||
fn encode_def_id(ebml_w: ebml::Writer, id: def_id) {
|
||||
ebml_w.wr_tagged_str(tag_def_id, def_to_str(id));
|
||||
}
|
||||
|
||||
fn encode_region_param(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
fn encode_region_param(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
it: @ast::item) {
|
||||
let opt_rp = ecx.tcx.region_paramd_items.find(it.id);
|
||||
for opt_rp.each |rp| {
|
||||
@@ -104,7 +104,7 @@ fn encode_region_param(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_mutability(ebml_w: ebml::writer, mt: class_mutability) {
|
||||
fn encode_mutability(ebml_w: ebml::Writer, mt: class_mutability) {
|
||||
do ebml_w.wr_tag(tag_class_mut) {
|
||||
let val = match mt {
|
||||
class_immutable => 'a',
|
||||
@@ -116,7 +116,7 @@ fn encode_mutability(ebml_w: ebml::writer, mt: class_mutability) {
|
||||
|
||||
type entry<T> = {val: T, pos: uint};
|
||||
|
||||
fn add_to_index(ecx: @encode_ctxt, ebml_w: ebml::writer, path: &[ident],
|
||||
fn add_to_index(ecx: @encode_ctxt, ebml_w: ebml::Writer, path: &[ident],
|
||||
&index: ~[entry<~str>], name: ident) {
|
||||
let mut full_path = ~[];
|
||||
vec::push_all(full_path, path);
|
||||
@@ -127,7 +127,7 @@ fn add_to_index(ecx: @encode_ctxt, ebml_w: ebml::writer, path: &[ident],
|
||||
pos: ebml_w.writer.tell()});
|
||||
}
|
||||
|
||||
fn encode_trait_ref(ebml_w: ebml::writer, ecx: @encode_ctxt, t: @trait_ref) {
|
||||
fn encode_trait_ref(ebml_w: ebml::Writer, ecx: @encode_ctxt, t: @trait_ref) {
|
||||
ebml_w.start_tag(tag_impl_trait);
|
||||
encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, t.ref_id));
|
||||
ebml_w.end_tag();
|
||||
@@ -135,7 +135,7 @@ fn encode_trait_ref(ebml_w: ebml::writer, ecx: @encode_ctxt, t: @trait_ref) {
|
||||
|
||||
|
||||
// Item info table encoding
|
||||
fn encode_family(ebml_w: ebml::writer, c: char) {
|
||||
fn encode_family(ebml_w: ebml::Writer, c: char) {
|
||||
ebml_w.start_tag(tag_items_data_item_family);
|
||||
ebml_w.writer.write(&[c as u8]);
|
||||
ebml_w.end_tag();
|
||||
@@ -143,7 +143,7 @@ fn encode_family(ebml_w: ebml::writer, c: char) {
|
||||
|
||||
fn def_to_str(did: def_id) -> ~str { fmt!("%d:%d", did.crate, did.node) }
|
||||
|
||||
fn encode_ty_type_param_bounds(ebml_w: ebml::writer, ecx: @encode_ctxt,
|
||||
fn encode_ty_type_param_bounds(ebml_w: ebml::Writer, ecx: @encode_ctxt,
|
||||
params: @~[ty::param_bounds]) {
|
||||
let ty_str_ctxt = @{diag: ecx.diag,
|
||||
ds: def_to_str,
|
||||
@@ -157,7 +157,7 @@ fn encode_ty_type_param_bounds(ebml_w: ebml::writer, ecx: @encode_ctxt,
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_type_param_bounds(ebml_w: ebml::writer, ecx: @encode_ctxt,
|
||||
fn encode_type_param_bounds(ebml_w: ebml::Writer, ecx: @encode_ctxt,
|
||||
params: ~[ty_param]) {
|
||||
let ty_param_bounds =
|
||||
@params.map(|param| ecx.tcx.ty_param_bounds.get(param.id));
|
||||
@@ -165,13 +165,13 @@ fn encode_type_param_bounds(ebml_w: ebml::writer, ecx: @encode_ctxt,
|
||||
}
|
||||
|
||||
|
||||
fn encode_variant_id(ebml_w: ebml::writer, vid: def_id) {
|
||||
fn encode_variant_id(ebml_w: ebml::Writer, vid: def_id) {
|
||||
ebml_w.start_tag(tag_items_data_item_variant);
|
||||
ebml_w.writer.write(str::to_bytes(def_to_str(vid)));
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn write_type(ecx: @encode_ctxt, ebml_w: ebml::writer, typ: ty::t) {
|
||||
fn write_type(ecx: @encode_ctxt, ebml_w: ebml::Writer, typ: ty::t) {
|
||||
let ty_str_ctxt =
|
||||
@{diag: ecx.diag,
|
||||
ds: def_to_str,
|
||||
@@ -181,13 +181,13 @@ fn write_type(ecx: @encode_ctxt, ebml_w: ebml::writer, typ: ty::t) {
|
||||
tyencode::enc_ty(ebml_w.writer, ty_str_ctxt, typ);
|
||||
}
|
||||
|
||||
fn encode_type(ecx: @encode_ctxt, ebml_w: ebml::writer, typ: ty::t) {
|
||||
fn encode_type(ecx: @encode_ctxt, ebml_w: ebml::Writer, typ: ty::t) {
|
||||
ebml_w.start_tag(tag_items_data_item_type);
|
||||
write_type(ecx, ebml_w, typ);
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_symbol(ecx: @encode_ctxt, ebml_w: ebml::writer, id: node_id) {
|
||||
fn encode_symbol(ecx: @encode_ctxt, ebml_w: ebml::Writer, id: node_id) {
|
||||
ebml_w.start_tag(tag_items_data_item_symbol);
|
||||
let sym = match ecx.item_symbols.find(id) {
|
||||
Some(x) => x,
|
||||
@@ -200,25 +200,25 @@ fn encode_symbol(ecx: @encode_ctxt, ebml_w: ebml::writer, id: node_id) {
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_discriminant(ecx: @encode_ctxt, ebml_w: ebml::writer, id: node_id) {
|
||||
fn encode_discriminant(ecx: @encode_ctxt, ebml_w: ebml::Writer, id: node_id) {
|
||||
ebml_w.start_tag(tag_items_data_item_symbol);
|
||||
ebml_w.writer.write(str::to_bytes(ecx.discrim_symbols.get(id)));
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_disr_val(_ecx: @encode_ctxt, ebml_w: ebml::writer, disr_val: int) {
|
||||
fn encode_disr_val(_ecx: @encode_ctxt, ebml_w: ebml::Writer, disr_val: int) {
|
||||
ebml_w.start_tag(tag_disr_val);
|
||||
ebml_w.writer.write(str::to_bytes(int::to_str(disr_val,10u)));
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_parent_item(ebml_w: ebml::writer, id: def_id) {
|
||||
fn encode_parent_item(ebml_w: ebml::Writer, id: def_id) {
|
||||
ebml_w.start_tag(tag_items_data_parent_item);
|
||||
ebml_w.writer.write(str::to_bytes(def_to_str(id)));
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_enum_variant_info(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
fn encode_enum_variant_info(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
id: node_id, variants: ~[variant],
|
||||
path: ast_map::path, index: @mut ~[entry<int>],
|
||||
ty_params: ~[ty_param]) {
|
||||
@@ -255,9 +255,9 @@ fn encode_enum_variant_info(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_path(ecx: @encode_ctxt, ebml_w: ebml::writer, path: ast_map::path,
|
||||
fn encode_path(ecx: @encode_ctxt, ebml_w: ebml::Writer, path: ast_map::path,
|
||||
name: ast_map::path_elt) {
|
||||
fn encode_path_elt(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
fn encode_path_elt(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
elt: ast_map::path_elt) {
|
||||
let (tag, name) = match elt {
|
||||
ast_map::path_mod(name) => (tag_path_elt_mod, name),
|
||||
@@ -274,7 +274,7 @@ fn encode_path(ecx: @encode_ctxt, ebml_w: ebml::writer, path: ast_map::path,
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod,
|
||||
fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::Writer, md: _mod,
|
||||
id: node_id, path: ast_map::path, name: ident) {
|
||||
ebml_w.start_tag(tag_items_data_item);
|
||||
encode_def_id(ebml_w, local_def(id));
|
||||
@@ -332,7 +332,7 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod,
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_visibility(ebml_w: ebml::writer, visibility: visibility) {
|
||||
fn encode_visibility(ebml_w: ebml::Writer, visibility: visibility) {
|
||||
encode_family(ebml_w, match visibility {
|
||||
public => 'g',
|
||||
private => 'j',
|
||||
@@ -340,7 +340,7 @@ fn encode_visibility(ebml_w: ebml::writer, visibility: visibility) {
|
||||
});
|
||||
}
|
||||
|
||||
fn encode_self_type(ebml_w: ebml::writer, self_type: ast::self_ty_) {
|
||||
fn encode_self_type(ebml_w: ebml::Writer, self_type: ast::self_ty_) {
|
||||
ebml_w.start_tag(tag_item_trait_method_self_ty);
|
||||
|
||||
// Encode the base self type.
|
||||
@@ -373,7 +373,7 @@ fn encode_self_type(ebml_w: ebml::writer, self_type: ast::self_ty_) {
|
||||
}
|
||||
|
||||
/* Returns an index of items in this class */
|
||||
fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
id: node_id, path: ast_map::path,
|
||||
class_tps: ~[ty_param],
|
||||
fields: ~[@struct_field],
|
||||
@@ -429,7 +429,7 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
}
|
||||
|
||||
// This is for encoding info for ctors and dtors
|
||||
fn encode_info_for_ctor(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
fn encode_info_for_ctor(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
id: node_id, ident: ident, path: ast_map::path,
|
||||
item: Option<inlined_item>, tps: ~[ty_param]) {
|
||||
ebml_w.start_tag(tag_items_data_item);
|
||||
@@ -454,7 +454,7 @@ fn encode_info_for_ctor(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_info_for_method(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
fn encode_info_for_method(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
impl_path: ast_map::path, should_inline: bool,
|
||||
parent_id: node_id,
|
||||
m: @method, all_tps: ~[ty_param]) {
|
||||
@@ -504,7 +504,7 @@ fn should_inline(attrs: ~[attribute]) -> bool {
|
||||
}
|
||||
|
||||
|
||||
fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
|
||||
fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item,
|
||||
index: @mut ~[entry<int>], path: ast_map::path) {
|
||||
|
||||
let tcx = ecx.tcx;
|
||||
@@ -516,7 +516,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
|
||||
};
|
||||
if !must_write && !reachable(ecx, item.id) { return; }
|
||||
|
||||
fn add_to_index_(item: @item, ebml_w: ebml::writer,
|
||||
fn add_to_index_(item: @item, ebml_w: ebml::Writer,
|
||||
index: @mut ~[entry<int>]) {
|
||||
vec::push(*index, {val: item.id, pos: ebml_w.writer.tell()});
|
||||
}
|
||||
@@ -795,7 +795,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_info_for_foreign_item(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
fn encode_info_for_foreign_item(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
nitem: @foreign_item,
|
||||
index: @mut ~[entry<int>],
|
||||
path: ast_map::path, abi: foreign_abi) {
|
||||
@@ -829,7 +829,7 @@ fn encode_info_for_foreign_item(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
crate: @crate) -> ~[entry<int>] {
|
||||
let index = @mut ~[];
|
||||
ebml_w.start_tag(tag_items_data);
|
||||
@@ -884,7 +884,7 @@ fn create_index<T: copy>(index: ~[entry<T>], hash_fn: fn@(T) -> uint) ->
|
||||
return buckets_frozen;
|
||||
}
|
||||
|
||||
fn encode_index<T>(ebml_w: ebml::writer, buckets: ~[@~[entry<T>]],
|
||||
fn encode_index<T>(ebml_w: ebml::Writer, buckets: ~[@~[entry<T>]],
|
||||
write_fn: fn(io::Writer, T)) {
|
||||
let writer = ebml_w.writer;
|
||||
ebml_w.start_tag(tag_index);
|
||||
@@ -919,7 +919,7 @@ fn write_int(writer: io::Writer, &&n: int) {
|
||||
writer.write_be_u32(n as u32);
|
||||
}
|
||||
|
||||
fn encode_meta_item(ebml_w: ebml::writer, mi: meta_item) {
|
||||
fn encode_meta_item(ebml_w: ebml::Writer, mi: meta_item) {
|
||||
match mi.node {
|
||||
meta_word(name) => {
|
||||
ebml_w.start_tag(tag_meta_item_word);
|
||||
@@ -956,7 +956,7 @@ fn encode_meta_item(ebml_w: ebml::writer, mi: meta_item) {
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_attributes(ebml_w: ebml::writer, attrs: ~[attribute]) {
|
||||
fn encode_attributes(ebml_w: ebml::Writer, attrs: ~[attribute]) {
|
||||
ebml_w.start_tag(tag_attributes);
|
||||
for attrs.each |attr| {
|
||||
ebml_w.start_tag(tag_attribute);
|
||||
@@ -1018,7 +1018,7 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> ~[attribute] {
|
||||
return attrs;
|
||||
}
|
||||
|
||||
fn encode_crate_deps(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
fn encode_crate_deps(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
cstore: cstore::cstore) {
|
||||
|
||||
fn get_ordered_deps(ecx: @encode_ctxt, cstore: cstore::cstore)
|
||||
@@ -1064,7 +1064,7 @@ fn encode_crate_deps(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_crate_dep(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
fn encode_crate_dep(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
dep: decoder::crate_dep) {
|
||||
ebml_w.start_tag(tag_crate_dep);
|
||||
ebml_w.start_tag(tag_crate_dep_name);
|
||||
@@ -1079,7 +1079,7 @@ fn encode_crate_dep(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn encode_hash(ebml_w: ebml::writer, hash: ~str) {
|
||||
fn encode_hash(ebml_w: ebml::Writer, hash: ~str) {
|
||||
ebml_w.start_tag(tag_crate_hash);
|
||||
ebml_w.writer.write(str::to_bytes(hash));
|
||||
ebml_w.end_tag();
|
||||
@@ -1113,7 +1113,7 @@ fn encode_metadata(parms: encode_parms, crate: @crate) -> ~[u8] {
|
||||
});
|
||||
|
||||
let buf_w = io::mem_buffer_writer(buf);
|
||||
let ebml_w = ebml::writer(buf_w);
|
||||
let ebml_w = ebml::Writer(buf_w);
|
||||
|
||||
encode_hash(ebml_w, ecx.link_meta.extras_hash);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import syntax::ast_map;
|
||||
import syntax::ast_util;
|
||||
import syntax::codemap::span;
|
||||
import std::ebml;
|
||||
import std::ebml::writer;
|
||||
import std::ebml::Writer;
|
||||
import std::ebml::get_doc;
|
||||
import std::map::hashmap;
|
||||
import std::serialization::serializer;
|
||||
@@ -78,7 +78,7 @@ trait tr {
|
||||
// Top-level methods.
|
||||
|
||||
fn encode_inlined_item(ecx: @e::encode_ctxt,
|
||||
ebml_w: ebml::writer,
|
||||
ebml_w: ebml::Writer,
|
||||
path: ast_map::path,
|
||||
ii: ast::inlined_item,
|
||||
maps: maps) {
|
||||
@@ -104,7 +104,7 @@ fn decode_inlined_item(cdata: cstore::crate_metadata,
|
||||
tcx: ty::ctxt,
|
||||
maps: maps,
|
||||
path: ast_map::path,
|
||||
par_doc: ebml::doc) -> Option<ast::inlined_item> {
|
||||
par_doc: ebml::Doc) -> Option<ast::inlined_item> {
|
||||
let dcx = @{cdata: cdata, tcx: tcx, maps: maps};
|
||||
match par_doc.opt_child(c::tag_ast) {
|
||||
None => None,
|
||||
@@ -222,7 +222,7 @@ impl<D: deserializer> D: def_id_deserializer_helpers {
|
||||
// We also have to adjust the spans: for now we just insert a dummy span,
|
||||
// but eventually we should add entries to the local codemap as required.
|
||||
|
||||
fn encode_ast(ebml_w: ebml::writer, item: ast::inlined_item) {
|
||||
fn encode_ast(ebml_w: ebml::Writer, item: ast::inlined_item) {
|
||||
do ebml_w.wr_tag(c::tag_tree as uint) {
|
||||
ast::serialize_inlined_item(ebml_w, item)
|
||||
}
|
||||
@@ -282,7 +282,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
|
||||
}
|
||||
}
|
||||
|
||||
fn decode_ast(par_doc: ebml::doc) -> ast::inlined_item {
|
||||
fn decode_ast(par_doc: ebml::Doc) -> ast::inlined_item {
|
||||
let chi_doc = par_doc[c::tag_tree as uint];
|
||||
let d = ebml::ebml_deserializer(chi_doc);
|
||||
ast::deserialize_inlined_item(d)
|
||||
@@ -336,11 +336,11 @@ fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item)
|
||||
// ______________________________________________________________________
|
||||
// Encoding and decoding of ast::def
|
||||
|
||||
fn encode_def(ebml_w: ebml::writer, def: ast::def) {
|
||||
fn encode_def(ebml_w: ebml::Writer, def: ast::def) {
|
||||
ast::serialize_def(ebml_w, def)
|
||||
}
|
||||
|
||||
fn decode_def(xcx: extended_decode_ctxt, doc: ebml::doc) -> ast::def {
|
||||
fn decode_def(xcx: extended_decode_ctxt, doc: ebml::Doc) -> ast::def {
|
||||
let dsr = ebml::ebml_deserializer(doc);
|
||||
let def = ast::deserialize_def(dsr);
|
||||
def.tr(xcx)
|
||||
@@ -388,7 +388,7 @@ impl ast::def: tr {
|
||||
// ______________________________________________________________________
|
||||
// Encoding and decoding of freevar information
|
||||
|
||||
fn encode_freevar_entry(ebml_w: ebml::writer, fv: freevar_entry) {
|
||||
fn encode_freevar_entry(ebml_w: ebml::Writer, fv: freevar_entry) {
|
||||
serialize_freevar_entry(ebml_w, fv)
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ trait ebml_deserializer_helper {
|
||||
fn read_freevar_entry(xcx: extended_decode_ctxt) -> freevar_entry;
|
||||
}
|
||||
|
||||
impl ebml::ebml_deserializer: ebml_deserializer_helper {
|
||||
impl ebml::EbmlDeserializer: ebml_deserializer_helper {
|
||||
fn read_freevar_entry(xcx: extended_decode_ctxt) -> freevar_entry {
|
||||
let fv = deserialize_freevar_entry(self);
|
||||
fv.tr(xcx)
|
||||
@@ -416,7 +416,7 @@ trait read_method_map_entry_helper {
|
||||
fn read_method_map_entry(xcx: extended_decode_ctxt) -> method_map_entry;
|
||||
}
|
||||
|
||||
impl ebml::ebml_deserializer: read_method_map_entry_helper {
|
||||
impl ebml::EbmlDeserializer: read_method_map_entry_helper {
|
||||
fn read_method_map_entry(xcx: extended_decode_ctxt) -> method_map_entry {
|
||||
let mme = deserialize_method_map_entry(self);
|
||||
{derefs: mme.derefs,
|
||||
@@ -445,7 +445,7 @@ impl method_origin: tr {
|
||||
// Encoding and decoding vtable_res
|
||||
|
||||
fn encode_vtable_res(ecx: @e::encode_ctxt,
|
||||
ebml_w: ebml::writer,
|
||||
ebml_w: ebml::Writer,
|
||||
dr: typeck::vtable_res) {
|
||||
// can't autogenerate this code because automatic serialization of
|
||||
// ty::t doesn't work, and there is no way (atm) to have
|
||||
@@ -457,7 +457,7 @@ fn encode_vtable_res(ecx: @e::encode_ctxt,
|
||||
}
|
||||
|
||||
fn encode_vtable_origin(ecx: @e::encode_ctxt,
|
||||
ebml_w: ebml::writer,
|
||||
ebml_w: ebml::Writer,
|
||||
vtable_origin: typeck::vtable_origin) {
|
||||
do ebml_w.emit_enum(~"vtable_origin") {
|
||||
match vtable_origin {
|
||||
@@ -504,7 +504,7 @@ trait vtable_deserialization_helpers {
|
||||
fn read_vtable_origin(xcx: extended_decode_ctxt) -> typeck::vtable_origin;
|
||||
}
|
||||
|
||||
impl ebml::ebml_deserializer: vtable_deserialization_helpers {
|
||||
impl ebml::EbmlDeserializer: vtable_deserialization_helpers {
|
||||
fn read_vtable_res(xcx: extended_decode_ctxt) -> typeck::vtable_res {
|
||||
@self.read_to_vec(|| self.read_vtable_origin(xcx) )
|
||||
}
|
||||
@@ -579,7 +579,7 @@ trait ebml_writer_helpers {
|
||||
fn emit_tpbt(ecx: @e::encode_ctxt, tpbt: ty::ty_param_bounds_and_ty);
|
||||
}
|
||||
|
||||
impl ebml::writer: ebml_writer_helpers {
|
||||
impl ebml::Writer: ebml_writer_helpers {
|
||||
fn emit_ty(ecx: @e::encode_ctxt, ty: ty::t) {
|
||||
e::write_type(ecx, self, ty)
|
||||
}
|
||||
@@ -618,7 +618,7 @@ trait write_tag_and_id {
|
||||
fn id(id: ast::node_id);
|
||||
}
|
||||
|
||||
impl ebml::writer: write_tag_and_id {
|
||||
impl ebml::Writer: write_tag_and_id {
|
||||
fn tag(tag_id: c::astencode_tag, f: fn()) {
|
||||
do self.wr_tag(tag_id as uint) { f() }
|
||||
}
|
||||
@@ -630,7 +630,7 @@ impl ebml::writer: write_tag_and_id {
|
||||
|
||||
fn encode_side_tables_for_ii(ecx: @e::encode_ctxt,
|
||||
maps: maps,
|
||||
ebml_w: ebml::writer,
|
||||
ebml_w: ebml::Writer,
|
||||
ii: ast::inlined_item) {
|
||||
do ebml_w.wr_tag(c::tag_table as uint) {
|
||||
ast_util::visit_ids_for_inlined_item(
|
||||
@@ -646,7 +646,7 @@ fn encode_side_tables_for_ii(ecx: @e::encode_ctxt,
|
||||
|
||||
fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
||||
maps: maps,
|
||||
ebml_w: ebml::writer,
|
||||
ebml_w: ebml::Writer,
|
||||
id: ast::node_id) {
|
||||
let tcx = ecx.tcx;
|
||||
|
||||
@@ -771,12 +771,12 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
||||
|
||||
trait doc_decoder_helpers {
|
||||
fn as_int() -> int;
|
||||
fn opt_child(tag: c::astencode_tag) -> Option<ebml::doc>;
|
||||
fn opt_child(tag: c::astencode_tag) -> Option<ebml::Doc>;
|
||||
}
|
||||
|
||||
impl ebml::doc: doc_decoder_helpers {
|
||||
impl ebml::Doc: doc_decoder_helpers {
|
||||
fn as_int() -> int { ebml::doc_as_u64(self) as int }
|
||||
fn opt_child(tag: c::astencode_tag) -> Option<ebml::doc> {
|
||||
fn opt_child(tag: c::astencode_tag) -> Option<ebml::Doc> {
|
||||
ebml::maybe_get_doc(self, tag as uint)
|
||||
}
|
||||
}
|
||||
@@ -789,7 +789,7 @@ trait ebml_deserializer_decoder_helpers {
|
||||
-> ty::ty_param_bounds_and_ty;
|
||||
}
|
||||
|
||||
impl ebml::ebml_deserializer: ebml_deserializer_decoder_helpers {
|
||||
impl ebml::EbmlDeserializer: ebml_deserializer_decoder_helpers {
|
||||
|
||||
fn read_ty(xcx: extended_decode_ctxt) -> ty::t {
|
||||
// Note: regions types embed local node ids. In principle, we
|
||||
@@ -831,7 +831,7 @@ impl ebml::ebml_deserializer: ebml_deserializer_decoder_helpers {
|
||||
}
|
||||
|
||||
fn decode_side_tables(xcx: extended_decode_ctxt,
|
||||
ast_doc: ebml::doc) {
|
||||
ast_doc: ebml::Doc) {
|
||||
let dcx = xcx.dcx;
|
||||
let tbl_doc = ast_doc[c::tag_table as uint];
|
||||
for ebml::docs(tbl_doc) |tag, entry_doc| {
|
||||
@@ -901,14 +901,14 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
|
||||
// Testing of astencode_gen
|
||||
|
||||
#[cfg(test)]
|
||||
fn encode_item_ast(ebml_w: ebml::writer, item: @ast::item) {
|
||||
fn encode_item_ast(ebml_w: ebml::Writer, item: @ast::item) {
|
||||
do ebml_w.wr_tag(c::tag_tree as uint) {
|
||||
ast::serialize_item(ebml_w, *item);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn decode_item_ast(par_doc: ebml::doc) -> @ast::item {
|
||||
fn decode_item_ast(par_doc: ebml::Doc) -> @ast::item {
|
||||
let chi_doc = par_doc[c::tag_tree as uint];
|
||||
let d = ebml::ebml_deserializer(chi_doc);
|
||||
@ast::deserialize_item(d)
|
||||
@@ -937,7 +937,7 @@ fn mk_ctxt() -> fake_ext_ctxt {
|
||||
#[cfg(test)]
|
||||
fn roundtrip(in_item: @ast::item) {
|
||||
let mbuf = io::mem_buffer();
|
||||
let ebml_w = ebml::writer(io::mem_buffer_writer(mbuf));
|
||||
let ebml_w = ebml::Writer(io::mem_buffer_writer(mbuf));
|
||||
encode_item_ast(ebml_w, in_item);
|
||||
let ebml_doc = ebml::doc(@io::mem_buffer_buf(mbuf));
|
||||
let out_item = decode_item_ast(ebml_doc);
|
||||
|
||||
Reference in New Issue
Block a user