Convert ret to return
This commit is contained in:
parent
dc499f193e
commit
b355936b4d
456 changed files with 3875 additions and 3798 deletions
|
|
@ -127,12 +127,14 @@ enum astencode_tag { // Reserves 0x50 -- 0x6f
|
|||
}
|
||||
|
||||
// djb's cdb hashes.
|
||||
fn hash_node_id(&&node_id: int) -> uint { ret 177573u ^ (node_id as uint); }
|
||||
fn hash_node_id(&&node_id: int) -> uint {
|
||||
return 177573u ^ (node_id as uint);
|
||||
}
|
||||
|
||||
fn hash_path(&&s: ~str) -> uint {
|
||||
let mut h = 5381u;
|
||||
for str::each(s) |ch| { h = (h << 5u) + h ^ (ch as uint); }
|
||||
ret h;
|
||||
return h;
|
||||
}
|
||||
|
||||
type link_meta = {name: @~str, vers: @~str, extras_hash: ~str};
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ fn visit_item(e: env, i: @ast::item) {
|
|||
alt attr::foreign_abi(i.attrs) {
|
||||
either::right(abi) {
|
||||
if abi != ast::foreign_abi_cdecl &&
|
||||
abi != ast::foreign_abi_stdcall { ret; }
|
||||
abi != ast::foreign_abi_stdcall { return; }
|
||||
}
|
||||
either::left(msg) { e.diag.span_fatal(i.span, msg); }
|
||||
}
|
||||
|
|
@ -177,10 +177,10 @@ fn existing_match(e: env, metas: ~[@ast::meta_item], hash: ~str) ->
|
|||
for e.crate_cache.each |c| {
|
||||
if loader::metadata_matches(*c.metas, metas)
|
||||
&& (hash.is_empty() || *c.hash == hash) {
|
||||
ret some(c.cnum);
|
||||
return some(c.cnum);
|
||||
}
|
||||
}
|
||||
ret none;
|
||||
return none;
|
||||
}
|
||||
|
||||
fn resolve_crate(e: env, ident: ast::ident, metas: ~[@ast::meta_item],
|
||||
|
|
@ -228,10 +228,10 @@ fn resolve_crate(e: env, ident: ast::ident, metas: ~[@ast::meta_item],
|
|||
let cstore = e.cstore;
|
||||
cstore::set_crate_data(cstore, cnum, cmeta);
|
||||
cstore::add_used_crate_file(cstore, cfilename);
|
||||
ret cnum;
|
||||
return cnum;
|
||||
}
|
||||
some(cnum) {
|
||||
ret cnum;
|
||||
return cnum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -266,7 +266,7 @@ fn resolve_crate_deps(e: env, cdata: @~[u8]) -> cstore::cnum_map {
|
|||
}
|
||||
}
|
||||
}
|
||||
ret cnum_map;
|
||||
return cnum_map;
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@ export maybe_get_item_ast, found_ast, found, found_parent, not_found;
|
|||
|
||||
fn get_symbol(cstore: cstore::cstore, def: ast::def_id) -> ~str {
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate).data;
|
||||
ret decoder::get_symbol(cdata, def.node);
|
||||
return decoder::get_symbol(cdata, def.node);
|
||||
}
|
||||
|
||||
fn get_type_param_count(cstore: cstore::cstore, def: ast::def_id) -> uint {
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate).data;
|
||||
ret decoder::get_type_param_count(cdata, def.node);
|
||||
return decoder::get_type_param_count(cdata, def.node);
|
||||
}
|
||||
|
||||
fn lookup_defs(cstore: cstore::cstore, cnum: ast::crate_num,
|
||||
|
|
@ -51,7 +51,7 @@ fn lookup_defs(cstore: cstore::cstore, cnum: ast::crate_num,
|
|||
let (c, data, def) = elt;
|
||||
vec::push(result, decoder::lookup_def(c, data, def));
|
||||
}
|
||||
ret result;
|
||||
return result;
|
||||
}
|
||||
|
||||
fn lookup_method_purity(cstore: cstore::cstore, did: ast::def_id)
|
||||
|
|
@ -83,7 +83,7 @@ fn resolve_path(cstore: cstore::cstore, cnum: ast::crate_num,
|
|||
}
|
||||
}
|
||||
}
|
||||
ret result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Iterates over all the paths in the given crate.
|
||||
|
|
@ -125,7 +125,7 @@ fn get_enum_variants(tcx: ty::ctxt, def: ast::def_id)
|
|||
-> ~[ty::variant_info] {
|
||||
let cstore = tcx.cstore;
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
ret decoder::get_enum_variants(cdata, def.node, tcx)
|
||||
return decoder::get_enum_variants(cdata, def.node, tcx)
|
||||
}
|
||||
|
||||
fn get_impls_for_mod(cstore: cstore::cstore, def: ast::def_id,
|
||||
|
|
@ -147,7 +147,7 @@ fn get_method_names_if_trait(cstore: cstore::cstore, def: ast::def_id)
|
|||
-> option<@dvec<@~str>> {
|
||||
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
ret decoder::get_method_names_if_trait(cdata, def.node);
|
||||
return decoder::get_method_names_if_trait(cdata, def.node);
|
||||
}
|
||||
|
||||
fn get_item_attrs(cstore: cstore::cstore,
|
||||
|
|
@ -173,7 +173,7 @@ fn get_type(tcx: ty::ctxt, def: ast::def_id) -> ty::ty_param_bounds_and_ty {
|
|||
fn get_region_param(cstore: metadata::cstore::cstore,
|
||||
def: ast::def_id) -> bool {
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
ret decoder::get_region_param(cdata, def.node);
|
||||
return decoder::get_region_param(cdata, def.node);
|
||||
}
|
||||
|
||||
fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id,
|
||||
|
|
@ -193,7 +193,7 @@ fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id,
|
|||
class_id, def} );
|
||||
debug!{"got field data %?", the_field};
|
||||
let ty = decoder::item_type(def, the_field, tcx, cdata);
|
||||
ret {bounds: @~[], rp: false, ty: ty};
|
||||
return {bounds: @~[], rp: false, ty: ty};
|
||||
}
|
||||
|
||||
// Given a def_id for an impl or class, return the traits it implements,
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ fn mk_cstore() -> cstore {
|
|||
let meta_cache = map::int_hash::<crate_metadata>();
|
||||
let crate_map = map::int_hash::<ast::crate_num>();
|
||||
let mod_path_map = new_def_hash();
|
||||
ret private(@{metas: meta_cache,
|
||||
return private(@{metas: meta_cache,
|
||||
use_crate_map: crate_map,
|
||||
mod_path_map: mod_path_map,
|
||||
mut used_crate_files: ~[],
|
||||
|
|
@ -80,17 +80,17 @@ fn mk_cstore() -> cstore {
|
|||
}
|
||||
|
||||
fn get_crate_data(cstore: cstore, cnum: ast::crate_num) -> crate_metadata {
|
||||
ret p(cstore).metas.get(cnum);
|
||||
return p(cstore).metas.get(cnum);
|
||||
}
|
||||
|
||||
fn get_crate_hash(cstore: cstore, cnum: ast::crate_num) -> @~str {
|
||||
let cdata = get_crate_data(cstore, cnum);
|
||||
ret decoder::get_crate_hash(cdata.data);
|
||||
return decoder::get_crate_hash(cdata.data);
|
||||
}
|
||||
|
||||
fn get_crate_vers(cstore: cstore, cnum: ast::crate_num) -> @~str {
|
||||
let cdata = get_crate_data(cstore, cnum);
|
||||
ret decoder::get_crate_vers(cdata.data);
|
||||
return decoder::get_crate_vers(cdata.data);
|
||||
}
|
||||
|
||||
fn set_crate_data(cstore: cstore, cnum: ast::crate_num,
|
||||
|
|
@ -104,7 +104,7 @@ fn set_crate_data(cstore: cstore, cnum: ast::crate_num,
|
|||
}
|
||||
|
||||
fn have_crate_data(cstore: cstore, cnum: ast::crate_num) -> bool {
|
||||
ret p(cstore).metas.contains_key(cnum);
|
||||
return p(cstore).metas.contains_key(cnum);
|
||||
}
|
||||
|
||||
fn iter_crate_data(cstore: cstore, i: fn(ast::crate_num, crate_metadata)) {
|
||||
|
|
@ -118,19 +118,19 @@ fn add_used_crate_file(cstore: cstore, lib: ~str) {
|
|||
}
|
||||
|
||||
fn get_used_crate_files(cstore: cstore) -> ~[~str] {
|
||||
ret p(cstore).used_crate_files;
|
||||
return p(cstore).used_crate_files;
|
||||
}
|
||||
|
||||
fn add_used_library(cstore: cstore, lib: ~str) -> bool {
|
||||
assert lib != ~"";
|
||||
|
||||
if vec::contains(p(cstore).used_libraries, lib) { ret false; }
|
||||
if vec::contains(p(cstore).used_libraries, lib) { return false; }
|
||||
vec::push(p(cstore).used_libraries, lib);
|
||||
ret true;
|
||||
return true;
|
||||
}
|
||||
|
||||
fn get_used_libraries(cstore: cstore) -> ~[~str] {
|
||||
ret p(cstore).used_libraries;
|
||||
return p(cstore).used_libraries;
|
||||
}
|
||||
|
||||
fn add_used_link_args(cstore: cstore, args: ~str) {
|
||||
|
|
@ -138,7 +138,7 @@ fn add_used_link_args(cstore: cstore, args: ~str) {
|
|||
}
|
||||
|
||||
fn get_used_link_args(cstore: cstore) -> ~[~str] {
|
||||
ret p(cstore).used_link_args;
|
||||
return p(cstore).used_link_args;
|
||||
}
|
||||
|
||||
fn add_use_stmt_cnum(cstore: cstore, use_id: ast::node_id,
|
||||
|
|
@ -164,15 +164,15 @@ fn get_dep_hashes(cstore: cstore) -> ~[@~str] {
|
|||
vec::push(result, {name: @cdata.name, hash: hash});
|
||||
};
|
||||
fn lteq(a: crate_hash, b: crate_hash) -> bool {
|
||||
ret *a.name <= *b.name;
|
||||
return *a.name <= *b.name;
|
||||
}
|
||||
let sorted = std::sort::merge_sort(lteq, result);
|
||||
debug!{"sorted:"};
|
||||
for sorted.each |x| {
|
||||
debug!{" hash[%s]: %s", *x.name, *x.hash};
|
||||
}
|
||||
fn mapper(ch: crate_hash) -> @~str { ret ch.hash; }
|
||||
ret vec::map(sorted, mapper);
|
||||
fn mapper(ch: crate_hash) -> @~str { return ch.hash; }
|
||||
return vec::map(sorted, mapper);
|
||||
}
|
||||
|
||||
fn get_path(cstore: cstore, d: ast::def_id) -> ~[ast::ident] {
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ fn lookup_hash(d: ebml::doc, eq_fn: fn(x:&[u8]) -> bool, hash: uint) ->
|
|||
for ebml::tagged_docs(bucket, belt) |elt| {
|
||||
let pos = io::u64_from_be_bytes(*elt.data, elt.start, 4u) as uint;
|
||||
if eq_fn(vec::slice(*elt.data, elt.start + 4u, elt.end)) {
|
||||
ret some(ebml::doc_at(d.data, pos).doc);
|
||||
return some(ebml::doc_at(d.data, pos).doc);
|
||||
}
|
||||
};
|
||||
none
|
||||
|
|
@ -83,7 +83,7 @@ fn lookup_hash(d: ebml::doc, eq_fn: fn(x:&[u8]) -> bool, hash: uint) ->
|
|||
|
||||
fn maybe_find_item(item_id: int, items: ebml::doc) -> option<ebml::doc> {
|
||||
fn eq_item(bytes: &[u8], item_id: int) -> bool {
|
||||
ret io::u64_from_be_bytes(vec::slice(bytes, 0u, 4u), 0u, 4u) as int
|
||||
return io::u64_from_be_bytes(vec::slice(bytes, 0u, 4u), 0u, 4u) as int
|
||||
== item_id;
|
||||
}
|
||||
lookup_hash(items,
|
||||
|
|
@ -92,7 +92,7 @@ fn maybe_find_item(item_id: int, items: ebml::doc) -> option<ebml::doc> {
|
|||
}
|
||||
|
||||
fn find_item(item_id: int, items: ebml::doc) -> ebml::doc {
|
||||
ret option::get(maybe_find_item(item_id, items));
|
||||
return option::get(maybe_find_item(item_id, items));
|
||||
}
|
||||
|
||||
// Looks up an item in the given metadata and returns an ebml doc pointing
|
||||
|
|
@ -112,12 +112,12 @@ fn item_family(item: ebml::doc) -> char {
|
|||
|
||||
fn item_symbol(item: ebml::doc) -> ~str {
|
||||
let sym = ebml::get_doc(item, tag_items_data_item_symbol);
|
||||
ret str::from_bytes(ebml::doc_data(sym));
|
||||
return str::from_bytes(ebml::doc_data(sym));
|
||||
}
|
||||
|
||||
fn item_parent_item(d: ebml::doc) -> option<ast::def_id> {
|
||||
for ebml::tagged_docs(d, tag_items_data_parent_item) |did| {
|
||||
ret some(ebml::with_doc_data(did, |d| parse_def_id(d)));
|
||||
return some(ebml::with_doc_data(did, |d| parse_def_id(d)));
|
||||
}
|
||||
none
|
||||
}
|
||||
|
|
@ -125,7 +125,7 @@ fn item_parent_item(d: ebml::doc) -> option<ast::def_id> {
|
|||
// XXX: This has nothing to do with classes.
|
||||
fn class_member_id(d: ebml::doc, cdata: cmd) -> ast::def_id {
|
||||
let tagdoc = ebml::get_doc(d, tag_def_id);
|
||||
ret translate_def_id(cdata, ebml::with_doc_data(tagdoc,
|
||||
return translate_def_id(cdata, ebml::with_doc_data(tagdoc,
|
||||
|d| parse_def_id(d)));
|
||||
}
|
||||
|
||||
|
|
@ -204,7 +204,7 @@ fn enum_variant_ids(item: ebml::doc, cdata: cmd) -> ~[ast::def_id] {
|
|||
let ext = ebml::with_doc_data(p, |d| parse_def_id(d));
|
||||
vec::push(ids, {crate: cdata.cnum, node: ext.node});
|
||||
};
|
||||
ret ids;
|
||||
return ids;
|
||||
}
|
||||
|
||||
// Given a path and serialized crate metadata, returns the IDs of the
|
||||
|
|
@ -215,16 +215,16 @@ fn resolve_path(path: ~[ast::ident], data: @~[u8]) -> ~[ast::def_id] {
|
|||
let data_len = data.len();
|
||||
let s_len = s.len();
|
||||
if data_len != s_len {
|
||||
ret false;
|
||||
return false;
|
||||
}
|
||||
let mut i = 0;
|
||||
while i < data_len {
|
||||
if data[i] != s[i] {
|
||||
ret false;
|
||||
return false;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
ret true;
|
||||
return true;
|
||||
}
|
||||
let s = ast_util::path_name_i(path);
|
||||
let md = ebml::doc(data);
|
||||
|
|
@ -236,7 +236,7 @@ fn resolve_path(path: ~[ast::ident], data: @~[u8]) -> ~[ast::def_id] {
|
|||
let did_doc = ebml::get_doc(doc, tag_def_id);
|
||||
vec::push(result, ebml::with_doc_data(did_doc, |d| parse_def_id(d)));
|
||||
}
|
||||
ret result;
|
||||
return result;
|
||||
}
|
||||
|
||||
fn item_path(item_doc: ebml::doc) -> ast_map::path {
|
||||
|
|
@ -260,7 +260,7 @@ fn item_path(item_doc: ebml::doc) -> ast_map::path {
|
|||
}
|
||||
}
|
||||
|
||||
ret result;
|
||||
return result;
|
||||
}
|
||||
|
||||
fn item_name(item: ebml::doc) -> ast::ident {
|
||||
|
|
@ -304,7 +304,7 @@ fn lookup_def(cnum: ast::crate_num, data: @~[u8], did_: ast::def_id) ->
|
|||
let item = lookup_item(did_.node, data);
|
||||
let did = {crate: cnum, node: did_.node};
|
||||
// We treat references to enums as references to types.
|
||||
ret def_like_to_def(item_to_def_like(item, did, cnum));
|
||||
return def_like_to_def(item_to_def_like(item, did, cnum));
|
||||
}
|
||||
|
||||
fn get_type(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
|
||||
|
|
@ -316,12 +316,12 @@ fn get_type(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
|
|||
item_ty_param_bounds(item, tcx, cdata)
|
||||
} else { @~[] };
|
||||
let rp = item_ty_region_param(item);
|
||||
ret {bounds: tp_bounds, rp: rp, ty: t};
|
||||
return {bounds: tp_bounds, rp: rp, ty: t};
|
||||
}
|
||||
|
||||
fn get_region_param(cdata: cmd, id: ast::node_id) -> bool {
|
||||
let item = lookup_item(id, cdata.data);
|
||||
ret item_ty_region_param(item);
|
||||
return item_ty_region_param(item);
|
||||
}
|
||||
|
||||
fn get_type_param_count(data: @~[u8], id: ast::node_id) -> uint {
|
||||
|
|
@ -382,7 +382,7 @@ fn class_dtor(cdata: cmd, id: ast::node_id) -> option<ast::def_id> {
|
|||
}
|
||||
|
||||
fn get_symbol(data: @~[u8], id: ast::node_id) -> ~str {
|
||||
ret item_symbol(lookup_item(id, data));
|
||||
return item_symbol(lookup_item(id, data));
|
||||
}
|
||||
|
||||
// Something that a name can resolve to.
|
||||
|
|
@ -394,7 +394,7 @@ enum def_like {
|
|||
|
||||
fn def_like_to_def(def_like: def_like) -> ast::def {
|
||||
alt def_like {
|
||||
dl_def(def) { ret def; }
|
||||
dl_def(def) { return def; }
|
||||
dl_impl(*) { fail ~"found impl in def_like_to_def"; }
|
||||
dl_field { fail ~"found field in def_like_to_def"; }
|
||||
}
|
||||
|
|
@ -445,7 +445,7 @@ fn each_path(cdata: cmd, f: fn(path_entry) -> bool) {
|
|||
|
||||
// If broken, stop here.
|
||||
if broken {
|
||||
ret;
|
||||
return;
|
||||
}
|
||||
|
||||
// Next, go through all the paths. We will find items that we didn't know
|
||||
|
|
@ -561,7 +561,7 @@ fn get_enum_variants(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
|
|||
id: did, disr_val: disr_val});
|
||||
disr_val += 1;
|
||||
}
|
||||
ret infos;
|
||||
return infos;
|
||||
}
|
||||
|
||||
// NB: These types are duplicated in resolve.rs
|
||||
|
|
@ -591,10 +591,10 @@ fn get_self_ty(item: ebml::doc) -> ast::self_ty_ {
|
|||
|
||||
let self_ty_kind = string[0];
|
||||
alt self_ty_kind as char {
|
||||
'r' => { ret ast::sty_by_ref; }
|
||||
'v' => { ret ast::sty_value; }
|
||||
'@' => { ret ast::sty_box(get_mutability(string[1])); }
|
||||
'~' => { ret ast::sty_uniq(get_mutability(string[1])); }
|
||||
'r' => { return ast::sty_by_ref; }
|
||||
'v' => { return ast::sty_value; }
|
||||
'@' => { return ast::sty_box(get_mutability(string[1])); }
|
||||
'~' => { return ast::sty_uniq(get_mutability(string[1])); }
|
||||
'&' => {
|
||||
let mutability = get_mutability(string[1]);
|
||||
|
||||
|
|
@ -609,7 +609,7 @@ fn get_self_ty(item: ebml::doc) -> ast::self_ty_ {
|
|||
region = ast::re_named(@region_string);
|
||||
}
|
||||
|
||||
ret ast::sty_region(@{ id: 0, node: region }, mutability);
|
||||
return ast::sty_region(@{ id: 0, node: region }, mutability);
|
||||
}
|
||||
_ => {
|
||||
fail fmt!{"unknown self type code: `%c`", self_ty_kind as char};
|
||||
|
|
@ -698,14 +698,14 @@ fn get_method_names_if_trait(cdata: cmd, node_id: ast::node_id)
|
|||
|
||||
let item = lookup_item(node_id, cdata.data);
|
||||
if item_family(item) != 'I' {
|
||||
ret none;
|
||||
return none;
|
||||
}
|
||||
|
||||
let resulting_method_names = @dvec();
|
||||
for ebml::tagged_docs(item, tag_item_trait_method) |method| {
|
||||
(*resulting_method_names).push(item_name(method));
|
||||
}
|
||||
ret some(resulting_method_names);
|
||||
return some(resulting_method_names);
|
||||
}
|
||||
|
||||
fn get_item_attrs(cdata: cmd,
|
||||
|
|
@ -769,39 +769,39 @@ fn read_path(d: ebml::doc) -> {path: ~str, pos: uint} {
|
|||
let pos = io::u64_from_be_bytes(desc, 0u, 4u) as uint;
|
||||
let pathbytes = vec::slice::<u8>(desc, 4u, vec::len::<u8>(desc));
|
||||
let path = str::from_bytes(pathbytes);
|
||||
ret {path: path, pos: pos};
|
||||
return {path: path, pos: pos};
|
||||
}
|
||||
|
||||
fn describe_def(items: ebml::doc, id: ast::def_id) -> ~str {
|
||||
if id.crate != ast::local_crate { ret ~"external"; }
|
||||
if id.crate != ast::local_crate { return ~"external"; }
|
||||
let it = alt maybe_find_item(id.node, items) {
|
||||
some(it) { it }
|
||||
none { fail (fmt!{"describe_def: item not found %?", id}); }
|
||||
};
|
||||
ret item_family_to_str(item_family(it));
|
||||
return item_family_to_str(item_family(it));
|
||||
}
|
||||
|
||||
fn item_family_to_str(fam: char) -> ~str {
|
||||
alt check fam {
|
||||
'c' { ret ~"const"; }
|
||||
'f' { ret ~"fn"; }
|
||||
'u' { ret ~"unsafe fn"; }
|
||||
'p' { ret ~"pure fn"; }
|
||||
'F' { ret ~"foreign fn"; }
|
||||
'U' { ret ~"unsafe foreign fn"; }
|
||||
'P' { ret ~"pure foreign fn"; }
|
||||
'y' { ret ~"type"; }
|
||||
'T' { ret ~"foreign type"; }
|
||||
't' { ret ~"type"; }
|
||||
'm' { ret ~"mod"; }
|
||||
'n' { ret ~"foreign mod"; }
|
||||
'v' { ret ~"enum"; }
|
||||
'i' { ret ~"impl"; }
|
||||
'I' { ret ~"trait"; }
|
||||
'C' { ret ~"class"; }
|
||||
'S' { ret ~"struct"; }
|
||||
'g' { ret ~"public field"; }
|
||||
'j' { ret ~"private field"; }
|
||||
'c' { return ~"const"; }
|
||||
'f' { return ~"fn"; }
|
||||
'u' { return ~"unsafe fn"; }
|
||||
'p' { return ~"pure fn"; }
|
||||
'F' { return ~"foreign fn"; }
|
||||
'U' { return ~"unsafe foreign fn"; }
|
||||
'P' { return ~"pure foreign fn"; }
|
||||
'y' { return ~"type"; }
|
||||
'T' { return ~"foreign type"; }
|
||||
't' { return ~"type"; }
|
||||
'm' { return ~"mod"; }
|
||||
'n' { return ~"foreign mod"; }
|
||||
'v' { return ~"enum"; }
|
||||
'i' { return ~"impl"; }
|
||||
'I' { return ~"trait"; }
|
||||
'C' { return ~"class"; }
|
||||
'S' { return ~"struct"; }
|
||||
'g' { return ~"public field"; }
|
||||
'j' { return ~"private field"; }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -827,7 +827,7 @@ fn get_meta_items(md: ebml::doc) -> ~[@ast::meta_item] {
|
|||
let subitems = get_meta_items(meta_item_doc);
|
||||
vec::push(items, attr::mk_list_item(@n, subitems));
|
||||
};
|
||||
ret items;
|
||||
return items;
|
||||
}
|
||||
|
||||
fn get_attributes(md: ebml::doc) -> ~[ast::attribute] {
|
||||
|
|
@ -848,7 +848,7 @@ fn get_attributes(md: ebml::doc) -> ~[ast::attribute] {
|
|||
}
|
||||
option::none { }
|
||||
}
|
||||
ret attrs;
|
||||
return attrs;
|
||||
}
|
||||
|
||||
fn list_meta_items(meta_items: ebml::doc, out: io::writer) {
|
||||
|
|
@ -868,7 +868,7 @@ fn list_crate_attributes(md: ebml::doc, hash: @~str, out: io::writer) {
|
|||
}
|
||||
|
||||
fn get_crate_attributes(data: @~[u8]) -> ~[ast::attribute] {
|
||||
ret get_attributes(ebml::doc(data));
|
||||
return get_attributes(ebml::doc(data));
|
||||
}
|
||||
|
||||
type crate_dep = {cnum: ast::crate_num, name: ast::ident,
|
||||
|
|
@ -889,7 +889,7 @@ fn get_crate_deps(data: @~[u8]) -> ~[crate_dep] {
|
|||
hash: @docstr(depdoc, tag_crate_dep_hash)});
|
||||
crate_num += 1;
|
||||
};
|
||||
ret deps;
|
||||
return deps;
|
||||
}
|
||||
|
||||
fn list_crate_deps(data: @~[u8], out: io::writer) {
|
||||
|
|
@ -906,12 +906,12 @@ fn list_crate_deps(data: @~[u8], out: io::writer) {
|
|||
fn get_crate_hash(data: @~[u8]) -> @~str {
|
||||
let cratedoc = ebml::doc(data);
|
||||
let hashdoc = ebml::get_doc(cratedoc, tag_crate_hash);
|
||||
ret @str::from_bytes(ebml::doc_data(hashdoc));
|
||||
return @str::from_bytes(ebml::doc_data(hashdoc));
|
||||
}
|
||||
|
||||
fn get_crate_vers(data: @~[u8]) -> @~str {
|
||||
let attrs = decoder::get_crate_attributes(data);
|
||||
ret alt attr::last_meta_item_value_str_by_name(
|
||||
return alt attr::last_meta_item_value_str_by_name(
|
||||
attr::find_linkage_metas(attrs), ~"vers") {
|
||||
some(ver) { ver }
|
||||
none { @~"0.0" }
|
||||
|
|
@ -968,7 +968,7 @@ fn get_crate_module_paths(bytes: @~[u8]) -> ~[(ast::def_id, ~str)] {
|
|||
// unified later by using the mods map
|
||||
vec::push(res, (did, path));
|
||||
}
|
||||
ret do vec::filter(res) |x| {
|
||||
return do vec::filter(res) |x| {
|
||||
let (_, xp) = x;
|
||||
mods.contains_key(xp)
|
||||
}
|
||||
|
|
@ -989,11 +989,11 @@ fn list_crate_metadata(bytes: @~[u8], out: io::writer) {
|
|||
// crate to the correct local crate number.
|
||||
fn translate_def_id(cdata: cmd, did: ast::def_id) -> ast::def_id {
|
||||
if did.crate == ast::local_crate {
|
||||
ret {crate: cdata.cnum, node: did.node};
|
||||
return {crate: cdata.cnum, node: did.node};
|
||||
}
|
||||
|
||||
alt cdata.cnum_map.find(did.crate) {
|
||||
option::some(n) { ret {crate: n, node: did.node}; }
|
||||
option::some(n) { return {crate: n, node: did.node}; }
|
||||
option::none { fail ~"didn't find a crate in the cnum_map"; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ fn encode_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, crate: @crate)
|
|||
encode_module_item_paths(ebml_w, ecx, crate.node.module, path, index);
|
||||
encode_reexport_paths(ebml_w, ecx, index);
|
||||
ebml_w.end_tag();
|
||||
ret index;
|
||||
return index;
|
||||
}
|
||||
|
||||
fn encode_reexport_paths(ebml_w: ebml::writer,
|
||||
|
|
@ -273,7 +273,7 @@ fn encode_family(ebml_w: ebml::writer, c: char) {
|
|||
ebml_w.end_tag();
|
||||
}
|
||||
|
||||
fn def_to_str(did: def_id) -> ~str { ret fmt!{"%d:%d", did.crate, did.node}; }
|
||||
fn def_to_str(did: def_id) -> ~str { fmt!{"%d:%d", did.crate, did.node} }
|
||||
|
||||
fn encode_type_param_bounds(ebml_w: ebml::writer, ecx: @encode_ctxt,
|
||||
params: ~[ty_param]) {
|
||||
|
|
@ -617,7 +617,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
|
|||
false
|
||||
}
|
||||
};
|
||||
if !must_write && !reachable(ecx, item.id) { ret; }
|
||||
if !must_write && !reachable(ecx, item.id) { return; }
|
||||
|
||||
fn add_to_index_(item: @item, ebml_w: ebml::writer,
|
||||
index: @mut ~[entry<int>]) {
|
||||
|
|
@ -854,7 +854,7 @@ 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) {
|
||||
if !reachable(ecx, nitem.id) { ret; }
|
||||
if !reachable(ecx, nitem.id) { return; }
|
||||
vec::push(*index, {val: nitem.id, pos: ebml_w.writer.tell()});
|
||||
|
||||
ebml_w.start_tag(tag_items_data_item);
|
||||
|
|
@ -922,7 +922,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
|||
with *visit::default_visitor()
|
||||
}));
|
||||
ebml_w.end_tag();
|
||||
ret *index;
|
||||
return *index;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -941,7 +941,7 @@ fn create_index<T: copy>(index: ~[entry<T>], hash_fn: fn@(T) -> uint) ->
|
|||
for buckets.each |bucket| {
|
||||
vec::push(buckets_frozen, @*bucket);
|
||||
}
|
||||
ret buckets_frozen;
|
||||
return buckets_frozen;
|
||||
}
|
||||
|
||||
fn encode_index<T>(ebml_w: ebml::writer, buckets: ~[@~[entry<T>]],
|
||||
|
|
@ -1047,7 +1047,7 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> ~[attribute] {
|
|||
let meta_items = vec::append(~[name_item, vers_item], other_items);
|
||||
let link_item = attr::mk_list_item(@~"link", meta_items);
|
||||
|
||||
ret attr::mk_attr(link_item);
|
||||
return attr::mk_attr(link_item);
|
||||
}
|
||||
|
||||
let mut attrs: ~[attribute] = ~[];
|
||||
|
|
@ -1070,7 +1070,7 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> ~[attribute] {
|
|||
|
||||
if !found_link_attr { vec::push(attrs, synthesize_link_attr(ecx, ~[])); }
|
||||
|
||||
ret attrs;
|
||||
return attrs;
|
||||
}
|
||||
|
||||
fn encode_crate_deps(ebml_w: ebml::writer, cstore: cstore::cstore) {
|
||||
|
|
@ -1100,7 +1100,7 @@ fn encode_crate_deps(ebml_w: ebml::writer, cstore: cstore::cstore) {
|
|||
}
|
||||
|
||||
// mut -> immutable hack for vec::map
|
||||
ret vec::slice(deps, 0u, vec::len(deps));
|
||||
return vec::slice(deps, 0u, vec::len(deps));
|
||||
}
|
||||
|
||||
// We're just going to write a list of crate 'name-hash-version's, with
|
||||
|
|
@ -1189,7 +1189,7 @@ fn encoded_ty(tcx: ty::ctxt, t: ty::t) -> ~str {
|
|||
abbrevs: tyencode::ac_no_abbrevs};
|
||||
let buf = io::mem_buffer();
|
||||
tyencode::enc_ty(io::mem_buffer_writer(buf), cx, t);
|
||||
ret io::mem_buffer_str(buf);
|
||||
return io::mem_buffer_str(buf);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ fn search<T: copy>(filesearch: filesearch, pick: pick<T>) -> option<T> {
|
|||
}
|
||||
if option::is_some(rslt) { break; }
|
||||
}
|
||||
ret rslt;
|
||||
return rslt;
|
||||
}
|
||||
|
||||
fn relative_target_lib_path(target_triple: ~str) -> ~[path] {
|
||||
|
|
@ -97,7 +97,7 @@ fn make_target_lib_path(sysroot: path,
|
|||
let path = vec::append(~[sysroot],
|
||||
relative_target_lib_path(target_triple));
|
||||
let path = path::connect_many(path);
|
||||
ret path;
|
||||
return path;
|
||||
}
|
||||
|
||||
fn get_default_sysroot() -> path {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ type ctxt = {
|
|||
|
||||
fn load_library_crate(cx: ctxt) -> {ident: ~str, data: @~[u8]} {
|
||||
alt find_library_crate(cx) {
|
||||
some(t) { ret t; }
|
||||
some(t) { return t; }
|
||||
none {
|
||||
cx.diag.span_fatal(
|
||||
cx.span, fmt!{"can't find crate for `%s`", *cx.ident});
|
||||
|
|
@ -52,12 +52,12 @@ fn find_library_crate(cx: ctxt) -> option<{ident: ~str, data: @~[u8]}> {
|
|||
}
|
||||
|
||||
fn libname(cx: ctxt) -> {prefix: ~str, suffix: ~str} {
|
||||
if cx.static { ret {prefix: ~"lib", suffix: ~".rlib"}; }
|
||||
if cx.static { return {prefix: ~"lib", suffix: ~".rlib"}; }
|
||||
alt cx.os {
|
||||
os_win32 { ret {prefix: ~"", suffix: ~".dll"}; }
|
||||
os_macos { ret {prefix: ~"lib", suffix: ~".dylib"}; }
|
||||
os_linux { ret {prefix: ~"lib", suffix: ~".so"}; }
|
||||
os_freebsd { ret {prefix: ~"lib", suffix: ~".so"}; }
|
||||
os_win32 { return {prefix: ~"", suffix: ~".dll"}; }
|
||||
os_macos { return {prefix: ~"lib", suffix: ~".dylib"}; }
|
||||
os_linux { return {prefix: ~"lib", suffix: ~".so"}; }
|
||||
os_freebsd { return {prefix: ~"lib", suffix: ~".so"}; }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ fn crate_matches(crate_data: @~[u8], metas: ~[@ast::meta_item],
|
|||
let linkage_metas = attr::find_linkage_metas(attrs);
|
||||
if hash.is_not_empty() {
|
||||
let chash = decoder::get_crate_hash(crate_data);
|
||||
if *chash != hash { ret false; }
|
||||
if *chash != hash { return false; }
|
||||
}
|
||||
metadata_matches(linkage_metas, metas)
|
||||
}
|
||||
|
|
@ -163,10 +163,10 @@ fn metadata_matches(extern_metas: ~[@ast::meta_item],
|
|||
debug!{"looking for %s", pprust::meta_item_to_str(*needed)};
|
||||
if !attr::contains(extern_metas, needed) {
|
||||
debug!{"missing %s", pprust::meta_item_to_str(*needed)};
|
||||
ret false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ret true;
|
||||
return true;
|
||||
}
|
||||
|
||||
fn get_metadata_section(os: os,
|
||||
|
|
@ -174,10 +174,10 @@ fn get_metadata_section(os: os,
|
|||
let mb = str::as_c_str(filename, |buf| {
|
||||
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
|
||||
});
|
||||
if mb as int == 0 { ret option::none::<@~[u8]>; }
|
||||
if mb as int == 0 { return option::none::<@~[u8]>; }
|
||||
let of = alt mk_object_file(mb) {
|
||||
option::some(of) { of }
|
||||
_ { ret option::none::<@~[u8]>; }
|
||||
_ { return option::none::<@~[u8]>; }
|
||||
};
|
||||
let si = mk_section_iter(of.llof);
|
||||
while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
|
||||
|
|
@ -188,12 +188,12 @@ fn get_metadata_section(os: os,
|
|||
let csz = llvm::LLVMGetSectionSize(si.llsi) as uint;
|
||||
unsafe {
|
||||
let cvbuf: *u8 = unsafe::reinterpret_cast(cbuf);
|
||||
ret some(@vec::unsafe::from_buf(cvbuf, csz));
|
||||
return some(@vec::unsafe::from_buf(cvbuf, csz));
|
||||
}
|
||||
}
|
||||
llvm::LLVMMoveToNextSection(si.llsi);
|
||||
}
|
||||
ret option::none::<@~[u8]>;
|
||||
return option::none::<@~[u8]>;
|
||||
}
|
||||
|
||||
fn meta_section_name(os: os) -> ~str {
|
||||
|
|
|
|||
|
|
@ -26,18 +26,18 @@ fn peek(st: @pstate) -> char {
|
|||
fn next(st: @pstate) -> char {
|
||||
let ch = st.data[st.pos] as char;
|
||||
st.pos = st.pos + 1u;
|
||||
ret ch;
|
||||
return ch;
|
||||
}
|
||||
|
||||
fn next_byte(st: @pstate) -> u8 {
|
||||
let b = st.data[st.pos];
|
||||
st.pos = st.pos + 1u;
|
||||
ret b;
|
||||
return b;
|
||||
}
|
||||
|
||||
fn parse_ident(st: @pstate, last: char) -> ast::ident {
|
||||
fn is_last(b: char, c: char) -> bool { ret c == b; }
|
||||
ret parse_ident_(st, |a| is_last(last, a) );
|
||||
fn is_last(b: char, c: char) -> bool { return c == b; }
|
||||
return parse_ident_(st, |a| is_last(last, a) );
|
||||
}
|
||||
|
||||
fn parse_ident_(st: @pstate, is_last: fn@(char) -> bool) ->
|
||||
|
|
@ -46,7 +46,7 @@ fn parse_ident_(st: @pstate, is_last: fn@(char) -> bool) ->
|
|||
while !is_last(peek(st)) {
|
||||
rslt += str::from_byte(next_byte(st));
|
||||
}
|
||||
ret @rslt;
|
||||
return @rslt;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -65,14 +65,14 @@ fn parse_ret_ty(st: @pstate, conv: conv_did) -> (ast::ret_style, ty::t) {
|
|||
|
||||
fn parse_path(st: @pstate) -> @ast::path {
|
||||
let mut idents: ~[ast::ident] = ~[];
|
||||
fn is_last(c: char) -> bool { ret c == '(' || c == ':'; }
|
||||
fn is_last(c: char) -> bool { return c == '(' || c == ':'; }
|
||||
vec::push(idents, parse_ident_(st, is_last));
|
||||
loop {
|
||||
alt peek(st) {
|
||||
':' { next(st); next(st); }
|
||||
c {
|
||||
if c == '(' {
|
||||
ret @{span: ast_util::dummy_sp(),
|
||||
return @{span: ast_util::dummy_sp(),
|
||||
global: false, idents: idents,
|
||||
rp: none, types: ~[]};
|
||||
} else { vec::push(idents, parse_ident_(st, is_last)); }
|
||||
|
|
@ -82,7 +82,7 @@ fn parse_path(st: @pstate) -> @ast::path {
|
|||
}
|
||||
|
||||
fn parse_ty_rust_fn(st: @pstate, conv: conv_did) -> ty::t {
|
||||
ret ty::mk_fn(st.tcx, parse_ty_fn(st, conv));
|
||||
return ty::mk_fn(st.tcx, parse_ty_fn(st, conv));
|
||||
}
|
||||
|
||||
fn parse_proto(c: char) -> ast::proto {
|
||||
|
|
@ -103,7 +103,7 @@ fn parse_vstore(st: @pstate) -> ty::vstore {
|
|||
if '0' <= c && c <= '9' {
|
||||
let n = parse_int(st) as uint;
|
||||
assert next(st) == '|';
|
||||
ret ty::vstore_fixed(n);
|
||||
return ty::vstore_fixed(n);
|
||||
}
|
||||
|
||||
alt check next(st) {
|
||||
|
|
@ -123,7 +123,7 @@ fn parse_substs(st: @pstate, conv: conv_did) -> ty::substs {
|
|||
while peek(st) != ']' { vec::push(params, parse_ty(st, conv)); }
|
||||
st.pos = st.pos + 1u;
|
||||
|
||||
ret {self_r: self_r,
|
||||
return {self_r: self_r,
|
||||
self_ty: self_ty,
|
||||
tps: params};
|
||||
}
|
||||
|
|
@ -178,70 +178,70 @@ fn parse_str(st: @pstate, term: char) -> ~str {
|
|||
result += str::from_byte(next_byte(st));
|
||||
}
|
||||
next(st);
|
||||
ret result;
|
||||
return result;
|
||||
}
|
||||
|
||||
fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
|
||||
alt check next(st) {
|
||||
'n' { ret ty::mk_nil(st.tcx); }
|
||||
'z' { ret ty::mk_bot(st.tcx); }
|
||||
'b' { ret ty::mk_bool(st.tcx); }
|
||||
'i' { ret ty::mk_int(st.tcx); }
|
||||
'u' { ret ty::mk_uint(st.tcx); }
|
||||
'l' { ret ty::mk_float(st.tcx); }
|
||||
'n' { return ty::mk_nil(st.tcx); }
|
||||
'z' { return ty::mk_bot(st.tcx); }
|
||||
'b' { return ty::mk_bool(st.tcx); }
|
||||
'i' { return ty::mk_int(st.tcx); }
|
||||
'u' { return ty::mk_uint(st.tcx); }
|
||||
'l' { return ty::mk_float(st.tcx); }
|
||||
'M' {
|
||||
alt check next(st) {
|
||||
'b' { ret ty::mk_mach_uint(st.tcx, ast::ty_u8); }
|
||||
'w' { ret ty::mk_mach_uint(st.tcx, ast::ty_u16); }
|
||||
'l' { ret ty::mk_mach_uint(st.tcx, ast::ty_u32); }
|
||||
'd' { ret ty::mk_mach_uint(st.tcx, ast::ty_u64); }
|
||||
'B' { ret ty::mk_mach_int(st.tcx, ast::ty_i8); }
|
||||
'W' { ret ty::mk_mach_int(st.tcx, ast::ty_i16); }
|
||||
'L' { ret ty::mk_mach_int(st.tcx, ast::ty_i32); }
|
||||
'D' { ret ty::mk_mach_int(st.tcx, ast::ty_i64); }
|
||||
'f' { ret ty::mk_mach_float(st.tcx, ast::ty_f32); }
|
||||
'F' { ret ty::mk_mach_float(st.tcx, ast::ty_f64); }
|
||||
'b' { return ty::mk_mach_uint(st.tcx, ast::ty_u8); }
|
||||
'w' { return ty::mk_mach_uint(st.tcx, ast::ty_u16); }
|
||||
'l' { return ty::mk_mach_uint(st.tcx, ast::ty_u32); }
|
||||
'd' { return ty::mk_mach_uint(st.tcx, ast::ty_u64); }
|
||||
'B' { return ty::mk_mach_int(st.tcx, ast::ty_i8); }
|
||||
'W' { return ty::mk_mach_int(st.tcx, ast::ty_i16); }
|
||||
'L' { return ty::mk_mach_int(st.tcx, ast::ty_i32); }
|
||||
'D' { return ty::mk_mach_int(st.tcx, ast::ty_i64); }
|
||||
'f' { return ty::mk_mach_float(st.tcx, ast::ty_f32); }
|
||||
'F' { return ty::mk_mach_float(st.tcx, ast::ty_f64); }
|
||||
}
|
||||
}
|
||||
'c' { ret ty::mk_char(st.tcx); }
|
||||
'c' { return ty::mk_char(st.tcx); }
|
||||
't' {
|
||||
assert (next(st) == '[');
|
||||
let def = parse_def(st, conv);
|
||||
let substs = parse_substs(st, conv);
|
||||
assert next(st) == ']';
|
||||
ret ty::mk_enum(st.tcx, def, substs);
|
||||
return ty::mk_enum(st.tcx, def, substs);
|
||||
}
|
||||
'x' {
|
||||
assert next(st) == '[';
|
||||
let def = parse_def(st, conv);
|
||||
let substs = parse_substs(st, conv);
|
||||
assert next(st) == ']';
|
||||
ret ty::mk_trait(st.tcx, def, substs);
|
||||
return ty::mk_trait(st.tcx, def, substs);
|
||||
}
|
||||
'p' {
|
||||
let did = parse_def(st, conv);
|
||||
ret ty::mk_param(st.tcx, parse_int(st) as uint, did);
|
||||
return ty::mk_param(st.tcx, parse_int(st) as uint, did);
|
||||
}
|
||||
's' {
|
||||
ret ty::mk_self(st.tcx);
|
||||
return ty::mk_self(st.tcx);
|
||||
}
|
||||
'@' { ret ty::mk_box(st.tcx, parse_mt(st, conv)); }
|
||||
'~' { ret ty::mk_uniq(st.tcx, parse_mt(st, conv)); }
|
||||
'*' { ret ty::mk_ptr(st.tcx, parse_mt(st, conv)); }
|
||||
'@' { return ty::mk_box(st.tcx, parse_mt(st, conv)); }
|
||||
'~' { return ty::mk_uniq(st.tcx, parse_mt(st, conv)); }
|
||||
'*' { return ty::mk_ptr(st.tcx, parse_mt(st, conv)); }
|
||||
'&' {
|
||||
let r = parse_region(st);
|
||||
let mt = parse_mt(st, conv);
|
||||
ret ty::mk_rptr(st.tcx, r, mt);
|
||||
return ty::mk_rptr(st.tcx, r, mt);
|
||||
}
|
||||
'U' { ret ty::mk_unboxed_vec(st.tcx, parse_mt(st, conv)); }
|
||||
'U' { return ty::mk_unboxed_vec(st.tcx, parse_mt(st, conv)); }
|
||||
'V' {
|
||||
let mt = parse_mt(st, conv);
|
||||
let v = parse_vstore(st);
|
||||
ret ty::mk_evec(st.tcx, mt, v);
|
||||
return ty::mk_evec(st.tcx, mt, v);
|
||||
}
|
||||
'v' {
|
||||
let v = parse_vstore(st);
|
||||
ret ty::mk_estr(st.tcx, v);
|
||||
return ty::mk_estr(st.tcx, v);
|
||||
}
|
||||
'R' {
|
||||
assert (next(st) == '[');
|
||||
|
|
@ -251,29 +251,29 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
|
|||
vec::push(fields, {ident: name, mt: parse_mt(st, conv)});
|
||||
}
|
||||
st.pos = st.pos + 1u;
|
||||
ret ty::mk_rec(st.tcx, fields);
|
||||
return ty::mk_rec(st.tcx, fields);
|
||||
}
|
||||
'T' {
|
||||
assert (next(st) == '[');
|
||||
let mut params = ~[];
|
||||
while peek(st) != ']' { vec::push(params, parse_ty(st, conv)); }
|
||||
st.pos = st.pos + 1u;
|
||||
ret ty::mk_tup(st.tcx, params);
|
||||
return ty::mk_tup(st.tcx, params);
|
||||
}
|
||||
'f' {
|
||||
parse_ty_rust_fn(st, conv)
|
||||
}
|
||||
'X' {
|
||||
ret ty::mk_var(st.tcx, ty::tv_vid(parse_int(st) as uint));
|
||||
return ty::mk_var(st.tcx, ty::tv_vid(parse_int(st) as uint));
|
||||
}
|
||||
'Y' { ret ty::mk_type(st.tcx); }
|
||||
'Y' { return ty::mk_type(st.tcx); }
|
||||
'C' {
|
||||
let ck = alt check next(st) {
|
||||
'&' { ty::ck_block }
|
||||
'@' { ty::ck_box }
|
||||
'~' { ty::ck_uniq }
|
||||
};
|
||||
ret ty::mk_opaque_closure_ptr(st.tcx, ck);
|
||||
return ty::mk_opaque_closure_ptr(st.tcx, ck);
|
||||
}
|
||||
'#' {
|
||||
let pos = parse_hex(st);
|
||||
|
|
@ -281,12 +281,12 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
|
|||
let len = parse_hex(st);
|
||||
assert (next(st) == '#');
|
||||
alt st.tcx.rcache.find({cnum: st.crate, pos: pos, len: len}) {
|
||||
some(tt) { ret tt; }
|
||||
some(tt) { return tt; }
|
||||
none {
|
||||
let ps = @{pos: pos with *st};
|
||||
let tt = parse_ty(ps, conv);
|
||||
st.tcx.rcache.insert({cnum: st.crate, pos: pos, len: len}, tt);
|
||||
ret tt;
|
||||
return tt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -304,7 +304,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
|
|||
debug!{"parsed a def_id %?", did};
|
||||
let substs = parse_substs(st, conv);
|
||||
assert (next(st) == ']');
|
||||
ret ty::mk_class(st.tcx, did, substs);
|
||||
return ty::mk_class(st.tcx, did, substs);
|
||||
}
|
||||
c { error!{"unexpected char in type string: %c", c}; fail;}
|
||||
}
|
||||
|
|
@ -317,21 +317,21 @@ fn parse_mt(st: @pstate, conv: conv_did) -> ty::mt {
|
|||
'?' { next(st); m = ast::m_const; }
|
||||
_ { m = ast::m_imm; }
|
||||
}
|
||||
ret {ty: parse_ty(st, conv), mutbl: m};
|
||||
return {ty: parse_ty(st, conv), mutbl: m};
|
||||
}
|
||||
|
||||
fn parse_def(st: @pstate, conv: conv_did) -> ast::def_id {
|
||||
let mut def = ~[];
|
||||
while peek(st) != '|' { vec::push(def, next_byte(st)); }
|
||||
st.pos = st.pos + 1u;
|
||||
ret conv(parse_def_id(def));
|
||||
return conv(parse_def_id(def));
|
||||
}
|
||||
|
||||
fn parse_int(st: @pstate) -> int {
|
||||
let mut n = 0;
|
||||
loop {
|
||||
let cur = peek(st);
|
||||
if cur < '0' || cur > '9' { ret n; }
|
||||
if cur < '0' || cur > '9' { return n; }
|
||||
st.pos = st.pos + 1u;
|
||||
n *= 10;
|
||||
n += (cur as int) - ('0' as int);
|
||||
|
|
@ -342,7 +342,7 @@ fn parse_hex(st: @pstate) -> uint {
|
|||
let mut n = 0u;
|
||||
loop {
|
||||
let cur = peek(st);
|
||||
if (cur < '0' || cur > '9') && (cur < 'a' || cur > 'f') { ret n; }
|
||||
if (cur < '0' || cur > '9') && (cur < 'a' || cur > 'f') { return n; }
|
||||
st.pos = st.pos + 1u;
|
||||
n *= 16u;
|
||||
if '0' <= cur && cur <= '9' {
|
||||
|
|
@ -378,7 +378,7 @@ fn parse_ty_fn(st: @pstate, conv: conv_did) -> ty::fn_ty {
|
|||
}
|
||||
st.pos += 1u; // eat the ']'
|
||||
let (ret_style, ret_ty) = parse_ret_ty(st, conv);
|
||||
ret {purity: purity, proto: proto, inputs: inputs, output: ret_ty,
|
||||
return {purity: purity, proto: proto, inputs: inputs, output: ret_ty,
|
||||
ret_style: ret_style};
|
||||
}
|
||||
|
||||
|
|
@ -405,7 +405,7 @@ fn parse_def_id(buf: &[u8]) -> ast::def_id {
|
|||
none { fail (fmt!{"internal error: parse_def_id: id expected, but \
|
||||
found %?", def_part}); }
|
||||
};
|
||||
ret {crate: crate_num, node: def_num};
|
||||
return {crate: crate_num, node: def_num};
|
||||
}
|
||||
|
||||
fn parse_bounds_data(data: @~[u8], start: uint,
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ enum abbrev_ctxt { ac_no_abbrevs, ac_use_abbrevs(hashmap<ty::t, ty_abbrev>), }
|
|||
|
||||
fn cx_uses_abbrevs(cx: @ctxt) -> bool {
|
||||
alt cx.abbrevs {
|
||||
ac_no_abbrevs { ret false; }
|
||||
ac_use_abbrevs(_) { ret true; }
|
||||
ac_no_abbrevs { return false; }
|
||||
ac_use_abbrevs(_) { return true; }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) {
|
|||
}
|
||||
ac_use_abbrevs(abbrevs) {
|
||||
alt abbrevs.find(t) {
|
||||
some(a) { w.write_str(*a.s); ret; }
|
||||
some(a) { w.write_str(*a.s); return; }
|
||||
none {
|
||||
let pos = w.tell();
|
||||
alt ty::type_def_id(t) {
|
||||
|
|
@ -79,7 +79,7 @@ fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) {
|
|||
let mut n = u;
|
||||
let mut len = 0u;
|
||||
while n != 0u { len += 1u; n = n >> 4u; }
|
||||
ret len;
|
||||
return len;
|
||||
}
|
||||
let abbrev_len = 3u + estimate_sz(pos) + estimate_sz(len);
|
||||
if abbrev_len < len {
|
||||
|
|
@ -89,7 +89,7 @@ fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) {
|
|||
let a = {pos: pos, len: len, s: @s};
|
||||
abbrevs.insert(t, a);
|
||||
}
|
||||
ret;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue