Convert ret to return

This commit is contained in:
Brian Anderson
2012-08-01 17:30:05 -07:00
parent dc499f193e
commit b355936b4d
456 changed files with 3875 additions and 3798 deletions

View File

@@ -66,13 +66,13 @@ const worst_case_glue_call_args: uint = 7u;
const abi_version: uint = 1u;
fn memcpy_glue_name() -> ~str { ret ~"rust_memcpy_glue"; }
fn memcpy_glue_name() -> ~str { return ~"rust_memcpy_glue"; }
fn bzero_glue_name() -> ~str { ret ~"rust_bzero_glue"; }
fn bzero_glue_name() -> ~str { return ~"rust_bzero_glue"; }
fn yield_glue_name() -> ~str { ret ~"rust_yield_glue"; }
fn yield_glue_name() -> ~str { return ~"rust_yield_glue"; }
fn no_op_type_glue_name() -> ~str { ret ~"rust_no_op_type_glue"; }
fn no_op_type_glue_name() -> ~str { return ~"rust_no_op_type_glue"; }
//
// Local Variables:
// mode: rust

View File

@@ -51,9 +51,9 @@ mod write {
fn is_object_or_assembly_or_exe(ot: output_type) -> bool {
if ot == output_type_assembly || ot == output_type_object ||
ot == output_type_exe {
ret true;
return true;
}
ret false;
return false;
}
// Decides what to call an intermediate file, given the name of the output
@@ -64,7 +64,7 @@ mod write {
some(dot_pos) { str::slice(output_path, 0u, dot_pos) }
none { output_path }
};
ret stem + ~"." + extension;
return stem + ~"." + extension;
}
fn run_passes(sess: session, llmod: ModuleRef, output: ~str) {
@@ -234,7 +234,7 @@ mod write {
llvm::LLVMDisposeModule(llmod);
if sess.time_llvm_passes() { llvm::LLVMRustPrintPassTimings(); }
ret;
return;
}
if opts.output_type == output_type_llvm_assembly {
@@ -334,7 +334,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str,
}
} else { vec::push(cmh_items, meta); }
}
ret {name: name, vers: vers, cmh_items: cmh_items};
return {name: name, vers: vers, cmh_items: cmh_items};
}
// This calculates CMH as defined above
@@ -343,11 +343,11 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str,
metas: provided_metas,
dep_hashes: ~[@~str]) -> ~str {
fn len_and_str(s: ~str) -> ~str {
ret fmt!{"%u_%s", str::len(s), s};
return fmt!{"%u_%s", str::len(s), s};
}
fn len_and_str_lit(l: ast::lit) -> ~str {
ret len_and_str(pprust::lit_to_str(@l));
return len_and_str(pprust::lit_to_str(@l));
}
let cmh_items = attr::sort_meta_items(metas.cmh_items);
@@ -374,18 +374,18 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str,
symbol_hasher.input_str(len_and_str(*dh));
}
ret truncated_hash_result(symbol_hasher);
return truncated_hash_result(symbol_hasher);
}
fn warn_missing(sess: session, name: ~str, default: ~str) {
if !sess.building_library { ret; }
if !sess.building_library { return; }
sess.warn(fmt!{"missing crate link meta `%s`, using `%s` as default",
name, default});
}
fn crate_meta_name(sess: session, _crate: ast::crate,
output: ~str, metas: provided_metas) -> @~str {
ret alt metas.name {
return alt metas.name {
some(v) { v }
none {
let name =
@@ -407,7 +407,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str,
fn crate_meta_vers(sess: session, _crate: ast::crate,
metas: provided_metas) -> @~str {
ret alt metas.vers {
return alt metas.vers {
some(v) { v }
none {
let vers = ~"0.0";
@@ -424,7 +424,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str,
let extras_hash =
crate_meta_extras_hash(symbol_hasher, c, provided_metas, dep_hashes);
ret {name: name, vers: vers, extras_hash: extras_hash};
return {name: name, vers: vers, extras_hash: extras_hash};
}
fn truncated_hash_result(symbol_hasher: hash::streaming) -> ~str unsafe {
@@ -447,16 +447,16 @@ fn symbol_hash(tcx: ty::ctxt, symbol_hasher: hash::streaming, t: ty::t,
let hash = truncated_hash_result(symbol_hasher);
// Prefix with _ so that it never blends into adjacent digits
ret ~"_" + hash;
return ~"_" + hash;
}
fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> ~str {
alt ccx.type_hashcodes.find(t) {
some(h) { ret h; }
some(h) { return h; }
none {
let hash = symbol_hash(ccx.tcx, ccx.symbol_hasher, t, ccx.link_meta);
ccx.type_hashcodes.insert(t, hash);
ret hash;
return hash;
}
}
}
@@ -491,10 +491,10 @@ fn sanitize(s: ~str) -> ~str {
if result.len() > 0u &&
result[0] != '_' as u8 &&
! char::is_XID_start(result[0] as char) {
ret ~"_" + result;
return ~"_" + result;
}
ret result;
return result;
}
fn mangle(ss: path) -> ~str {
@@ -513,14 +513,14 @@ fn mangle(ss: path) -> ~str {
}
fn exported_name(path: path, hash: @~str, vers: @~str) -> ~str {
ret mangle(
return mangle(
vec::append_one(vec::append_one(path, path_name(hash)),
path_name(vers)));
}
fn mangle_exported_name(ccx: @crate_ctxt, path: path, t: ty::t) -> ~str {
let hash = get_symbol_hash(ccx, t);
ret exported_name(path, @hash, ccx.link_meta.vers);
return exported_name(path, @hash, ccx.link_meta.vers);
}
fn mangle_internal_name_by_type_only(ccx: @crate_ctxt,
@@ -528,20 +528,20 @@ fn mangle_internal_name_by_type_only(ccx: @crate_ctxt,
~str {
let s = @util::ppaux::ty_to_short_str(ccx.tcx, t);
let hash = get_symbol_hash(ccx, t);
ret mangle(~[path_name(name), path_name(s), path_name(@hash)]);
return mangle(~[path_name(name), path_name(s), path_name(@hash)]);
}
fn mangle_internal_name_by_path_and_seq(ccx: @crate_ctxt, path: path,
flav: @~str) -> ~str {
ret mangle(vec::append_one(path, path_name(@ccx.names(*flav))));
return mangle(vec::append_one(path, path_name(@ccx.names(*flav))));
}
fn mangle_internal_name_by_path(_ccx: @crate_ctxt, path: path) -> ~str {
ret mangle(path);
return mangle(path);
}
fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: @~str) -> ~str {
ret ccx.names(*flav);
return ccx.names(*flav);
}
// If the user wants an exe generated we need to invoke
@@ -558,15 +558,15 @@ fn link_binary(sess: session,
(config.os == session::os_linux ||
config.os == session::os_freebsd) &&
option::is_some(found) && option::get(found) == 0u {
ret str::slice(filename, 3u, str::len(filename));
} else { ret filename; }
return str::slice(filename, 3u, str::len(filename));
} else { return filename; }
};
fn rmext(filename: ~str) -> ~str {
let mut parts = str::split_char(filename, '.');
vec::pop(parts);
ret str::connect(parts, ~".");
return str::connect(parts, ~".");
}
ret alt config.os {
return alt config.os {
session::os_macos { rmext(rmlib(filename)) }
session::os_linux { rmext(rmlib(filename)) }
session::os_freebsd { rmext(rmlib(filename)) }

View File

@@ -18,7 +18,7 @@ fn get_rpath_flags(sess: session::session, out_filename: ~str) -> ~[~str] {
// No rpath on windows
if os == session::os_win32 {
ret ~[];
return ~[];
}
debug!{"preparing the RPATH!"};
@@ -89,7 +89,7 @@ fn get_rpaths(os: session::os, cwd: path::path, sysroot: path::path,
// Remove duplicates
let rpaths = minimize_rpaths(rpaths);
ret rpaths;
return rpaths;
}
fn get_rpaths_relative_to_output(os: session::os,
@@ -148,9 +148,9 @@ fn get_relative_to(abs1: path::path, abs2: path::path) -> path::path {
vec::push_all(path, vec::view(split2, start_idx, len2 - 1u));
if vec::is_not_empty(path) {
ret path::connect_many(path);
return path::connect_many(path);
} else {
ret ~".";
return ~".";
}
}
@@ -192,7 +192,7 @@ fn minimize_rpaths(rpaths: ~[~str]) -> ~[~str] {
set.insert(rpath, ());
}
}
ret minimized;
return minimized;
}
#[cfg(unix)]

View File

@@ -36,7 +36,7 @@ fn declare_upcalls(targ_cfg: @session::config,
let mut arg_tys: ~[TypeRef] = ~[];
for tys.each |t| { vec::push(arg_tys, t); }
let fn_ty = T_fn(arg_tys, rv);
ret base::decl_cdecl_fn(llmod, prefix + name, fn_ty);
return base::decl_cdecl_fn(llmod, prefix + name, fn_ty);
}
fn nothrow(f: ValueRef) -> ValueRef {
base::set_no_unwind(f); f
@@ -47,7 +47,7 @@ fn declare_upcalls(targ_cfg: @session::config,
let int_t = T_int(targ_cfg);
let size_t = T_size_t(targ_cfg);
ret @{_fail: dv(~"fail", ~[T_ptr(T_i8()),
return @{_fail: dv(~"fail", ~[T_ptr(T_i8()),
T_ptr(T_i8()),
size_t]),
trace: dv(~"trace", ~[T_ptr(T_i8()),

View File

@@ -3,7 +3,7 @@ import session::sess_os_to_meta_os;
import metadata::loader::meta_section_name;
fn get_target_strs(target_os: session::os) -> target_strs::t {
ret {
return {
module_asm: ~"",
meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)),

View File

@@ -3,7 +3,7 @@ import session::sess_os_to_meta_os;
import metadata::loader::meta_section_name;
fn get_target_strs(target_os: session::os) -> target_strs::t {
ret {
return {
module_asm: ~"",
meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)),

View File

@@ -50,7 +50,7 @@ fn default_configuration(sess: session, argv0: ~str, input: input) ->
session::arch_arm { ~"arm" }
};
ret ~[ // Target bindings.
return ~[ // Target bindings.
attr::mk_word_item(@os::family()),
mk(@~"target_os", os::sysname()),
mk(@~"target_family", os::family()),
@@ -76,7 +76,7 @@ fn build_configuration(sess: session, argv0: ~str, input: input) ->
~[attr::mk_word_item(@~"notest")]
}
};
ret vec::append(vec::append(user_cfg, gen_cfg), default_cfg);
return vec::append(vec::append(user_cfg, gen_cfg), default_cfg);
}
// Convert strings provided as --cfg [cfgspec] into a crate_cfg
@@ -86,7 +86,7 @@ fn parse_cfgspecs(cfgspecs: ~[~str]) -> ast::crate_cfg {
// meta_word variant.
let mut words = ~[];
for cfgspecs.each |s| { vec::push(words, attr::mk_word_item(@s)); }
ret words;
return words;
}
enum input {
@@ -111,13 +111,13 @@ fn parse_input(sess: session, cfg: ast::crate_cfg, input: input)
}
fn time<T>(do_it: bool, what: ~str, thunk: fn() -> T) -> T {
if !do_it { ret thunk(); }
if !do_it { return thunk(); }
let start = std::time::precise_time_s();
let rv = thunk();
let end = std::time::precise_time_s();
io::stdout().write_str(fmt!{"time: %3.3f s\t%s\n",
end - start, what});
ret rv;
return rv;
}
enum compile_upto {
@@ -135,7 +135,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
let time_passes = sess.time_passes();
let mut crate = time(time_passes, ~"parsing",
||parse_input(sess, cfg, input) );
if upto == cu_parse { ret {crate: crate, tcx: none}; }
if upto == cu_parse { return {crate: crate, tcx: none}; }
sess.building_library = session::building_library(
sess.opts.crate_type, crate, sess.opts.test);
@@ -150,7 +150,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
syntax::ext::expand::expand_crate(sess.parse_sess, sess.opts.cfg,
crate));
if upto == cu_expand { ret {crate: crate, tcx: none}; }
if upto == cu_expand { return {crate: crate, tcx: none}; }
crate = time(time_passes, ~"intrinsic injection", ||
front::intrinsic_inject::inject_intrinsic(sess, crate));
@@ -205,7 +205,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
middle::check_const::check_crate(sess, crate, ast_map, def_map,
method_map, ty_cx));
if upto == cu_typeck { ret {crate: crate, tcx: some(ty_cx)}; }
if upto == cu_typeck { return {crate: crate, tcx: some(ty_cx)}; }
time(time_passes, ~"block-use checking", ||
middle::block_use::check_crate(ty_cx, crate));
@@ -228,7 +228,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
time(time_passes, ~"lint checking", || lint::check_crate(ty_cx, crate));
if upto == cu_no_trans { ret {crate: crate, tcx: some(ty_cx)}; }
if upto == cu_no_trans { return {crate: crate, tcx: some(ty_cx)}; }
let outputs = option::get(outputs);
let maps = {mutbl_map: mutbl_map, root_map: root_map,
@@ -247,13 +247,13 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
sess.opts.output_type != link::output_type_exe ||
sess.opts.static && sess.building_library;
if stop_after_codegen { ret {crate: crate, tcx: some(ty_cx)}; }
if stop_after_codegen { return {crate: crate, tcx: some(ty_cx)}; }
time(time_passes, ~"linking", ||
link::link_binary(sess, outputs.obj_filename,
outputs.out_filename, link_meta));
ret {crate: crate, tcx: some(ty_cx)};
return {crate: crate, tcx: some(ty_cx)};
}
fn compile_input(sess: session, cfg: ast::crate_cfg, input: input,
@@ -338,7 +338,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input,
}
fn get_os(triple: ~str) -> option<session::os> {
ret if str::contains(triple, ~"win32") ||
if str::contains(triple, ~"win32") ||
str::contains(triple, ~"mingw32") {
some(session::os_win32)
} else if str::contains(triple, ~"darwin") {
@@ -347,11 +347,12 @@ fn get_os(triple: ~str) -> option<session::os> {
some(session::os_linux)
} else if str::contains(triple, ~"freebsd") {
some(session::os_freebsd)
} else { none };
} else { none }
}
fn get_arch(triple: ~str) -> option<session::arch> {
ret if str::contains(triple, ~"i386") || str::contains(triple, ~"i486") ||
if str::contains(triple, ~"i386") ||
str::contains(triple, ~"i486") ||
str::contains(triple, ~"i586") ||
str::contains(triple, ~"i686") ||
str::contains(triple, ~"i786") {
@@ -361,7 +362,7 @@ fn get_arch(triple: ~str) -> option<session::arch> {
} else if str::contains(triple, ~"arm") ||
str::contains(triple, ~"xscale") {
some(session::arch_arm)
} else { none };
} else { none }
}
fn build_target_config(sopts: @session::options,
@@ -388,7 +389,7 @@ fn build_target_config(sopts: @session::options,
let target_cfg: @session::config =
@{os: os, arch: arch, target_strs: target_strs, int_type: int_type,
uint_type: uint_type, float_type: float_type};
ret target_cfg;
return target_cfg;
}
fn host_triple() -> ~str {
@@ -401,7 +402,7 @@ fn host_triple() -> ~str {
// be grabbing (at compile time) the target triple that this rustc is
// built with and calling that (at runtime) the host triple.
let ht = env!{"CFG_HOST_TRIPLE"};
ret if ht != ~"" {
return if ht != ~"" {
ht
} else {
fail ~"rustc built without CFG_HOST_TRIPLE"
@@ -530,7 +531,7 @@ fn build_session_options(matches: getopts::matches,
parse_only: parse_only,
no_trans: no_trans,
debugging_opts: debugging_opts};
ret sopts;
return sopts;
}
fn build_session(sopts: @session::options,
@@ -573,22 +574,23 @@ fn build_session_(sopts: @session::options,
fn parse_pretty(sess: session, &&name: ~str) -> pp_mode {
if str::eq(name, ~"normal") {
ret ppm_normal;
return ppm_normal;
} else if str::eq(name, ~"expanded") {
ret ppm_expanded;
return ppm_expanded;
} else if str::eq(name, ~"typed") {
ret ppm_typed;
return ppm_typed;
} else if str::eq(name, ~"expanded,identified") {
ret ppm_expanded_identified;
return ppm_expanded_identified;
} else if str::eq(name, ~"identified") {
ret ppm_identified;
return ppm_identified;
}
sess.fatal(~"argument to `pretty` must be one of `normal`, `typed`, or " +
~"`identified`");
}
fn opts() -> ~[getopts::opt] {
ret ~[optflag(~"h"), optflag(~"help"), optflag(~"v"), optflag(~"version"),
return ~[optflag(~"h"), optflag(~"help"),
optflag(~"v"), optflag(~"version"),
optflag(~"emit-llvm"), optflagopt(~"pretty"),
optflag(~"ls"), optflag(~"parse-only"), optflag(~"no-trans"),
optflag(~"O"), optopt(~"opt-level"), optmulti(~"L"), optflag(~"S"),
@@ -699,7 +701,7 @@ fn build_output_filenames(input: input,
}
}
}
ret @{out_filename: out_path,
return @{out_filename: out_path,
obj_filename: obj_path};
}

View File

@@ -121,7 +121,7 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) {
let mut args = args;
let binary = vec::shift(args);
if vec::len(args) == 0u { usage(binary); ret; }
if vec::len(args) == 0u { usage(binary); return; }
let matches =
alt getopts::getopts(args, opts()) {
@@ -133,24 +133,24 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) {
if opt_present(matches, ~"h") || opt_present(matches, ~"help") {
usage(binary);
ret;
return;
}
let lint_flags = vec::append(getopts::opt_strs(matches, ~"W"),
getopts::opt_strs(matches, ~"warn"));
if lint_flags.contains(~"help") {
describe_warnings();
ret;
return;
}
if getopts::opt_strs(matches, ~"Z").contains(~"help") {
describe_debug_flags();
ret;
return;
}
if opt_present(matches, ~"v") || opt_present(matches, ~"version") {
version(binary);
ret;
return;
}
let input = alt vec::len(matches.free) {
0u { early_error(demitter, ~"no input filename given") }
@@ -176,7 +176,10 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) {
~"normal"),
|a| parse_pretty(sess, a) );
alt pretty {
some::<pp_mode>(ppm) { pretty_print_input(sess, cfg, input, ppm); ret; }
some::<pp_mode>(ppm) {
pretty_print_input(sess, cfg, input, ppm);
return;
}
none::<pp_mode> {/* continue */ }
}
let ls = opt_present(matches, ~"ls");
@@ -189,7 +192,7 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) {
early_error(demitter, ~"can not list metadata for stdin");
}
}
ret;
return;
}
compile_input(sess, cfg, input, odir, ofile);

View File

@@ -168,7 +168,7 @@ impl session for session {
self.span_lint_level(level, span, msg);
}
fn next_node_id() -> ast::node_id {
ret syntax::parse::next_node_id(self.parse_sess);
return syntax::parse::next_node_id(self.parse_sess);
}
fn diagnostic() -> diagnostic::span_handler {
self.span_diagnostic

View File

@@ -31,7 +31,7 @@ fn strip_items(crate: @ast::crate, in_cfg: in_cfg_pred)
let fold = fold::make_fold(precursor);
let res = @fold.fold_crate(*crate);
ret res;
return res;
}
fn filter_item(cx: ctxt, &&item: @ast::item) ->
@@ -54,8 +54,10 @@ fn fold_mod(cx: ctxt, m: ast::_mod, fld: fold::ast_fold) ->
let filtered_items = vec::filter_map(m.items, item_filter);
let view_item_filter = |a| filter_view_item(cx, a);
let filtered_view_items = vec::filter_map(m.view_items, view_item_filter);
ret {view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(x)),
items: vec::filter_map(filtered_items, |x| fld.fold_item(x))};
return {
view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(x)),
items: vec::filter_map(filtered_items, |x| fld.fold_item(x))
};
}
fn filter_foreign_item(cx: ctxt, &&item: @ast::foreign_item) ->
@@ -72,8 +74,10 @@ fn fold_foreign_mod(cx: ctxt, nm: ast::foreign_mod,
let view_item_filter = |a| filter_view_item(cx, a);
let filtered_view_items = vec::filter_map(
nm.view_items, view_item_filter);
ret {view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(x)),
items: filtered_items};
return {
view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(x)),
items: filtered_items
};
}
fn filter_stmt(cx: ctxt, &&stmt: @ast::stmt) ->
@@ -97,7 +101,7 @@ fn fold_block(cx: ctxt, b: ast::blk_, fld: fold::ast_fold) ->
ast::blk_ {
let filter = |a| filter_stmt(cx, a);
let filtered_stmts = vec::filter_map(b.stmts, filter);
ret {view_items: b.view_items,
return {view_items: b.view_items,
stmts: vec::map(filtered_stmts, |x| fld.fold_stmt(x)),
expr: option::map(b.expr, |x| fld.fold_expr(x)),
id: b.id,
@@ -105,15 +109,15 @@ fn fold_block(cx: ctxt, b: ast::blk_, fld: fold::ast_fold) ->
}
fn item_in_cfg(cx: ctxt, item: @ast::item) -> bool {
ret cx.in_cfg(item.attrs);
return cx.in_cfg(item.attrs);
}
fn foreign_item_in_cfg(cx: ctxt, item: @ast::foreign_item) -> bool {
ret cx.in_cfg(item.attrs);
return cx.in_cfg(item.attrs);
}
fn view_item_in_cfg(cx: ctxt, item: @ast::view_item) -> bool {
ret cx.in_cfg(item.attrs);
return cx.in_cfg(item.attrs);
}
// Determine if an item should be translated in the current crate
@@ -134,13 +138,13 @@ fn metas_in_cfg(cfg: ast::crate_cfg, metas: ~[@ast::meta_item]) -> bool {
|&&i| attr::get_meta_item_list(i) ));
let has_cfg_metas = vec::len(cfg_metas) > 0u;
if !has_cfg_metas { ret true; }
if !has_cfg_metas { return true; }
for cfg_metas.each |cfg_mi| {
if attr::contains(cfg, cfg_mi) { ret true; }
if attr::contains(cfg, cfg_mi) { return true; }
}
ret false;
return false;
}

View File

@@ -23,7 +23,7 @@ fn inject_libcore_ref(sess: session,
crate: @ast::crate) -> @ast::crate {
fn spanned<T: copy>(x: T) -> @ast::spanned<T> {
ret @{node: x,
return @{node: x,
span: dummy_sp()};
}
@@ -43,6 +43,6 @@ fn inject_libcore_ref(sess: session,
let vis = vec::append(~[vi1, vi2], crate.node.module.view_items);
ret @{node: {module: { view_items: vis with crate.node.module }
return @{node: {module: { view_items: vis with crate.node.module }
with crate.node} with *crate }
}

View File

@@ -24,6 +24,6 @@ fn inject_intrinsic(sess: session,
let items = vec::append(~[item], crate.node.module.items);
ret @{node: {module: { items: items with crate.node.module }
return @{node: {module: { items: items with crate.node.module }
with crate.node} with *crate }
}

View File

@@ -51,7 +51,7 @@ fn generate_test_harness(sess: session::session,
let fold = fold::make_fold(precursor);
let res = @fold.fold_crate(*crate);
ret res;
return res;
}
fn strip_test_functions(crate: @ast::crate) -> @ast::crate {
@@ -82,7 +82,7 @@ fn fold_mod(_cx: test_ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod {
let mod_nomain =
{view_items: m.view_items, items: vec::filter_map(m.items, nomain)};
ret fold::noop_fold_mod(mod_nomain, fld);
return fold::noop_fold_mod(mod_nomain, fld);
}
fn fold_crate(cx: test_ctxt, c: ast::crate_, fld: fold::ast_fold) ->
@@ -91,7 +91,7 @@ fn fold_crate(cx: test_ctxt, c: ast::crate_, fld: fold::ast_fold) ->
// Add a special __test module to the crate that will contain code
// generated for the test harness
ret {module: add_test_module(cx, folded.module) with folded};
return {module: add_test_module(cx, folded.module) with folded};
}
@@ -121,7 +121,7 @@ fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) ->
let res = fold::noop_fold_item(i, fld);
vec::pop(cx.path);
ret res;
return res;
}
fn is_test_fn(i: @ast::item) -> bool {
@@ -140,7 +140,7 @@ fn is_test_fn(i: @ast::item) -> bool {
}
}
ret has_test_attr && has_test_signature(i);
return has_test_attr && has_test_signature(i);
}
fn is_ignored(cx: test_ctxt, i: @ast::item) -> bool {
@@ -148,7 +148,7 @@ fn is_ignored(cx: test_ctxt, i: @ast::item) -> bool {
let ignoreitems = attr::attr_metas(ignoreattrs);
let cfg_metas = vec::concat(vec::filter_map(ignoreitems,
|&&i| attr::get_meta_item_list(i) ));
ret if vec::is_not_empty(ignoreitems) {
return if vec::is_not_empty(ignoreitems) {
config::metas_in_cfg(cx.crate.node.config, cfg_metas)
} else {
false
@@ -161,7 +161,7 @@ fn should_fail(i: @ast::item) -> bool {
fn add_test_module(cx: test_ctxt, m: ast::_mod) -> ast::_mod {
let testmod = mk_test_module(cx);
ret {items: vec::append_one(m.items, testmod) with m};
return {items: vec::append_one(m.items, testmod) with m};
}
/*
@@ -203,11 +203,11 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item {
debug!{"Synthetic test module:\n%s\n", pprust::item_to_str(@item)};
ret @item;
return @item;
}
fn nospan<T: copy>(t: T) -> ast::spanned<T> {
ret {node: t, span: dummy_sp()};
return {node: t, span: dummy_sp()};
}
fn path_node(ids: ~[ast::ident]) -> @ast::path {
@@ -238,7 +238,7 @@ fn mk_tests(cx: test_ctxt) -> @ast::item {
node: item_,
vis: ast::public,
span: dummy_sp()};
ret @item;
return @item;
}
fn mk_path(cx: test_ctxt, path: ~[ast::ident]) -> ~[ast::ident] {
@@ -270,7 +270,7 @@ fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty {
let inner_ty = @{id: cx.sess.next_node_id(),
node: ast::ty_vec(vec_mt),
span: dummy_sp()};
ret @{id: cx.sess.next_node_id(),
return @{id: cx.sess.next_node_id(),
node: ast::ty_uniq({ty: inner_ty, mutbl: ast::m_imm}),
span: dummy_sp()};
}
@@ -286,7 +286,7 @@ fn mk_test_desc_vec(cx: test_ctxt) -> @ast::expr {
callee_id: cx.sess.next_node_id(),
node: ast::expr_vec(descs, ast::m_imm),
span: dummy_sp()};
ret @{id: cx.sess.next_node_id(),
return @{id: cx.sess.next_node_id(),
callee_id: cx.sess.next_node_id(),
node: ast::expr_vstore(inner_expr, ast::vstore_uniq),
span: dummy_sp()};
@@ -358,7 +358,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
let desc_rec: ast::expr =
{id: cx.sess.next_node_id(), callee_id: cx.sess.next_node_id(),
node: desc_rec_, span: span};
ret @desc_rec;
return @desc_rec;
}
// Produces a bare function that wraps the test function
@@ -400,7 +400,7 @@ fn mk_test_wrapper(cx: test_ctxt,
span: span
};
ret @wrapper_expr;
return @wrapper_expr;
}
fn mk_main(cx: test_ctxt) -> @ast::item {
@@ -451,7 +451,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
node: item_,
vis: ast::public,
span: dummy_sp()};
ret @item;
return @item;
}
fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
@@ -497,7 +497,7 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
{id: cx.sess.next_node_id(), callee_id: cx.sess.next_node_id(),
node: test_main_call_expr_, span: dummy_sp()};
ret @test_main_call_expr;
return @test_main_call_expr;
}
// Local Variables:

View File

@@ -995,28 +995,28 @@ fn associate_type(tn: type_names, s: ~str, t: TypeRef) {
}
fn type_has_name(tn: type_names, t: TypeRef) -> option<~str> {
ret tn.type_names.find(t);
return tn.type_names.find(t);
}
fn name_has_type(tn: type_names, s: ~str) -> option<TypeRef> {
ret tn.named_types.find(s);
return tn.named_types.find(s);
}
fn mk_type_names() -> type_names {
fn hash(&&t: TypeRef) -> uint { ret t as uint; }
fn eq(&&a: TypeRef, &&b: TypeRef) -> bool { ret a as uint == b as uint; }
fn hash(&&t: TypeRef) -> uint { return t as uint; }
fn eq(&&a: TypeRef, &&b: TypeRef) -> bool { a as uint == b as uint }
@{type_names: std::map::hashmap(hash, eq),
named_types: std::map::str_hash()}
}
fn type_to_str(names: type_names, ty: TypeRef) -> ~str {
ret type_to_str_inner(names, ~[], ty);
return type_to_str_inner(names, ~[], ty);
}
fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) ->
~str {
alt type_has_name(names, ty) {
option::some(n) { ret n; }
option::some(n) { return n; }
_ {}
}
@@ -1032,20 +1032,20 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) ->
if first { first = false; } else { s += ~", "; }
s += type_to_str_inner(names, outer, t);
}
ret s;
return s;
}
alt kind {
Void { ret ~"Void"; }
Half { ret ~"Half"; }
Float { ret ~"Float"; }
Double { ret ~"Double"; }
X86_FP80 { ret ~"X86_FP80"; }
FP128 { ret ~"FP128"; }
PPC_FP128 { ret ~"PPC_FP128"; }
Label { ret ~"Label"; }
Void { return ~"Void"; }
Half { return ~"Half"; }
Float { return ~"Float"; }
Double { return ~"Double"; }
X86_FP80 { return ~"X86_FP80"; }
FP128 { return ~"FP128"; }
PPC_FP128 { return ~"PPC_FP128"; }
Label { return ~"Label"; }
Integer {
ret ~"i" + int::str(llvm::LLVMGetIntTypeWidth(ty) as int);
return ~"i" + int::str(llvm::LLVMGetIntTypeWidth(ty) as int);
}
Function {
let mut s = ~"fn(";
@@ -1058,7 +1058,7 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) ->
s += tys_str(names, outer, args);
s += ~") -> ";
s += type_to_str_inner(names, outer, out_ty);
ret s;
return s;
}
Struct {
let mut s: ~str = ~"{";
@@ -1069,11 +1069,11 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) ->
}
s += tys_str(names, outer, elts);
s += ~"}";
ret s;
return s;
}
Array {
let el_ty = llvm::LLVMGetElementType(ty);
ret ~"[" + type_to_str_inner(names, outer, el_ty) + ~" x " +
return ~"[" + type_to_str_inner(names, outer, el_ty) + ~" x " +
uint::str(llvm::LLVMGetArrayLength(ty) as uint) + ~"]";
}
Pointer {
@@ -1082,7 +1082,7 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) ->
i += 1u;
if tout as int == ty as int {
let n: uint = vec::len::<TypeRef>(outer0) - i;
ret ~"*\\" + int::str(n as int);
return ~"*\\" + int::str(n as int);
}
}
let addrstr = {
@@ -1093,17 +1093,17 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) ->
fmt!{"addrspace(%u)", addrspace}
}
};
ret addrstr + ~"*" +
return addrstr + ~"*" +
type_to_str_inner(names, outer, llvm::LLVMGetElementType(ty));
}
Vector { ret ~"Vector"; }
Metadata { ret ~"Metadata"; }
X86_MMX { ret ~"X86_MMAX"; }
Vector { return ~"Vector"; }
Metadata { return ~"Metadata"; }
X86_MMX { return ~"X86_MMAX"; }
}
}
fn float_width(llt: TypeRef) -> uint {
ret alt llvm::LLVMGetTypeKind(llt) as int {
return alt llvm::LLVMGetTypeKind(llt) as int {
1 { 32u }
2 { 64u }
3 { 80u }
@@ -1116,7 +1116,7 @@ fn fn_ty_param_tys(fn_ty: TypeRef) -> ~[TypeRef] unsafe {
let args = vec::from_elem(llvm::LLVMCountParamTypes(fn_ty) as uint,
0 as TypeRef);
llvm::LLVMGetParamTypes(fn_ty, vec::unsafe::to_ptr(args));
ret args;
return args;
}
@@ -1133,7 +1133,7 @@ type target_data = {lltd: TargetDataRef, dtor: @target_data_res};
fn mk_target_data(string_rep: ~str) -> target_data {
let lltd =
str::as_c_str(string_rep, |buf| llvm::LLVMCreateTargetData(buf) );
ret {lltd: lltd, dtor: @target_data_res(lltd)};
return {lltd: lltd, dtor: @target_data_res(lltd)};
}
/* Memory-managed interface to pass managers. */
@@ -1148,7 +1148,7 @@ type pass_manager = {llpm: PassManagerRef, dtor: @pass_manager_res};
fn mk_pass_manager() -> pass_manager {
let llpm = llvm::LLVMCreatePassManager();
ret {llpm: llpm, dtor: @pass_manager_res(llpm)};
return {llpm: llpm, dtor: @pass_manager_res(llpm)};
}
/* Memory-managed interface to object files. */
@@ -1163,8 +1163,8 @@ type object_file = {llof: ObjectFileRef, dtor: @object_file_res};
fn mk_object_file(llmb: MemoryBufferRef) -> option<object_file> {
let llof = llvm::LLVMCreateObjectFile(llmb);
if llof as int == 0 { ret option::none::<object_file>; }
ret option::some({llof: llof, dtor: @object_file_res(llof)});
if llof as int == 0 { return option::none::<object_file>; }
return option::some({llof: llof, dtor: @object_file_res(llof)});
}
/* Memory-managed interface to section iterators. */
@@ -1179,7 +1179,7 @@ type section_iter = {llsi: SectionIteratorRef, dtor: @section_iter_res};
fn mk_section_iter(llof: ObjectFileRef) -> section_iter {
let llsi = llvm::LLVMGetSections(llof);
ret {llsi: llsi, dtor: @section_iter_res(llsi)};
return {llsi: llsi, dtor: @section_iter_res(llsi)};
}
//

View File

@@ -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};

View File

@@ -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:

View File

@@ -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,

View File

@@ -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] {

View File

@@ -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"; }
}
}

View File

@@ -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);
}

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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,

View File

@@ -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;
}
}
}

View File

@@ -147,12 +147,12 @@ fn decode_inlined_item(cdata: cstore::crate_metadata,
fn reserve_id_range(sess: session,
from_id_range: ast_util::id_range) -> ast_util::id_range {
// Handle the case of an empty range:
if ast_util::empty(from_id_range) { ret from_id_range; }
if ast_util::empty(from_id_range) { return from_id_range; }
let cnt = from_id_range.max - from_id_range.min;
let to_id_min = sess.parse_sess.next_id;
let to_id_max = sess.parse_sess.next_id + cnt;
sess.parse_sess.next_id = to_id_max;
ret {min: to_id_min, max: to_id_min};
return {min: to_id_min, max: to_id_min};
}
impl translation_routines for extended_decode_ctxt {
@@ -972,7 +972,7 @@ fn test_more() {
roundtrip(#ast[item]{
fn foo(x: uint, y: uint) -> uint {
let z = x + y;
ret z;
return z;
}
});
}
@@ -983,13 +983,13 @@ fn test_simplification() {
let item_in = ast::ii_item(#ast[item] {
fn new_int_alist<B: copy>() -> alist<int, B> {
fn eq_int(&&a: int, &&b: int) -> bool { a == b }
ret {eq_fn: eq_int, mut data: ~[]};
return {eq_fn: eq_int, mut data: ~[]};
}
});
let item_out = simplify_ast(item_in);
let item_exp = ast::ii_item(#ast[item] {
fn new_int_alist<B: copy>() -> alist<int, B> {
ret {eq_fn: eq_int, mut data: ~[]};
return {eq_fn: eq_int, mut data: ~[]};
}
});
alt (item_out, item_exp) {

View File

@@ -267,7 +267,7 @@ fn check_crate(tcx: ty::ctxt,
make_stat(bccx, bccx.req_pure_paths)});
}
ret (bccx.root_map, bccx.mutbl_map);
return (bccx.root_map, bccx.mutbl_map);
fn make_stat(bccx: borrowck_ctxt, stat: uint) -> ~str {
let stat_f = stat as float;
@@ -410,12 +410,12 @@ fn save_and_restore<T:copy,U>(&save_and_restore_t: T, f: fn() -> U) -> U {
let old_save_and_restore_t = save_and_restore_t;
let u <- f();
save_and_restore_t = old_save_and_restore_t;
ret u;
return u;
}
/// Creates and returns a new root_map
fn root_map() -> root_map {
ret hashmap(root_map_key_hash, root_map_key_eq);
return hashmap(root_map_key_hash, root_map_key_eq);
fn root_map_key_eq(k1: root_map_key, k2: root_map_key) -> bool {
k1.id == k2.id && k1.derefs == k2.derefs

View File

@@ -133,12 +133,12 @@ impl public_methods for borrowck_ctxt {
alt expr.node {
ast::expr_unary(ast::deref, e_base) {
if self.method_map.contains_key(expr.id) {
ret self.cat_rvalue(expr, expr_ty);
return self.cat_rvalue(expr, expr_ty);
}
let base_cmt = self.cat_expr(e_base);
alt self.cat_deref(expr, base_cmt, 0u, true) {
some(cmt) { ret cmt; }
some(cmt) { return cmt; }
none {
tcx.sess.span_bug(
e_base.span,
@@ -150,7 +150,7 @@ impl public_methods for borrowck_ctxt {
ast::expr_field(base, f_name, _) {
if self.method_map.contains_key(expr.id) {
ret self.cat_method_ref(expr, expr_ty);
return self.cat_method_ref(expr, expr_ty);
}
let base_cmt = self.cat_autoderef(base);
@@ -159,7 +159,7 @@ impl public_methods for borrowck_ctxt {
ast::expr_index(base, _) {
if self.method_map.contains_key(expr.id) {
ret self.cat_rvalue(expr, expr_ty);
return self.cat_rvalue(expr, expr_ty);
}
self.cat_index(expr, base)
@@ -183,7 +183,7 @@ impl public_methods for borrowck_ctxt {
ast::expr_lit(*) | ast::expr_break | ast::expr_mac(*) |
ast::expr_again | ast::expr_rec(*) | ast::expr_struct(*) |
ast::expr_unary_move(*) {
ret self.cat_rvalue(expr, expr_ty);
return self.cat_rvalue(expr, expr_ty);
}
}
}
@@ -297,7 +297,7 @@ impl public_methods for borrowck_ctxt {
}
fn cat_discr(cmt: cmt, alt_id: ast::node_id) -> cmt {
ret @{cat:cat_discr(cmt, alt_id) with *cmt};
return @{cat:cat_discr(cmt, alt_id) with *cmt};
}
/// inherited mutability: used in cases where the mutability of a
@@ -388,7 +388,7 @@ impl public_methods for borrowck_ctxt {
}
};
ret alt deref_kind(self.tcx, base_cmt.ty) {
return alt deref_kind(self.tcx, base_cmt.ty) {
deref_ptr(ptr) {
// (a) the contents are loanable if the base is loanable
// and this is a *unique* vector
@@ -461,7 +461,7 @@ impl private_methods for borrowck_ctxt {
loop {
ctr += 1u;
alt self.cat_deref(base, cmt, ctr, false) {
none { ret cmt; }
none { return cmt; }
some(cmt1) { cmt = cmt1; }
}
}
@@ -476,7 +476,7 @@ fn field_mutbl(tcx: ty::ctxt,
ty::ty_rec(fields) {
for fields.each |f| {
if f.ident == f_name {
ret some(f.mt.mutbl);
return some(f.mt.mutbl);
}
}
}
@@ -487,12 +487,12 @@ fn field_mutbl(tcx: ty::ctxt,
ast::class_mutable { ast::m_mutbl }
ast::class_immutable { ast::m_imm }
};
ret some(m);
return some(m);
}
}
}
_ { }
}
ret none;
return none;
}

View File

@@ -85,7 +85,7 @@ impl methods for check_loan_ctxt {
fn purity(scope_id: ast::node_id) -> option<purity_cause> {
let default_purity = alt self.declared_purity {
// an unsafe declaration overrides all
ast::unsafe_fn { ret none; }
ast::unsafe_fn { return none; }
// otherwise, remember what was declared as the
// default, but we must scan for requirements
@@ -103,11 +103,11 @@ impl methods for check_loan_ctxt {
loop {
alt pure_map.find(scope_id) {
none {}
some(e) {ret some(pc_cmt(e));}
some(e) {return some(pc_cmt(e));}
}
alt region_map.find(scope_id) {
none { ret default_purity; }
none { return default_purity; }
some(next_scope_id) { scope_id = next_scope_id; }
}
}
@@ -123,13 +123,13 @@ impl methods for check_loan_ctxt {
for req_loan_map.find(scope_id).each |loanss| {
for (*loanss).each |loans| {
for (*loans).each |loan| {
if !f(loan) { ret; }
if !f(loan) { return; }
}
}
}
alt region_map.find(scope_id) {
none { ret; }
none { return; }
some(next_scope_id) { scope_id = next_scope_id; }
}
}
@@ -140,7 +140,7 @@ impl methods for check_loan_ctxt {
f: fn(loan) -> bool) {
for self.walk_loans(scope_id) |loan| {
if loan.lp == lp {
if !f(loan) { ret; }
if !f(loan) { return; }
}
}
}
@@ -182,11 +182,14 @@ impl methods for check_loan_ctxt {
let is_fn_arg =
did.crate == ast::local_crate &&
(*self.fn_args).contains(did.node);
if is_fn_arg { ret; } // case (a) above
if is_fn_arg { return; } // case (a) above
}
ast::expr_fn_block(*) | ast::expr_fn(*) |
ast::expr_loop_body(*) | ast::expr_do_body(*) {
if self.is_stack_closure(expr.id) { ret; } // case (b) above
if self.is_stack_closure(expr.id) {
// case (b) above
return;
}
}
_ {}
}
@@ -198,7 +201,7 @@ impl methods for check_loan_ctxt {
alt ty::get(callee_ty).struct {
ty::ty_fn(fn_ty) {
alt fn_ty.purity {
ast::pure_fn { ret; } // case (c) above
ast::pure_fn { return; } // case (c) above
ast::impure_fn | ast::unsafe_fn | ast::extern_fn {
self.report_purity_error(
pc, callee_span,
@@ -207,7 +210,7 @@ impl methods for check_loan_ctxt {
}
}
}
_ { ret; } // case (d) above
_ { return; } // case (d) above
}
}
@@ -223,7 +226,7 @@ impl methods for check_loan_ctxt {
}
fn is_allowed_pure_arg(expr: @ast::expr) -> bool {
ret alt expr.node {
return alt expr.node {
ast::expr_path(_) {
let def = self.tcx().def_map.get(expr.id);
let did = ast_util::def_id_of_def(def);
@@ -239,7 +242,7 @@ impl methods for check_loan_ctxt {
fn check_for_conflicting_loans(scope_id: ast::node_id) {
let new_loanss = alt self.req_maps.req_loan_map.find(scope_id) {
none { ret; }
none { return; }
some(loanss) { loanss }
};
@@ -310,7 +313,7 @@ impl methods for check_loan_ctxt {
self.bccx.span_err(
ex.span,
at.ing_form(self.bccx.cmt_to_str(cmt)));
ret;
return;
}
}
}
@@ -360,7 +363,7 @@ impl methods for check_loan_ctxt {
loan.cmt.span,
fmt!{"loan of %s granted here",
self.bccx.cmt_to_str(loan.cmt)});
ret;
return;
}
}
}
@@ -428,7 +431,7 @@ impl methods for check_loan_ctxt {
self.bccx.span_err(
cmt.span,
fmt!{"moving out of %s", self.bccx.cmt_to_str(cmt)});
ret;
return;
}
}
@@ -436,7 +439,7 @@ impl methods for check_loan_ctxt {
// check for a conflicting loan:
let lp = alt cmt.lp {
none { ret; }
none { return; }
some(lp) { lp }
};
for self.walk_loans_of(cmt.id, lp) |loan| {
@@ -448,7 +451,7 @@ impl methods for check_loan_ctxt {
loan.cmt.span,
fmt!{"loan of %s granted here",
self.bccx.cmt_to_str(loan.cmt)});
ret;
return;
}
}
@@ -458,14 +461,14 @@ impl methods for check_loan_ctxt {
fn check_last_use(expr: @ast::expr) {
let cmt = self.bccx.cat_expr(expr);
let lp = alt cmt.lp {
none { ret; }
none { return; }
some(lp) { lp }
};
for self.walk_loans_of(cmt.id, lp) |_loan| {
debug!{"Removing last use entry %? due to outstanding loan",
expr.id};
self.bccx.last_use_map.remove(expr.id);
ret;
return;
}
}

View File

@@ -55,7 +55,7 @@ fn gather_loans(bccx: borrowck_ctxt, crate: @ast::crate) -> req_maps {
visit_fn: req_loans_in_fn,
with *visit::default_visitor()});
visit::visit_crate(*crate, glcx, v);
ret glcx.req_maps;
return glcx.req_maps;
}
fn req_loans_in_fn(fk: visit::fn_kind,

View File

@@ -310,7 +310,7 @@ impl private_methods for &preserve_ctxt {
// would be sort of pointless to avoid rooting the inner
// box by rooting an outer box, as it would just keep more
// memory live than necessary, so we set root_ub to none.
ret err({cmt:cmt, code:err_root_not_permitted});
return err({cmt:cmt, code:err_root_not_permitted});
}
let root_region = ty::re_scope(self.root_ub);
@@ -327,10 +327,10 @@ impl private_methods for &preserve_ctxt {
#debug["Elected to root"];
let rk = {id: base.id, derefs: derefs};
self.bccx.root_map.insert(rk, scope_id);
ret ok(pc_ok);
return ok(pc_ok);
} else {
#debug["Unable to root"];
ret err({cmt:cmt,
return err({cmt:cmt,
code:err_out_of_root_scope(root_region,
self.scope_region)});
}
@@ -338,7 +338,7 @@ impl private_methods for &preserve_ctxt {
// we won't be able to root long enough
_ => {
ret err({cmt:cmt,
return err({cmt:cmt,
code:err_out_of_root_scope(root_region,
self.scope_region)});
}

View File

@@ -121,5 +121,5 @@ fn compute_capture_vars(tcx: ty::ctxt,
let mut result = ~[];
for cap_map.each_value |cap_var| { vec::push(result, cap_var); }
ret result;
return result;
}

View File

@@ -31,13 +31,13 @@ fn check_expr(tcx: ty::ctxt, ex: @expr, &&s: (), v: visit::vt<()>) {
let pat_ty = node_id_to_type(tcx, scrut.id);
if type_is_empty(tcx, pat_ty) && arms.is_empty() {
// Vacuously exhaustive
ret;
return;
}
alt ty::get(pat_ty).struct {
ty_enum(did, _) {
if (*enum_variants(tcx, did)).is_empty() && arms.is_empty() {
ret;
return;
}
}
_ { /* We assume only enum types can be uninhabited */ }
@@ -79,7 +79,7 @@ fn raw_pat(p: @pat) -> @pat {
fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: ~[@pat]) {
assert(pats.is_not_empty());
let ext = alt is_useful(tcx, vec::map(pats, |p| ~[p]), ~[wild()]) {
not_useful { ret; } // This is good, wildcard pattern isn't reachable
not_useful { return; } // This is good, wildcard pattern isn't reachable
useful_ { none }
useful(ty, ctor) {
alt ty::get(ty).struct {
@@ -132,8 +132,8 @@ enum ctor {
// Note: is_useful doesn't work on empty types, as the paper notes.
// So it assumes that v is non-empty.
fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful {
if m.len() == 0u { ret useful_; }
if m[0].len() == 0u { ret not_useful; }
if m.len() == 0u { return useful_; }
if m[0].len() == 0u { return not_useful; }
let real_pat = alt vec::find(m, |r| r[0].id != 0) {
some(r) { r[0] } none { v[0] }
};
@@ -160,7 +160,7 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful {
alt is_useful_specialized(tcx, m, v, variant(va.id),
va.args.len(), left_ty) {
not_useful {}
u { ret u; }
u { return u; }
}
}
not_useful
@@ -234,9 +234,9 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> {
alt ty::get(left_ty).struct {
ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_tup(_) | ty::ty_rec(_) {
for m.each |r| {
if !is_wild(tcx, r[0]) { ret none; }
if !is_wild(tcx, r[0]) { return none; }
}
ret some(single);
return some(single);
}
ty::ty_enum(eid, _) {
let mut found = ~[];
@@ -249,7 +249,7 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> {
if found.len() != (*variants).len() {
for vec::each(*variants) |v| {
if !found.contains(variant(v.id)) {
ret some(variant(v.id));
return some(variant(v.id));
}
}
fail;
@@ -346,7 +346,7 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint,
let (c_lo, c_hi) = alt check ctor_id {
val(v) { (v, v) }
range(lo, hi) { (lo, hi) }
single { ret some(vec::tail(r)); }
single { return some(vec::tail(r)); }
};
let v_lo = eval_const_expr(tcx, lo),
v_hi = eval_const_expr(tcx, hi);
@@ -373,7 +373,7 @@ fn check_local(tcx: ty::ctxt, loc: @local, &&s: (), v: visit::vt<()>) {
fn is_refutable(tcx: ty::ctxt, pat: @pat) -> bool {
alt tcx.def_map.find(pat.id) {
some(def_variant(enum_id, var_id)) {
if vec::len(*ty::enum_variants(tcx, enum_id)) != 1u { ret true; }
if vec::len(*ty::enum_variants(tcx, enum_id)) != 1u { return true; }
}
_ {}
}
@@ -386,16 +386,16 @@ fn is_refutable(tcx: ty::ctxt, pat: @pat) -> bool {
pat_lit(_) | pat_range(_, _) => { true }
pat_rec(fields, _) => {
for fields.each |it| {
if is_refutable(tcx, it.pat) { ret true; }
if is_refutable(tcx, it.pat) { return true; }
}
false
}
pat_tup(elts) => {
for elts.each |elt| { if is_refutable(tcx, elt) { ret true; } }
for elts.each |elt| { if is_refutable(tcx, elt) { return true; } }
false
}
pat_enum(_, some(args)) => {
for args.each |p| { if is_refutable(tcx, p) { ret true; } };
for args.each |p| { if is_refutable(tcx, p) { return true; } };
false
}
pat_enum(_,_) => { false }

View File

@@ -64,7 +64,7 @@ fn check_expr(sess: session, def_map: resolve3::DefMap,
expr_unary(deref, _){
sess.span_err(e.span,
~"disallowed operator in constant expression");
ret;
return;
}
expr_lit(@{node: lit_str(_), _}) {
sess.span_err(e.span,
@@ -106,7 +106,7 @@ fn check_expr(sess: session, def_map: resolve3::DefMap,
_ {
sess.span_err(e.span,
~"constant contains unimplemented expression type");
ret;
return;
}
}
}

View File

@@ -77,7 +77,7 @@ fn collect_freevars(def_map: resolve3::DefMap, blk: ast::blk)
let v = visit::mk_vt(@{visit_item: ignore_item, visit_expr: walk_expr
with *visit::default_visitor()});
v.visit_block(blk, 1, v);
ret @*refs;
return @*refs;
}
// Build a map from every function and for-each body to a set of the
@@ -100,17 +100,17 @@ fn annotate_freevars(def_map: resolve3::DefMap, crate: @ast::crate) ->
with *visit::default_simple_visitor()});
visit::visit_crate(*crate, (), visitor);
ret freevars;
return freevars;
}
fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info {
alt tcx.freevars.find(fid) {
none { fail ~"get_freevars: " + int::str(fid) + ~" has no freevars"; }
some(d) { ret d; }
some(d) { return d; }
}
}
fn has_freevars(tcx: ty::ctxt, fid: ast::node_id) -> bool {
ret vec::len(*get_freevars(tcx, fid)) != 0u;
return vec::len(*get_freevars(tcx, fid)) != 0u;
}
// Local Variables:

View File

@@ -100,7 +100,7 @@ fn with_appropriate_checker(cx: ctx, id: node_id, b: fn(check_fn)) {
is_move: bool, var_t: ty::t, sp: span) {
// all captured data must be sendable, regardless of whether it is
// moved in or copied in. Note that send implies owned.
if !check_send(cx, var_t, sp) { ret; }
if !check_send(cx, var_t, sp) { return; }
// copied in data must be copyable, but moved in data can be anything
let is_implicit = fv.is_some();
@@ -115,7 +115,7 @@ fn with_appropriate_checker(cx: ctx, id: node_id, b: fn(check_fn)) {
fn check_for_box(cx: ctx, id: node_id, fv: option<@freevar_entry>,
is_move: bool, var_t: ty::t, sp: span) {
// all captured data must be owned
if !check_owned(cx.tcx, var_t, sp) { ret; }
if !check_owned(cx.tcx, var_t, sp) { return; }
// copied in data must be copyable, but moved in data can be anything
let is_implicit = fv.is_some();
@@ -498,14 +498,14 @@ fn check_cast_for_escaping_regions(
let target_ty = ty::expr_ty(cx.tcx, target);
let target_substs = alt ty::get(target_ty).struct {
ty::ty_trait(_, substs) => {substs}
_ => { ret; /* not a cast to a trait */ }
_ => { return; /* not a cast to a trait */ }
};
// Check, based on the region associated with the trait, whether it can
// possibly escape the enclosing fn item (note that all type parameters
// must have been declared on the enclosing fn item):
alt target_substs.self_r {
some(ty::re_scope(*)) => { ret; /* case (1) */ }
some(ty::re_scope(*)) => { return; /* case (1) */ }
none | some(ty::re_static) | some(ty::re_free(*)) => {}
some(ty::re_bound(*)) | some(ty::re_var(*)) => {
cx.tcx.sess.span_bug(

View File

@@ -119,7 +119,7 @@ class LanguageItemCollector {
fn match_and_collect_item(item_def_id: def_id, key: ~str, value: ~str) {
if !str_eq(key, ~"lang") {
ret; // Didn't match.
return; // Didn't match.
}
alt self.item_refs.find(value) {

View File

@@ -481,7 +481,7 @@ fn check_fn(tcx: ty::ctxt, fk: visit::fn_kind, decl: ast::fn_decl,
// don't complain about blocks, since they tend to get their modes
// specified from the outside
alt fk {
visit::fk_fn_block(*) => { ret; }
visit::fk_fn_block(*) => { return; }
_ => {}
}

View File

@@ -149,7 +149,7 @@ fn check_crate(tcx: ty::ctxt,
last_use_map);
visit::visit_crate(*crate, initial_maps, visitor);
tcx.sess.abort_if_errors();
ret last_use_map;
return last_use_map;
}
impl of to_str::to_str for live_node {
@@ -291,7 +291,7 @@ class ir_maps {
vk_local(_, name) | vk_arg(_, name, _) {name}
vk_field(name) {@(~"self." + *name)}
vk_self {@~"self"}
vk_implicit_ret {@~"<implicit-ret>"}
vk_implicit_return {@~"<implicit-ret>"}
}
}
@@ -367,7 +367,7 @@ fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
}
// Special nodes and variables:
// - exit_ln represents the end of the fn, either by ret or fail
// - exit_ln represents the end of the fn, either by return or fail
// - implicit_ret_var is a pseudo-variable that represents
// an implicit return
let specials = {
@@ -701,7 +701,7 @@ class liveness {
fn merge_from_succ(ln: live_node, succ_ln: live_node,
first_merge: bool) -> bool {
if ln == succ_ln { ret false; }
if ln == succ_ln { return false; }
let mut changed = false;
do self.indices2(ln, succ_ln) |idx, succ_idx| {
@@ -717,16 +717,16 @@ class liveness {
debug!{"merge_from_succ(ln=%s, succ=%s, first_merge=%b, changed=%b)",
ln.to_str(), self.ln_str(succ_ln), first_merge, changed};
ret changed;
return changed;
fn copy_if_invalid(src: live_node, &dst: live_node) -> bool {
if src.is_valid() {
if !dst.is_valid() {
dst = src;
ret true;
return true;
}
}
ret false;
return false;
}
}
@@ -837,11 +837,11 @@ class liveness {
fn propagate_through_stmt(stmt: @stmt, succ: live_node) -> live_node {
alt stmt.node {
stmt_decl(decl, _) {
ret self.propagate_through_decl(decl, succ);
return self.propagate_through_decl(decl, succ);
}
stmt_expr(expr, _) | stmt_semi(expr, _) {
ret self.propagate_through_expr(expr, succ);
return self.propagate_through_expr(expr, succ);
}
}
}
@@ -1275,15 +1275,15 @@ class liveness {
alt def {
def_self(_) {
// Note: the field_map is empty unless we are in a ctor
ret self.ir.field_map.find(fld).map(|var| {
return self.ir.field_map.find(fld).map(|var| {
let ln = self.live_node(expr.id, expr.span);
(ln, var)
});
}
_ { ret none; }
_ { return none; }
}
}
_ { ret none; }
_ { return none; }
}
}
@@ -1347,7 +1347,7 @@ class liveness {
let r <- f();
self.break_ln = bl;
self.cont_ln = cl;
ret r;
return r;
}
}
@@ -1558,7 +1558,7 @@ impl check_methods for @liveness {
if self.ir.method_map.contains_key(expr.id) {
// actually an rvalue, since this calls a method
ret vt.visit_expr(expr, self, vt);
return vt.visit_expr(expr, self, vt);
}
alt expr.node {
@@ -1671,20 +1671,20 @@ impl check_methods for @liveness {
move_span,
fmt!{"illegal move from argument `%s`, which is not \
copy or move mode", *name});
ret;
return;
}
vk_field(name) {
self.tcx.sess.span_err(
move_span,
fmt!{"illegal move from field `%s`", *name});
ret;
return;
}
vk_self {
self.tcx.sess.span_err(
move_span,
~"illegal move from self (cannot move out of a field of \
self)");
ret;
return;
}
vk_local(*) | vk_implicit_ret {
self.tcx.sess.span_bug(
@@ -1790,9 +1790,9 @@ impl check_methods for @liveness {
sp, fmt!{"unused variable: `%s`", *name});
}
}
ret true;
return true;
}
ret false;
return false;
}
fn warn_about_dead_assign(sp: span, ln: live_node, var: variable) {

View File

@@ -18,7 +18,7 @@ fn pat_id_map(dm: resolve3::DefMap, pat: @pat) -> pat_id_map {
do pat_bindings(dm, pat) |p_id, _s, n| {
map.insert(path_to_ident(n), p_id);
};
ret map;
return map;
}
fn pat_is_variant(dm: resolve3::DefMap, pat: @pat) -> bool {
@@ -49,5 +49,5 @@ fn pat_bindings(dm: resolve3::DefMap, pat: @pat,
fn pat_binding_ids(dm: resolve3::DefMap, pat: @pat) -> ~[node_id] {
let mut found = ~[];
pat_bindings(dm, pat, |b_id, _sp, _pt| vec::push(found, b_id) );
ret found;
return found;
}

View File

@@ -89,11 +89,11 @@ fn scope_contains(region_map: region_map, superscope: ast::node_id,
let mut subscope = subscope;
while superscope != subscope {
alt region_map.find(subscope) {
none { ret false; }
none { return false; }
some(scope) { subscope = scope; }
}
}
ret true;
return true;
}
/// Determines whether one region is a subregion of another. This is
@@ -129,7 +129,7 @@ fn nearest_common_ancestor(region_map: region_map, scope_a: ast::node_id,
let mut scope = scope;
loop {
alt region_map.find(scope) {
none { ret result; }
none { return result; }
some(superscope) {
vec::push(result, superscope);
scope = superscope;
@@ -138,7 +138,7 @@ fn nearest_common_ancestor(region_map: region_map, scope_a: ast::node_id,
}
}
if scope_a == scope_b { ret some(scope_a); }
if scope_a == scope_b { return some(scope_a); }
let a_ancestors = ancestors_of(region_map, scope_a);
let b_ancestors = ancestors_of(region_map, scope_b);
@@ -154,18 +154,18 @@ fn nearest_common_ancestor(region_map: region_map, scope_a: ast::node_id,
// then the corresponding scope is a superscope of the other.
if a_ancestors[a_index] != b_ancestors[b_index] {
ret none;
return none;
}
loop {
// Loop invariant: a_ancestors[a_index] == b_ancestors[b_index]
// for all indices between a_index and the end of the array
if a_index == 0u { ret some(scope_a); }
if b_index == 0u { ret some(scope_b); }
if a_index == 0u { return some(scope_a); }
if b_index == 0u { return some(scope_b); }
a_index -= 1u;
b_index -= 1u;
if a_ancestors[a_index] != b_ancestors[b_index] {
ret some(a_ancestors[a_index + 1u]);
return some(a_ancestors[a_index + 1u]);
}
}
}
@@ -318,7 +318,7 @@ fn resolve_crate(sess: session, def_map: resolve3::DefMap,
with *visit::default_visitor()
});
visit::visit_crate(*crate, cx, visitor);
ret cx.region_map;
return cx.region_map;
}
// ___________________________________________________________________________
@@ -480,7 +480,7 @@ fn determine_rp_in_ty(ty: @ast::ty,
// be region-parameterized. if cx.item_id is zero, then this type
// is not a member of a type defn nor is it a constitutent of an
// impl etc. So we can ignore it and its components.
if cx.item_id == 0 { ret; }
if cx.item_id == 0 { return; }
// if this type directly references a region, either via a
// region pointer like &r.ty or a region-parameterized path
@@ -572,5 +572,5 @@ fn determine_rp_in_crate(sess: session,
}
// return final set
ret cx.region_paramd_items;
return cx.region_paramd_items;
}

View File

@@ -231,7 +231,7 @@ enum EnumVariantOrConstResolution {
type Atom = uint;
fn Atom(n: uint) -> Atom {
ret n;
return n;
}
class AtomTable {
@@ -249,7 +249,7 @@ class AtomTable {
fn intern(string: @~str) -> Atom {
alt self.atoms.find(string) {
none { /* fall through */ }
some(atom) { ret atom; }
some(atom) { return atom; }
}
let atom = Atom(self.atom_count);
@@ -257,17 +257,17 @@ class AtomTable {
self.atoms.insert(string, atom);
self.strings.push(string);
ret atom;
return atom;
}
fn atom_to_str(atom: Atom) -> @~str {
ret self.strings.get_elt(atom);
return self.strings.get_elt(atom);
}
fn atoms_to_strs(atoms: ~[Atom], f: fn(@~str) -> bool) {
for atoms.each |atom| {
if !f(self.atom_to_str(atom)) {
ret;
return;
}
}
}
@@ -287,13 +287,13 @@ class AtomTable {
}
// XXX: Shouldn't copy here. We need string builder functionality.
ret @result;
return @result;
}
}
/// Creates a hash table of atoms.
fn atom_hashmap<V:copy>() -> hashmap<Atom,V> {
ret hashmap::<Atom,V>(|a| a, |a, b| a == b);
return hashmap::<Atom,V>(|a| a, |a, b| a == b);
}
/**
@@ -368,15 +368,15 @@ class ImportResolution {
fn target_for_namespace(namespace: Namespace) -> option<Target> {
alt namespace {
ModuleNS { ret copy self.module_target; }
TypeNS { ret copy self.type_target; }
ValueNS { ret copy self.value_target; }
ModuleNS { return copy self.module_target; }
TypeNS { return copy self.type_target; }
ValueNS { return copy self.value_target; }
ImplNS {
if (*self.impl_target).len() > 0u {
ret some(copy *(*self.impl_target).get_elt(0u));
return some(copy *(*self.impl_target).get_elt(0u));
}
ret none;
return none;
}
}
}
@@ -453,7 +453,7 @@ class Module {
}
fn all_imports_resolved() -> bool {
ret self.imports.len() == self.resolved_import_count;
return self.imports.len() == self.resolved_import_count;
}
}
@@ -462,8 +462,8 @@ class Module {
pure fn is_none<T>(x: option<T>) -> bool {
alt x {
none { ret true; }
some(_) { ret false; }
none { return true; }
some(_) { return false; }
}
}
@@ -471,10 +471,10 @@ fn unused_import_lint_level(session: session) -> level {
for session.opts.lint_opts.each |lint_option_pair| {
let (lint_type, lint_level) = lint_option_pair;
if lint_type == unused_imports {
ret lint_level;
return lint_level;
}
}
ret allow;
return allow;
}
// Records the definitions (at most one for each namespace) that a name is
@@ -518,8 +518,8 @@ class NameBindings {
/// Returns the module node if applicable.
fn get_module_if_available() -> option<@Module> {
alt self.module_def {
NoModuleDef { ret none; }
ModuleDef(module_) { ret some(module_); }
NoModuleDef { return none; }
ModuleDef(module_) { return some(module_); }
}
}
@@ -534,40 +534,40 @@ class NameBindings {
~"get_module called on a node with no module definition!";
}
ModuleDef(module_) {
ret module_;
return module_;
}
}
}
fn defined_in_namespace(namespace: Namespace) -> bool {
alt namespace {
ModuleNS { ret self.module_def != NoModuleDef; }
TypeNS { ret self.type_def != none; }
ValueNS { ret self.value_def != none; }
ImplNS { ret self.impl_defs.len() >= 1u; }
ModuleNS { return self.module_def != NoModuleDef; }
TypeNS { return self.type_def != none; }
ValueNS { return self.value_def != none; }
ImplNS { return self.impl_defs.len() >= 1u; }
}
}
fn def_for_namespace(namespace: Namespace) -> option<def> {
alt namespace {
TypeNS {
ret self.type_def;
return self.type_def;
}
ValueNS {
ret self.value_def;
return self.value_def;
}
ModuleNS {
alt self.module_def {
NoModuleDef {
ret none;
return none;
}
ModuleDef(module_) {
alt module_.def_id {
none {
ret none;
return none;
}
some(def_id) {
ret some(def_mod(def_id));
return some(def_mod(def_id));
}
}
}
@@ -578,9 +578,9 @@ class NameBindings {
// necessarily the right def.
if self.impl_defs.len() == 0u {
ret none;
return none;
}
ret some(def_ty(self.impl_defs[0].did));
return some(def_ty(self.impl_defs[0].did));
}
}
}
@@ -766,7 +766,7 @@ class Resolver {
-> @Module {
alt reduced_graph_parent {
ModuleReducedGraphParent(module_) {
ret module_;
return module_;
}
}
}
@@ -802,10 +802,10 @@ class Resolver {
none {
let child = @NameBindings();
module_.children.insert(name, child);
ret (child, new_parent);
return (child, new_parent);
}
some(child) {
ret (child, new_parent);
return (child, new_parent);
}
}
}
@@ -813,7 +813,7 @@ class Resolver {
fn block_needs_anonymous_module(block: blk) -> bool {
// If the block has view items, we need an anonymous module.
if block.node.view_items.len() > 0u {
ret true;
return true;
}
// Check each statement.
@@ -822,7 +822,7 @@ class Resolver {
stmt_decl(declaration, _) {
alt declaration.node {
decl_item(_) {
ret true;
return true;
}
_ {
// Keep searching.
@@ -838,13 +838,13 @@ class Resolver {
// If we found neither view items nor items, we don't need to create
// an anonymous module.
ret false;
return false;
}
fn get_parent_link(parent: ReducedGraphParent, name: Atom) -> ParentLink {
alt parent {
ModuleReducedGraphParent(module_) {
ret ModuleParentLink(module_, name);
return ModuleParentLink(module_, name);
}
}
}
@@ -1483,7 +1483,7 @@ class Resolver {
debug!{"(building reduced graph for impls in external \
module) no def ID for `%s`, skipping",
self.module_to_str(module_)};
ret;
return;
}
some(_) {
// Continue.
@@ -1623,7 +1623,7 @@ class Resolver {
debug!{"(resolving imports for module) all imports resolved for \
%s",
self.module_to_str(module_)};
ret;
return;
}
let import_count = module_.imports.len();
@@ -1740,7 +1740,7 @@ class Resolver {
}
}
ret resolution_result;
return resolution_result;
}
fn resolve_single_import(module_: @Module, containing_module: @Module,
@@ -1757,7 +1757,7 @@ class Resolver {
if !self.name_is_exported(containing_module, source) {
debug!{"(resolving single import) name `%s` is unexported",
*(*self.atom_table).atom_to_str(source)};
ret Failed;
return Failed;
}
// We need to resolve all four namespaces for this to succeed.
@@ -1813,7 +1813,7 @@ class Resolver {
if containing_module.glob_count > 0u {
debug!{"(resolving single import) unresolved glob; \
bailing out"};
ret Indeterminate;
return Indeterminate;
}
// Now search the exported imports within the containing
@@ -1850,11 +1850,11 @@ class Resolver {
alt (*import_resolution).
target_for_namespace(namespace) {
none {
ret UnboundResult;
return UnboundResult;
}
some(target) {
import_resolution.used = true;
ret BoundResult(target.target_module,
return BoundResult(target.target_module,
target.bindings);
}
}
@@ -1865,9 +1865,9 @@ class Resolver {
-> ImplNamespaceResult {
if (*import_resolution.impl_target).len() == 0u {
ret UnboundImplResult;
return UnboundImplResult;
}
ret BoundImplResult(import_resolution.
return BoundImplResult(import_resolution.
impl_target);
}
@@ -1896,7 +1896,7 @@ class Resolver {
// The import is unresolved. Bail out.
debug!{"(resolving single import) unresolved import; \
bailing out"};
ret Indeterminate;
return Indeterminate;
}
}
}
@@ -1958,7 +1958,7 @@ class Resolver {
If this name wasn't found in any of the four namespaces, it's
definitely unresolved
*/
(none, none, none, v) if v.len() == 0 { ret Failed; }
(none, none, none, v) if v.len() == 0 { return Failed; }
_ {}
}
@@ -1966,7 +1966,7 @@ class Resolver {
import_resolution.outstanding_references -= 1u;
debug!{"(resolving single import) successfully resolved import"};
ret Success(());
return Success(());
}
/**
@@ -1989,7 +1989,7 @@ class Resolver {
if !(*containing_module).all_imports_resolved() {
debug!{"(resolving glob import) target module has unresolved \
imports; bailing out"};
ret Indeterminate;
return Indeterminate;
}
assert containing_module.glob_count == 0u;
@@ -2125,7 +2125,7 @@ class Resolver {
}
debug!{"(resolving glob import) successfully resolved import"};
ret Success(());
return Success(());
}
fn resolve_module_path_from_root(module_: @Module,
@@ -2150,13 +2150,13 @@ class Resolver {
Failed {
self.session.span_err(span, ~"unresolved name");
ret Failed;
return Failed;
}
Indeterminate {
debug!{"(resolving module path for import) module \
resolution is indeterminate: %s",
*(*self.atom_table).atom_to_str(name)};
ret Indeterminate;
return Indeterminate;
}
Success(target) {
alt target.bindings.module_def {
@@ -2166,7 +2166,7 @@ class Resolver {
fmt!{"not a module: %s",
*(*self.atom_table).
atom_to_str(name)});
ret Failed;
return Failed;
}
ModuleDef(module_) {
search_module = module_;
@@ -2178,7 +2178,7 @@ class Resolver {
index += 1u;
}
ret Success(search_module);
return Success(search_module);
}
/**
@@ -2207,19 +2207,19 @@ class Resolver {
alt self.resolve_module_in_lexical_scope(module_, first_element) {
Failed {
self.session.span_err(span, ~"unresolved name");
ret Failed;
return Failed;
}
Indeterminate {
debug!{"(resolving module path for import) indeterminate; \
bailing"};
ret Indeterminate;
return Indeterminate;
}
Success(resulting_module) {
search_module = resulting_module;
}
}
ret self.resolve_module_path_from_root(search_module,
return self.resolve_module_path_from_root(search_module,
module_path,
1u,
xray,
@@ -2244,7 +2244,7 @@ class Resolver {
some(name_bindings)
if (*name_bindings).defined_in_namespace(namespace) {
ret Success(Target(module_, name_bindings));
return Success(Target(module_, name_bindings));
}
some(_) | none { /* Not found; continue. */ }
}
@@ -2268,7 +2268,7 @@ class Resolver {
}
some(target) {
import_resolution.used = true;
ret Success(copy target);
return Success(copy target);
}
}
}
@@ -2283,7 +2283,7 @@ class Resolver {
// No more parents. This module was unresolved.
debug!{"(resolving item in lexical scope) unresolved \
module"};
ret Failed;
return Failed;
}
ModuleParentLink(parent_module_node, _) |
BlockParentLink(parent_module_node, _) {
@@ -2303,11 +2303,11 @@ class Resolver {
debug!{"(resolving item in lexical scope) indeterminate \
higher scope; bailing"};
ret Indeterminate;
return Indeterminate;
}
Success(target) {
// We found the module.
ret Success(copy target);
return Success(copy target);
}
}
}
@@ -2322,28 +2322,28 @@ class Resolver {
NoModuleDef {
error!{"!!! (resolving module in lexical scope) module
wasn't actually a module!"};
ret Failed;
return Failed;
}
ModuleDef(module_) {
ret Success(module_);
return Success(module_);
}
}
}
Indeterminate {
debug!{"(resolving module in lexical scope) indeterminate; \
bailing"};
ret Indeterminate;
return Indeterminate;
}
Failed {
debug!{"(resolving module in lexical scope) failed to \
resolve"};
ret Failed;
return Failed;
}
}
}
fn name_is_exported(module_: @Module, name: Atom) -> bool {
ret module_.exported_names.size() == 0u ||
return module_.exported_names.size() == 0u ||
module_.exported_names.contains_key(name);
}
@@ -2365,7 +2365,7 @@ class Resolver {
if xray == NoXray && !self.name_is_exported(module_, name) {
debug!{"(resolving name in module) name `%s` is unexported",
*(*self.atom_table).atom_to_str(name)};
ret Failed;
return Failed;
}
// First, check the direct children of the module.
@@ -2374,7 +2374,7 @@ class Resolver {
if (*name_bindings).defined_in_namespace(namespace) {
debug!{"(resolving name in module) found node as child"};
ret Success(Target(module_, name_bindings));
return Success(Target(module_, name_bindings));
}
some(_) | none {
// Continue.
@@ -2386,7 +2386,7 @@ class Resolver {
if module_.glob_count > 0u {
debug!{"(resolving name in module) module has glob; bailing out"};
ret Indeterminate;
return Indeterminate;
}
// Otherwise, we check the list of resolved imports.
@@ -2395,7 +2395,7 @@ class Resolver {
if import_resolution.outstanding_references != 0u {
debug!{"(resolving name in module) import unresolved; \
bailing out"};
ret Indeterminate;
return Indeterminate;
}
alt (*import_resolution).target_for_namespace(namespace) {
@@ -2408,7 +2408,7 @@ class Resolver {
debug!{"(resolving name in module) resolved to \
import"};
import_resolution.used = true;
ret Success(copy target);
return Success(copy target);
}
}
}
@@ -2420,7 +2420,7 @@ class Resolver {
// We're out of luck.
debug!{"(resolving name in module) failed to resolve %s",
*(*self.atom_table).atom_to_str(name)};
ret Failed;
return Failed;
}
/**
@@ -2468,7 +2468,7 @@ class Resolver {
Indeterminate {
debug!{"(resolving one-level renaming import) module result \
is indeterminate; bailing"};
ret Indeterminate;
return Indeterminate;
}
Success(name_bindings) {
debug!{"(resolving one-level renaming import) module result \
@@ -2491,7 +2491,7 @@ class Resolver {
Indeterminate {
debug!{"(resolving one-level renaming import) value result \
is indeterminate; bailing"};
ret Indeterminate;
return Indeterminate;
}
Success(name_bindings) {
debug!{"(resolving one-level renaming import) value result \
@@ -2514,7 +2514,7 @@ class Resolver {
Indeterminate {
debug!{"(resolving one-level renaming import) type result is \
indeterminate; bailing"};
ret Indeterminate;
return Indeterminate;
}
Success(name_bindings) {
debug!{"(resolving one-level renaming import) type result \
@@ -2554,7 +2554,7 @@ class Resolver {
Indeterminate {
debug!{"(resolving one-level renaming import) impl result is \
indeterminate; bailing"};
ret Indeterminate;
return Indeterminate;
}
Success(name_bindings) {
debug!{"(resolving one-level renaming import) impl result \
@@ -2569,7 +2569,7 @@ class Resolver {
self.session.span_err(import_directive.span,
~"unresolved import");
ret Failed;
return Failed;
}
// Otherwise, proceed and write in the bindings.
@@ -2605,7 +2605,7 @@ class Resolver {
}
debug!{"(resolving one-level renaming import) successfully resolved"};
ret Success(());
return Success(());
}
fn report_unresolved_imports(module_: @Module) {
@@ -2663,7 +2663,7 @@ class Resolver {
debug!{"(recording exports for module subtree) not recording \
exports for `%s`",
self.module_to_str(module_)};
ret;
return;
}
}
@@ -2749,7 +2749,7 @@ class Resolver {
debug!{"(building impl scopes for module subtree) not \
resolving implementations for `%s`",
self.module_to_str(module_)};
ret;
return;
}
}
@@ -2903,7 +2903,7 @@ class Resolver {
is_ty_param = false;
}
_ {
ret some(def_like);
return some(def_like);
}
}
@@ -2947,7 +2947,7 @@ class Resolver {
argument out of scope");
}
ret none;
return none;
}
}
}
@@ -2969,14 +2969,14 @@ class Resolver {
argument out of scope");
}
ret none;
return none;
}
}
rib_index += 1u;
}
ret some(dl_def(def));
return some(dl_def(def));
}
fn search_ribs(ribs: @dvec<@Rib>, name: Atom, span: span,
@@ -2992,7 +2992,7 @@ class Resolver {
let rib = (*ribs).get_elt(i);
alt rib.bindings.find(name) {
some(def_like) {
ret self.upvarify(ribs, i, def_like, span,
return self.upvarify(ribs, i, def_like, span,
allow_capturing_self);
}
none {
@@ -3001,7 +3001,7 @@ class Resolver {
}
}
ret none;
return none;
}
// XXX: This shouldn't be unsafe!
@@ -3595,7 +3595,7 @@ class Resolver {
};
}
fn check_consistent_bindings(arm: arm) {
if arm.pats.len() == 0 { ret; }
if arm.pats.len() == 0 { return; }
let good = self.num_bindings(arm.pats[0]);
for arm.pats.each() |p: @pat| {
if self.num_bindings(p) != good {
@@ -3890,13 +3890,13 @@ class Resolver {
of name bindings with no def?!";
}
some(def @ def_variant(*)) {
ret FoundEnumVariant(def);
return FoundEnumVariant(def);
}
some(def_const(*)) {
ret FoundConst;
return FoundConst;
}
some(_) {
ret EnumVariantOrConstNotFound;
return EnumVariantOrConstNotFound;
}
}
}
@@ -3906,7 +3906,7 @@ class Resolver {
}
Failed {
ret EnumVariantOrConstNotFound;
return EnumVariantOrConstNotFound;
}
}
}
@@ -3925,18 +3925,18 @@ class Resolver {
}
if path.global {
ret self.resolve_crate_relative_path(path,
return self.resolve_crate_relative_path(path,
self.xray_context,
namespace);
}
if path.idents.len() > 1u {
ret self.resolve_module_relative_path(path,
return self.resolve_module_relative_path(path,
self.xray_context,
namespace);
}
ret self.resolve_identifier(path.idents.last(),
return self.resolve_identifier(path.idents.last(),
namespace,
check_ribs,
path.span);
@@ -3953,7 +3953,7 @@ class Resolver {
namespace,
span) {
some(def) {
ret some(def);
return some(def);
}
none {
// Continue.
@@ -3961,7 +3961,7 @@ class Resolver {
}
}
ret self.resolve_item_by_identifier_in_lexical_scope(identifier,
return self.resolve_item_by_identifier_in_lexical_scope(identifier,
namespace);
}
@@ -3976,7 +3976,7 @@ class Resolver {
debug!{"(resolving definition of name in module) name `%s` is \
unexported",
*(*self.atom_table).atom_to_str(name)};
ret NoNameDefinition;
return NoNameDefinition;
}
// First, search children.
@@ -3985,7 +3985,7 @@ class Resolver {
alt (*child_name_bindings).def_for_namespace(namespace) {
some(def) {
// Found it. Stop the search here.
ret ChildNameDefinition(def);
return ChildNameDefinition(def);
}
none {
// Continue.
@@ -4006,23 +4006,23 @@ class Resolver {
some(def) {
// Found it.
import_resolution.used = true;
ret ImportNameDefinition(def);
return ImportNameDefinition(def);
}
none {
// This can happen with external impls, due to
// the imperfect way we read the metadata.
ret NoNameDefinition;
return NoNameDefinition;
}
}
}
none {
ret NoNameDefinition;
return NoNameDefinition;
}
}
}
none {
ret NoNameDefinition;
return NoNameDefinition;
}
}
}
@@ -4037,7 +4037,7 @@ class Resolver {
(*module_path_atoms).push((*self.atom_table).intern(ident));
}
ret module_path_atoms;
return module_path_atoms;
}
fn resolve_module_relative_path(path: @path,
@@ -4058,7 +4058,7 @@ class Resolver {
fmt!{"use of undeclared module `%s`",
*(*self.atom_table).atoms_to_str
((*module_path_atoms).get())});
ret none;
return none;
}
Indeterminate {
@@ -4083,10 +4083,10 @@ class Resolver {
((*module_path_atoms).get()),
*(*self.atom_table).atom_to_str
(name)});
ret none;
return none;
}
ChildNameDefinition(def) | ImportNameDefinition(def) {
ret some(def);
return some(def);
}
}
}
@@ -4112,7 +4112,7 @@ class Resolver {
fmt!{"use of undeclared module `::%s`",
*(*self.atom_table).atoms_to_str
((*module_path_atoms).get())});
ret none;
return none;
}
Indeterminate {
@@ -4137,10 +4137,10 @@ class Resolver {
((*module_path_atoms).get()),
*(*self.atom_table).atom_to_str
(name)});
ret none;
return none;
}
ChildNameDefinition(def) | ImportNameDefinition(def) {
ret some(def);
return some(def);
}
}
}
@@ -4174,10 +4174,10 @@ class Resolver {
local: %?",
*(*self.atom_table).atom_to_str(name),
def};
ret some(def);
return some(def);
}
some(dl_field) | some(dl_impl(_)) | none {
ret none;
return none;
}
}
}
@@ -4203,7 +4203,7 @@ class Resolver {
debug!{"(resolving item path in lexical scope) \
resolved `%s` to item",
*(*self.atom_table).atom_to_str(name)};
ret some(def);
return some(def);
}
}
}
@@ -4211,7 +4211,7 @@ class Resolver {
fail ~"unexpected indeterminate result";
}
Failed {
ret none;
return none;
}
}
}
@@ -4452,7 +4452,7 @@ class Resolver {
}
}
ret found_traits;
return found_traits;
}
fn add_trait_info_if_containing_method(found_traits: @dvec<def_id>,
@@ -4494,7 +4494,7 @@ class Resolver {
fn check_for_unused_imports_if_necessary() {
if self.unused_import_lint_level == allow {
ret;
return;
}
let root_module = (*self.graph_root).get_module();
@@ -4517,7 +4517,7 @@ class Resolver {
debug!{"(checking for unused imports in module subtree) not \
checking for unused imports for `%s`",
self.module_to_str(module_)};
ret;
return;
}
}
@@ -4590,7 +4590,7 @@ class Resolver {
}
if atoms.len() == 0u {
ret ~"???";
return ~"???";
}
let mut string = ~"";
@@ -4607,7 +4607,7 @@ class Resolver {
i -= 1u;
}
ret string;
return string;
}
fn dump_module(module_: @Module) {
@@ -4696,7 +4696,7 @@ fn resolve_crate(session: session, lang_items: LanguageItems, crate: @crate)
let resolver = @Resolver(session, lang_items, crate);
(*resolver).resolve(resolver);
ret {
return {
def_map: resolver.def_map,
exp_map: resolver.export_map,
impl_map: resolver.impl_map,

View File

@@ -54,17 +54,19 @@ fn trans_opt(bcx: block, o: opt) -> opt_result {
let cell = empty_dest_cell();
bcx = tvec::trans_estr(bcx, s, ast::vstore_uniq, by_val(cell));
add_clean_temp(bcx, *cell, strty);
ret single_result(rslt(bcx, *cell));
return single_result(rslt(bcx, *cell));
}
_ {
ret single_result(
return single_result(
rslt(bcx, consts::const_expr(ccx, l)));
}
}
}
var(disr_val, _) { ret single_result(rslt(bcx, C_int(ccx, disr_val))); }
var(disr_val, _) {
return single_result(rslt(bcx, C_int(ccx, disr_val)));
}
range(l1, l2) {
ret range_result(rslt(bcx, consts::const_expr(ccx, l1)),
return range_result(rslt(bcx, consts::const_expr(ccx, l1)),
rslt(bcx, consts::const_expr(ccx, l2)));
}
}
@@ -74,7 +76,7 @@ fn variant_opt(tcx: ty::ctxt, pat_id: ast::node_id) -> opt {
let vdef = ast_util::variant_def_ids(tcx.def_map.get(pat_id));
let variants = ty::enum_variants(tcx, vdef.enm);
for vec::each(*variants) |v| {
if vdef.var == v.id { ret var(v.disr_val, vdef); }
if vdef.var == v.id { return var(v.disr_val, vdef); }
}
core::unreachable();
}
@@ -110,11 +112,11 @@ type match_ = ~[match_branch];
fn has_nested_bindings(m: match_, col: uint) -> bool {
for vec::each(m) |br| {
alt br.pats[col].node {
ast::pat_ident(_, _, some(_)) { ret true; }
ast::pat_ident(_, _, some(_)) { return true; }
_ {}
}
}
ret false;
return false;
}
fn expand_nested_bindings(bcx: block, m: match_, col: uint, val: ValueRef)
@@ -175,7 +177,7 @@ fn enter_match(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef,
none { }
}
}
ret result;
return result;
}
fn enter_default(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef)
@@ -275,7 +277,7 @@ fn enter_uniq(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef)
fn get_options(ccx: @crate_ctxt, m: match_, col: uint) -> ~[opt] {
fn add_to_set(tcx: ty::ctxt, &&set: dvec<opt>, val: opt) {
if set.any(|l| opt_eq(tcx, l, val)) {ret;}
if set.any(|l| opt_eq(tcx, l, val)) {return;}
set.push(val);
}
@@ -294,7 +296,7 @@ fn get_options(ccx: @crate_ctxt, m: match_, col: uint) -> ~[opt] {
}
}
}
ret vec::from_mut(dvec::unwrap(found));
return vec::from_mut(dvec::unwrap(found));
}
fn extract_variant_args(bcx: block, pat_id: ast::node_id,
@@ -320,7 +322,7 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id,
GEP_enum(bcx, blobptr, vdefs_tg, vdefs_var,
enum_ty_substs, i)
};
ret {vals: args, bcx: bcx};
return {vals: args, bcx: bcx};
}
fn collect_record_fields(m: match_, col: uint) -> ~[ast::ident] {
@@ -337,7 +339,7 @@ fn collect_record_fields(m: match_, col: uint) -> ~[ast::ident] {
_ { }
}
}
ret fields;
return fields;
}
fn root_pats_as_necessary(bcx: block, m: match_, col: uint, val: ValueRef) {
@@ -354,7 +356,7 @@ fn root_pats_as_necessary(bcx: block, m: match_, col: uint, val: ValueRef) {
let ty = node_id_type(bcx, pat_id);
let val = load_if_immediate(bcx, val, ty);
root_value(bcx, val, ty, scope_id);
ret; // if we kept going, we'd only be rooting same value again
return; // if we kept going, we'd only be rooting same value again
}
}
}
@@ -362,23 +364,23 @@ fn root_pats_as_necessary(bcx: block, m: match_, col: uint, val: ValueRef) {
fn any_box_pat(m: match_, col: uint) -> bool {
for vec::each(m) |br| {
alt br.pats[col].node { ast::pat_box(_) { ret true; } _ { } }
alt br.pats[col].node { ast::pat_box(_) { return true; } _ { } }
}
ret false;
return false;
}
fn any_uniq_pat(m: match_, col: uint) -> bool {
for vec::each(m) |br| {
alt br.pats[col].node { ast::pat_uniq(_) { ret true; } _ { } }
alt br.pats[col].node { ast::pat_uniq(_) { return true; } _ { } }
}
ret false;
return false;
}
fn any_tup_pat(m: match_, col: uint) -> bool {
for vec::each(m) |br| {
alt br.pats[col].node { ast::pat_tup(_) { ret true; } _ { } }
alt br.pats[col].node { ast::pat_tup(_) { return true; } _ { } }
}
ret false;
return false;
}
type exit_node = {bound: bind_map, from: BasicBlockRef, to: BasicBlockRef};
@@ -403,13 +405,13 @@ fn pick_col(m: match_) -> uint {
for vec::each(scores) |score| {
// Irrefutable columns always go first, they'd only be duplicated in
// the branches.
if score == 0u { ret i; }
if score == 0u { return i; }
// If no irrefutable ones are found, we pick the one with the biggest
// branching factor.
if score > max_score { max_score = score; best_col = i; }
i += 1u;
}
ret best_col;
return best_col;
}
fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
@@ -421,7 +423,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
let _icx = bcx.insn_ctxt(~"alt::compile_submatch");
let mut bcx = bcx;
let tcx = bcx.tcx(), dm = tcx.def_map;
if m.len() == 0u { Br(bcx, option::get(chk)()); ret; }
if m.len() == 0u { Br(bcx, option::get(chk)()); return; }
if m[0].pats.len() == 0u {
let data = m[0].data;
alt data.guard {
@@ -464,7 +466,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
to: data.bodycx.llbb});
}
Br(bcx, data.bodycx.llbb);
ret;
return;
}
let col = pick_col(m);
@@ -496,7 +498,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
}
compile_submatch(bcx, enter_rec(bcx, dm, m, col, rec_fields, val),
vec::append(rec_vals, vals_left), chk, exits);
ret;
return;
}
if any_tup_pat(m, col) {
@@ -512,7 +514,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
}
compile_submatch(bcx, enter_tup(bcx, dm, m, col, val, n_tup_elts),
vec::append(tup_vals, vals_left), chk, exits);
ret;
return;
}
// Unbox in case of a box field
@@ -523,7 +525,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
GEPi(bcx, box_no_addrspace, ~[0u, abi::box_field_body]);
compile_submatch(bcx, enter_box(bcx, dm, m, col, val),
vec::append(~[unboxed], vals_left), chk, exits);
ret;
return;
}
if any_uniq_pat(m, col) {
@@ -533,7 +535,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
GEPi(bcx, box_no_addrspace, ~[0u, abi::box_field_body]);
compile_submatch(bcx, enter_uniq(bcx, dm, m, col, val),
vec::append(~[unboxed], vals_left), chk, exits);
ret;
return;
}
// Decide what kind of branch we need
@@ -676,7 +678,7 @@ fn make_phi_bindings(bcx: block, map: ~[exit_node],
if !success {
Unreachable(bcx);
}
ret success;
return success;
}
// Copies by-value bindings into their homes.
@@ -746,7 +748,7 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm],
let mut bodies = ~[], matches = ~[];
let {bcx, val, _} = trans_temp_expr(bcx, expr);
if bcx.unreachable { ret bcx; }
if bcx.unreachable { return bcx; }
for vec::each(arms) |a| {
let body = scope_block(bcx, a.body.info(), ~"case_body");
@@ -762,11 +764,11 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm],
fn mk_fail(bcx: block, sp: span, msg: ~str,
done: @mut option<BasicBlockRef>) -> BasicBlockRef {
alt *done { some(bb) { ret bb; } _ { } }
alt *done { some(bb) { return bb; } _ { } }
let fail_cx = sub_block(bcx, ~"case_fallthrough");
trans_fail(fail_cx, some(sp), msg);
*done = some(fail_cx.llbb);
ret fail_cx.llbb;
return fail_cx.llbb;
}
let t = node_id_type(bcx, expr.id);
let mk_fail = alt mode {
@@ -819,7 +821,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef,
// Necessary since bind_irrefutable_pat is called outside trans_alt
alt pat.node {
ast::pat_ident(_, _,inner) {
if pat_is_variant(bcx.tcx().def_map, pat) { ret bcx; }
if pat_is_variant(bcx.tcx().def_map, pat) { return bcx; }
if make_copy {
let ty = node_id_type(bcx, pat.id);
let llty = type_of::type_of(ccx, ty);
@@ -873,7 +875,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef,
}
ast::pat_wild | ast::pat_lit(_) | ast::pat_range(_, _) { }
}
ret bcx;
return bcx;
}
// Local Variables:

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,7 @@ import driver::session::session;
fn B(cx: block) -> BuilderRef {
let b = cx.fcx.ccx.builder.B;
llvm::LLVMPositionBuilderAtEnd(b, cx.llbb);
ret b;
return b;
}
fn count_insn(cx: block, category: ~str) {
@@ -60,11 +60,11 @@ fn count_insn(cx: block, category: ~str) {
// terminated, we're saying that trying to add any further statements in the
// block is an error. On the other hand, if something is unreachable, that
// means that the block was terminated in some way that we don't want to check
// for (fail/break/ret statements, call to diverging functions, etc), and
// for (fail/break/return statements, call to diverging functions, etc), and
// further instructions to the block should simply be ignored.
fn RetVoid(cx: block) {
if cx.unreachable { ret; }
if cx.unreachable { return; }
assert (!cx.terminated);
cx.terminated = true;
count_insn(cx, ~"retvoid");
@@ -72,7 +72,7 @@ fn RetVoid(cx: block) {
}
fn Ret(cx: block, V: ValueRef) {
if cx.unreachable { ret; }
if cx.unreachable { return; }
assert (!cx.terminated);
cx.terminated = true;
count_insn(cx, ~"ret");
@@ -80,7 +80,7 @@ fn Ret(cx: block, V: ValueRef) {
}
fn AggregateRet(cx: block, RetVals: ~[ValueRef]) {
if cx.unreachable { ret; }
if cx.unreachable { return; }
assert (!cx.terminated);
cx.terminated = true;
unsafe {
@@ -90,7 +90,7 @@ fn AggregateRet(cx: block, RetVals: ~[ValueRef]) {
}
fn Br(cx: block, Dest: BasicBlockRef) {
if cx.unreachable { ret; }
if cx.unreachable { return; }
assert (!cx.terminated);
cx.terminated = true;
count_insn(cx, ~"br");
@@ -99,7 +99,7 @@ fn Br(cx: block, Dest: BasicBlockRef) {
fn CondBr(cx: block, If: ValueRef, Then: BasicBlockRef,
Else: BasicBlockRef) {
if cx.unreachable { ret; }
if cx.unreachable { return; }
assert (!cx.terminated);
cx.terminated = true;
count_insn(cx, ~"condbr");
@@ -108,19 +108,19 @@ fn CondBr(cx: block, If: ValueRef, Then: BasicBlockRef,
fn Switch(cx: block, V: ValueRef, Else: BasicBlockRef, NumCases: uint)
-> ValueRef {
if cx.unreachable { ret _Undef(V); }
if cx.unreachable { return _Undef(V); }
assert !cx.terminated;
cx.terminated = true;
ret llvm::LLVMBuildSwitch(B(cx), V, Else, NumCases as c_uint);
return llvm::LLVMBuildSwitch(B(cx), V, Else, NumCases as c_uint);
}
fn AddCase(S: ValueRef, OnVal: ValueRef, Dest: BasicBlockRef) {
if llvm::LLVMIsUndef(S) == lib::llvm::True { ret; }
if llvm::LLVMIsUndef(S) == lib::llvm::True { return; }
llvm::LLVMAddCase(S, OnVal, Dest);
}
fn IndirectBr(cx: block, Addr: ValueRef, NumDests: uint) {
if cx.unreachable { ret; }
if cx.unreachable { return; }
assert (!cx.terminated);
cx.terminated = true;
count_insn(cx, ~"indirectbr");
@@ -131,12 +131,12 @@ fn IndirectBr(cx: block, Addr: ValueRef, NumDests: uint) {
// lot more efficient) than doing str::as_c_str("", ...) every time.
fn noname() -> *libc::c_char unsafe {
const cnull: uint = 0u;
ret unsafe::reinterpret_cast(ptr::addr_of(cnull));
return unsafe::reinterpret_cast(ptr::addr_of(cnull));
}
fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
Then: BasicBlockRef, Catch: BasicBlockRef) {
if cx.unreachable { ret; }
if cx.unreachable { return; }
assert (!cx.terminated);
cx.terminated = true;
debug!{"Invoke(%s with arguments (%s))",
@@ -153,7 +153,7 @@ fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
fn FastInvoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
Then: BasicBlockRef, Catch: BasicBlockRef) {
if cx.unreachable { ret; }
if cx.unreachable { return; }
assert (!cx.terminated);
cx.terminated = true;
unsafe {
@@ -166,7 +166,7 @@ fn FastInvoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
}
fn Unreachable(cx: block) {
if cx.unreachable { ret; }
if cx.unreachable { return; }
cx.unreachable = true;
if !cx.terminated {
count_insn(cx, ~"unreachable");
@@ -175,223 +175,223 @@ fn Unreachable(cx: block) {
}
fn _Undef(val: ValueRef) -> ValueRef {
ret llvm::LLVMGetUndef(val_ty(val));
return llvm::LLVMGetUndef(val_ty(val));
}
/* Arithmetic */
fn Add(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"add");
ret llvm::LLVMBuildAdd(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildAdd(B(cx), LHS, RHS, noname());
}
fn NSWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"nswadd");
ret llvm::LLVMBuildNSWAdd(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildNSWAdd(B(cx), LHS, RHS, noname());
}
fn NUWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"nuwadd");
ret llvm::LLVMBuildNUWAdd(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildNUWAdd(B(cx), LHS, RHS, noname());
}
fn FAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"fadd");
ret llvm::LLVMBuildFAdd(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildFAdd(B(cx), LHS, RHS, noname());
}
fn Sub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"sub");
ret llvm::LLVMBuildSub(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildSub(B(cx), LHS, RHS, noname());
}
fn NSWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"nwsub");
ret llvm::LLVMBuildNSWSub(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildNSWSub(B(cx), LHS, RHS, noname());
}
fn NUWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"nuwsub");
ret llvm::LLVMBuildNUWSub(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildNUWSub(B(cx), LHS, RHS, noname());
}
fn FSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"sub");
ret llvm::LLVMBuildFSub(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildFSub(B(cx), LHS, RHS, noname());
}
fn Mul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"mul");
ret llvm::LLVMBuildMul(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildMul(B(cx), LHS, RHS, noname());
}
fn NSWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"nswmul");
ret llvm::LLVMBuildNSWMul(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildNSWMul(B(cx), LHS, RHS, noname());
}
fn NUWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"nuwmul");
ret llvm::LLVMBuildNUWMul(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildNUWMul(B(cx), LHS, RHS, noname());
}
fn FMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"fmul");
ret llvm::LLVMBuildFMul(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildFMul(B(cx), LHS, RHS, noname());
}
fn UDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"udiv");
ret llvm::LLVMBuildUDiv(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildUDiv(B(cx), LHS, RHS, noname());
}
fn SDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"sdiv");
ret llvm::LLVMBuildSDiv(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildSDiv(B(cx), LHS, RHS, noname());
}
fn ExactSDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"extractsdiv");
ret llvm::LLVMBuildExactSDiv(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildExactSDiv(B(cx), LHS, RHS, noname());
}
fn FDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"fdiv");
ret llvm::LLVMBuildFDiv(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildFDiv(B(cx), LHS, RHS, noname());
}
fn URem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"urem");
ret llvm::LLVMBuildURem(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildURem(B(cx), LHS, RHS, noname());
}
fn SRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"srem");
ret llvm::LLVMBuildSRem(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildSRem(B(cx), LHS, RHS, noname());
}
fn FRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"frem");
ret llvm::LLVMBuildFRem(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildFRem(B(cx), LHS, RHS, noname());
}
fn Shl(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"shl");
ret llvm::LLVMBuildShl(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildShl(B(cx), LHS, RHS, noname());
}
fn LShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"lshr");
ret llvm::LLVMBuildLShr(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildLShr(B(cx), LHS, RHS, noname());
}
fn AShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"ashr");
ret llvm::LLVMBuildAShr(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildAShr(B(cx), LHS, RHS, noname());
}
fn And(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"and");
ret llvm::LLVMBuildAnd(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildAnd(B(cx), LHS, RHS, noname());
}
fn Or(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"or");
ret llvm::LLVMBuildOr(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildOr(B(cx), LHS, RHS, noname());
}
fn Xor(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"xor");
ret llvm::LLVMBuildXor(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildXor(B(cx), LHS, RHS, noname());
}
fn BinOp(cx: block, Op: Opcode, LHS: ValueRef, RHS: ValueRef) ->
ValueRef {
if cx.unreachable { ret _Undef(LHS); }
if cx.unreachable { return _Undef(LHS); }
count_insn(cx, ~"binop");
ret llvm::LLVMBuildBinOp(B(cx), Op, LHS, RHS, noname());
return llvm::LLVMBuildBinOp(B(cx), Op, LHS, RHS, noname());
}
fn Neg(cx: block, V: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(V); }
if cx.unreachable { return _Undef(V); }
count_insn(cx, ~"neg");
ret llvm::LLVMBuildNeg(B(cx), V, noname());
return llvm::LLVMBuildNeg(B(cx), V, noname());
}
fn NSWNeg(cx: block, V: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(V); }
if cx.unreachable { return _Undef(V); }
count_insn(cx, ~"nswneg");
ret llvm::LLVMBuildNSWNeg(B(cx), V, noname());
return llvm::LLVMBuildNSWNeg(B(cx), V, noname());
}
fn NUWNeg(cx: block, V: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(V); }
if cx.unreachable { return _Undef(V); }
count_insn(cx, ~"nuwneg");
ret llvm::LLVMBuildNUWNeg(B(cx), V, noname());
return llvm::LLVMBuildNUWNeg(B(cx), V, noname());
}
fn FNeg(cx: block, V: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(V); }
if cx.unreachable { return _Undef(V); }
count_insn(cx, ~"fneg");
ret llvm::LLVMBuildFNeg(B(cx), V, noname());
return llvm::LLVMBuildFNeg(B(cx), V, noname());
}
fn Not(cx: block, V: ValueRef) -> ValueRef {
if cx.unreachable { ret _Undef(V); }
if cx.unreachable { return _Undef(V); }
count_insn(cx, ~"not");
ret llvm::LLVMBuildNot(B(cx), V, noname());
return llvm::LLVMBuildNot(B(cx), V, noname());
}
/* Memory */
fn Malloc(cx: block, Ty: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_i8())); }
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); }
count_insn(cx, ~"malloc");
ret llvm::LLVMBuildMalloc(B(cx), Ty, noname());
return llvm::LLVMBuildMalloc(B(cx), Ty, noname());
}
fn ArrayMalloc(cx: block, Ty: TypeRef, Val: ValueRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_i8())); }
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); }
count_insn(cx, ~"arraymalloc");
ret llvm::LLVMBuildArrayMalloc(B(cx), Ty, Val, noname());
return llvm::LLVMBuildArrayMalloc(B(cx), Ty, Val, noname());
}
fn Alloca(cx: block, Ty: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(Ty)); }
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(Ty)); }
count_insn(cx, ~"alloca");
ret llvm::LLVMBuildAlloca(B(cx), Ty, noname());
return llvm::LLVMBuildAlloca(B(cx), Ty, noname());
}
fn ArrayAlloca(cx: block, Ty: TypeRef, Val: ValueRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(Ty)); }
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(Ty)); }
count_insn(cx, ~"arrayalloca");
ret llvm::LLVMBuildArrayAlloca(B(cx), Ty, Val, noname());
return llvm::LLVMBuildArrayAlloca(B(cx), Ty, Val, noname());
}
fn Free(cx: block, PointerVal: ValueRef) {
if cx.unreachable { ret; }
if cx.unreachable { return; }
count_insn(cx, ~"free");
llvm::LLVMBuildFree(B(cx), PointerVal);
}
@@ -402,14 +402,14 @@ fn Load(cx: block, PointerVal: ValueRef) -> ValueRef {
let ty = val_ty(PointerVal);
let eltty = if llvm::LLVMGetTypeKind(ty) == lib::llvm::Array {
llvm::LLVMGetElementType(ty) } else { ccx.int_type };
ret llvm::LLVMGetUndef(eltty);
return llvm::LLVMGetUndef(eltty);
}
count_insn(cx, ~"load");
ret llvm::LLVMBuildLoad(B(cx), PointerVal, noname());
return llvm::LLVMBuildLoad(B(cx), PointerVal, noname());
}
fn Store(cx: block, Val: ValueRef, Ptr: ValueRef) {
if cx.unreachable { ret; }
if cx.unreachable { return; }
debug!{"Store %s -> %s",
val_str(cx.ccx().tn, Val),
val_str(cx.ccx().tn, Ptr)};
@@ -418,10 +418,10 @@ fn Store(cx: block, Val: ValueRef, Ptr: ValueRef) {
}
fn GEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); }
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); }
unsafe {
count_insn(cx, ~"gep");
ret llvm::LLVMBuildGEP(B(cx), Pointer, vec::unsafe::to_ptr(Indices),
return llvm::LLVMBuildGEP(B(cx), Pointer, vec::unsafe::to_ptr(Indices),
Indices.len() as c_uint, noname());
}
}
@@ -432,15 +432,15 @@ fn GEPi(cx: block, base: ValueRef, ixs: ~[uint]) -> ValueRef {
let mut v: ~[ValueRef] = ~[];
for vec::each(ixs) |i| { vec::push(v, C_i32(i as i32)); }
count_insn(cx, ~"gepi");
ret InBoundsGEP(cx, base, v);
return InBoundsGEP(cx, base, v);
}
fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) ->
ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); }
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); }
unsafe {
count_insn(cx, ~"inboundsgep");
ret llvm::LLVMBuildInBoundsGEP(B(cx), Pointer,
return llvm::LLVMBuildInBoundsGEP(B(cx), Pointer,
vec::unsafe::to_ptr(Indices),
Indices.len() as c_uint,
noname());
@@ -448,168 +448,168 @@ fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) ->
}
fn StructGEP(cx: block, Pointer: ValueRef, Idx: uint) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); }
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); }
count_insn(cx, ~"structgep");
ret llvm::LLVMBuildStructGEP(B(cx), Pointer, Idx as c_uint, noname());
return llvm::LLVMBuildStructGEP(B(cx), Pointer, Idx as c_uint, noname());
}
fn GlobalString(cx: block, _Str: *libc::c_char) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_i8())); }
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); }
count_insn(cx, ~"globalstring");
ret llvm::LLVMBuildGlobalString(B(cx), _Str, noname());
return llvm::LLVMBuildGlobalString(B(cx), _Str, noname());
}
fn GlobalStringPtr(cx: block, _Str: *libc::c_char) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_i8())); }
if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); }
count_insn(cx, ~"globalstringptr");
ret llvm::LLVMBuildGlobalStringPtr(B(cx), _Str, noname());
return llvm::LLVMBuildGlobalStringPtr(B(cx), _Str, noname());
}
/* Casts */
fn Trunc(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"trunc");
ret llvm::LLVMBuildTrunc(B(cx), Val, DestTy, noname());
return llvm::LLVMBuildTrunc(B(cx), Val, DestTy, noname());
}
fn ZExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"zext");
ret llvm::LLVMBuildZExt(B(cx), Val, DestTy, noname());
return llvm::LLVMBuildZExt(B(cx), Val, DestTy, noname());
}
fn SExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"sext");
ret llvm::LLVMBuildSExt(B(cx), Val, DestTy, noname());
return llvm::LLVMBuildSExt(B(cx), Val, DestTy, noname());
}
fn FPToUI(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"fptoui");
ret llvm::LLVMBuildFPToUI(B(cx), Val, DestTy, noname());
return llvm::LLVMBuildFPToUI(B(cx), Val, DestTy, noname());
}
fn FPToSI(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"fptosi");
ret llvm::LLVMBuildFPToSI(B(cx), Val, DestTy, noname());
return llvm::LLVMBuildFPToSI(B(cx), Val, DestTy, noname());
}
fn UIToFP(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"uitofp");
ret llvm::LLVMBuildUIToFP(B(cx), Val, DestTy, noname());
return llvm::LLVMBuildUIToFP(B(cx), Val, DestTy, noname());
}
fn SIToFP(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"sitofp");
ret llvm::LLVMBuildSIToFP(B(cx), Val, DestTy, noname());
return llvm::LLVMBuildSIToFP(B(cx), Val, DestTy, noname());
}
fn FPTrunc(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"fptrunc");
ret llvm::LLVMBuildFPTrunc(B(cx), Val, DestTy, noname());
return llvm::LLVMBuildFPTrunc(B(cx), Val, DestTy, noname());
}
fn FPExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"fpext");
ret llvm::LLVMBuildFPExt(B(cx), Val, DestTy, noname());
return llvm::LLVMBuildFPExt(B(cx), Val, DestTy, noname());
}
fn PtrToInt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"ptrtoint");
ret llvm::LLVMBuildPtrToInt(B(cx), Val, DestTy, noname());
return llvm::LLVMBuildPtrToInt(B(cx), Val, DestTy, noname());
}
fn IntToPtr(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"inttoptr");
ret llvm::LLVMBuildIntToPtr(B(cx), Val, DestTy, noname());
return llvm::LLVMBuildIntToPtr(B(cx), Val, DestTy, noname());
}
fn BitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"bitcast");
ret llvm::LLVMBuildBitCast(B(cx), Val, DestTy, noname());
return llvm::LLVMBuildBitCast(B(cx), Val, DestTy, noname());
}
fn ZExtOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) ->
ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"zextorbitcast");
ret llvm::LLVMBuildZExtOrBitCast(B(cx), Val, DestTy, noname());
return llvm::LLVMBuildZExtOrBitCast(B(cx), Val, DestTy, noname());
}
fn SExtOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) ->
ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"sextorbitcast");
ret llvm::LLVMBuildSExtOrBitCast(B(cx), Val, DestTy, noname());
return llvm::LLVMBuildSExtOrBitCast(B(cx), Val, DestTy, noname());
}
fn TruncOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) ->
ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"truncorbitcast");
ret llvm::LLVMBuildTruncOrBitCast(B(cx), Val, DestTy, noname());
return llvm::LLVMBuildTruncOrBitCast(B(cx), Val, DestTy, noname());
}
fn Cast(cx: block, Op: Opcode, Val: ValueRef, DestTy: TypeRef,
_Name: *u8) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"cast");
ret llvm::LLVMBuildCast(B(cx), Op, Val, DestTy, noname());
return llvm::LLVMBuildCast(B(cx), Op, Val, DestTy, noname());
}
fn PointerCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"pointercast");
ret llvm::LLVMBuildPointerCast(B(cx), Val, DestTy, noname());
return llvm::LLVMBuildPointerCast(B(cx), Val, DestTy, noname());
}
fn IntCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"intcast");
ret llvm::LLVMBuildIntCast(B(cx), Val, DestTy, noname());
return llvm::LLVMBuildIntCast(B(cx), Val, DestTy, noname());
}
fn FPCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); }
if cx.unreachable { return llvm::LLVMGetUndef(DestTy); }
count_insn(cx, ~"fpcast");
ret llvm::LLVMBuildFPCast(B(cx), Val, DestTy, noname());
return llvm::LLVMBuildFPCast(B(cx), Val, DestTy, noname());
}
/* Comparisons */
fn ICmp(cx: block, Op: IntPredicate, LHS: ValueRef, RHS: ValueRef)
-> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); }
if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); }
count_insn(cx, ~"icmp");
ret llvm::LLVMBuildICmp(B(cx), Op as c_uint, LHS, RHS, noname());
return llvm::LLVMBuildICmp(B(cx), Op as c_uint, LHS, RHS, noname());
}
fn FCmp(cx: block, Op: RealPredicate, LHS: ValueRef, RHS: ValueRef)
-> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); }
if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); }
count_insn(cx, ~"fcmp");
ret llvm::LLVMBuildFCmp(B(cx), Op as c_uint, LHS, RHS, noname());
return llvm::LLVMBuildFCmp(B(cx), Op as c_uint, LHS, RHS, noname());
}
/* Miscellaneous instructions */
fn EmptyPhi(cx: block, Ty: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(Ty); }
if cx.unreachable { return llvm::LLVMGetUndef(Ty); }
count_insn(cx, ~"emptyphi");
ret llvm::LLVMBuildPhi(B(cx), Ty, noname());
return llvm::LLVMBuildPhi(B(cx), Ty, noname());
}
fn Phi(cx: block, Ty: TypeRef, vals: ~[ValueRef], bbs: ~[BasicBlockRef])
-> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(Ty); }
if cx.unreachable { return llvm::LLVMGetUndef(Ty); }
assert vals.len() == bbs.len();
let phi = EmptyPhi(cx, Ty);
unsafe {
@@ -617,12 +617,12 @@ fn Phi(cx: block, Ty: TypeRef, vals: ~[ValueRef], bbs: ~[BasicBlockRef])
llvm::LLVMAddIncoming(phi, vec::unsafe::to_ptr(vals),
vec::unsafe::to_ptr(bbs),
vals.len() as c_uint);
ret phi;
return phi;
}
}
fn AddIncomingToPhi(phi: ValueRef, val: ValueRef, bb: BasicBlockRef) {
if llvm::LLVMIsUndef(phi) == lib::llvm::True { ret; }
if llvm::LLVMIsUndef(phi) == lib::llvm::True { return; }
unsafe {
let valptr = unsafe::reinterpret_cast(ptr::addr_of(val));
let bbptr = unsafe::reinterpret_cast(ptr::addr_of(bb));
@@ -636,7 +636,7 @@ fn _UndefReturn(cx: block, Fn: ValueRef) -> ValueRef {
let retty = if llvm::LLVMGetTypeKind(ty) == lib::llvm::Integer {
llvm::LLVMGetReturnType(ty) } else { ccx.int_type };
count_insn(cx, ~"");
ret llvm::LLVMGetUndef(retty);
return llvm::LLVMGetUndef(retty);
}
fn add_span_comment(bcx: block, sp: span, text: ~str) {
@@ -666,7 +666,7 @@ fn add_comment(bcx: block, text: ~str) {
}
fn Call(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef {
if cx.unreachable { ret _UndefReturn(cx, Fn); }
if cx.unreachable { return _UndefReturn(cx, Fn); }
unsafe {
count_insn(cx, ~"call");
@@ -674,103 +674,104 @@ fn Call(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef {
val_str(cx.ccx().tn, Fn),
Args.map(|arg| val_str(cx.ccx().tn, arg))};
ret llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args),
return llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args),
Args.len() as c_uint, noname());
}
}
fn FastCall(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef {
if cx.unreachable { ret _UndefReturn(cx, Fn); }
if cx.unreachable { return _UndefReturn(cx, Fn); }
unsafe {
count_insn(cx, ~"fastcall");
let v = llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args),
Args.len() as c_uint, noname());
lib::llvm::SetInstructionCallConv(v, lib::llvm::FastCallConv);
ret v;
return v;
}
}
fn CallWithConv(cx: block, Fn: ValueRef, Args: ~[ValueRef],
Conv: CallConv) -> ValueRef {
if cx.unreachable { ret _UndefReturn(cx, Fn); }
if cx.unreachable { return _UndefReturn(cx, Fn); }
unsafe {
count_insn(cx, ~"callwithconv");
let v = llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args),
Args.len() as c_uint, noname());
lib::llvm::SetInstructionCallConv(v, Conv);
ret v;
return v;
}
}
fn Select(cx: block, If: ValueRef, Then: ValueRef, Else: ValueRef) ->
ValueRef {
if cx.unreachable { ret _Undef(Then); }
if cx.unreachable { return _Undef(Then); }
count_insn(cx, ~"select");
ret llvm::LLVMBuildSelect(B(cx), If, Then, Else, noname());
return llvm::LLVMBuildSelect(B(cx), If, Then, Else, noname());
}
fn VAArg(cx: block, list: ValueRef, Ty: TypeRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(Ty); }
if cx.unreachable { return llvm::LLVMGetUndef(Ty); }
count_insn(cx, ~"vaarg");
ret llvm::LLVMBuildVAArg(B(cx), list, Ty, noname());
return llvm::LLVMBuildVAArg(B(cx), list, Ty, noname());
}
fn ExtractElement(cx: block, VecVal: ValueRef, Index: ValueRef) ->
ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(T_nil()); }
if cx.unreachable { return llvm::LLVMGetUndef(T_nil()); }
count_insn(cx, ~"extractelement");
ret llvm::LLVMBuildExtractElement(B(cx), VecVal, Index, noname());
return llvm::LLVMBuildExtractElement(B(cx), VecVal, Index, noname());
}
fn InsertElement(cx: block, VecVal: ValueRef, EltVal: ValueRef,
Index: ValueRef) {
if cx.unreachable { ret; }
if cx.unreachable { return; }
count_insn(cx, ~"insertelement");
llvm::LLVMBuildInsertElement(B(cx), VecVal, EltVal, Index, noname());
}
fn ShuffleVector(cx: block, V1: ValueRef, V2: ValueRef,
Mask: ValueRef) {
if cx.unreachable { ret; }
if cx.unreachable { return; }
count_insn(cx, ~"shufflevector");
llvm::LLVMBuildShuffleVector(B(cx), V1, V2, Mask, noname());
}
fn ExtractValue(cx: block, AggVal: ValueRef, Index: uint) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(T_nil()); }
if cx.unreachable { return llvm::LLVMGetUndef(T_nil()); }
count_insn(cx, ~"extractvalue");
ret llvm::LLVMBuildExtractValue(B(cx), AggVal, Index as c_uint, noname());
return llvm::LLVMBuildExtractValue(
B(cx), AggVal, Index as c_uint, noname());
}
fn InsertValue(cx: block, AggVal: ValueRef, EltVal: ValueRef,
Index: uint) {
if cx.unreachable { ret; }
if cx.unreachable { return; }
count_insn(cx, ~"insertvalue");
llvm::LLVMBuildInsertValue(B(cx), AggVal, EltVal, Index as c_uint,
noname());
}
fn IsNull(cx: block, Val: ValueRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); }
if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); }
count_insn(cx, ~"isnull");
ret llvm::LLVMBuildIsNull(B(cx), Val, noname());
return llvm::LLVMBuildIsNull(B(cx), Val, noname());
}
fn IsNotNull(cx: block, Val: ValueRef) -> ValueRef {
if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); }
if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); }
count_insn(cx, ~"isnotnull");
ret llvm::LLVMBuildIsNotNull(B(cx), Val, noname());
return llvm::LLVMBuildIsNotNull(B(cx), Val, noname());
}
fn PtrDiff(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef {
let ccx = cx.fcx.ccx;
if cx.unreachable { ret llvm::LLVMGetUndef(ccx.int_type); }
if cx.unreachable { return llvm::LLVMGetUndef(ccx.int_type); }
count_insn(cx, ~"ptrdiff");
ret llvm::LLVMBuildPtrDiff(B(cx), LHS, RHS, noname());
return llvm::LLVMBuildPtrDiff(B(cx), LHS, RHS, noname());
}
fn Trap(cx: block) {
if cx.unreachable { ret; }
if cx.unreachable { return; }
let b = B(cx);
let BB: BasicBlockRef = llvm::LLVMGetInsertBlock(b);
let FN: ValueRef = llvm::LLVMGetBasicBlockParent(BB);
@@ -791,7 +792,7 @@ fn LandingPad(cx: block, Ty: TypeRef, PersFn: ValueRef,
NumClauses: uint) -> ValueRef {
assert !cx.terminated && !cx.unreachable;
count_insn(cx, ~"landingpad");
ret llvm::LLVMBuildLandingPad(B(cx), Ty, PersFn,
return llvm::LLVMBuildLandingPad(B(cx), Ty, PersFn,
NumClauses as c_uint, noname());
}
@@ -804,7 +805,7 @@ fn Resume(cx: block, Exn: ValueRef) -> ValueRef {
assert (!cx.terminated);
cx.terminated = true;
count_insn(cx, ~"resume");
ret llvm::LLVMBuildResume(B(cx), Exn);
return llvm::LLVMBuildResume(B(cx), Exn);
}
// Atomic Operations

View File

@@ -113,7 +113,7 @@ fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> ~str {
fn mk_tuplified_uniq_cbox_ty(tcx: ty::ctxt, cdata_ty: ty::t) -> ty::t {
let cbox_ty = tuplify_box_ty(tcx, cdata_ty);
ret ty::mk_imm_uniq(tcx, cbox_ty);
return ty::mk_imm_uniq(tcx, cbox_ty);
}
// Given a closure ty, emits a corresponding tuple ty
@@ -132,7 +132,7 @@ fn mk_closure_tys(tcx: ty::ctxt,
}
let cdata_ty = ty::mk_tup(tcx, bound_tys);
debug!{"cdata_ty=%s", ty_to_str(tcx, cdata_ty)};
ret cdata_ty;
return cdata_ty;
}
fn allocate_cbox(bcx: block,
@@ -168,7 +168,7 @@ fn allocate_cbox(bcx: block,
}
};
ret {bcx: bcx, val: val};
return {bcx: bcx, val: val};
}
type closure_result = {
@@ -247,7 +247,7 @@ fn store_environment(bcx: block,
}
for vec::each(temp_cleanups) |cleanup| { revoke_clean(bcx, cleanup); }
ret {llbox: llbox, cdata_ty: cdata_ty, bcx: bcx};
return {llbox: llbox, cdata_ty: cdata_ty, bcx: bcx};
}
// Given a context and a list of upvars, build a closure. This just
@@ -307,7 +307,7 @@ fn build_closure(bcx0: block,
vec::push(env_vals,
env_ref(nil_ret, ty::mk_nil_ptr(tcx), lv_owned));
}
ret store_environment(bcx, env_vals, ck);
return store_environment(bcx, env_vals, ck);
}
// Given an enclosing block context, a new function context, a closure type,
@@ -361,7 +361,7 @@ fn trans_expr_fn(bcx: block,
is_loop_body: option<option<ValueRef>>,
dest: dest) -> block {
let _icx = bcx.insn_ctxt(~"closure::trans_expr_fn");
if dest == ignore { ret bcx; }
if dest == ignore { return bcx; }
let ccx = bcx.ccx();
let fty = node_id_type(bcx, id);
let llfnty = type_of_fn_from_ty(ccx, fty);
@@ -399,7 +399,7 @@ fn trans_expr_fn(bcx: block,
};
fill_fn_pair(bcx, get_dest_addr(dest), llfn, closure);
ret bcx;
return bcx;
}
fn make_fn_glue(
@@ -421,7 +421,7 @@ fn make_fn_glue(
}
};
ret alt ty::get(t).struct {
return alt ty::get(t).struct {
ty::ty_fn({proto: ast::proto_bare, _}) |
ty::ty_fn({proto: ast::proto_block, _}) |
ty::ty_fn({proto: ast::proto_any, _}) { bcx }
@@ -439,8 +439,11 @@ fn make_opaque_cbox_take_glue(
// Easy cases:
let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_take_glue");
alt ck {
ty::ck_block { ret bcx; }
ty::ck_box { incr_refcnt_of_boxed(bcx, Load(bcx, cboxptr)); ret bcx; }
ty::ck_block { return bcx; }
ty::ck_box {
incr_refcnt_of_boxed(bcx, Load(bcx, cboxptr));
return bcx;
}
ty::ck_uniq { /* hard case: */ }
}
@@ -507,7 +510,7 @@ fn make_opaque_cbox_free_glue(
-> block {
let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_free_glue");
alt ck {
ty::ck_block { ret bcx; }
ty::ck_block { return bcx; }
ty::ck_box | ty::ck_uniq { /* hard cases: */ }
}
@@ -537,3 +540,4 @@ fn make_opaque_cbox_free_glue(
}
}
}

View File

@@ -24,7 +24,7 @@ import util::ppaux::ty_to_str;
type namegen = fn@(~str) -> ~str;
fn new_namegen() -> namegen {
let i = @mut 0;
ret fn@(prefix: ~str) -> ~str { *i += 1; prefix + int::str(*i) };
return fn@(prefix: ~str) -> ~str { *i += 1; prefix + int::str(*i) };
}
type tydesc_info =
@@ -247,7 +247,7 @@ fn cleanup_type(cx: ty::ctxt, ty: ty::t) -> cleantype {
}
fn add_clean(cx: block, val: ValueRef, ty: ty::t) {
if !ty::type_needs_drop(cx.tcx(), ty) { ret; }
if !ty::type_needs_drop(cx.tcx(), ty) { return; }
debug!{"add_clean(%s, %s, %s)",
cx.to_str(), val_str(cx.ccx().tn, val),
ty_to_str(cx.ccx().tcx, ty)};
@@ -259,7 +259,7 @@ fn add_clean(cx: block, val: ValueRef, ty: ty::t) {
}
}
fn add_clean_temp(cx: block, val: ValueRef, ty: ty::t) {
if !ty::type_needs_drop(cx.tcx(), ty) { ret; }
if !ty::type_needs_drop(cx.tcx(), ty) { return; }
debug!{"add_clean_temp(%s, %s, %s)",
cx.to_str(), val_str(cx.ccx().tn, val),
ty_to_str(cx.ccx().tcx, ty)};
@@ -267,9 +267,9 @@ fn add_clean_temp(cx: block, val: ValueRef, ty: ty::t) {
fn do_drop(bcx: block, val: ValueRef, ty: ty::t) ->
block {
if ty::type_is_immediate(ty) {
ret base::drop_ty_immediate(bcx, val, ty);
return base::drop_ty_immediate(bcx, val, ty);
} else {
ret base::drop_ty(bcx, val, ty);
return base::drop_ty(bcx, val, ty);
}
}
do in_scope_cx(cx) |info| {
@@ -279,7 +279,7 @@ fn add_clean_temp(cx: block, val: ValueRef, ty: ty::t) {
}
}
fn add_clean_temp_mem(cx: block, val: ValueRef, ty: ty::t) {
if !ty::type_needs_drop(cx.tcx(), ty) { ret; }
if !ty::type_needs_drop(cx.tcx(), ty) { return; }
debug!{"add_clean_temp_mem(%s, %s, %s)",
cx.to_str(), val_str(cx.ccx().tn, val),
ty_to_str(cx.ccx().tcx, ty)};
@@ -429,12 +429,14 @@ fn rslt(bcx: block, val: ValueRef) -> result {
}
fn ty_str(tn: type_names, t: TypeRef) -> ~str {
ret lib::llvm::type_to_str(tn, t);
return lib::llvm::type_to_str(tn, t);
}
fn val_ty(v: ValueRef) -> TypeRef { ret llvm::LLVMTypeOf(v); }
fn val_ty(v: ValueRef) -> TypeRef { return llvm::LLVMTypeOf(v); }
fn val_str(tn: type_names, v: ValueRef) -> ~str { ret ty_str(tn, val_ty(v)); }
fn val_str(tn: type_names, v: ValueRef) -> ~str {
return ty_str(tn, val_ty(v));
}
// Returns the nth element of the given LLVM structure type.
fn struct_elt(llstructty: TypeRef, n: uint) -> TypeRef unsafe {
@@ -442,14 +444,14 @@ fn struct_elt(llstructty: TypeRef, n: uint) -> TypeRef unsafe {
assert (n < elt_count);
let elt_tys = vec::from_elem(elt_count, T_nil());
llvm::LLVMGetStructElementTypes(llstructty, to_ptr(elt_tys));
ret llvm::LLVMGetElementType(elt_tys[n]);
return llvm::LLVMGetElementType(elt_tys[n]);
}
fn in_scope_cx(cx: block, f: fn(scope_info)) {
let mut cur = cx;
loop {
alt cur.kind {
block_scope(inf) { f(inf); ret; }
block_scope(inf) { f(inf); return; }
_ {}
}
cur = block_parent(cur);
@@ -502,35 +504,35 @@ fn T_void() -> TypeRef {
// of 10 nil values will have 10-bit size -- but it doesn't seem like we
// have any other options until it's fixed upstream.
ret llvm::LLVMVoidType();
return llvm::LLVMVoidType();
}
fn T_nil() -> TypeRef {
// NB: See above in T_void().
ret llvm::LLVMInt1Type();
return llvm::LLVMInt1Type();
}
fn T_metadata() -> TypeRef { ret llvm::LLVMMetadataType(); }
fn T_metadata() -> TypeRef { return llvm::LLVMMetadataType(); }
fn T_i1() -> TypeRef { ret llvm::LLVMInt1Type(); }
fn T_i1() -> TypeRef { return llvm::LLVMInt1Type(); }
fn T_i8() -> TypeRef { ret llvm::LLVMInt8Type(); }
fn T_i8() -> TypeRef { return llvm::LLVMInt8Type(); }
fn T_i16() -> TypeRef { ret llvm::LLVMInt16Type(); }
fn T_i16() -> TypeRef { return llvm::LLVMInt16Type(); }
fn T_i32() -> TypeRef { ret llvm::LLVMInt32Type(); }
fn T_i32() -> TypeRef { return llvm::LLVMInt32Type(); }
fn T_i64() -> TypeRef { ret llvm::LLVMInt64Type(); }
fn T_i64() -> TypeRef { return llvm::LLVMInt64Type(); }
fn T_f32() -> TypeRef { ret llvm::LLVMFloatType(); }
fn T_f32() -> TypeRef { return llvm::LLVMFloatType(); }
fn T_f64() -> TypeRef { ret llvm::LLVMDoubleType(); }
fn T_f64() -> TypeRef { return llvm::LLVMDoubleType(); }
fn T_bool() -> TypeRef { ret T_i1(); }
fn T_bool() -> TypeRef { return T_i1(); }
fn T_int(targ_cfg: @session::config) -> TypeRef {
ret alt targ_cfg.arch {
return alt targ_cfg.arch {
session::arch_x86 { T_i32() }
session::arch_x86_64 { T_i64() }
session::arch_arm { T_i32() }
@@ -567,40 +569,40 @@ fn T_float_ty(cx: @crate_ctxt, t: ast::float_ty) -> TypeRef {
}
fn T_float(targ_cfg: @session::config) -> TypeRef {
ret alt targ_cfg.arch {
return alt targ_cfg.arch {
session::arch_x86 { T_f64() }
session::arch_x86_64 { T_f64() }
session::arch_arm { T_f64() }
};
}
fn T_char() -> TypeRef { ret T_i32(); }
fn T_char() -> TypeRef { return T_i32(); }
fn T_size_t(targ_cfg: @session::config) -> TypeRef {
ret T_int(targ_cfg);
return T_int(targ_cfg);
}
fn T_fn(inputs: ~[TypeRef], output: TypeRef) -> TypeRef unsafe {
ret llvm::LLVMFunctionType(output, to_ptr(inputs),
return llvm::LLVMFunctionType(output, to_ptr(inputs),
inputs.len() as c_uint,
False);
}
fn T_fn_pair(cx: @crate_ctxt, tfn: TypeRef) -> TypeRef {
ret T_struct(~[T_ptr(tfn), T_opaque_cbox_ptr(cx)]);
return T_struct(~[T_ptr(tfn), T_opaque_cbox_ptr(cx)]);
}
fn T_ptr(t: TypeRef) -> TypeRef {
ret llvm::LLVMPointerType(t, 0u as c_uint);
return llvm::LLVMPointerType(t, 0u as c_uint);
}
fn T_struct(elts: ~[TypeRef]) -> TypeRef unsafe {
ret llvm::LLVMStructType(to_ptr(elts), elts.len() as c_uint, False);
return llvm::LLVMStructType(to_ptr(elts), elts.len() as c_uint, False);
}
fn T_named_struct(name: ~str) -> TypeRef {
let c = llvm::LLVMGetGlobalContext();
ret str::as_c_str(name, |buf| llvm::LLVMStructCreateNamed(c, buf));
return str::as_c_str(name, |buf| llvm::LLVMStructCreateNamed(c, buf));
}
fn set_struct_body(t: TypeRef, elts: ~[TypeRef]) unsafe {
@@ -608,7 +610,7 @@ fn set_struct_body(t: TypeRef, elts: ~[TypeRef]) unsafe {
elts.len() as c_uint, False);
}
fn T_empty_struct() -> TypeRef { ret T_struct(~[]); }
fn T_empty_struct() -> TypeRef { return T_struct(~[]); }
// A vtable is, in reality, a vtable pointer followed by zero or more pointers
// to tydescs and other vtables that it closes over. But the types and number
@@ -635,7 +637,7 @@ fn T_task(targ_cfg: @session::config) -> TypeRef {
~[t_int, t_int, t_int, t_int,
t_int, t_int, t_int, t_int];
set_struct_body(t, elems);
ret t;
return t;
}
fn T_tydesc_field(cx: @crate_ctxt, field: uint) -> TypeRef unsafe {
@@ -647,15 +649,15 @@ fn T_tydesc_field(cx: @crate_ctxt, field: uint) -> TypeRef unsafe {
llvm::LLVMGetStructElementTypes(cx.tydesc_type,
to_ptr::<TypeRef>(tydesc_elts));
let t = llvm::LLVMGetElementType(tydesc_elts[field]);
ret t;
return t;
}
fn T_glue_fn(cx: @crate_ctxt) -> TypeRef {
let s = ~"glue_fn";
alt name_has_type(cx.tn, s) { some(t) { ret t; } _ {} }
alt name_has_type(cx.tn, s) { some(t) { return t; } _ {} }
let t = T_tydesc_field(cx, abi::tydesc_field_drop_glue);
associate_type(cx.tn, s, t);
ret t;
return t;
}
fn T_tydesc(targ_cfg: @session::config) -> TypeRef {
@@ -672,27 +674,27 @@ fn T_tydesc(targ_cfg: @session::config) -> TypeRef {
glue_fn_ty, glue_fn_ty, glue_fn_ty, glue_fn_ty,
T_ptr(T_i8()), T_ptr(T_i8())];
set_struct_body(tydesc, elems);
ret tydesc;
return tydesc;
}
fn T_array(t: TypeRef, n: uint) -> TypeRef {
ret llvm::LLVMArrayType(t, n as c_uint);
return llvm::LLVMArrayType(t, n as c_uint);
}
// Interior vector.
fn T_vec2(targ_cfg: @session::config, t: TypeRef) -> TypeRef {
ret T_struct(~[T_int(targ_cfg), // fill
return T_struct(~[T_int(targ_cfg), // fill
T_int(targ_cfg), // alloc
T_array(t, 0u)]); // elements
}
fn T_vec(ccx: @crate_ctxt, t: TypeRef) -> TypeRef {
ret T_vec2(ccx.sess.targ_cfg, t);
return T_vec2(ccx.sess.targ_cfg, t);
}
// Note that the size of this one is in bytes.
fn T_opaque_vec(targ_cfg: @session::config) -> TypeRef {
ret T_vec2(targ_cfg, T_i8());
return T_vec2(targ_cfg, T_i8());
}
// Let T be the content of a box @T. tuplify_box_ty(t) returns the
@@ -700,120 +702,120 @@ fn T_opaque_vec(targ_cfg: @session::config) -> TypeRef {
// returns).
fn tuplify_box_ty(tcx: ty::ctxt, t: ty::t) -> ty::t {
let ptr = ty::mk_ptr(tcx, {ty: ty::mk_nil(tcx), mutbl: ast::m_imm});
ret ty::mk_tup(tcx, ~[ty::mk_uint(tcx), ty::mk_type(tcx),
return ty::mk_tup(tcx, ~[ty::mk_uint(tcx), ty::mk_type(tcx),
ptr, ptr,
t]);
}
fn T_box_header_fields(cx: @crate_ctxt) -> ~[TypeRef] {
let ptr = T_ptr(T_i8());
ret ~[cx.int_type, T_ptr(cx.tydesc_type), ptr, ptr];
return ~[cx.int_type, T_ptr(cx.tydesc_type), ptr, ptr];
}
fn T_box_header(cx: @crate_ctxt) -> TypeRef {
ret T_struct(T_box_header_fields(cx));
return T_struct(T_box_header_fields(cx));
}
fn T_box(cx: @crate_ctxt, t: TypeRef) -> TypeRef {
ret T_struct(vec::append(T_box_header_fields(cx), ~[t]));
return T_struct(vec::append(T_box_header_fields(cx), ~[t]));
}
fn T_box_ptr(t: TypeRef) -> TypeRef {
const box_addrspace: uint = 1u;
ret llvm::LLVMPointerType(t, box_addrspace as c_uint);
return llvm::LLVMPointerType(t, box_addrspace as c_uint);
}
fn T_opaque_box(cx: @crate_ctxt) -> TypeRef {
ret T_box(cx, T_i8());
return T_box(cx, T_i8());
}
fn T_opaque_box_ptr(cx: @crate_ctxt) -> TypeRef {
ret T_box_ptr(T_opaque_box(cx));
return T_box_ptr(T_opaque_box(cx));
}
fn T_unique(cx: @crate_ctxt, t: TypeRef) -> TypeRef {
ret T_struct(vec::append(T_box_header_fields(cx), ~[t]));
return T_struct(vec::append(T_box_header_fields(cx), ~[t]));
}
fn T_unique_ptr(t: TypeRef) -> TypeRef {
const unique_addrspace: uint = 1u;
ret llvm::LLVMPointerType(t, unique_addrspace as c_uint);
return llvm::LLVMPointerType(t, unique_addrspace as c_uint);
}
fn T_port(cx: @crate_ctxt, _t: TypeRef) -> TypeRef {
ret T_struct(~[cx.int_type]); // Refcount
return T_struct(~[cx.int_type]); // Refcount
}
fn T_chan(cx: @crate_ctxt, _t: TypeRef) -> TypeRef {
ret T_struct(~[cx.int_type]); // Refcount
return T_struct(~[cx.int_type]); // Refcount
}
fn T_taskptr(cx: @crate_ctxt) -> TypeRef { ret T_ptr(cx.task_type); }
fn T_taskptr(cx: @crate_ctxt) -> TypeRef { return T_ptr(cx.task_type); }
// This type must never be used directly; it must always be cast away.
fn T_typaram(tn: type_names) -> TypeRef {
let s = ~"typaram";
alt name_has_type(tn, s) { some(t) { ret t; } _ {} }
alt name_has_type(tn, s) { some(t) { return t; } _ {} }
let t = T_i8();
associate_type(tn, s, t);
ret t;
return t;
}
fn T_typaram_ptr(tn: type_names) -> TypeRef { ret T_ptr(T_typaram(tn)); }
fn T_typaram_ptr(tn: type_names) -> TypeRef { return T_ptr(T_typaram(tn)); }
fn T_opaque_cbox_ptr(cx: @crate_ctxt) -> TypeRef {
// closures look like boxes (even when they are fn~ or fn&)
// see trans_closure.rs
ret T_opaque_box_ptr(cx);
return T_opaque_box_ptr(cx);
}
fn T_enum_discrim(cx: @crate_ctxt) -> TypeRef {
ret cx.int_type;
return cx.int_type;
}
fn T_opaque_enum(cx: @crate_ctxt) -> TypeRef {
let s = ~"opaque_enum";
alt name_has_type(cx.tn, s) { some(t) { ret t; } _ {} }
alt name_has_type(cx.tn, s) { some(t) { return t; } _ {} }
let t = T_struct(~[T_enum_discrim(cx), T_i8()]);
associate_type(cx.tn, s, t);
ret t;
return t;
}
fn T_opaque_enum_ptr(cx: @crate_ctxt) -> TypeRef {
ret T_ptr(T_opaque_enum(cx));
return T_ptr(T_opaque_enum(cx));
}
fn T_captured_tydescs(cx: @crate_ctxt, n: uint) -> TypeRef {
ret T_struct(vec::from_elem::<TypeRef>(n, T_ptr(cx.tydesc_type)));
return T_struct(vec::from_elem::<TypeRef>(n, T_ptr(cx.tydesc_type)));
}
fn T_opaque_trait(cx: @crate_ctxt) -> TypeRef {
T_struct(~[T_ptr(cx.tydesc_type), T_opaque_box_ptr(cx)])
}
fn T_opaque_port_ptr() -> TypeRef { ret T_ptr(T_i8()); }
fn T_opaque_port_ptr() -> TypeRef { return T_ptr(T_i8()); }
fn T_opaque_chan_ptr() -> TypeRef { ret T_ptr(T_i8()); }
fn T_opaque_chan_ptr() -> TypeRef { return T_ptr(T_i8()); }
// LLVM constant constructors.
fn C_null(t: TypeRef) -> ValueRef { ret llvm::LLVMConstNull(t); }
fn C_null(t: TypeRef) -> ValueRef { return llvm::LLVMConstNull(t); }
fn C_integral(t: TypeRef, u: u64, sign_extend: Bool) -> ValueRef {
ret llvm::LLVMConstInt(t, u, sign_extend);
return llvm::LLVMConstInt(t, u, sign_extend);
}
fn C_floating(s: ~str, t: TypeRef) -> ValueRef {
ret str::as_c_str(s, |buf| llvm::LLVMConstRealOfString(t, buf));
return str::as_c_str(s, |buf| llvm::LLVMConstRealOfString(t, buf));
}
fn C_nil() -> ValueRef {
// NB: See comment above in T_void().
ret C_integral(T_i1(), 0u64, False);
return C_integral(T_i1(), 0u64, False);
}
fn C_bool(b: bool) -> ValueRef {
@@ -821,29 +823,29 @@ fn C_bool(b: bool) -> ValueRef {
}
fn C_i32(i: i32) -> ValueRef {
ret C_integral(T_i32(), i as u64, True);
return C_integral(T_i32(), i as u64, True);
}
fn C_i64(i: i64) -> ValueRef {
ret C_integral(T_i64(), i as u64, True);
return C_integral(T_i64(), i as u64, True);
}
fn C_int(cx: @crate_ctxt, i: int) -> ValueRef {
ret C_integral(cx.int_type, i as u64, True);
return C_integral(cx.int_type, i as u64, True);
}
fn C_uint(cx: @crate_ctxt, i: uint) -> ValueRef {
ret C_integral(cx.int_type, i as u64, False);
return C_integral(cx.int_type, i as u64, False);
}
fn C_u8(i: uint) -> ValueRef { ret C_integral(T_i8(), i as u64, False); }
fn C_u8(i: uint) -> ValueRef { return C_integral(T_i8(), i as u64, False); }
// This is a 'c-like' raw string, which differs from
// our boxed-and-length-annotated strings.
fn C_cstr(cx: @crate_ctxt, s: ~str) -> ValueRef {
alt cx.const_cstr_cache.find(s) {
some(llval) { ret llval; }
some(llval) { return llval; }
none { }
}
@@ -859,7 +861,7 @@ fn C_cstr(cx: @crate_ctxt, s: ~str) -> ValueRef {
cx.const_cstr_cache.insert(s, g);
ret g;
return g;
}
fn C_estr_slice(cx: @crate_ctxt, s: ~str) -> ValueRef {
@@ -869,7 +871,7 @@ fn C_estr_slice(cx: @crate_ctxt, s: ~str) -> ValueRef {
// Returns a Plain Old LLVM String:
fn C_postr(s: ~str) -> ValueRef {
ret do str::as_c_str(s) |buf| {
return do str::as_c_str(s) |buf| {
llvm::LLVMConstString(buf, str::len(s) as c_uint, False)
};
}
@@ -878,27 +880,27 @@ fn C_zero_byte_arr(size: uint) -> ValueRef unsafe {
let mut i = 0u;
let mut elts: ~[ValueRef] = ~[];
while i < size { vec::push(elts, C_u8(0u)); i += 1u; }
ret llvm::LLVMConstArray(T_i8(), vec::unsafe::to_ptr(elts),
return llvm::LLVMConstArray(T_i8(), vec::unsafe::to_ptr(elts),
elts.len() as c_uint);
}
fn C_struct(elts: ~[ValueRef]) -> ValueRef unsafe {
ret llvm::LLVMConstStruct(vec::unsafe::to_ptr(elts),
return llvm::LLVMConstStruct(vec::unsafe::to_ptr(elts),
elts.len() as c_uint, False);
}
fn C_named_struct(T: TypeRef, elts: ~[ValueRef]) -> ValueRef unsafe {
ret llvm::LLVMConstNamedStruct(T, vec::unsafe::to_ptr(elts),
return llvm::LLVMConstNamedStruct(T, vec::unsafe::to_ptr(elts),
elts.len() as c_uint);
}
fn C_array(ty: TypeRef, elts: ~[ValueRef]) -> ValueRef unsafe {
ret llvm::LLVMConstArray(ty, vec::unsafe::to_ptr(elts),
return llvm::LLVMConstArray(ty, vec::unsafe::to_ptr(elts),
elts.len() as c_uint);
}
fn C_bytes(bytes: ~[u8]) -> ValueRef unsafe {
ret llvm::LLVMConstString(
return llvm::LLVMConstString(
unsafe::reinterpret_cast(vec::unsafe::to_ptr(bytes)),
bytes.len() as c_uint, False);
}
@@ -911,7 +913,7 @@ fn C_shape(ccx: @crate_ctxt, bytes: ~[u8]) -> ValueRef {
llvm::LLVMSetInitializer(llglobal, llshape);
llvm::LLVMSetGlobalConstant(llglobal, True);
lib::llvm::SetLinkage(llglobal, lib::llvm::InternalLinkage);
ret llvm::LLVMConstPointerCast(llglobal, T_ptr(T_i8()));
return llvm::LLVMConstPointerCast(llglobal, T_ptr(T_i8()));
}
fn get_param(fndecl: ValueRef, param: uint) -> ValueRef {
@@ -945,18 +947,18 @@ fn hash_mono_id(&&mi: mono_id) -> uint {
fn umax(cx: block, a: ValueRef, b: ValueRef) -> ValueRef {
let cond = build::ICmp(cx, lib::llvm::IntULT, a, b);
ret build::Select(cx, cond, b, a);
return build::Select(cx, cond, b, a);
}
fn umin(cx: block, a: ValueRef, b: ValueRef) -> ValueRef {
let cond = build::ICmp(cx, lib::llvm::IntULT, a, b);
ret build::Select(cx, cond, a, b);
return build::Select(cx, cond, a, b);
}
fn align_to(cx: block, off: ValueRef, align: ValueRef) -> ValueRef {
let mask = build::Sub(cx, align, C_int(cx.ccx(), 1));
let bumped = build::Add(cx, off, mask);
ret build::And(cx, bumped, build::Not(cx, mask));
return build::And(cx, bumped, build::Not(cx, mask));
}
fn path_str(p: path) -> ~str {

View File

@@ -51,7 +51,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
let ty = ty::expr_ty(cx.tcx, e1);
let is_float = ty::type_is_fp(ty);
let signed = ty::type_is_signed(ty);
ret alt b {
return alt b {
ast::add {
if is_float { llvm::LLVMConstFAdd(te1, te2) }
else { llvm::LLVMConstAdd(te1, te2) }
@@ -96,7 +96,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
let te = const_expr(cx, e);
let ty = ty::expr_ty(cx.tcx, e);
let is_float = ty::type_is_fp(ty);
ret alt u {
return alt u {
ast::box(_) |
ast::uniq(_) |
ast::deref { cx.sess.span_bug(e.span,

View File

@@ -130,7 +130,7 @@ enum debug_metadata {
fn cast_safely<T: copy, U>(val: T) -> U unsafe {
let val2 = val;
ret unsafe::transmute(val2);
return unsafe::transmute(val2);
}
fn md_from_metadata<T>(val: debug_metadata) -> T unsafe {
@@ -153,11 +153,11 @@ fn cached_metadata<T: copy>(cache: metadata_cache, mdtag: int,
for items.each |item| {
let md: T = md_from_metadata::<T>(item);
if eq(md) {
ret option::some(md);
return option::some(md);
}
}
}
ret option::none;
return option::none;
}
fn create_compile_unit(cx: @crate_ctxt)
@@ -167,7 +167,7 @@ fn create_compile_unit(cx: @crate_ctxt)
let tg = CompileUnitTag;
alt cached_metadata::<@metadata<compile_unit_md>>(cache, tg,
|md| md.data.name == crate_name) {
option::some(md) { ret md; }
option::some(md) { return md; }
option::none {}
}
@@ -189,7 +189,7 @@ fn create_compile_unit(cx: @crate_ctxt)
let mdval = @{node: unit_node, data: {name: crate_name}};
update_cache(cache, tg, compile_unit_metadata(mdval));
ret mdval;
return mdval;
}
fn get_cache(cx: @crate_ctxt) -> metadata_cache {
@@ -210,7 +210,7 @@ fn create_file(cx: @crate_ctxt, full_path: ~str) -> @metadata<file_md> {
let tg = FileDescriptorTag;
alt cached_metadata::<@metadata<file_md>>(
cache, tg, |md| md.data.path == full_path) {
option::some(md) { ret md; }
option::some(md) { return md; }
option::none {}
}
@@ -224,7 +224,7 @@ fn create_file(cx: @crate_ctxt, full_path: ~str) -> @metadata<file_md> {
let val = llmdnode(file_md);
let mdval = @{node: val, data: {path: full_path}};
update_cache(cache, tg, file_metadata(mdval));
ret mdval;
return mdval;
}
fn line_from_span(cm: codemap::codemap, sp: span) -> uint {
@@ -249,7 +249,7 @@ fn create_block(cx: block) -> @metadata<block_md> {
/*alt cached_metadata::<@metadata<block_md>>(
cache, tg,
{|md| start == md.data.start && end == md.data.end}) {
option::some(md) { ret md; }
option::some(md) { return md; }
option::none {}
}*/
@@ -272,7 +272,7 @@ fn create_block(cx: block) -> @metadata<block_md> {
let val = llmdnode(lldata);
let mdval = @{node: val, data: {start: start, end: end}};
//update_cache(cache, tg, block_metadata(mdval));
ret mdval;
return mdval;
}
fn size_and_align_of(cx: @crate_ctxt, t: ty::t) -> (int, int) {
@@ -287,7 +287,7 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span)
let tg = BasicTypeDescriptorTag;
alt cached_metadata::<@metadata<tydesc_md>>(
cache, tg, |md| ty::type_id(t) == md.data.hash) {
option::some(md) { ret md; }
option::some(md) { return md; }
option::none {}
}
@@ -333,7 +333,7 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span)
let mdval = @{node: llnode, data: {hash: ty::type_id(t)}};
update_cache(cache, tg, tydesc_metadata(mdval));
add_named_metadata(cx, ~"llvm.dbg.ty", llnode);
ret mdval;
return mdval;
}
fn create_pointer_type(cx: @crate_ctxt, t: ty::t, span: span,
@@ -343,7 +343,7 @@ fn create_pointer_type(cx: @crate_ctxt, t: ty::t, span: span,
/*let cache = cx.llmetadata;
alt cached_metadata::<@metadata<tydesc_md>>(
cache, tg, {|md| ty::hash_ty(t) == ty::hash_ty(md.data.hash)}) {
option::some(md) { ret md; }
option::some(md) { return md; }
option::none {}
}*/
let (size, align) = size_and_align_of(cx, t);
@@ -355,7 +355,7 @@ fn create_pointer_type(cx: @crate_ctxt, t: ty::t, span: span,
let mdval = @{node: llnode, data: {hash: ty::type_id(t)}};
//update_cache(cache, tg, tydesc_metadata(mdval));
add_named_metadata(cx, ~"llvm.dbg.ty", llnode);
ret mdval;
return mdval;
}
type struct_ctxt = {
@@ -368,7 +368,7 @@ type struct_ctxt = {
};
fn finish_structure(cx: @struct_ctxt) -> ValueRef {
ret create_composite_type(StructureTypeTag, cx.name, cx.file, cx.line,
return create_composite_type(StructureTypeTag, cx.name, cx.file, cx.line,
cx.total_size, cx.align, 0, option::none,
option::some(cx.members));
}
@@ -382,7 +382,7 @@ fn create_structure(file: @metadata<file_md>, name: ~str, line: int)
mut total_size: 0,
align: 64 //XXX different alignment per arch?
};
ret cx;
return cx;
}
fn create_derived_type(type_tag: int, file: ValueRef, name: ~str, line: int,
@@ -398,7 +398,7 @@ fn create_derived_type(type_tag: int, file: ValueRef, name: ~str, line: int,
lli64(offset),
lli32(0),
ty];
ret llmdnode(lldata);
return llmdnode(lldata);
}
fn add_member(cx: @struct_ctxt, name: ~str, line: int, size: int, align: int,
@@ -426,7 +426,7 @@ fn create_record(cx: @crate_ctxt, t: ty::t, fields: ~[ast::ty_field],
size as int, align as int, ty_md.node);
}
let mdval = @{node: finish_structure(scx), data:{hash: ty::type_id(t)}};
ret mdval;
return mdval;
}
fn create_boxed_type(cx: @crate_ctxt, outer: ty::t, _inner: ty::t,
@@ -436,7 +436,7 @@ fn create_boxed_type(cx: @crate_ctxt, outer: ty::t, _inner: ty::t,
/*let cache = cx.llmetadata;
alt cached_metadata::<@metadata<tydesc_md>>(
cache, tg, {|md| ty::hash_ty(outer) == ty::hash_ty(md.data.hash)}) {
option::some(md) { ret md; }
option::some(md) { return md; }
option::none {}
}*/
let fname = filename_from_span(cx, span);
@@ -455,7 +455,7 @@ fn create_boxed_type(cx: @crate_ctxt, outer: ty::t, _inner: ty::t,
let mdval = @{node: llnode, data: {hash: ty::type_id(outer)}};
//update_cache(cache, tg, tydesc_metadata(mdval));
add_named_metadata(cx, ~"llvm.dbg.ty", llnode);
ret mdval;
return mdval;
}
fn create_composite_type(type_tag: int, name: ~str, file: ValueRef, line: int,
@@ -485,7 +485,7 @@ fn create_composite_type(type_tag: int, name: ~str, file: ValueRef, line: int,
lli32(0), // runtime language
llnull()
];
ret llmdnode(lldata);
return llmdnode(lldata);
}
fn create_vec(cx: @crate_ctxt, vec_t: ty::t, elem_t: ty::t,
@@ -510,7 +510,7 @@ fn create_vec(cx: @crate_ctxt, vec_t: ty::t, elem_t: ty::t,
add_member(scx, ~"data", 0, 0, // clang says the size should be 0
sys::min_align_of::<u8>() as int, data_ptr);
let llnode = finish_structure(scx);
ret @{node: llnode, data: {hash: ty::type_id(vec_t)}};
return @{node: llnode, data: {hash: ty::type_id(vec_t)}};
}
fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty)
@@ -518,7 +518,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty)
/*let cache = get_cache(cx);
alt cached_metadata::<@metadata<tydesc_md>>(
cache, tg, {|md| t == md.data.hash}) {
option::some(md) { ret md; }
option::some(md) { return md; }
option::none {}
}*/
@@ -563,7 +563,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty)
cx.sess.span_bug(span, "t_to_ty: Can't handle this type");
}
};
ret @{node: ty, span: span};
return @{node: ty, span: span};
}
alt ty.node {
@@ -574,7 +574,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty)
};
let md = create_ty(cx, inner_t, mt.ty);
let box = create_boxed_type(cx, t, inner_t, ty.span, md);
ret create_pointer_type(cx, t, ty.span, box);
return create_pointer_type(cx, t, ty.span, box);
}
ast::ty_uniq(mt) {
@@ -584,29 +584,29 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty)
_ { cx.sess.span_bug(ty.span, "t_to_ty was incoherent"); }
};
let md = create_ty(cx, inner_t, mt.ty);
ret create_pointer_type(cx, t, ty.span, md);
return create_pointer_type(cx, t, ty.span, md);
}
ast::ty_infer {
let inferred = t_to_ty(cx, t, ty.span);
ret create_ty(cx, t, inferred);
return create_ty(cx, t, inferred);
}
ast::ty_rec(fields) {
ret create_record(cx, t, fields, ty.span);
return create_record(cx, t, fields, ty.span);
}
ast::ty_vec(mt) {
let inner_t = ty::sequence_element_type(cx.tcx, t);
let inner_ast_t = t_to_ty(cx, inner_t, mt.ty.span);
let v = create_vec(cx, t, inner_t, ty.span, inner_ast_t);
ret create_pointer_type(cx, t, ty.span, v);
return create_pointer_type(cx, t, ty.span, v);
}
ast::ty_path(_, id) {
alt cx.tcx.def_map.get(id) {
ast::def_prim_ty(pty) {
ret create_basic_type(cx, t, pty, ty.span);
return create_basic_type(cx, t, pty, ty.span);
}
_ {}
}
@@ -631,7 +631,7 @@ fn create_var(type_tag: int, context: ValueRef, name: ~str, file: ValueRef,
ret_ty,
lli32(0)
];
ret llmdnode(lldata);
return llmdnode(lldata);
}
fn create_local_var(bcx: block, local: @ast::local)
@@ -641,7 +641,7 @@ fn create_local_var(bcx: block, local: @ast::local)
let tg = AutoVariableTag;
alt cached_metadata::<@metadata<local_var_md>>(
cache, tg, |md| md.data.id == local.node.id) {
option::some(md) { ret md; }
option::some(md) { return md; }
option::none {}
}
@@ -681,7 +681,7 @@ fn create_local_var(bcx: block, local: @ast::local)
let declargs = ~[llmdnode(~[llptr]), mdnode];
trans::build::Call(bcx, cx.intrinsics.get(~"llvm.dbg.declare"),
declargs);
ret mdval;
return mdval;
}
fn create_arg(bcx: block, arg: ast::arg, sp: span)
@@ -691,7 +691,7 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span)
let tg = ArgVariableTag;
alt cached_metadata::<@metadata<argument_md>>(
cache, ArgVariableTag, |md| md.data.id == arg.id) {
option::some(md) { ret md; }
option::some(md) { return md; }
option::none {}
}
@@ -712,12 +712,12 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span)
let declargs = ~[llmdnode(~[llptr]), mdnode];
trans::build::Call(bcx, cx.intrinsics.get(~"llvm.dbg.declare"),
declargs);
ret mdval;
return mdval;
}
fn update_source_pos(cx: block, s: span) {
if !cx.sess().opts.debuginfo {
ret;
return;
}
let cm = cx.sess().codemap;
let blockmd = create_block(cx);
@@ -779,7 +779,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
let cache = get_cache(cx);
alt cached_metadata::<@metadata<subprogram_md>>(
cache, SubprogramTag, |md| md.data.id == id) {
option::some(md) { ret md; }
option::some(md) { return md; }
option::none {}
}
@@ -824,5 +824,5 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
let mdval = @{node: val, data: {id: id}};
update_cache(cache, SubprogramTag, subprogram_metadata(mdval));
ret mdval;
return mdval;
}

View File

@@ -38,7 +38,7 @@ enum x86_64_reg_class {
}
fn is_sse(++c: x86_64_reg_class) -> bool {
ret alt c {
return alt c {
sse_fs_class | sse_fv_class |
sse_ds_class | sse_dv_class { true }
_ { false }
@@ -47,7 +47,7 @@ fn is_sse(++c: x86_64_reg_class) -> bool {
fn is_ymm(cls: ~[x86_64_reg_class]) -> bool {
let len = vec::len(cls);
ret (len > 2u &&
return (len > 2u &&
is_sse(cls[0]) &&
cls[1] == sseup_class &&
cls[2] == sseup_class) ||
@@ -60,7 +60,7 @@ fn is_ymm(cls: ~[x86_64_reg_class]) -> bool {
fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
fn align(off: uint, ty: TypeRef) -> uint {
let a = ty_align(ty);
ret (off + a - 1u) / a * a;
return (off + a - 1u) / a * a;
}
fn struct_tys(ty: TypeRef) -> ~[TypeRef] {
@@ -69,11 +69,11 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
do vec::as_buf(elts) |buf, _len| {
llvm::LLVMGetStructElementTypes(ty, buf);
}
ret elts;
return elts;
}
fn ty_align(ty: TypeRef) -> uint {
ret alt llvm::LLVMGetTypeKind(ty) as int {
return alt llvm::LLVMGetTypeKind(ty) as int {
8 /* integer */ {
((llvm::LLVMGetIntTypeWidth(ty) as uint) + 7u) / 8u
}
@@ -96,7 +96,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
}
fn ty_size(ty: TypeRef) -> uint {
ret alt llvm::LLVMGetTypeKind(ty) as int {
return alt llvm::LLVMGetTypeKind(ty) as int {
8 /* integer */ {
((llvm::LLVMGetIntTypeWidth(ty) as uint) + 7u) / 8u
}
@@ -130,11 +130,11 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
i: uint,
newv: x86_64_reg_class) {
if cls[i] == newv {
ret;
return;
} else if cls[i] == no_class {
cls[i] = newv;
} else if newv == no_class {
ret;
return;
} else if cls[i] == memory_class || newv == memory_class {
cls[i] = memory_class;
} else if cls[i] == integer_class || newv == integer_class {
@@ -180,7 +180,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
unify(cls, ix + i, memory_class);
i += 1u;
}
ret;
return;
}
alt llvm::LLVMGetTypeKind(ty) as int {
@@ -229,25 +229,25 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
while i < e {
if cls[i] != sseup_class {
all_mem(cls);
ret;
return;
}
i += 1u;
}
} else {
all_mem(cls);
ret
return
}
} else {
while i < e {
if cls[i] == memory_class {
all_mem(cls);
ret;
return;
}
if cls[i] == x87up_class {
// for darwin
// cls[i] = sse_ds_class;
all_mem(cls);
ret;
return;
}
if cls[i] == sseup_class {
cls[i] = sse_int_class;
@@ -268,11 +268,11 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
let cls = vec::to_mut(vec::from_elem(words, no_class));
if words > 4u {
all_mem(cls);
ret vec::from_mut(cls);
return vec::from_mut(cls);
}
classify(ty, cls, 0u, 0u);
fixup(ty, cls);
ret vec::from_mut(cls);
return vec::from_mut(cls);
}
fn llreg_ty(cls: ~[x86_64_reg_class]) -> TypeRef {
@@ -284,7 +284,7 @@ fn llreg_ty(cls: ~[x86_64_reg_class]) -> TypeRef {
}
len += 1u;
}
ret len;
return len;
}
let mut tys = ~[];
@@ -315,7 +315,7 @@ fn llreg_ty(cls: ~[x86_64_reg_class]) -> TypeRef {
}
i += 1u;
}
ret T_struct(tys);
return T_struct(tys);
}
type x86_64_llty = {
@@ -334,7 +334,7 @@ fn x86_64_tys(atys: ~[TypeRef],
rty: TypeRef,
ret_def: bool) -> x86_64_tys {
fn is_reg_ty(ty: TypeRef) -> bool {
ret alt llvm::LLVMGetTypeKind(ty) as int {
return alt llvm::LLVMGetTypeKind(ty) as int {
8 /* integer */ |
12 /* pointer */ |
2 /* float */ |
@@ -344,13 +344,13 @@ fn x86_64_tys(atys: ~[TypeRef],
}
fn is_pass_byval(cls: ~[x86_64_reg_class]) -> bool {
ret cls[0] == memory_class ||
return cls[0] == memory_class ||
cls[0] == x87_class ||
cls[0] == complex_x87_class;
}
fn is_ret_bysret(cls: ~[x86_64_reg_class]) -> bool {
ret cls[0] == memory_class;
return cls[0] == memory_class;
}
fn x86_64_ty(ty: TypeRef,
@@ -369,7 +369,7 @@ fn x86_64_tys(atys: ~[TypeRef],
llty = llreg_ty(cls);
}
}
ret ({ cast: cast, ty: llty }, ty_attr);
return ({ cast: cast, ty: llty }, ty_attr);
}
let mut arg_tys = ~[];
@@ -393,7 +393,7 @@ fn x86_64_tys(atys: ~[TypeRef],
ty: T_void()
};
}
ret {
return {
arg_tys: arg_tys,
ret_ty: ret_ty,
attrs: attrs,
@@ -417,13 +417,13 @@ fn decl_x86_64_fn(tys: x86_64_tys,
_ {}
}
}
ret llfn;
return llfn;
}
fn link_name(i: @ast::foreign_item) -> ~str {
alt attr::first_attr_value_str_by_name(i.attrs, ~"link_name") {
none { ret *i.ident; }
option::some(ln) { ret *ln; }
none { return *i.ident; }
option::some(ln) { return *ln; }
}
}
@@ -458,7 +458,7 @@ fn c_stack_tys(ccx: @crate_ctxt,
} else {
option::none
};
ret @{
return @{
arg_tys: llargtys,
ret_ty: llretty,
ret_def: ret_def,
@@ -501,7 +501,7 @@ fn build_shim_fn_(ccx: @crate_ctxt,
build_return(bcx);
finish_fn(fcx, lltop);
ret llshimfn;
return llshimfn;
}
type wrap_arg_builder = fn(bcx: block, tys: @c_stack_tys,
@@ -631,7 +631,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
}
}
}
ret llargvals;
return llargvals;
}
fn build_ret(bcx: block, tys: @c_stack_tys,
@@ -650,7 +650,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
}
}
if x86_64.sret || !tys.ret_def {
ret;
return;
}
let n = vec::len(tys.arg_tys);
let llretptr = GEPi(bcx, llargbundle, ~[0u, n]);
@@ -681,7 +681,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
let llbasefn = base_fn(ccx, lname, tys, cc);
// Name the shim function
let shim_name = lname + ~"__c_stack_shim";
ret build_shim_fn_(ccx, shim_name, llbasefn, tys, cc,
return build_shim_fn_(ccx, shim_name, llbasefn, tys, cc,
build_args, build_ret);
}
@@ -734,7 +734,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
let _icx = bcx.insn_ctxt(~"foreign::wrap::build_args");
let mut i = 0u;
let n = vec::len(tys.arg_tys);
let implicit_args = first_real_arg; // ret + env
let implicit_args = first_real_arg; // return + env
while i < n {
let llargval = get_param(llwrapfn, i + implicit_args);
store_inbounds(bcx, llargval, llargbundle, ~[0u, i]);
@@ -1005,7 +1005,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
let llty = type_of_fn_from_ty(ccx, t);
let llfndecl = decl_internal_cdecl_fn(ccx.llmod, ps, llty);
trans_fn(ccx, path, decl, body, llfndecl, no_self, none, id);
ret llfndecl;
return llfndecl;
}
fn build_shim_fn(ccx: @crate_ctxt, path: ast_map::path,
@@ -1028,7 +1028,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
vec::push(llargvals, llargval);
i += 1u;
}
ret llargvals;
return llargvals;
}
fn build_ret(_bcx: block, _tys: @c_stack_tys,
@@ -1040,7 +1040,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
let shim_name = link::mangle_internal_name_by_path(
ccx, vec::append_one(path,
ast_map::path_name(@~"__rust_stack_shim")));
ret build_shim_fn_(ccx, shim_name, llrustfn, tys,
return build_shim_fn_(ccx, shim_name, llrustfn, tys,
lib::llvm::CCallConv,
build_args, build_ret);
}
@@ -1111,7 +1111,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
option::some(x86_64) {
if x86_64.sret || !tys.ret_def {
RetVoid(bcx);
ret;
return;
}
let n = vec::len(tys.arg_tys);
let llretval = load_inbounds(bcx, llargbundle, ~[0u, n]);
@@ -1153,7 +1153,7 @@ fn register_foreign_fn(ccx: @crate_ctxt, sp: span,
let _icx = ccx.insn_ctxt(~"foreign::register_foreign_fn");
let t = ty::node_id_to_type(ccx.tcx, node_id);
let (llargtys, llretty, ret_ty) = c_arg_and_ret_lltys(ccx, node_id);
ret if ccx.sess.targ_cfg.arch == arch_x86_64 {
return if ccx.sess.targ_cfg.arch == arch_x86_64 {
let ret_def = !ty::type_is_bot(ret_ty) && !ty::type_is_nil(ret_ty);
let x86_64 = x86_64_tys(llargtys, llretty, ret_def);
do decl_x86_64_fn(x86_64) |fnty| {

View File

@@ -18,7 +18,7 @@ import std::map::hashmap;
fn trans_impl(ccx: @crate_ctxt, path: path, name: ast::ident,
methods: ~[@ast::method], tps: ~[ast::ty_param]) {
let _icx = ccx.insn_ctxt(~"impl::trans_impl");
if tps.len() > 0u { ret; }
if tps.len() > 0u { return; }
let sub_path = vec::append_one(path, path_name(name));
for vec::each(methods) |m| {
if m.tps.len() == 0u {
@@ -45,7 +45,7 @@ fn trans_self_arg(bcx: block, base: @ast::expr, derefs: uint) -> result {
// other arguments failing:
assert temp_cleanups == ~[];
ret result;
return result;
}
fn trans_method_callee(bcx: block, callee_id: ast::node_id,
@@ -285,7 +285,7 @@ fn make_impl_vtable(ccx: @crate_ctxt, impl_id: ast::def_id, substs: ~[ty::t],
fn trans_cast(bcx: block, val: @ast::expr, id: ast::node_id, dest: dest)
-> block {
let _icx = bcx.insn_ctxt(~"impl::trans_cast");
if dest == ignore { ret trans_expr(bcx, val, ignore); }
if dest == ignore { return trans_expr(bcx, val, ignore); }
let ccx = bcx.ccx();
let v_ty = expr_ty(bcx, val);
let {bcx: bcx, box: llbox, body: body} = malloc_boxed(bcx, v_ty);

View File

@@ -59,9 +59,9 @@ fn traverse_export(cx: ctx, exp_id: node_id) {
}
fn traverse_def_id(cx: ctx, did: def_id) {
if did.crate != local_crate { ret; }
if did.crate != local_crate { return; }
let n = alt cx.tcx.items.find(did.node) {
none { ret; } // This can happen for self, for example
none { return; } // This can happen for self, for example
some(n) { n }
};
alt n {
@@ -85,7 +85,7 @@ fn traverse_public_mod(cx: ctx, m: _mod) {
}
fn traverse_public_item(cx: ctx, item: @item) {
if cx.rmap.contains_key(item.id) { ret; }
if cx.rmap.contains_key(item.id) { return; }
cx.rmap.insert(item.id, ());
alt item.node {
item_mod(m) { traverse_public_mod(cx, m); }
@@ -151,7 +151,7 @@ fn mk_ty_visitor() -> visit::vt<ctx> {
}
fn traverse_ty(ty: @ty, cx: ctx, v: visit::vt<ctx>) {
if cx.rmap.contains_key(ty.id) { ret; }
if cx.rmap.contains_key(ty.id) { return; }
cx.rmap.insert(ty.id, ());
alt ty.node {

View File

@@ -37,7 +37,7 @@ impl methods for reflector {
let tr = type_of::type_of(self.bcx.ccx(), t);
let s = shape::llsize_of_real(self.bcx.ccx(), tr);
let a = shape::llalign_of_min(self.bcx.ccx(), tr);
ret ~[self.c_uint(s),
return ~[self.c_uint(s),
self.c_uint(a)];
}
@@ -306,5 +306,5 @@ fn emit_calls_to_trait_visit_ty(bcx: block, t: ty::t,
});
r.visit_ty(t);
Br(r.bcx, final.llbb);
ret final;
return final;
}

View File

@@ -43,7 +43,7 @@ fn hash_nominal_id(&&ri: nominal_id) -> uint {
h *= 33u;
h += ty::type_id(t);
}
ret h;
return h;
}
fn eq_nominal_id(&&mi: nominal_id, &&ni: nominal_id) -> bool {
@@ -57,7 +57,7 @@ fn eq_nominal_id(&&mi: nominal_id, &&ni: nominal_id) -> bool {
}
fn new_nominal_id_hash<T: copy>() -> hashmap<nominal_id, T> {
ret hashmap(hash_nominal_id, eq_nominal_id);
return hashmap(hash_nominal_id, eq_nominal_id);
}
type enum_data = {did: ast::def_id, substs: ty::substs};
@@ -113,7 +113,7 @@ fn mk_global(ccx: @crate_ctxt, name: ~str, llval: ValueRef, internal: bool) ->
lib::llvm::SetLinkage(llglobal, lib::llvm::InternalLinkage);
}
ret llglobal;
return llglobal;
}
@@ -124,7 +124,7 @@ fn mk_global(ccx: @crate_ctxt, name: ~str, llval: ValueRef, internal: bool) ->
fn round_up(size: u16, align: u8) -> u16 {
assert (align >= 1u8);
let alignment = align as u16;
ret size - 1u16 + alignment & !(alignment - 1u16);
return size - 1u16 + alignment & !(alignment - 1u16);
}
type size_align = {size: u16, align: u8};
@@ -149,7 +149,7 @@ fn enum_kind(ccx: @crate_ctxt, did: ast::def_id) -> enum_kind {
// Returns the code corresponding to the pointer size on this architecture.
fn s_int(tcx: ty_ctxt) -> u8 {
ret alt tcx.sess.targ_cfg.arch {
return alt tcx.sess.targ_cfg.arch {
session::arch_x86 { shape_i32 }
session::arch_x86_64 { shape_i64 }
session::arch_arm { shape_i32 }
@@ -157,7 +157,7 @@ fn s_int(tcx: ty_ctxt) -> u8 {
}
fn s_uint(tcx: ty_ctxt) -> u8 {
ret alt tcx.sess.targ_cfg.arch {
return alt tcx.sess.targ_cfg.arch {
session::arch_x86 { shape_u32 }
session::arch_x86_64 { shape_u64 }
session::arch_arm { shape_u32 }
@@ -165,7 +165,7 @@ fn s_uint(tcx: ty_ctxt) -> u8 {
}
fn s_float(tcx: ty_ctxt) -> u8 {
ret alt tcx.sess.targ_cfg.arch {
return alt tcx.sess.targ_cfg.arch {
session::arch_x86 { shape_f64 }
session::arch_x86_64 { shape_f64 }
session::arch_arm { shape_f64 }
@@ -173,15 +173,15 @@ fn s_float(tcx: ty_ctxt) -> u8 {
}
fn s_variant_enum_t(tcx: ty_ctxt) -> u8 {
ret s_int(tcx);
return s_int(tcx);
}
fn s_tydesc(_tcx: ty_ctxt) -> u8 {
ret shape_tydesc;
return shape_tydesc;
}
fn s_send_tydesc(_tcx: ty_ctxt) -> u8 {
ret shape_send_tydesc;
return shape_send_tydesc;
}
fn mk_ctxt(llmod: ModuleRef) -> ctxt {
@@ -190,7 +190,7 @@ fn mk_ctxt(llmod: ModuleRef) -> ctxt {
lib::llvm::llvm::LLVMAddGlobal(llmod, llshapetablesty, buf)
});
ret {mut next_tag_id: 0u16,
return {mut next_tag_id: 0u16,
pad: 0u16,
tag_id_to_index: new_nominal_id_hash(),
tag_order: dvec(),
@@ -367,7 +367,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] {
fn shape_of_variant(ccx: @crate_ctxt, v: ty::variant_info) -> ~[u8] {
let mut s = ~[];
for vec::each(v.args) |t| { s += shape_of(ccx, t); }
ret s;
return s;
}
fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
@@ -456,7 +456,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
header += data;
header += lv_table;
ret mk_global(ccx, ~"tag_shapes", C_bytes(header), true);
return mk_global(ccx, ~"tag_shapes", C_bytes(header), true);
/* tjc: Not annotating FIXMEs in this module because of #1498 */
fn largest_variants(ccx: @crate_ctxt,
@@ -530,7 +530,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
if candidates[i] { vec::push(result, i); }
i += 1u;
}
ret result;
return result;
}
fn compute_static_enum_size(ccx: @crate_ctxt, largest_variants: ~[uint],
@@ -563,7 +563,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
if max_align < align { max_align = align; }
}
ret {size: max_size, align: max_align};
return {size: max_size, align: max_align};
}
}
@@ -577,7 +577,7 @@ fn gen_resource_shapes(ccx: @crate_ctxt) -> ValueRef {
dtors += ~[trans::base::get_res_dtor(ccx, ri.did, id, ri.tps)];
}
}
ret mk_global(ccx, ~"resource_shapes", C_struct(dtors), true);
return mk_global(ccx, ~"resource_shapes", C_struct(dtors), true);
}
fn gen_shape_tables(ccx: @crate_ctxt) {
@@ -614,13 +614,13 @@ type tag_metrics = {
// Returns the number of bytes clobbered by a Store to this type.
fn llsize_of_store(cx: @crate_ctxt, t: TypeRef) -> uint {
ret llvm::LLVMStoreSizeOfType(cx.td.lltd, t) as uint;
return llvm::LLVMStoreSizeOfType(cx.td.lltd, t) as uint;
}
// Returns the number of bytes between successive elements of type T in an
// array of T. This is the "ABI" size. It includes any ABI-mandated padding.
fn llsize_of_alloc(cx: @crate_ctxt, t: TypeRef) -> uint {
ret llvm::LLVMABISizeOfType(cx.td.lltd, t) as uint;
return llvm::LLVMABISizeOfType(cx.td.lltd, t) as uint;
}
// Returns, as near as we can figure, the "real" size of a type. As in, the
@@ -644,7 +644,7 @@ fn llsize_of_real(cx: @crate_ctxt, t: TypeRef) -> uint {
// (i.e. including alignment-padding), but goodness knows which alignment it
// winds up using. Probably the ABI one? Not recommended.
fn llsize_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef {
ret llvm::LLVMConstIntCast(lib::llvm::llvm::LLVMSizeOf(t), cx.int_type,
return llvm::LLVMConstIntCast(lib::llvm::llvm::LLVMSizeOf(t), cx.int_type,
False);
}
@@ -653,22 +653,22 @@ fn llsize_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef {
// packing the type into structs. This will be used for things like
// allocations inside a stack frame, which LLVM has a free hand in.
fn llalign_of_pref(cx: @crate_ctxt, t: TypeRef) -> uint {
ret llvm::LLVMPreferredAlignmentOfType(cx.td.lltd, t) as uint;
return llvm::LLVMPreferredAlignmentOfType(cx.td.lltd, t) as uint;
}
// Returns the minimum alignment of a type required by the plattform.
// This is the alignment that will be used for struct fields, arrays,
// and similar ABI-mandated things.
fn llalign_of_min(cx: @crate_ctxt, t: TypeRef) -> uint {
ret llvm::LLVMABIAlignmentOfType(cx.td.lltd, t) as uint;
return llvm::LLVMABIAlignmentOfType(cx.td.lltd, t) as uint;
}
// Returns the "default" alignment of t, which is calculated by casting
// null to a record containing a single-bit followed by a t value, then
// doing gep(0,1) to get at the trailing (and presumably padded) t cell.
fn llalign_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef {
ret llvm::LLVMConstIntCast(lib::llvm::llvm::LLVMAlignOf(t), cx.int_type,
False);
return llvm::LLVMConstIntCast(
lib::llvm::llvm::LLVMAlignOf(t), cx.int_type, False);
}
// Computes the static size of a enum, without using mk_tup(), which is
@@ -678,7 +678,7 @@ fn llalign_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef {
// Computes the size of the data part of an enum.
fn static_size_of_enum(cx: @crate_ctxt, t: ty::t) -> uint {
if cx.enum_sizes.contains_key(t) { ret cx.enum_sizes.get(t); }
if cx.enum_sizes.contains_key(t) { return cx.enum_sizes.get(t); }
alt ty::get(t).struct {
ty::ty_enum(tid, substs) {
// Compute max(variant sizes).
@@ -695,7 +695,7 @@ fn static_size_of_enum(cx: @crate_ctxt, t: ty::t) -> uint {
if max_size < this_size { max_size = this_size; }
}
cx.enum_sizes.insert(t, max_size);
ret max_size;
return max_size;
}
_ { cx.sess.bug(~"static_size_of_enum called on non-enum"); }
}

View File

@@ -57,7 +57,7 @@ fn pointer_add(bcx: block, ptr: ValueRef, bytes: ValueRef) -> ValueRef {
let _icx = bcx.insn_ctxt(~"tvec::pointer_add");
let old_ty = val_ty(ptr);
let bptr = PointerCast(bcx, ptr, T_ptr(T_i8()));
ret PointerCast(bcx, InBoundsGEP(bcx, bptr, ~[bytes]), old_ty);
return PointerCast(bcx, InBoundsGEP(bcx, bptr, ~[bytes]), old_ty);
}
fn alloc_raw(bcx: block, unit_ty: ty::t,
@@ -72,7 +72,7 @@ fn alloc_raw(bcx: block, unit_ty: ty::t,
base::malloc_general_dyn(bcx, vecbodyty, heap, vecsize);
Store(bcx, fill, GEPi(bcx, body, ~[0u, abi::vec_elt_fill]));
Store(bcx, alloc, GEPi(bcx, body, ~[0u, abi::vec_elt_alloc]));
ret {bcx: bcx, val: box};
return {bcx: bcx, val: box};
}
fn alloc_uniq_raw(bcx: block, unit_ty: ty::t,
fill: ValueRef, alloc: ValueRef) -> result {
@@ -89,7 +89,7 @@ fn alloc_vec(bcx: block, unit_ty: ty::t, elts: uint, heap: heap) -> result {
let alloc = if elts < 4u { Mul(bcx, C_int(ccx, 4), unit_sz) }
else { fill };
let {bcx: bcx, val: vptr} = alloc_raw(bcx, unit_ty, fill, alloc, heap);
ret {bcx: bcx, val: vptr};
return {bcx: bcx, val: vptr};
}
fn duplicate_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> result {
@@ -106,7 +106,7 @@ fn duplicate_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> result {
let bcx = if ty::type_needs_drop(bcx.tcx(), unit_ty) {
iter_vec_raw(bcx, new_data_ptr, vec_ty, fill, base::take_ty)
} else { bcx };
ret rslt(bcx, newptr);
return rslt(bcx, newptr);
}
fn make_drop_glue_unboxed(bcx: block, vptr: ValueRef, vec_ty: ty::t) ->
@@ -127,7 +127,7 @@ fn trans_evec(bcx: block, args: ~[@ast::expr],
for vec::each(args) |arg| {
bcx = base::trans_expr(bcx, arg, base::ignore);
}
ret bcx;
return bcx;
}
let vec_ty = node_id_type(bcx, id);
@@ -205,13 +205,13 @@ fn trans_evec(bcx: block, args: ~[@ast::expr],
alt vst {
ast::vstore_fixed(_) {
// We wrote into the destination in the fixed case.
ret bcx;
return bcx;
}
ast::vstore_slice(_) {
ret base::store_in_dest(bcx, Load(bcx, val), dest);
return base::store_in_dest(bcx, Load(bcx, val), dest);
}
_ {
ret base::store_in_dest(bcx, val, dest);
return base::store_in_dest(bcx, val, dest);
}
}
}
@@ -220,10 +220,10 @@ fn trans_vstore(bcx: block, e: @ast::expr,
v: ast::vstore, dest: dest) -> block {
alt e.node {
ast::expr_lit(@{node: ast::lit_str(s), span: _}) {
ret trans_estr(bcx, s, v, dest);
return trans_estr(bcx, s, v, dest);
}
ast::expr_vec(es, mutbl) {
ret trans_evec(bcx, es, v, e.id, dest);
return trans_evec(bcx, es, v, e.id, dest);
}
_ {
bcx.sess().span_bug(e.span, ~"vstore on non-sequence type");
@@ -269,7 +269,7 @@ fn get_base_and_len(cx: block, v: ValueRef, e_ty: ty::t)
fn trans_estr(bcx: block, s: @~str, vstore: ast::vstore,
dest: dest) -> block {
let _icx = bcx.insn_ctxt(~"tvec::trans_estr");
if dest == base::ignore { ret bcx; }
if dest == base::ignore { return bcx; }
let ccx = bcx.ccx();
let c = alt vstore {
@@ -338,7 +338,7 @@ fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t,
~[C_int(bcx.ccx(), 1)]),
body_cx.llbb);
Br(body_cx, header_cx.llbb);
ret next_cx;
return next_cx;
}
@@ -354,7 +354,7 @@ fn iter_vec_unboxed(bcx: block, body_ptr: ValueRef, vec_ty: ty::t,
let _icx = bcx.insn_ctxt(~"tvec::iter_vec_unboxed");
let fill = get_fill(bcx, body_ptr);
let dataptr = get_dataptr(bcx, body_ptr);
ret iter_vec_raw(bcx, dataptr, vec_ty, fill, f);
return iter_vec_raw(bcx, dataptr, vec_ty, fill, f);
}
//

View File

@@ -36,7 +36,7 @@ fn type_of_fn(cx: @crate_ctxt, inputs: ~[ty::arg],
// ... then explicit args.
vec::push_all(atys, type_of_explicit_args(cx, inputs));
ret T_fn(atys, llvm::LLVMVoidType());
return T_fn(atys, llvm::LLVMVoidType());
}
// Given a function type and a count of ty params, construct an llvm type
@@ -69,7 +69,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
debug!{"type_of %?: %?", t, ty::get(t)};
// Check the cache.
if cx.lltypes.contains_key(t) { ret cx.lltypes.get(t); }
if cx.lltypes.contains_key(t) { return cx.lltypes.get(t); }
// Replace any typedef'd types with their equivalent non-typedef
// type. This ensures that all LLVM nominal types that contain
@@ -188,7 +188,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
}
};
ret llty;
return llty;
}
// This should only be called from type_of, above, because it
@@ -221,7 +221,7 @@ fn type_of_enum(cx: @crate_ctxt, did: ast::def_id, t: ty::t)
};
common::set_struct_body(named_llty, lltys);
ret named_llty;
return named_llty;
}
fn llvm_type_name(cx: @crate_ctxt, t: ty::t) -> ~str {
@@ -233,7 +233,7 @@ fn llvm_type_name(cx: @crate_ctxt, t: ty::t) -> ~str {
(~"class", did, substs.tps)
}
};
ret fmt!{
return fmt!{
"%s %s[#%d]",
name,
util::ppaux::parameterized(

View File

@@ -36,7 +36,7 @@ type ctx = {ccx: @crate_ctxt,
fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
-> ~[type_uses] {
alt ccx.type_use_cache.find(fn_id) {
some(uses) { ret uses; }
some(uses) { return uses; }
none {}
}
let fn_id_loc = if fn_id.crate == local_crate { fn_id }
@@ -57,7 +57,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
if fn_id_loc.crate != local_crate {
let uses = vec::from_mut(copy cx.uses);
ccx.type_use_cache.insert(fn_id, uses);
ret uses;
return uses;
}
let map_node = alt ccx.tcx.items.find(fn_id_loc.node) {
some(x) { x }

View File

@@ -28,7 +28,7 @@ fn content_ty(t: ty::t) -> ty::t {
fn autoderef(bcx: block, v: ValueRef, t: ty::t) -> {v: ValueRef, t: ty::t} {
let content_ty = content_ty(t);
let v = opaque_box_body(bcx, content_ty, v);
ret {v: v, t: content_ty};
return {v: v, t: content_ty};
}
fn duplicate(bcx: block, v: ValueRef, t: ty::t) -> result {
@@ -52,5 +52,5 @@ fn duplicate(bcx: block, v: ValueRef, t: ty::t) -> result {
let td = Load(bcx, src_tydesc_ptr);
Store(bcx, td, dst_tydesc_ptr);
ret rslt(bcx, dst_box);
return rslt(bcx, dst_box);
}

View File

@@ -41,14 +41,18 @@ type pre_and_post_state = {prestate: prestate, poststate: poststate};
type ts_ann = {conditions: pre_and_post, states: pre_and_post_state};
fn true_precond(num_vars: uint) -> precond { ret create_tritv(num_vars); }
fn true_precond(num_vars: uint) -> precond { return create_tritv(num_vars); }
fn true_postcond(num_vars: uint) -> postcond { ret true_precond(num_vars); }
fn true_postcond(num_vars: uint) -> postcond {
return true_precond(num_vars);
}
fn empty_prestate(num_vars: uint) -> prestate { ret true_precond(num_vars); }
fn empty_prestate(num_vars: uint) -> prestate {
return true_precond(num_vars);
}
fn empty_poststate(num_vars: uint) -> poststate {
ret true_precond(num_vars);
return true_precond(num_vars);
}
fn false_postcond(num_vars: uint) -> postcond {
@@ -58,23 +62,23 @@ fn false_postcond(num_vars: uint) -> postcond {
}
fn empty_pre_post(num_vars: uint) -> pre_and_post {
ret {precondition: empty_prestate(num_vars),
return {precondition: empty_prestate(num_vars),
postcondition: empty_poststate(num_vars)};
}
fn empty_states(num_vars: uint) -> pre_and_post_state {
ret {prestate: true_precond(num_vars),
return {prestate: true_precond(num_vars),
poststate: true_postcond(num_vars)};
}
fn empty_ann(num_vars: uint) -> ts_ann {
ret {conditions: empty_pre_post(num_vars),
return {conditions: empty_pre_post(num_vars),
states: empty_states(num_vars)};
}
fn get_pre(&&p: pre_and_post) -> precond { ret p.precondition; }
fn get_pre(&&p: pre_and_post) -> precond { return p.precondition; }
fn get_post(&&p: pre_and_post) -> postcond { ret p.postcondition; }
fn get_post(&&p: pre_and_post) -> postcond { return p.postcondition; }
fn difference(p1: precond, p2: precond) -> bool { p1.difference(p2) }
@@ -86,7 +90,7 @@ fn pps_len(p: pre_and_post) -> uint {
// gratuitous check
assert (p.precondition.nbits == p.postcondition.nbits);
ret p.precondition.nbits;
return p.precondition.nbits;
}
fn require(i: uint, p: pre_and_post) {
@@ -102,54 +106,54 @@ fn require_and_preserve(i: uint, p: pre_and_post) {
fn set_in_postcond(i: uint, p: pre_and_post) -> bool {
// sets the ith bit in p's post
ret set_in_postcond_(i, p.postcondition);
return set_in_postcond_(i, p.postcondition);
}
fn set_in_postcond_(i: uint, p: postcond) -> bool {
let was_set = p.get(i);
p.set(i, ttrue);
ret was_set != ttrue;
return was_set != ttrue;
}
fn set_in_poststate(i: uint, s: pre_and_post_state) -> bool {
// sets the ith bit in p's post
ret set_in_poststate_(i, s.poststate);
return set_in_poststate_(i, s.poststate);
}
fn set_in_poststate_(i: uint, p: poststate) -> bool {
let was_set = p.get(i);
p.set(i, ttrue);
ret was_set != ttrue;
return was_set != ttrue;
}
fn clear_in_poststate(i: uint, s: pre_and_post_state) -> bool {
// sets the ith bit in p's post
ret clear_in_poststate_(i, s.poststate);
return clear_in_poststate_(i, s.poststate);
}
fn clear_in_poststate_(i: uint, s: poststate) -> bool {
let was_set = s.get(i);
s.set(i, tfalse);
ret was_set != tfalse;
return was_set != tfalse;
}
fn clear_in_prestate(i: uint, s: pre_and_post_state) -> bool {
// sets the ith bit in p's pre
ret clear_in_prestate_(i, s.prestate);
return clear_in_prestate_(i, s.prestate);
}
fn clear_in_prestate_(i: uint, s: prestate) -> bool {
let was_set = s.get(i);
s.set(i, tfalse);
ret was_set != tfalse;
return was_set != tfalse;
}
fn clear_in_postcond(i: uint, s: pre_and_post) -> bool {
// sets the ith bit in p's post
let was_set = s.postcondition.get(i);
s.postcondition.set(i, tfalse);
ret was_set != tfalse;
return was_set != tfalse;
}
// Sets all the bits in a's precondition to equal the
@@ -195,12 +199,12 @@ fn extend_poststate(p: poststate, newv: poststate) -> bool {
fn relax_prestate(i: uint, p: prestate) -> bool {
let was_set = p.get(i);
p.set(i, dont_care);
ret was_set != dont_care;
return was_set != dont_care;
}
// Clears the given bit in p
fn relax_poststate(i: uint, p: poststate) -> bool {
ret relax_prestate(i, p);
return relax_prestate(i, p);
}
// Clears the given bit in p
@@ -212,14 +216,14 @@ fn clear(p: precond) { p.clear(); }
// Sets all the bits in p to true
fn set(p: precond) { p.set_all(); }
fn ann_precond(a: ts_ann) -> precond { ret a.conditions.precondition; }
fn ann_precond(a: ts_ann) -> precond { return a.conditions.precondition; }
fn ann_prestate(a: ts_ann) -> prestate { ret a.states.prestate; }
fn ann_prestate(a: ts_ann) -> prestate { return a.states.prestate; }
fn ann_poststate(a: ts_ann) -> poststate { ret a.states.poststate; }
fn ann_poststate(a: ts_ann) -> poststate { return a.states.poststate; }
fn pp_clone(p: pre_and_post) -> pre_and_post {
ret {precondition: clone(p.precondition),
return {precondition: clone(p.precondition),
postcondition: clone(p.postcondition)};
}

View File

@@ -31,7 +31,7 @@ enum oper_type {
/* logging funs */
fn def_id_to_str(d: def_id) -> ~str {
ret int::str(d.crate) + ~"," + int::str(d.node);
return int::str(d.crate) + ~"," + int::str(d.node);
}
fn comma_str(args: ~[@constr_arg_use]) -> ~str {
@@ -45,11 +45,11 @@ fn comma_str(args: ~[@constr_arg_use]) -> ~str {
carg_lit(l) { rslt += lit_to_str(l); }
}
}
ret rslt;
return rslt;
}
fn constraint_to_str(tcx: ty::ctxt, c: sp_constr) -> ~str {
ret fmt!{"%s(%s) - arising from %s",
return fmt!{"%s(%s) - arising from %s",
path_to_str(c.node.path),
comma_str(c.node.args),
codemap::span_to_str(c.span, tcx.sess.codemap)};
@@ -69,7 +69,7 @@ fn tritv_to_str(fcx: fn_ctxt, v: tritv::t) -> ~str {
}
}
}
ret s;
return s;
}
fn log_tritv(fcx: fn_ctxt, v: tritv::t) {
@@ -86,7 +86,7 @@ fn first_difference_string(fcx: fn_ctxt, expected: tritv::t, actual: tritv::t)
break;
}
}
ret s;
return s;
}
fn log_tritv_err(fcx: fn_ctxt, v: tritv::t) {
@@ -100,7 +100,7 @@ fn tos(v: ~[uint]) -> ~str {
rslt += ~"0";
} else if i == 1u { rslt += ~"1"; } else { rslt += ~"?"; }
}
ret rslt;
return rslt;
}
fn log_cond(v: ~[uint]) { log(debug, tos(v)); }
@@ -146,7 +146,7 @@ fn log_states_err(pp: pre_and_post_state) {
fn print_ident(i: ident) { log(debug, ~" " + *i + ~" "); }
fn print_idents(&idents: ~[ident]) {
if vec::len::<ident>(idents) == 0u { ret; }
if vec::len::<ident>(idents) == 0u { return; }
log(debug, ~"an ident: " + *vec::pop::<ident>(idents));
print_idents(idents);
}
@@ -241,7 +241,7 @@ type crate_ctxt = {tcx: ty::ctxt, node_anns: node_ann_table, fm: fn_info_map};
fn get_fn_info(ccx: crate_ctxt, id: node_id) -> fn_info {
assert (ccx.fm.contains_key(id));
ret ccx.fm.get(id);
return ccx.fm.get(id);
}
fn add_node(ccx: crate_ctxt, i: node_id, a: ts_ann) {
@@ -254,8 +254,8 @@ fn add_node(ccx: crate_ctxt, i: node_id, a: ts_ann) {
fn get_ts_ann(ccx: crate_ctxt, i: node_id) -> option<ts_ann> {
if i as uint < vec::len(*ccx.node_anns) {
ret some::<ts_ann>(ccx.node_anns[i]);
} else { ret none::<ts_ann>; }
return some::<ts_ann>(ccx.node_anns[i]);
} else { return none::<ts_ann>; }
}
@@ -266,20 +266,20 @@ fn node_id_to_ts_ann(ccx: crate_ctxt, id: node_id) -> ts_ann {
error!{"node_id_to_ts_ann: no ts_ann for node_id %d", id};
fail;
}
some(tt) { ret tt; }
some(tt) { return tt; }
}
}
fn node_id_to_poststate(ccx: crate_ctxt, id: node_id) -> poststate {
debug!{"node_id_to_poststate"};
ret node_id_to_ts_ann(ccx, id).states.poststate;
return node_id_to_ts_ann(ccx, id).states.poststate;
}
fn stmt_to_ann(ccx: crate_ctxt, s: stmt) -> ts_ann {
debug!{"stmt_to_ann"};
alt s.node {
stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) {
ret node_id_to_ts_ann(ccx, id);
return node_id_to_ts_ann(ccx, id);
}
}
}
@@ -288,25 +288,25 @@ fn stmt_to_ann(ccx: crate_ctxt, s: stmt) -> ts_ann {
/* fails if e has no annotation */
fn expr_states(ccx: crate_ctxt, e: @expr) -> pre_and_post_state {
debug!{"expr_states"};
ret node_id_to_ts_ann(ccx, e.id).states;
return node_id_to_ts_ann(ccx, e.id).states;
}
/* fails if e has no annotation */
fn expr_pp(ccx: crate_ctxt, e: @expr) -> pre_and_post {
debug!{"expr_pp"};
ret node_id_to_ts_ann(ccx, e.id).conditions;
return node_id_to_ts_ann(ccx, e.id).conditions;
}
fn stmt_pp(ccx: crate_ctxt, s: stmt) -> pre_and_post {
ret stmt_to_ann(ccx, s).conditions;
return stmt_to_ann(ccx, s).conditions;
}
/* fails if b has no annotation */
fn block_pp(ccx: crate_ctxt, b: blk) -> pre_and_post {
debug!{"block_pp"};
ret node_id_to_ts_ann(ccx, b.node.id).conditions;
return node_id_to_ts_ann(ccx, b.node.id).conditions;
}
fn clear_pp(pp: pre_and_post) {
@@ -321,84 +321,85 @@ fn clear_precond(ccx: crate_ctxt, id: node_id) {
fn block_states(ccx: crate_ctxt, b: blk) -> pre_and_post_state {
debug!{"block_states"};
ret node_id_to_ts_ann(ccx, b.node.id).states;
return node_id_to_ts_ann(ccx, b.node.id).states;
}
fn stmt_states(ccx: crate_ctxt, s: stmt) -> pre_and_post_state {
ret stmt_to_ann(ccx, s).states;
return stmt_to_ann(ccx, s).states;
}
fn expr_precond(ccx: crate_ctxt, e: @expr) -> precond {
ret expr_pp(ccx, e).precondition;
return expr_pp(ccx, e).precondition;
}
fn expr_postcond(ccx: crate_ctxt, e: @expr) -> postcond {
ret expr_pp(ccx, e).postcondition;
return expr_pp(ccx, e).postcondition;
}
fn expr_prestate(ccx: crate_ctxt, e: @expr) -> prestate {
ret expr_states(ccx, e).prestate;
return expr_states(ccx, e).prestate;
}
fn expr_poststate(ccx: crate_ctxt, e: @expr) -> poststate {
ret expr_states(ccx, e).poststate;
return expr_states(ccx, e).poststate;
}
fn stmt_precond(ccx: crate_ctxt, s: stmt) -> precond {
ret stmt_pp(ccx, s).precondition;
return stmt_pp(ccx, s).precondition;
}
fn stmt_postcond(ccx: crate_ctxt, s: stmt) -> postcond {
ret stmt_pp(ccx, s).postcondition;
return stmt_pp(ccx, s).postcondition;
}
fn states_to_poststate(ss: pre_and_post_state) -> poststate {
ret ss.poststate;
return ss.poststate;
}
fn stmt_prestate(ccx: crate_ctxt, s: stmt) -> prestate {
ret stmt_states(ccx, s).prestate;
return stmt_states(ccx, s).prestate;
}
fn stmt_poststate(ccx: crate_ctxt, s: stmt) -> poststate {
ret stmt_states(ccx, s).poststate;
return stmt_states(ccx, s).poststate;
}
fn block_precond(ccx: crate_ctxt, b: blk) -> precond {
ret block_pp(ccx, b).precondition;
return block_pp(ccx, b).precondition;
}
fn block_postcond(ccx: crate_ctxt, b: blk) -> postcond {
ret block_pp(ccx, b).postcondition;
return block_pp(ccx, b).postcondition;
}
fn block_prestate(ccx: crate_ctxt, b: blk) -> prestate {
ret block_states(ccx, b).prestate;
return block_states(ccx, b).prestate;
}
fn block_poststate(ccx: crate_ctxt, b: blk) -> poststate {
ret block_states(ccx, b).poststate;
return block_states(ccx, b).poststate;
}
fn set_prestate_ann(ccx: crate_ctxt, id: node_id, pre: prestate) -> bool {
debug!{"set_prestate_ann"};
ret set_prestate(node_id_to_ts_ann(ccx, id), pre);
return set_prestate(node_id_to_ts_ann(ccx, id), pre);
}
fn extend_prestate_ann(ccx: crate_ctxt, id: node_id, pre: prestate) -> bool {
debug!{"extend_prestate_ann"};
ret extend_prestate(node_id_to_ts_ann(ccx, id).states.prestate, pre);
return extend_prestate(node_id_to_ts_ann(ccx, id).states.prestate, pre);
}
fn set_poststate_ann(ccx: crate_ctxt, id: node_id, post: poststate) -> bool {
debug!{"set_poststate_ann"};
ret set_poststate(node_id_to_ts_ann(ccx, id), post);
return set_poststate(node_id_to_ts_ann(ccx, id), post);
}
fn extend_poststate_ann(ccx: crate_ctxt, id: node_id, post: poststate) ->
bool {
debug!{"extend_poststate_ann"};
ret extend_poststate(node_id_to_ts_ann(ccx, id).states.poststate, post);
return extend_poststate(
node_id_to_ts_ann(ccx, id).states.poststate, post);
}
fn set_pre_and_post(ccx: crate_ctxt, id: node_id, pre: precond,
@@ -430,14 +431,14 @@ fn set_postcond_false(ccx: crate_ctxt, id: node_id) {
}
fn pure_exp(ccx: crate_ctxt, id: node_id, p: prestate) -> bool {
ret set_prestate_ann(ccx, id, p) | set_poststate_ann(ccx, id, p);
return set_prestate_ann(ccx, id, p) | set_poststate_ann(ccx, id, p);
}
fn num_constraints(m: fn_info) -> uint { ret m.num_constraints; }
fn num_constraints(m: fn_info) -> uint { return m.num_constraints; }
fn new_crate_ctxt(cx: ty::ctxt) -> crate_ctxt {
let na: ~[mut ts_ann] = ~[mut];
ret {tcx: cx, node_anns: @mut na, fm: int_hash::<fn_info>()};
return {tcx: cx, node_anns: @mut na, fm: int_hash::<fn_info>()};
}
/* Use e's type to determine whether it returns.
@@ -445,15 +446,15 @@ fn new_crate_ctxt(cx: ty::ctxt) -> crate_ctxt {
the answer is noreturn. */
fn controlflow_expr(ccx: crate_ctxt, e: @expr) -> ret_style {
alt ty::get(ty::node_id_to_type(ccx.tcx, e.id)).struct {
ty::ty_fn(f) { ret f.ret_style; }
_ { ret return_val; }
ty::ty_fn(f) { return f.ret_style; }
_ { return return_val; }
}
}
fn constraints_expr(cx: ty::ctxt, e: @expr) -> ~[@ty::constr] {
alt ty::get(ty::node_id_to_type(cx, e.id)).struct {
ty::ty_fn(f) { ret f.constraints; }
_ { ret ~[]; }
ty::ty_fn(f) { return f.constraints; }
_ { return ~[]; }
}
}
@@ -463,12 +464,12 @@ fn node_id_to_def_strict(cx: ty::ctxt, id: node_id) -> def {
error!{"node_id_to_def: node_id %d has no def", id};
fail;
}
some(d) { ret d; }
some(d) { return d; }
}
}
fn node_id_to_def(ccx: crate_ctxt, id: node_id) -> option<def> {
ret ccx.tcx.def_map.find(id);
return ccx.tcx.def_map.find(id);
}
fn norm_a_constraint(id: def_id, c: constraint) -> ~[norm_constraint] {
@@ -480,7 +481,7 @@ fn norm_a_constraint(id: def_id, c: constraint) -> ~[norm_constraint] {
def_id: id,
args: pd.node.args})});
}
ret rslt;
return rslt;
}
@@ -491,7 +492,7 @@ fn constraints(fcx: fn_ctxt) -> ~[norm_constraint] {
for fcx.enclosing.constrs.each |key, val| {
vec::push_all(rslt, norm_a_constraint(key, val));
};
ret rslt;
return rslt;
}
// FIXME (#2539): Would rather take an immutable vec as an argument,
@@ -499,12 +500,12 @@ fn constraints(fcx: fn_ctxt) -> ~[norm_constraint] {
fn match_args(fcx: fn_ctxt, occs: @dvec<pred_args>,
occ: ~[@constr_arg_use]) -> uint {
debug!{"match_args: looking at %s",
constr_args_to_str(fn@(i: inst) -> ~str { ret *i.ident; }, occ)};
constr_args_to_str(fn@(i: inst) -> ~str { *i.ident }, occ)};
for (*occs).each |pd| {
log(debug,
~"match_args: candidate " + pred_args_to_str(pd));
fn eq(p: inst, q: inst) -> bool { ret p.node == q.node; }
if ty::args_eq(eq, pd.node.args, occ) { ret pd.node.bit_num; }
fn eq(p: inst, q: inst) -> bool { return p.node == q.node; }
if ty::args_eq(eq, pd.node.args, occ) { return pd.node.bit_num; }
}
fcx.ccx.tcx.sess.bug(~"match_args: no match for occurring args");
}
@@ -514,7 +515,7 @@ fn def_id_for_constr(tcx: ty::ctxt, t: node_id) -> def_id {
none {
tcx.sess.bug(~"node_id_for_constr: bad node_id " + int::str(t));
}
some(def_fn(i, _)) { ret i; }
some(def_fn(i, _)) { return i; }
_ { tcx.sess.bug(~"node_id_for_constr: pred is not a function"); }
}
}
@@ -525,7 +526,7 @@ fn expr_to_constr_arg(tcx: ty::ctxt, e: @expr) -> @constr_arg_use {
alt tcx.def_map.find(e.id) {
some(def_local(nid, _)) | some(def_arg(nid, _)) |
some(def_binding(nid)) | some(def_upvar(nid, _, _)) {
ret @respan(p.span,
return @respan(p.span,
carg_ident({ident: p.idents[0], node: nid}));
}
some(what) {
@@ -540,7 +541,7 @@ fn expr_to_constr_arg(tcx: ty::ctxt, e: @expr) -> @constr_arg_use {
}
}
}
expr_lit(l) { ret @respan(e.span, carg_lit(l)); }
expr_lit(l) { return @respan(e.span, carg_lit(l)); }
_ {
tcx.sess.span_fatal(e.span,
~"arguments to constrained functions must be " +
@@ -562,7 +563,7 @@ fn expr_to_constr(tcx: ty::ctxt, e: @expr) -> sp_constr {
expr_call(operator, args, _) {
alt operator.node {
expr_path(p) {
ret respan(e.span,
return respan(e.span,
{path: p,
def_id: def_id_for_constr(tcx, operator.id),
args: exprs_to_constr_args(tcx, args)});
@@ -581,7 +582,7 @@ fn expr_to_constr(tcx: ty::ctxt, e: @expr) -> sp_constr {
fn pred_args_to_str(p: pred_args) -> ~str {
~"<" + uint::str(p.node.bit_num) + ~", " +
constr_args_to_str(fn@(i: inst) -> ~str {ret *i.ident; },
constr_args_to_str(fn@(i: inst) -> ~str {return *i.ident; },
p.node.args)
+ ~">"
}
@@ -592,7 +593,7 @@ fn substitute_constr_args(cx: ty::ctxt, actuals: ~[@expr], c: @ty::constr) ->
for c.node.args.each |a| {
vec::push(rslt, substitute_arg(cx, actuals, a));
}
ret {path: c.node.path,
return {path: c.node.path,
def_id: c.node.id,
args: rslt};
}
@@ -603,13 +604,13 @@ fn substitute_arg(cx: ty::ctxt, actuals: ~[@expr], a: @constr_arg) ->
alt a.node {
carg_ident(i) {
if i < num_actuals {
ret expr_to_constr_arg(cx, actuals[i]);
return expr_to_constr_arg(cx, actuals[i]);
} else {
cx.sess.span_fatal(a.span, ~"constraint argument out of bounds");
}
}
carg_base { ret @respan(a.span, carg_base); }
carg_lit(l) { ret @respan(a.span, carg_lit(l)); }
carg_base { return @respan(a.span, carg_base); }
carg_lit(l) { return @respan(a.span, carg_lit(l)); }
}
}
@@ -622,30 +623,30 @@ fn pred_args_matches(pattern: ~[constr_arg_general_<inst>],
alt c.node {
carg_ident(p) {
alt n {
carg_ident(q) { if p.node != q.node { ret false; } }
_ { ret false; }
carg_ident(q) { if p.node != q.node { return false; } }
_ { return false; }
}
}
carg_base { if n != carg_base { ret false; } }
carg_base { if n != carg_base { return false; } }
carg_lit(l) {
alt n {
carg_lit(m) { if !const_eval::lit_eq(l, m) { ret false; } }
_ { ret false; }
carg_lit(m) { if !const_eval::lit_eq(l, m) { return false; } }
_ { return false; }
}
}
}
i += 1u;
}
ret true;
return true;
}
fn find_instance_(pattern: ~[constr_arg_general_<inst>],
descs: ~[pred_args]) ->
option<uint> {
for descs.each |d| {
if pred_args_matches(pattern, d) { ret some(d.node.bit_num); }
if pred_args_matches(pattern, d) { return some(d.node.bit_num); }
}
ret none;
return none;
}
type inst = {ident: ident, node: node_id};
@@ -660,7 +661,7 @@ type subst = ~[{from: inst, to: inst}];
fn find_instances(_fcx: fn_ctxt, subst: subst,
c: constraint) -> ~[{from: uint, to: uint}] {
if vec::len(subst) == 0u { ret ~[]; }
if vec::len(subst) == 0u { return ~[]; }
let mut res = ~[];
do (*c.descs).swap |v| {
let v <- vec::from_mut(v);
@@ -676,14 +677,14 @@ fn find_instances(_fcx: fn_ctxt, subst: subst,
}
vec::to_mut(v)
}
ret res;
return res;
}
fn find_in_subst(id: node_id, s: subst) -> option<inst> {
for s.each |p| {
if id == p.from.node { ret some(p.to); }
if id == p.from.node { return some(p.to); }
}
ret none;
return none;
}
fn find_in_subst_bool(s: subst, id: node_id) -> bool {
@@ -721,7 +722,7 @@ fn replace(subst: subst, d: pred_args) -> ~[constr_arg_general_<inst>] {
}
}
ret rslt;
return rslt;
}
enum if_ty { if_check, plain_if, }
@@ -738,7 +739,7 @@ fn local_node_id_to_def_id_strict(fcx: fn_ctxt, sp: span, i: node_id) ->
alt local_node_id_to_def(fcx, i) {
some(def_local(nid, _)) | some(def_arg(nid, _)) |
some(def_upvar(nid, _, _)) {
ret local_def(nid);
return local_def(nid);
}
some(_) {
fcx.ccx.tcx.sess.span_fatal(sp,
@@ -800,7 +801,7 @@ fn copy_in_poststate_two(fcx: fn_ctxt, src_post: poststate,
alt ty {
oper_swap { subst = ~[{from: dest, to: src}, {from: src, to: dest}]; }
oper_assign_op {
ret; // Don't do any propagation
return; // Don't do any propagation
}
_ { subst = ~[{from: src, to: dest}]; }
}
@@ -844,17 +845,17 @@ fn forget_in_poststate(fcx: fn_ctxt, p: poststate, dead_v: node_id) -> bool {
changed |= clear_in_poststate_(c.bit_num, p);
}
}
ret changed;
return changed;
}
fn any_eq(v: ~[node_id], d: node_id) -> bool {
for v.each |i| { if i == d { ret true; } }
for v.each |i| { if i == d { return true; } }
false
}
fn constraint_mentions(_fcx: fn_ctxt, c: norm_constraint, v: node_id) ->
bool {
ret args_mention(c.c.node.args, any_eq, ~[v]);
return args_mention(c.c.node.args, any_eq, ~[v]);
}
fn args_mention<T>(args: ~[@constr_arg_use],
@@ -862,9 +863,11 @@ fn args_mention<T>(args: ~[@constr_arg_use],
s: ~[T]) -> bool {
for args.each |a| {
alt a.node { carg_ident(p1) { if q(s, p1.node) { ret true; } } _ { } }
alt a.node {
carg_ident(p1) { if q(s, p1.node) { return true; } } _ { }
}
}
ret false;
return false;
}
fn use_var(fcx: fn_ctxt, v: node_id) {
@@ -906,13 +909,13 @@ fn args_to_constr_args(tcx: ty::ctxt, args: ~[arg],
carg_lit(l) { carg_lit(l) }
}));
}
ret actuals;
return actuals;
}
fn ast_constr_to_ts_constr(tcx: ty::ctxt, args: ~[arg], c: @constr) ->
tsconstr {
let tconstr = ty::ast_constr_to_constr(tcx, c);
ret {path: tconstr.node.path,
return {path: tconstr.node.path,
def_id: tconstr.node.id,
args: args_to_constr_args(tcx, args, tconstr.node.args)};
}
@@ -920,7 +923,7 @@ fn ast_constr_to_ts_constr(tcx: ty::ctxt, args: ~[arg], c: @constr) ->
fn ast_constr_to_sp_constr(tcx: ty::ctxt, args: ~[arg], c: @constr) ->
sp_constr {
let tconstr = ast_constr_to_ts_constr(tcx, args, c);
ret respan(c.span, tconstr);
return respan(c.span, tconstr);
}
type binding = {lhs: ~[dest], rhs: option<initializer>};
@@ -936,7 +939,7 @@ fn local_to_bindings(tcx: ty::ctxt, loc: @local) -> binding {
fn locals_to_bindings(tcx: ty::ctxt, locals: ~[@local]) -> ~[binding] {
let mut rslt = ~[];
for locals.each |loc| { vec::push(rslt, local_to_bindings(tcx, loc)); }
ret rslt;
return rslt;
}
fn callee_modes(fcx: fn_ctxt, callee: node_id) -> ~[mode] {
@@ -946,7 +949,7 @@ fn callee_modes(fcx: fn_ctxt, callee: node_id) -> ~[mode] {
ty::ty_fn({inputs: args, _}) {
let mut modes = ~[];
for args.each |arg| { vec::push(modes, arg.mode); }
ret modes;
return modes;
}
_ {
// Shouldn't happen; callee should be ty_fn.
@@ -973,7 +976,7 @@ fn arg_bindings(ops: ~[init_op], es: ~[@expr]) -> ~[binding] {
{lhs: ~[call], rhs: some({op: op, expr: es[i]})});
i += 1u;
}
ret bindings;
return bindings;
}
//

View File

@@ -49,7 +49,7 @@ fn find_locals(tcx: ty::ctxt,
with *visitor};
visit::visit_fn(fk, f_decl, f_body, sp,
id, cx, visit::mk_vt(visitor));
ret cx;
return cx;
}
fn add_constraint(tcx: ty::ctxt, c: sp_constr, next: uint, tbl: constr_map) ->
@@ -68,7 +68,7 @@ fn add_constraint(tcx: ty::ctxt, c: sp_constr, next: uint, tbl: constr_map) ->
tbl.insert(d_id, {path:p, descs:rslt});
}
}
ret next + 1u;
return next + 1u;
}
fn contains_constrained_calls(tcx: ty::ctxt, body: blk) -> bool {
@@ -83,7 +83,7 @@ fn contains_constrained_calls(tcx: ty::ctxt, body: blk) -> bool {
let vtor = visit::default_visitor::<cx>();
let vtor = @{visit_expr: visit_expr with *vtor};
visit::visit_block(body, cx, visit::mk_vt(vtor));
ret cx.has;
return cx.has;
fn visit_expr(e: @expr, &&cx: cx, v: visit::vt<cx>) {
import syntax::print::pprust;

View File

@@ -48,7 +48,7 @@ fn find_pre_post_item(ccx: crate_ctxt, i: item) {
}
item_mod(m) { find_pre_post_mod(m); }
item_foreign_mod(nm) { find_pre_post_foreign_mod(nm); }
item_ty(*) | item_enum(*) | item_trait(*) { ret; }
item_ty(*) | item_enum(*) | item_trait(*) { return; }
item_class(*) {
fail ~"find_pre_post_item: shouldn't be called on item_class";
}
@@ -72,7 +72,7 @@ fn find_pre_post_exprs(fcx: fn_ctxt, args: ~[@expr], id: node_id) {
for args.each |e| { do_one(fcx, e); }
fn get_pp(ccx: crate_ctxt, &&e: @expr) -> pre_and_post {
ret expr_pp(ccx, e);
return expr_pp(ccx, e);
}
let pps = vec::map(args, |a| get_pp(fcx.ccx, a) );
@@ -396,7 +396,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
_ {}
}
find_pre_post_block(fcx, an_alt.body);
ret block_pp(fcx.ccx, an_alt.body);
return block_pp(fcx.ccx, an_alt.body);
}
let mut alt_pps = ~[];
for alts.each |a| { vec::push(alt_pps, do_an_alt(fcx, a)); }
@@ -404,7 +404,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
&&next: pre_and_post) -> pre_and_post {
union(pp.precondition, seq_preconds(fcx, ~[antec, next]));
intersect(pp.postcondition, next.postcondition);
ret pp;
return pp;
}
let antec_pp = pp_clone(expr_pp(fcx.ccx, ex));
let e_pp =

View File

@@ -84,7 +84,7 @@ fn seq_states(fcx: fn_ctxt, pres: prestate, bindings: ~[binding]) ->
}
}
}
ret {changed: changed, post: post};
return {changed: changed, post: post};
}
fn find_pre_post_state_sub(fcx: fn_ctxt, pres: prestate, e: @expr,
@@ -100,7 +100,7 @@ fn find_pre_post_state_sub(fcx: fn_ctxt, pres: prestate, e: @expr,
}
changed = set_poststate_ann(fcx.ccx, parent, post) || changed;
ret changed;
return changed;
}
fn find_pre_post_state_two(fcx: fn_ctxt, pres: prestate, lhs: @expr,
@@ -162,7 +162,7 @@ fn find_pre_post_state_two(fcx: fn_ctxt, pres: prestate, lhs: @expr,
_ { }
}
changed = set_poststate_ann(fcx.ccx, parent, post) || changed;
ret changed;
return changed;
}
fn find_pre_post_state_call(fcx: fn_ctxt, pres: prestate, a: @expr,
@@ -178,7 +178,7 @@ fn find_pre_post_state_call(fcx: fn_ctxt, pres: prestate, a: @expr,
%u exprs vs. %u ops",
vec::len(bs), vec::len(ops)});
}
ret find_pre_post_state_exprs(fcx, pres, id, ops,
return find_pre_post_state_exprs(fcx, pres, id, ops,
bs, cf) || changed;
}
@@ -195,7 +195,7 @@ fn find_pre_post_state_exprs(fcx: fn_ctxt, pres: prestate, id: node_id,
}
_ { changed |= set_poststate_ann(fcx.ccx, id, rs.post); }
}
ret changed;
return changed;
}
fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk,
@@ -261,7 +261,7 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk,
changed |= set_poststate_ann(fcx.ccx, id, poststate_res);
}
}
ret changed;
return changed;
}
fn find_pre_post_state_cap_clause(fcx: fn_ctxt, e_id: node_id,
@@ -276,7 +276,7 @@ fn find_pre_post_state_cap_clause(fcx: fn_ctxt, e_id: node_id,
forget_in_poststate(fcx, post, cap_item.id);
}
}
ret set_poststate_ann(ccx, e_id, post) || pres_changed;
return set_poststate_ann(ccx, e_id, post) || pres_changed;
}
fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
@@ -284,41 +284,41 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
alt e.node {
expr_new(p, _, v) {
ret find_pre_post_state_two(fcx, pres, p, v, e.id, oper_pure);
return find_pre_post_state_two(fcx, pres, p, v, e.id, oper_pure);
}
expr_vstore(ee, _) {
let mut changed = find_pre_post_state_expr(fcx, pres, ee);
set_prestate_ann(fcx.ccx, e.id, expr_prestate(fcx.ccx, ee));
set_poststate_ann(fcx.ccx, e.id, expr_poststate(fcx.ccx, ee));
ret changed;
return changed;
}
expr_vec(elts, _) {
ret find_pre_post_state_exprs(fcx, pres, e.id,
return find_pre_post_state_exprs(fcx, pres, e.id,
vec::from_elem(vec::len(elts),
init_assign), elts,
return_val);
}
expr_call(operator, operands, _) {
debug!{"hey it's a call: %s", expr_to_str(e)};
ret find_pre_post_state_call(fcx, pres, operator, e.id,
return find_pre_post_state_call(fcx, pres, operator, e.id,
callee_arg_init_ops(fcx, operator.id),
operands,
controlflow_expr(fcx.ccx, operator));
}
expr_path(_) { ret pure_exp(fcx.ccx, e.id, pres); }
expr_path(_) { return pure_exp(fcx.ccx, e.id, pres); }
expr_log(_, lvl, ex) {
ret find_pre_post_state_two(fcx, pres, lvl, ex, e.id, oper_pure);
return find_pre_post_state_two(fcx, pres, lvl, ex, e.id, oper_pure);
}
expr_mac(_) { fcx.ccx.tcx.sess.bug(~"unexpanded macro"); }
expr_lit(l) { ret pure_exp(fcx.ccx, e.id, pres); }
expr_lit(l) { return pure_exp(fcx.ccx, e.id, pres); }
expr_fn(_, _, _, cap_clause) {
ret find_pre_post_state_cap_clause(fcx, e.id, pres, cap_clause);
return find_pre_post_state_cap_clause(fcx, e.id, pres, cap_clause);
}
expr_fn_block(_, _, cap_clause) {
ret find_pre_post_state_cap_clause(fcx, e.id, pres, cap_clause);
return find_pre_post_state_cap_clause(fcx, e.id, pres, cap_clause);
}
expr_block(b) {
ret find_pre_post_state_block(fcx, pres, b) |
return find_pre_post_state_block(fcx, pres, b) |
set_prestate_ann(fcx.ccx, e.id, pres) |
set_poststate_ann(fcx.ccx, e.id, block_poststate(fcx.ccx, b));
}
@@ -337,30 +337,31 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
set_poststate_ann(fcx.ccx, e.id,
expr_poststate(fcx.ccx, base))
});
ret changed;
return changed;
}
expr_tup(elts) {
ret find_pre_post_state_exprs(fcx, pres, e.id,
return find_pre_post_state_exprs(fcx, pres, e.id,
vec::from_elem(vec::len(elts),
init_assign), elts,
return_val);
}
expr_move(lhs, rhs) {
ret find_pre_post_state_two(fcx, pres, lhs, rhs, e.id, oper_move);
return find_pre_post_state_two(fcx, pres, lhs, rhs, e.id, oper_move);
}
expr_assign(lhs, rhs) {
ret find_pre_post_state_two(fcx, pres, lhs, rhs, e.id, oper_assign);
return find_pre_post_state_two(
fcx, pres, lhs, rhs, e.id, oper_assign);
}
expr_swap(lhs, rhs) {
ret find_pre_post_state_two(fcx, pres, lhs, rhs, e.id, oper_swap);
return find_pre_post_state_two(fcx, pres, lhs, rhs, e.id, oper_swap);
// Could be more precise and actually swap the role of
// lhs and rhs in constraints
}
expr_ret(maybe_ret_val) {
let mut changed = set_prestate_ann(fcx.ccx, e.id, pres);
/* everything is true if execution continues after
a ret expression (since execution never continues locally
after a ret expression */
a return expression (since execution never continues locally
after a return expression */
let post = false_postcond(num_constrs);
set_poststate_ann(fcx.ccx, e.id, post);
@@ -371,10 +372,10 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
changed |= find_pre_post_state_expr(fcx, pres, ret_val);
}
}
ret changed;
return changed;
}
expr_if(antec, conseq, maybe_alt) {
ret join_then_else(fcx, antec, conseq, maybe_alt, e.id, plain_if,
return join_then_else(fcx, antec, conseq, maybe_alt, e.id, plain_if,
pres);
}
expr_binary(bop, l, r) {
@@ -382,15 +383,15 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
let mut changed = find_pre_post_state_expr(fcx, pres, l);
changed |=
find_pre_post_state_expr(fcx, expr_poststate(fcx.ccx, l), r);
ret changed | set_prestate_ann(fcx.ccx, e.id, pres) |
return changed | set_prestate_ann(fcx.ccx, e.id, pres) |
set_poststate_ann(fcx.ccx, e.id,
expr_poststate(fcx.ccx, l));
} else {
ret find_pre_post_state_two(fcx, pres, l, r, e.id, oper_pure);
return find_pre_post_state_two(fcx, pres, l, r, e.id, oper_pure);
}
}
expr_assign_op(op, lhs, rhs) {
ret find_pre_post_state_two(fcx, pres, lhs, rhs, e.id,
return find_pre_post_state_two(fcx, pres, lhs, rhs, e.id,
oper_assign_op);
}
expr_while(test, body) {
@@ -407,11 +408,11 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
or cont, we assume nothing about the poststate */
/* which is still unsound -- see ~[Break-unsound] */
if has_nonlocal_exits(body) {
ret changed | set_poststate_ann(fcx.ccx, e.id, pres);
return changed | set_poststate_ann(fcx.ccx, e.id, pres);
} else {
let e_post = expr_poststate(fcx.ccx, test);
let b_post = block_poststate(fcx.ccx, body);
ret changed |
return changed |
set_poststate_ann(fcx.ccx, e.id,
intersect_states(e_post, b_post));
}
@@ -433,14 +434,14 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
deinitialize everything before breaking */
let post = empty_poststate(num_constrs);
post.kill();
ret changed | set_poststate_ann(fcx.ccx, e.id, post);
return changed | set_poststate_ann(fcx.ccx, e.id, post);
} else {
ret changed | set_poststate_ann(fcx.ccx, e.id,
return changed | set_poststate_ann(fcx.ccx, e.id,
false_postcond(num_constrs));
}
}
expr_index(val, sub) {
ret find_pre_post_state_two(fcx, pres, val, sub, e.id, oper_pure);
return find_pre_post_state_two(fcx, pres, val, sub, e.id, oper_pure);
}
expr_alt(val, alts, _) {
let mut changed =
@@ -470,19 +471,19 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
a_post = e_post;
}
ret changed | set_poststate_ann(fcx.ccx, e.id, a_post);
return changed | set_poststate_ann(fcx.ccx, e.id, a_post);
}
expr_field(x, _, _) | expr_loop_body(x) | expr_do_body(x) |
expr_unary(_, x) |
expr_addr_of(_, x) | expr_assert(x) | expr_cast(x, _) |
expr_copy(x) {
ret find_pre_post_state_sub(fcx, pres, x, e.id, none);
return find_pre_post_state_sub(fcx, pres, x, e.id, none);
}
expr_fail(maybe_fail_val) {
/* if execution continues after fail, then everything is true!
woo! */
let post = false_postcond(num_constrs);
ret set_prestate_ann(fcx.ccx, e.id, pres) |
return set_prestate_ann(fcx.ccx, e.id, pres) |
set_poststate_ann(fcx.ccx, e.id, post) |
option::map_default(
maybe_fail_val, false,
@@ -492,13 +493,14 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
expr_check(_, p) {
/* predicate p holds after this expression executes */
let c: sp_constr = expr_to_constr(fcx.ccx.tcx, p);
ret find_pre_post_state_sub(fcx, pres, p, e.id, some(c.node));
return find_pre_post_state_sub(fcx, pres, p, e.id, some(c.node));
}
expr_if_check(p, conseq, maybe_alt) {
ret join_then_else(fcx, p, conseq, maybe_alt, e.id, if_check, pres);
return join_then_else(
fcx, p, conseq, maybe_alt, e.id, if_check, pres);
}
expr_break { ret pure_exp(fcx.ccx, e.id, pres); }
expr_again { ret pure_exp(fcx.ccx, e.id, pres); }
expr_break { return pure_exp(fcx.ccx, e.id, pres); }
expr_again { return pure_exp(fcx.ccx, e.id, pres); }
}
}
@@ -529,10 +531,11 @@ fn find_pre_post_state_stmt(fcx: fn_ctxt, pres: prestate, s: @stmt) -> bool {
debug!{"poststate = %s", stmt_ann.states.poststate.to_str()};
debug!{"changed = %s", bool::to_str(changed)};
ret changed;
return changed;
}
decl_item(an_item) {
ret set_prestate(stmt_ann, pres) | set_poststate(stmt_ann, pres);
return set_prestate(stmt_ann, pres)
| set_poststate(stmt_ann, pres);
/* the outer visitor will recurse into the item */
}
}
@@ -549,7 +552,7 @@ fn find_pre_post_state_stmt(fcx: fn_ctxt, pres: prestate, s: @stmt) -> bool {
debug!{"poststate = %s", stmt_ann.states.poststate.to_str()};
debug!{"changed = %s", bool::to_str(changed)};
ret changed;
return changed;
}
}
}
@@ -582,7 +585,7 @@ fn find_pre_post_state_block(fcx: fn_ctxt, pres0: prestate, b: blk) -> bool {
set_prestate_ann(fcx.ccx, b.node.id, pres0);
set_poststate_ann(fcx.ccx, b.node.id, post);
ret changed;
return changed;
}
fn find_pre_post_state_fn(fcx: fn_ctxt,
@@ -607,7 +610,7 @@ fn find_pre_post_state_fn(fcx: fn_ctxt,
fcx.ccx.tcx.sess.span_note(f_body.span, fcx.name);
*/
ret changed;
return changed;
}
//
// Local Variables:

View File

@@ -94,7 +94,7 @@ class t {
fn doesntcare() -> bool {
for uint::range(0, self.nbits) |i| {
if self.get(i) != dont_care { ret false; }
if self.get(i) != dont_care { return false; }
}
true
}
@@ -134,7 +134,7 @@ class t {
changed = change(changed, old, newv);
self.set(i, newv);
}
ret changed;
return changed;
}
fn become(source: t) -> bool {
@@ -155,7 +155,7 @@ class t {
changed = change(changed, old, newv);
self.set(i, newv);
}
ret changed;
return changed;
}
new(len: uint) {

View File

@@ -542,12 +542,12 @@ type node_type_table = @smallintmap::smallintmap<t>;
fn mk_rcache() -> creader_cache {
type val = {cnum: int, pos: uint, len: uint};
fn hash_cache_entry(k: val) -> uint {
ret (k.cnum as uint) + k.pos + k.len;
return (k.cnum as uint) + k.pos + k.len;
}
fn eq_cache_entries(a: val, b: val) -> bool {
ret a.cnum == b.cnum && a.pos == b.pos && a.len == b.len;
return a.cnum == b.cnum && a.pos == b.pos && a.len == b.len;
}
ret map::hashmap(hash_cache_entry, eq_cache_entries);
return map::hashmap(hash_cache_entry, eq_cache_entries);
}
fn new_ty_hash<V: copy>() -> map::hashmap<t, V> {
@@ -608,7 +608,7 @@ fn mk_t(cx: ctxt, st: sty) -> t { mk_t_with_id(cx, st, none) }
fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t {
let key = {struct: st, o_def_id: o_def_id};
alt cx.interner.find(key) {
some(t) { unsafe { ret unsafe::reinterpret_cast(t); } }
some(t) { unsafe { return unsafe::reinterpret_cast(t); } }
_ {}
}
let mut flags = 0u;
@@ -624,7 +624,7 @@ fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t {
let mut f = 0u;
for substs.tps.each |tt| { f |= get(tt).flags; }
substs.self_r.iter(|r| f |= rflags(r));
ret f;
return f;
}
alt st {
ty_estr(vstore_slice(r)) {
@@ -816,7 +816,7 @@ fn walk_ty(ty: t, f: fn(t)) {
}
fn maybe_walk_ty(ty: t, f: fn(t) -> bool) {
if !f(ty) { ret; }
if !f(ty) { return; }
alt get(ty).struct {
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
ty_estr(_) | ty_type | ty_opaque_box | ty_self |
@@ -991,7 +991,7 @@ fn fold_regions(
fn do_fold(cx: ctxt, ty: t, in_fn: bool,
fldr: fn(region, bool) -> region) -> t {
if !type_has_regions(ty) { ret ty; }
if !type_has_regions(ty) { return ty; }
fold_regions_and_ty(
cx, ty,
|r| fldr(r, in_fn),
@@ -1005,7 +1005,7 @@ fn fold_region(cx: ctxt, t0: t, fldop: fn(region, bool) -> region) -> t {
fn do_fold(cx: ctxt, t0: t, under_r: bool,
fldop: fn(region, bool) -> region) -> t {
let tb = get(t0);
if !tbox_has_flag(tb, has_regions) { ret t0; }
if !tbox_has_flag(tb, has_regions) { return t0; }
alt tb.struct {
ty_rptr(r, {ty: t1, mutbl: m}) {
let m_r = fldop(r, under_r);
@@ -1038,9 +1038,9 @@ fn fold_region(cx: ctxt, t0: t, fldop: fn(region, bool) -> region) -> t {
// Substitute *only* type parameters. Used in trans where regions are erased.
fn subst_tps(cx: ctxt, tps: ~[t], typ: t) -> t {
if tps.len() == 0u { ret typ; }
if tps.len() == 0u { return typ; }
let tb = ty::get(typ);
if !tbox_has_flag(tb, has_params) { ret typ; }
if !tbox_has_flag(tb, has_params) { return typ; }
alt tb.struct {
ty_param(p) { tps[p.idx] }
sty { fold_sty_to_ty(cx, sty, |t| subst_tps(cx, tps, t)) }
@@ -1068,16 +1068,16 @@ fn subst(cx: ctxt,
substs_to_str(cx, substs),
ty_to_str(cx, typ)};
if substs_is_noop(substs) { ret typ; }
if substs_is_noop(substs) { return typ; }
let r = do_subst(cx, substs, typ);
debug!{" r = %s", ty_to_str(cx, r)};
ret r;
return r;
fn do_subst(cx: ctxt,
substs: substs,
typ: t) -> t {
let tb = get(typ);
if !tbox_has_flag(tb, needs_subst) { ret typ; }
if !tbox_has_flag(tb, needs_subst) { return typ; }
alt tb.struct {
ty_param(p) {substs.tps[p.idx]}
ty_self {substs.self_ty.get()}
@@ -1129,7 +1129,7 @@ fn type_is_structural(ty: t) -> bool {
}
fn type_is_copyable(cx: ctxt, ty: t) -> bool {
ret kind_can_be_copied(type_kind(cx, ty));
return kind_can_be_copied(type_kind(cx, ty));
}
fn type_is_sequence(ty: t) -> bool {
@@ -1148,8 +1148,8 @@ fn type_is_str(ty: t) -> bool {
fn sequence_element_type(cx: ctxt, ty: t) -> t {
alt get(ty).struct {
ty_estr(_) { ret mk_mach_uint(cx, ast::ty_u8); }
ty_evec(mt, _) | ty_unboxed_vec(mt) { ret mt.ty; }
ty_estr(_) { return mk_mach_uint(cx, ast::ty_u8); }
ty_evec(mt, _) | ty_unboxed_vec(mt) { return mt.ty; }
_ { cx.sess.bug(
~"sequence_element_type called on non-sequence value");
}
@@ -1158,16 +1158,16 @@ fn sequence_element_type(cx: ctxt, ty: t) -> t {
fn get_element_type(ty: t, i: uint) -> t {
alt get(ty).struct {
ty_rec(flds) { ret flds[i].mt.ty; }
ty_tup(ts) { ret ts[i]; }
ty_rec(flds) { return flds[i].mt.ty; }
ty_tup(ts) { return ts[i]; }
_ { fail ~"get_element_type called on invalid type"; }
}
}
pure fn type_is_box(ty: t) -> bool {
alt get(ty).struct {
ty_box(_) { ret true; }
_ { ret false; }
ty_box(_) { return true; }
_ { return false; }
}
}
@@ -1189,26 +1189,26 @@ pure fn type_is_region_ptr(ty: t) -> bool {
pure fn type_is_slice(ty: t) -> bool {
alt get(ty).struct {
ty_evec(_, vstore_slice(_)) | ty_estr(vstore_slice(_)) { true }
_ { ret false; }
_ { return false; }
}
}
pure fn type_is_unique_box(ty: t) -> bool {
alt get(ty).struct {
ty_uniq(_) { ret true; }
_ { ret false; }
ty_uniq(_) { return true; }
_ { return false; }
}
}
pure fn type_is_unsafe_ptr(ty: t) -> bool {
alt get(ty).struct {
ty_ptr(_) { ret true; }
_ { ret false; }
ty_ptr(_) { return true; }
_ { return false; }
}
}
pure fn type_is_vec(ty: t) -> bool {
ret alt get(ty).struct {
return alt get(ty).struct {
ty_evec(_, _) | ty_unboxed_vec(_) { true }
ty_estr(_) { true }
_ { false }
@@ -1217,10 +1217,10 @@ pure fn type_is_vec(ty: t) -> bool {
pure fn type_is_unique(ty: t) -> bool {
alt get(ty).struct {
ty_uniq(_) { ret true; }
ty_uniq(_) { return true; }
ty_evec(_, vstore_uniq) { true }
ty_estr(vstore_uniq) { true }
_ { ret false; }
_ { return false; }
}
}
@@ -1233,13 +1233,13 @@ pure fn type_is_scalar(ty: t) -> bool {
}
fn type_is_immediate(ty: t) -> bool {
ret type_is_scalar(ty) || type_is_boxed(ty) ||
return type_is_scalar(ty) || type_is_boxed(ty) ||
type_is_unique(ty) || type_is_region_ptr(ty);
}
fn type_needs_drop(cx: ctxt, ty: t) -> bool {
alt cx.needs_drop_cache.find(ty) {
some(result) { ret result; }
some(result) { return result; }
none {/* fall through */ }
}
@@ -1293,7 +1293,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
};
cx.needs_drop_cache.insert(ty, result);
ret result;
return result;
}
// Some things don't need cleanups during unwinding because the
@@ -1302,7 +1302,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
// cleanups.
fn type_needs_unwind_cleanup(cx: ctxt, ty: t) -> bool {
alt cx.needs_unwind_cleanup_cache.find(ty) {
some(result) { ret result; }
some(result) { return result; }
none { }
}
@@ -1310,7 +1310,7 @@ fn type_needs_unwind_cleanup(cx: ctxt, ty: t) -> bool {
let needs_unwind_cleanup =
type_needs_unwind_cleanup_(cx, ty, tycache, false);
cx.needs_unwind_cleanup_cache.insert(ty, needs_unwind_cleanup);
ret needs_unwind_cleanup;
return needs_unwind_cleanup;
}
fn type_needs_unwind_cleanup_(cx: ctxt, ty: t,
@@ -1319,7 +1319,7 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t,
// Prevent infinite recursion
alt tycache.find(ty) {
some(_) { ret false; }
some(_) { return false; }
none { tycache.insert(ty, ()); }
}
@@ -1373,7 +1373,7 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t,
result
}
ret needs_unwind_cleanup;
return needs_unwind_cleanup;
}
enum kind { kind_(u32) }
@@ -1583,7 +1583,7 @@ fn mutable_type_kind(cx: ctxt, ty: mt) -> kind {
fn type_kind(cx: ctxt, ty: t) -> kind {
alt cx.kind_cache.find(ty) {
some(result) { ret result; }
some(result) { return result; }
none {/* fall through */ }
}
@@ -1735,7 +1735,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
}
cx.kind_cache.insert(ty, result);
ret result;
return result;
}
/// gives a rough estimate of how much space it takes to represent
@@ -1816,7 +1816,7 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
ty_to_str(cx, r_ty),
ty_to_str(cx, ty),
r};
ret r;
return r;
}
fn subtypes_require(cx: ctxt, seen: @mut ~[def_id],
@@ -1848,7 +1848,7 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
ty_box(mt) |
ty_uniq(mt) |
ty_rptr(_, mt) {
ret type_requires(cx, seen, r_ty, mt.ty);
return type_requires(cx, seen, r_ty, mt.ty);
}
ty_ptr(mt) {
@@ -1904,7 +1904,7 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
ty_to_str(cx, ty),
r};
ret r;
return r;
}
let seen = @mut ~[];
@@ -1915,46 +1915,48 @@ fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) ->
bool {
let sty = get(ty).struct;
debug!{"type_structurally_contains: %s", ty_to_str(cx, ty)};
if test(sty) { ret true; }
if test(sty) { return true; }
alt sty {
ty_enum(did, substs) {
for vec::each(*enum_variants(cx, did)) |variant| {
for variant.args.each |aty| {
let sty = subst(cx, substs, aty);
if type_structurally_contains(cx, sty, test) { ret true; }
if type_structurally_contains(cx, sty, test) { return true; }
}
}
ret false;
return false;
}
ty_rec(fields) {
for fields.each |field| {
if type_structurally_contains(cx, field.mt.ty, test) { ret true; }
if type_structurally_contains(cx, field.mt.ty, test) {
return true;
}
}
ret false;
return false;
}
ty_class(did, substs) {
for lookup_class_fields(cx, did).each |field| {
let ft = lookup_field_type(cx, did, field.id, substs);
if type_structurally_contains(cx, ft, test) { ret true; }
if type_structurally_contains(cx, ft, test) { return true; }
}
ret false;
return false;
}
ty_tup(ts) {
for ts.each |tt| {
if type_structurally_contains(cx, tt, test) { ret true; }
if type_structurally_contains(cx, tt, test) { return true; }
}
ret false;
return false;
}
ty_evec(mt, vstore_fixed(_)) {
ret type_structurally_contains(cx, mt.ty, test);
return type_structurally_contains(cx, mt.ty, test);
}
_ { ret false; }
_ { return false; }
}
}
fn type_structurally_contains_uniques(cx: ctxt, ty: t) -> bool {
ret type_structurally_contains(cx, ty, |sty| {
return type_structurally_contains(cx, ty, |sty| {
alt sty {
ty_uniq(_) |
ty_evec(_, vstore_uniq) |
@@ -1979,7 +1981,7 @@ fn type_is_fp(ty: t) -> bool {
}
fn type_is_numeric(ty: t) -> bool {
ret type_is_integral(ty) || type_is_fp(ty);
return type_is_integral(ty) || type_is_fp(ty);
}
fn type_is_signed(ty: t) -> bool {
@@ -2044,13 +2046,13 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool {
}
}
ret result;
return result;
}
fn type_is_enum(ty: t) -> bool {
alt get(ty).struct {
ty_enum(_, _) { ret true; }
_ { ret false;}
ty_enum(_, _) { return true; }
_ { return false;}
}
}
@@ -2061,18 +2063,18 @@ fn type_is_c_like_enum(cx: ctxt, ty: t) -> bool {
ty_enum(did, substs) {
let variants = enum_variants(cx, did);
let some_n_ary = vec::any(*variants, |v| vec::len(v.args) > 0u);
ret !some_n_ary;
return !some_n_ary;
}
_ { ret false;}
_ { return false;}
}
}
fn type_param(ty: t) -> option<uint> {
alt get(ty).struct {
ty_param(p) { ret some(p.idx); }
ty_param(p) { return some(p.idx); }
_ {/* fall through */ }
}
ret none;
return none;
}
// Returns the type and mutability of *t.
@@ -2110,7 +2112,7 @@ fn type_autoderef(cx: ctxt, t: t) -> t {
let mut t = t;
loop {
alt deref(cx, t, false) {
none { ret t; }
none { return t; }
some(mt) { t = mt.ty; }
}
}
@@ -2243,13 +2245,13 @@ fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t {
fn node_id_to_type_params(cx: ctxt, id: ast::node_id) -> ~[t] {
alt cx.node_type_substs.find(id) {
none { ret ~[]; }
some(ts) { ret ts; }
none { return ~[]; }
some(ts) { return ts; }
}
}
fn node_id_has_type_params(cx: ctxt, id: ast::node_id) -> bool {
ret cx.node_type_substs.contains_key(id);
return cx.node_type_substs.contains_key(id);
}
// Type accessors for substructures of types
@@ -2283,8 +2285,8 @@ fn ty_fn_ret_style(fty: t) -> ast::ret_style {
fn is_fn_ty(fty: t) -> bool {
alt get(fty).struct {
ty_fn(_) { ret true; }
_ { ret false; }
ty_fn(_) { return true; }
_ { return false; }
}
}
@@ -2301,14 +2303,14 @@ fn is_pred_ty(fty: t) -> bool {
fn ty_var_id(typ: t) -> tv_vid {
alt get(typ).struct {
ty_var(vid) { ret vid; }
ty_var(vid) { return vid; }
_ { error!{"ty_var_id called on non-var ty"}; fail; }
}
}
fn ty_var_integral_id(typ: t) -> tvi_vid {
alt get(typ).struct {
ty_var_integral(vid) { ret vid; }
ty_var_integral(vid) { return vid; }
_ { error!{"ty_var_integral_id called on ty other than \
ty_var_integral"};
fail; }
@@ -2317,14 +2319,14 @@ fn ty_var_integral_id(typ: t) -> tvi_vid {
// Type accessors for AST nodes
fn block_ty(cx: ctxt, b: ast::blk) -> t {
ret node_id_to_type(cx, b.node.id);
return node_id_to_type(cx, b.node.id);
}
// Returns the type of a pattern as a monotype. Like @expr_ty, this function
// doesn't provide type parameter substitutions.
fn pat_ty(cx: ctxt, pat: @ast::pat) -> t {
ret node_id_to_type(cx, pat.id);
return node_id_to_type(cx, pat.id);
}
@@ -2335,17 +2337,17 @@ fn pat_ty(cx: ctxt, pat: @ast::pat) -> t {
// instead of "fn(t) -> T with T = int". If this isn't what you want, see
// expr_ty_params_and_ty() below.
fn expr_ty(cx: ctxt, expr: @ast::expr) -> t {
ret node_id_to_type(cx, expr.id);
return node_id_to_type(cx, expr.id);
}
fn expr_ty_params_and_ty(cx: ctxt,
expr: @ast::expr) -> {params: ~[t], ty: t} {
ret {params: node_id_to_type_params(cx, expr.id),
return {params: node_id_to_type_params(cx, expr.id),
ty: node_id_to_type(cx, expr.id)};
}
fn expr_has_ty_params(cx: ctxt, expr: @ast::expr) -> bool {
ret node_id_has_type_params(cx, expr.id);
return node_id_has_type_params(cx, expr.id);
}
fn expr_is_lval(method_map: typeck::method_map, e: @ast::expr) -> bool {
@@ -2361,15 +2363,15 @@ fn expr_is_lval(method_map: typeck::method_map, e: @ast::expr) -> bool {
fn stmt_node_id(s: @ast::stmt) -> ast::node_id {
alt s.node {
ast::stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) {
ret id;
return id;
}
}
}
fn field_idx(id: ast::ident, fields: ~[field]) -> option<uint> {
let mut i = 0u;
for fields.each |f| { if f.ident == id { ret some(i); } i += 1u; }
ret none;
for fields.each |f| { if f.ident == id { return some(i); } i += 1u; }
return none;
}
fn get_field(rec_ty: t, id: ast::ident) -> field {
@@ -2386,8 +2388,8 @@ fn get_fields(rec_ty:t) -> ~[field] {
fn method_idx(id: ast::ident, meths: ~[method]) -> option<uint> {
let mut i = 0u;
for meths.each |m| { if m.ident == id { ret some(i); } i += 1u; }
ret none;
for meths.each |m| { if m.ident == id { return some(i); } i += 1u; }
return none;
}
/// Returns a vector containing the indices of all type parameters that appear
@@ -2419,7 +2421,7 @@ fn occurs_check(tcx: ctxt, sp: span, vid: tv_vid, rt: t) {
}
// Fast path
if !type_needs_infer(rt) { ret; }
if !type_needs_infer(rt) { return; }
// Occurs check!
if vec::contains(vars_in_type(rt), vid) {
@@ -2539,7 +2541,7 @@ fn type_err_to_str(cx: ctxt, err: type_err) -> ~str {
}
alt err {
terr_mismatch { ret ~"types differ"; }
terr_mismatch { return ~"types differ"; }
terr_ret_style_mismatch(expect, actual) {
fn to_str(s: ast::ret_style) -> ~str {
alt s {
@@ -2547,69 +2549,71 @@ fn type_err_to_str(cx: ctxt, err: type_err) -> ~str {
ast::return_val { ~"return-by-value" }
}
}
ret to_str(actual) + ~" function found where " + to_str(expect) +
return to_str(actual) + ~" function found where " + to_str(expect) +
~" function was expected";
}
terr_purity_mismatch(f1, f2) {
ret fmt!{"expected %s fn but found %s fn",
return fmt!{"expected %s fn but found %s fn",
purity_to_str(f1), purity_to_str(f2)};
}
terr_proto_mismatch(e, a) {
ret fmt!{"closure protocol mismatch (%s vs %s)",
return fmt!{"closure protocol mismatch (%s vs %s)",
proto_to_str(e), proto_to_str(a)};
}
terr_mutability { ret ~"values differ in mutability"; }
terr_box_mutability { ret ~"boxed values differ in mutability"; }
terr_vec_mutability { ret ~"vectors differ in mutability"; }
terr_ptr_mutability { ret ~"pointers differ in mutability"; }
terr_ref_mutability { ret ~"references differ in mutability"; }
terr_mutability { return ~"values differ in mutability"; }
terr_box_mutability { return ~"boxed values differ in mutability"; }
terr_vec_mutability { return ~"vectors differ in mutability"; }
terr_ptr_mutability { return ~"pointers differ in mutability"; }
terr_ref_mutability { return ~"references differ in mutability"; }
terr_ty_param_size(e_sz, a_sz) {
ret ~"expected a type with " + uint::to_str(e_sz, 10u) +
return ~"expected a type with " + uint::to_str(e_sz, 10u) +
~" type params but found one with " + uint::to_str(a_sz, 10u) +
~" type params";
}
terr_tuple_size(e_sz, a_sz) {
ret ~"expected a tuple with " + uint::to_str(e_sz, 10u) +
return ~"expected a tuple with " + uint::to_str(e_sz, 10u) +
~" elements but found one with " + uint::to_str(a_sz, 10u) +
~" elements";
}
terr_record_size(e_sz, a_sz) {
ret ~"expected a record with " + uint::to_str(e_sz, 10u) +
return ~"expected a record with " + uint::to_str(e_sz, 10u) +
~" fields but found one with " + uint::to_str(a_sz, 10u) +
~" fields";
}
terr_record_mutability { ret ~"record elements differ in mutability"; }
terr_record_mutability {
return ~"record elements differ in mutability";
}
terr_record_fields(e_fld, a_fld) {
ret ~"expected a record with field `" + *e_fld +
return ~"expected a record with field `" + *e_fld +
~"` but found one with field `" + *a_fld + ~"`";
}
terr_arg_count { ret ~"incorrect number of function parameters"; }
terr_arg_count { return ~"incorrect number of function parameters"; }
terr_mode_mismatch(e_mode, a_mode) {
ret ~"expected argument mode " + mode_to_str(e_mode) +
return ~"expected argument mode " + mode_to_str(e_mode) +
~" but found " + mode_to_str(a_mode);
}
terr_regions_differ(subregion, superregion) {
ret fmt!{"%s does not necessarily outlive %s",
return fmt!{"%s does not necessarily outlive %s",
explain_region(cx, subregion),
explain_region(cx, superregion)};
}
terr_vstores_differ(k, e_vs, a_vs) {
ret fmt!{"%s storage differs: expected %s but found %s",
return fmt!{"%s storage differs: expected %s but found %s",
terr_vstore_kind_to_str(k),
vstore_to_str(cx, e_vs),
vstore_to_str(cx, a_vs)};
}
terr_in_field(err, fname) {
ret fmt!{"in field `%s`, %s", *fname, type_err_to_str(cx, *err)};
return fmt!{"in field `%s`, %s", *fname, type_err_to_str(cx, *err)};
}
terr_sorts(exp, act) {
ret fmt!{"%s vs %s", ty_sort_str(cx, exp), ty_sort_str(cx, act)};
return fmt!{"%s vs %s", ty_sort_str(cx, exp), ty_sort_str(cx, act)};
}
terr_self_substs {
ret ~"inconsistent self substitution"; // XXX this is more of a bug
return ~"inconsistent self substitution"; // XXX this is more of a bug
}
terr_no_integral_type {
ret ~"couldn't determine an appropriate integral type for integer \
return ~"couldn't determine an appropriate integral type for integer \
literal";
}
}
@@ -2629,7 +2633,7 @@ fn store_trait_methods(cx: ctxt, id: ast::node_id, ms: @~[method]) {
fn trait_methods(cx: ctxt, id: ast::def_id) -> @~[method] {
alt cx.trait_method_cache.find(id) {
some(ms) { ret ms; }
some(ms) { return ms; }
_ {}
}
// Local traits are supposed to have been added explicitly.
@@ -2789,7 +2793,7 @@ fn type_is_empty(cx: ctxt, t: t) -> bool {
fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[variant_info] {
alt cx.enum_var_cache.find(id) {
some(variants) { ret variants; }
some(variants) { return variants; }
_ { /* fallthrough */ }
}
@@ -2844,7 +2848,7 @@ fn enum_variant_with_id(cx: ctxt, enum_id: ast::def_id,
let mut i = 0u;
while i < vec::len::<variant_info>(*variants) {
let variant = variants[i];
if ast_util::def_eq(variant.id, variant_id) { ret variant; }
if ast_util::def_eq(variant.id, variant_id) { return variant; }
i += 1u;
}
cx.sess.bug(~"enum_variant_with_id(): no variant exists with that ID");
@@ -2855,14 +2859,14 @@ fn enum_variant_with_id(cx: ctxt, enum_id: ast::def_id,
// the type cache. Returns the type parameters and type.
fn lookup_item_type(cx: ctxt, did: ast::def_id) -> ty_param_bounds_and_ty {
alt cx.tcache.find(did) {
some(tpt) { ret tpt; }
some(tpt) { return tpt; }
none {
// The item is in this crate. The caller should have added it to the
// type cache already
assert did.crate != ast::local_crate;
let tyt = csearch::get_type(cx, did);
cx.tcache.insert(did, tyt);
ret tyt;
return tyt;
}
}
}
@@ -2908,7 +2912,7 @@ fn lookup_class_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] {
}
}
else {
ret csearch::get_class_fields(cx, did);
return csearch::get_class_fields(cx, did);
}
}
@@ -2962,7 +2966,7 @@ fn lookup_class_method_by_name(cx:ctxt, did: ast::def_id, name: ident,
let ms = lookup_class_method_ids(cx, did);
for ms.each |m| {
if m.name == name {
ret ast_util::local_def(m.id);
return ast_util::local_def(m.id);
}
}
cx.sess.span_fatal(sp, fmt!{"Class doesn't have a method \
@@ -3087,7 +3091,7 @@ fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool {
/*bot*/ ~[f, f, f, f, t, t, f, f],
/*struct*/ ~[t, t, t, t, t, t, t, t]];
ret tbl[tycat(ty)][opcat(op)];
return tbl[tycat(ty)][opcat(op)];
}
fn ty_params_to_tys(tcx: ty::ctxt, tps: ~[ast::ty_param]) -> ~[t] {
@@ -3099,7 +3103,7 @@ fn ty_params_to_tys(tcx: ty::ctxt, tps: ~[ast::ty_param]) -> ~[t] {
/// Returns an equivalent type with all the typedefs and self regions removed.
fn normalize_ty(cx: ctxt, t: t) -> t {
alt cx.normalized_cache.find(t) {
some(t) { ret t; }
some(t) { return t; }
none { }
}
@@ -3136,7 +3140,7 @@ fn normalize_ty(cx: ctxt, t: t) -> t {
let sty = fold_sty(get(t).struct, |t| { normalize_ty(cx, t) });
let t_norm = mk_t(cx, sty);
cx.normalized_cache.insert(t, t_norm);
ret t_norm;
return t_norm;
}
// Local Variables:

View File

@@ -228,13 +228,13 @@ fn require_same_types(
fn arg_is_argv_ty(_tcx: ty::ctxt, a: ty::arg) -> bool {
alt ty::get(a.ty).struct {
ty::ty_evec(mt, vstore_uniq) {
if mt.mutbl != ast::m_imm { ret false; }
if mt.mutbl != ast::m_imm { return false; }
alt ty::get(mt.ty).struct {
ty::ty_estr(vstore_uniq) { ret true; }
_ { ret false; }
ty::ty_estr(vstore_uniq) { return true; }
_ { return false; }
}
}
_ { ret false; }
_ { return false; }
}
}
@@ -253,7 +253,7 @@ fn check_main_fn_ty(ccx: @crate_ctxt,
ast::item_fn(_,ps,_) if vec::is_not_empty(ps) {
tcx.sess.span_err(main_span,
~"main function is not allowed to have type parameters");
ret;
return;
}
_ {}
}

View File

@@ -142,7 +142,7 @@ fn ast_path_to_ty<AC: ast_conv, RS: region_scope copy owned>(
ast_path_to_substs_and_ty(self, rscope, did, path);
write_ty_to_tcx(tcx, path_id, ty);
write_substs_to_tcx(tcx, path_id, substs.tps);
ret {substs: substs, ty: ty};
return {substs: substs, ty: ty};
}
const NO_REGIONS: uint = 1u;
@@ -157,7 +157,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>(
fn ast_mt_to_mt<AC: ast_conv, RS: region_scope copy owned>(
self: AC, rscope: RS, mt: ast::mt) -> ty::mt {
ret {ty: ast_ty_to_ty(self, rscope, mt.ty), mutbl: mt.mutbl};
return {ty: ast_ty_to_ty(self, rscope, mt.ty), mutbl: mt.mutbl};
}
// Handle @, ~, and & being able to mean estrs and evecs.
@@ -172,13 +172,13 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>(
// to convert to an e{vec,str}, there can't be a mutability argument
_ if a_seq_ty.mutbl != ast::m_imm {}
ast::ty_vec(mt) {
ret ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt), vst);
return ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt), vst);
}
ast::ty_path(path, id) {
alt tcx.def_map.find(id) {
some(ast::def_prim_ty(ast::ty_str)) {
check_path_args(tcx, path, NO_TPS | NO_REGIONS);
ret ty::mk_estr(tcx, vst);
return ty::mk_estr(tcx, vst);
}
_ {}
}
@@ -187,7 +187,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>(
}
let seq_ty = ast_mt_to_mt(self, rscope, a_seq_ty);
ret constr(seq_ty);
return constr(seq_ty);
}
fn check_path_args(tcx: ty::ctxt,
@@ -213,7 +213,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>(
let tcx = self.tcx();
alt tcx.ast_ty_to_ty_cache.find(ast_ty) {
some(ty::atttce_resolved(ty)) { ret ty; }
some(ty::atttce_resolved(ty)) { return ty; }
some(ty::atttce_unresolved) {
tcx.sess.span_fatal(ast_ty.span, ~"illegal recursive type; \
insert an enum in the cycle, \
@@ -348,7 +348,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>(
};
tcx.ast_ty_to_ty_cache.insert(ast_ty, ty::atttce_resolved(typ));
ret typ;
return typ;
}
fn ty_of_arg<AC: ast_conv, RS: region_scope copy owned>(

View File

@@ -157,9 +157,9 @@ impl methods of get_and_find_region for isr_alist {
fn find(br: ty::bound_region) -> option<ty::region> {
for list::each(self) |isr| {
let (isr_br, isr_r) = isr;
if isr_br == br { ret some(isr_r); }
if isr_br == br { return some(isr_r); }
}
ret none;
return none;
}
}
@@ -653,7 +653,7 @@ impl methods for @fn_ctxt {
self.region_lb = lb;
let v <- f();
self.region_lb = old_region_lb;
ret v;
return v;
}
}
@@ -681,7 +681,7 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t {
// reported on the enum definition as well because the enum is not
// instantiable.
if vec::contains(enum_dids, did) {
ret t1;
return t1;
}
vec::push(enum_dids, did);
}
@@ -690,7 +690,7 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t {
// Otherwise, deref if type is derefable:
alt ty::deref_sty(fcx.ccx.tcx, sty, false) {
none { ret t1; }
none { return t1; }
some(mt) { t1 = mt.ty; }
}
};
@@ -726,7 +726,7 @@ fn check_expr_with(fcx: @fn_ctxt, expr: @ast::expr, expected: ty::t) -> bool {
fn check_expr(fcx: @fn_ctxt, expr: @ast::expr,
expected: option<ty::t>) -> bool {
ret do check_expr_with_unifier(fcx, expr, expected) {
return do check_expr_with_unifier(fcx, expr, expected) {
for expected.each |t| {
demand::suptype(fcx, expr.span, t, fcx.expr_ty(expr));
}
@@ -898,7 +898,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
let mut bot = check_expr(fcx, lhs, none);
bot |= check_expr_with(fcx, rhs, fcx.expr_ty(lhs));
fcx.write_ty(id, ty::mk_nil(fcx.ccx.tcx));
ret bot;
return bot;
}
// A generic function for doing all of the checking for call expressions
@@ -928,7 +928,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
ty::ty_fn(f) {
bot |= (f.ret_style == ast::noreturn);
fcx.write_ty(call_expr_id, f.output);
ret bot;
return bot;
}
_ { fcx.ccx.tcx.sess.span_fatal(sp, ~"calling non-function"); }
}
@@ -945,7 +945,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
let bot = check_decl_local(fcx, local);
check_block_no_value(fcx, body);
fcx.write_nil(node_id);
ret bot;
return bot;
}
// A generic function for checking the then and else in an if
@@ -969,7 +969,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
}
};
fcx.write_ty(id, if_t);
ret if_bot;
return if_bot;
}
fn lookup_op_method(fcx: @fn_ctxt, op_ex: @ast::expr,
@@ -1000,7 +1000,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
let lhs_bot = check_expr(fcx, lhs, none);
let lhs_t = fcx.expr_ty(lhs);
let lhs_t = structurally_resolved_type(fcx, lhs.span, lhs_t);
ret alt (op, ty::get(lhs_t).struct) {
return alt (op, ty::get(lhs_t).struct) {
(_, _) if ty::type_is_integral(lhs_t) &&
ast_util::is_shift_binop(op) {
// Shift is a special case: rhs can be any integral type
@@ -1049,7 +1049,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
alt lookup_op_method(fcx, ex,
lhs_expr, lhs_resolved_t,
name, ~[rhs]) {
some(pair) { ret pair; }
some(pair) { return pair; }
_ {}
}
}
@@ -1242,7 +1242,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
}
}
}
ret bot;
return bot;
}
@@ -1421,8 +1421,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
alt fcx.mk_eqty(ret_ty, ty::mk_nil(tcx)) {
result::ok(_) { /* fall through */ }
result::err(_) {
tcx.sess.span_err(expr.span,
~"`ret;` in function returning non-nil"); }
tcx.sess.span_err(
expr.span,
~"`return;` in function returning non-nil"); }
}
}
some(e) { check_expr_with(fcx, e, ret_ty); }
@@ -1902,7 +1903,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
unifier();
debug!{"<< bot=%b", bot};
ret bot;
return bot;
}
fn require_integral(fcx: @fn_ctxt, sp: span, t: ty::t) {
@@ -1916,7 +1917,7 @@ fn require_integral(fcx: @fn_ctxt, sp: span, t: ty::t) {
fn check_decl_initializer(fcx: @fn_ctxt, nid: ast::node_id,
init: ast::initializer) -> bool {
let lty = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, init.expr.span, nid));
ret check_expr_with(fcx, init.expr, lty);
return check_expr_with(fcx, init.expr, lty);
}
fn check_decl_local(fcx: @fn_ctxt, local: @ast::local) -> bool {
@@ -1941,7 +1942,7 @@ fn check_decl_local(fcx: @fn_ctxt, local: @ast::local) -> bool {
pat_region: region
};
alt::check_pat(pcx, local.node.pat, t);
ret bot;
return bot;
}
fn check_stmt(fcx: @fn_ctxt, stmt: @ast::stmt) -> bool {
@@ -1967,7 +1968,7 @@ fn check_stmt(fcx: @fn_ctxt, stmt: @ast::stmt) -> bool {
}
}
fcx.write_nil(node_id);
ret bot;
return bot;
}
fn check_block_no_value(fcx: @fn_ctxt, blk: ast::blk) -> bool {
@@ -1977,7 +1978,7 @@ fn check_block_no_value(fcx: @fn_ctxt, blk: ast::blk) -> bool {
let nilty = ty::mk_nil(fcx.ccx.tcx);
demand::suptype(fcx, blk.span, nilty, blkty);
}
ret bot;
return bot;
}
fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool {
@@ -2160,17 +2161,17 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
ast::def_arg(nid, _) {
assert (fcx.locals.contains_key(nid));
let typ = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, sp, nid));
ret no_params(typ);
return no_params(typ);
}
ast::def_local(nid, _) {
assert (fcx.locals.contains_key(nid));
let typ = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, sp, nid));
ret no_params(typ);
return no_params(typ);
}
ast::def_self(_) {
alt fcx.self_info {
some(self_info) {
ret no_params(self_info.self_ty);
return no_params(self_info.self_ty);
}
none {
fcx.ccx.tcx.sess.span_bug(sp, ~"def_self with no self_info");
@@ -2179,7 +2180,7 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
}
ast::def_fn(id, ast::extern_fn) {
// extern functions are just u8 pointers
ret {
return {
bounds: @~[],
rp: false,
ty: ty::mk_ptr(
@@ -2194,26 +2195,26 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
ast::def_fn(id, ast::unsafe_fn) {
// Unsafe functions can only be touched in an unsafe context
fcx.require_unsafe(sp, ~"access to unsafe function");
ret ty::lookup_item_type(fcx.ccx.tcx, id);
return ty::lookup_item_type(fcx.ccx.tcx, id);
}
ast::def_fn(id, _) | ast::def_const(id) |
ast::def_variant(_, id) | ast::def_class(id, _) {
ret ty::lookup_item_type(fcx.ccx.tcx, id);
return ty::lookup_item_type(fcx.ccx.tcx, id);
}
ast::def_binding(nid) {
assert (fcx.locals.contains_key(nid));
let typ = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, sp, nid));
ret no_params(typ);
return no_params(typ);
}
ast::def_ty(_) | ast::def_prim_ty(_) {
fcx.ccx.tcx.sess.span_fatal(sp, ~"expected value but found type");
}
ast::def_upvar(_, inner, _) {
ret ty_param_bounds_and_ty_for_def(fcx, sp, *inner);
return ty_param_bounds_and_ty_for_def(fcx, sp, *inner);
}
ast::def_ty_param(did, n) {
ret no_params(ty::mk_param(fcx.ccx.tcx, n, did));
return no_params(ty::mk_param(fcx.ccx.tcx, n, did));
}
ast::def_mod(*) | ast::def_foreign_mod(*) {
fcx.ccx.tcx.sess.span_fatal(sp, ~"expected value but found module");
@@ -2288,7 +2289,7 @@ fn instantiate_path(fcx: @fn_ctxt,
// resolution is possible, then an error is reported.
fn structurally_resolved_type(fcx: @fn_ctxt, sp: span, tp: ty::t) -> ty::t {
alt infer::resolve_type(fcx.infcx, tp, force_tvar) {
result::ok(t_s) if !ty::type_is_var(t_s) { ret t_s; }
result::ok(t_s) if !ty::type_is_var(t_s) { return t_s; }
_ {
fcx.ccx.tcx.sess.span_fatal
(sp, ~"the type of this value must be known in this context");
@@ -2303,17 +2304,17 @@ fn structure_of(fcx: @fn_ctxt, sp: span, typ: ty::t) -> ty::sty {
fn type_is_integral(fcx: @fn_ctxt, sp: span, typ: ty::t) -> bool {
let typ_s = structurally_resolved_type(fcx, sp, typ);
ret ty::type_is_integral(typ_s);
return ty::type_is_integral(typ_s);
}
fn type_is_scalar(fcx: @fn_ctxt, sp: span, typ: ty::t) -> bool {
let typ_s = structurally_resolved_type(fcx, sp, typ);
ret ty::type_is_scalar(typ_s);
return ty::type_is_scalar(typ_s);
}
fn type_is_c_like_enum(fcx: @fn_ctxt, sp: span, typ: ty::t) -> bool {
let typ_s = structurally_resolved_type(fcx, sp, typ);
ret ty::type_is_c_like_enum(fcx.ccx.tcx, typ_s);
return ty::type_is_c_like_enum(fcx.ccx.tcx, typ_s);
}
fn ast_expr_vstore_to_vstore(fcx: @fn_ctxt, e: @ast::expr, n: uint,
@@ -2350,7 +2351,7 @@ fn check_bounds_are_used(ccx: @crate_ctxt,
tps: ~[ast::ty_param],
ty: ty::t) {
// make a vector of booleans initially false, set to true when used
if tps.len() == 0u { ret; }
if tps.len() == 0u { return; }
let tps_used = vec::to_mut(vec::from_elem(tps.len(), false));
ty::walk_regions_and_ty(
@@ -2437,7 +2438,7 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) {
other {
tcx.sess.span_err(it.span, ~"unrecognized intrinsic function: `" +
other + ~"`");
ret;
return;
}
};
let fty = ty::mk_fn(tcx, {purity: ast::impure_fn,

View File

@@ -40,7 +40,7 @@ fn check_alt(fcx: @fn_ctxt,
bot |= !arm_non_bot;
if !arm_non_bot { result_ty = ty::mk_bot(tcx); }
fcx.write_ty(expr.id, result_ty);
ret bot;
return bot;
}
type pat_ctxt = {
@@ -197,7 +197,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
ex_f_count, f_count});
}
fn matches(name: ast::ident, f: ty::field) -> bool {
ret str::eq(*name, *f.ident);
return str::eq(*name, *f.ident);
}
for fields.each |f| {
alt vec::find(ex_fields, |a| matches(f.ident, a)) {

View File

@@ -160,7 +160,7 @@ class lookup {
}
}
if self.candidates.len() == 0u { ret none; }
if self.candidates.len() == 0u { return none; }
if self.candidates.len() > 1u {
self.tcx().sess.span_err(
@@ -359,7 +359,7 @@ class lookup {
// multiple-methods-in-scope errors.
if self.fcx.ccx.trait_map.contains_key(self.expr.id) {
ret;
return;
}
let impls_vecs = self.fcx.ccx.impl_map.get(self.expr.id);
@@ -376,7 +376,7 @@ class lookup {
// we want to find the innermost scope that has any
// matches and then ignore outer scopes
if added_any {ret;}
if added_any {return;}
}
}
@@ -428,7 +428,7 @@ class lookup {
}
}
ret added_any;
return added_any;
}
fn add_candidates_from_m(self_substs: ty::substs,
@@ -563,7 +563,7 @@ class lookup {
self.fcx.write_ty_substs(self.node_id, cand.fty, all_substs);
ret cand.entry;
return cand.entry;
}
}

View File

@@ -93,7 +93,7 @@ fn visit_local(l: @ast::local, &&rcx: @rcx, v: rvt) {
let e = rcx.errors_reported;
v.visit_pat(l.node.pat, rcx, v);
if e != rcx.errors_reported {
ret; // if decl has errors, skip initializer expr
return; // if decl has errors, skip initializer expr
}
v.visit_ty(l.node.ty, rcx, v);
@@ -131,7 +131,7 @@ fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) {
// uses will also be enclosed (and otherwise, an error will
// have been reported at the def'n site).
alt lookup_def(rcx.fcx, e.span, e.id) {
ast::def_local(*) | ast::def_arg(*) | ast::def_upvar(*) { ret; }
ast::def_local(*) | ast::def_arg(*) | ast::def_upvar(*) { return; }
_ { }
}
}
@@ -151,7 +151,7 @@ fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) {
// check_cast_for_escaping_regions() in kind.rs explaining how
// it goes about doing that.
alt rcx.resolve_node_type(e.id) {
result::err(_) => { ret; /* typeck will fail anyhow */ }
result::err(_) => { return; /* typeck will fail anyhow */ }
result::ok(target_ty) => {
alt ty::get(target_ty).struct {
ty::ty_trait(_, substs) {
@@ -173,7 +173,7 @@ fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) {
_ { }
}
if !visit_node(e.id, e.span, rcx) { ret; }
if !visit_node(e.id, e.span, rcx) { return; }
visit::visit_expr(e, rcx, v);
}
@@ -192,7 +192,7 @@ fn visit_node(id: ast::node_id, span: span, rcx: @rcx) -> bool {
// is going to fail anyway, so just stop here and let typeck
// report errors later on in the writeback phase.
let ty = alt rcx.resolve_node_type(id) {
result::err(_) { ret true; }
result::err(_) { return true; }
result::ok(ty) { ty }
};
@@ -206,7 +206,7 @@ fn visit_node(id: ast::node_id, span: span, rcx: @rcx) -> bool {
ppaux::region_to_str(tcx, encl_region)};
// Otherwise, look at the type and see if it is a region pointer.
ret constrain_regions_in_type(rcx, encl_region, span, ty);
return constrain_regions_in_type(rcx, encl_region, span, ty);
}
fn constrain_regions_in_type(
@@ -220,7 +220,7 @@ fn constrain_regions_in_type(
rcx.fcx.ccx.tcx, ty,
|r| constrain_region(rcx, encl_region, span, r),
|t| ty::type_has_regions(t));
ret (e == rcx.errors_reported);
return (e == rcx.errors_reported);
fn constrain_region(rcx: @rcx,
encl_region: ty::region,
@@ -238,7 +238,7 @@ fn constrain_regions_in_type(
// (e.g., the `&` in `fn(&T)`). Such regions need not be
// constrained by `encl_region` as they are placeholders
// for regions that are as-yet-unknown.
ret;
return;
}
_ {}
}

View File

@@ -56,7 +56,7 @@ fn replace_bound_regions_in_fn_ty(
none { none }
};
ret {isr: isr,
return {isr: isr,
self_info: new_self_info,
fn_ty: alt check ty::get(t_fn).struct { ty::ty_fn(o) {o} }};
@@ -169,7 +169,7 @@ fn replace_bound_regions_in_fn_ty(
*/
fn region_of(fcx: @fn_ctxt, expr: @ast::expr) -> ty::region {
debug!{"region_of(expr=%s)", expr_to_str(expr)};
ret alt expr.node {
return alt expr.node {
ast::expr_path(path) {
def(fcx, expr, lookup_def(fcx, path.span, expr.id))}
ast::expr_field(base, _, _) {

View File

@@ -81,7 +81,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t,
debug!{"(checking vtable) @0 relating ty to trait ty
with did %?", idid};
relate_trait_tys(fcx, sp, trait_ty, ity);
ret vtable_param(n, n_bound);
return vtable_param(n, n_bound);
}
}
}
@@ -110,7 +110,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t,
}
}
}
ret vtable_trait(did, substs.tps);
return vtable_trait(did, substs.tps);
}
_ {
@@ -178,11 +178,11 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t,
alt found.len() {
0u { /* fallthrough */ }
1u { ret found[0]; }
1u { return found[0]; }
_ {
fcx.ccx.tcx.sess.span_err(
sp, ~"multiple applicable methods in scope");
ret found[0];
return found[0];
}
}
}

View File

@@ -9,9 +9,9 @@ export resolve_type_vars_in_expr;
fn resolve_type_vars_in_type(fcx: @fn_ctxt, sp: span, typ: ty::t) ->
option<ty::t> {
if !ty::type_needs_infer(typ) { ret some(typ); }
if !ty::type_needs_infer(typ) { return some(typ); }
alt resolve_type(fcx.infcx, typ, resolve_all | force_all) {
result::ok(new_type) { ret some(new_type); }
result::ok(new_type) { return some(new_type); }
result::err(e) {
if !fcx.ccx.tcx.sess.has_errors() {
fcx.ccx.tcx.sess.span_err(
@@ -20,7 +20,7 @@ fn resolve_type_vars_in_type(fcx: @fn_ctxt, sp: span, typ: ty::t) ->
for this expression: %s",
infer::fixup_err_to_str(e)})
}
ret none;
return none;
}
}
}
@@ -31,7 +31,7 @@ fn resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id)
alt resolve_type_vars_in_type(fcx, sp, n_ty) {
none {
wbcx.success = false;
ret none;
return none;
}
some(t) {
@@ -44,14 +44,14 @@ fn resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id)
for substs.tps.each |subst| {
alt resolve_type_vars_in_type(fcx, sp, subst) {
some(t) { vec::push(new_tps, t); }
none { wbcx.success = false; ret none; }
none { wbcx.success = false; return none; }
}
}
write_substs_to_tcx(tcx, id, new_tps);
}
none {}
}
ret some(t);
return some(t);
}
}
}
@@ -73,12 +73,12 @@ type wb_ctxt =
type wb_vt = visit::vt<wb_ctxt>;
fn visit_stmt(s: @ast::stmt, wbcx: wb_ctxt, v: wb_vt) {
if !wbcx.success { ret; }
if !wbcx.success { return; }
resolve_type_vars_for_node(wbcx, s.span, ty::stmt_node_id(s));
visit::visit_stmt(s, wbcx, v);
}
fn visit_expr(e: @ast::expr, wbcx: wb_ctxt, v: wb_vt) {
if !wbcx.success { ret; }
if !wbcx.success { return; }
resolve_type_vars_for_node(wbcx, e.span, e.id);
alt e.node {
ast::expr_fn(_, decl, _, _) |
@@ -113,12 +113,12 @@ fn visit_expr(e: @ast::expr, wbcx: wb_ctxt, v: wb_vt) {
visit::visit_expr(e, wbcx, v);
}
fn visit_block(b: ast::blk, wbcx: wb_ctxt, v: wb_vt) {
if !wbcx.success { ret; }
if !wbcx.success { return; }
resolve_type_vars_for_node(wbcx, b.span, b.node.id);
visit::visit_block(b, wbcx, v);
}
fn visit_pat(p: @ast::pat, wbcx: wb_ctxt, v: wb_vt) {
if !wbcx.success { ret; }
if !wbcx.success { return; }
resolve_type_vars_for_node(wbcx, p.span, p.id);
debug!{"Type for pattern binding %s (id %d) resolved to %s",
pat_to_str(p), p.id,
@@ -128,7 +128,7 @@ fn visit_pat(p: @ast::pat, wbcx: wb_ctxt, v: wb_vt) {
visit::visit_pat(p, wbcx, v);
}
fn visit_local(l: @ast::local, wbcx: wb_ctxt, v: wb_vt) {
if !wbcx.success { ret; }
if !wbcx.success { return; }
let var_id = lookup_local(wbcx.fcx, l.span, l.node.id);
let var_ty = ty::mk_var(wbcx.fcx.tcx(), var_id);
alt resolve_type(wbcx.fcx.infcx, var_ty, resolve_all | force_all) {
@@ -170,7 +170,7 @@ fn resolve_type_vars_in_expr(fcx: @fn_ctxt, e: @ast::expr) -> bool {
if wbcx.success {
infer::resolve_borrowings(fcx.infcx);
}
ret wbcx.success;
return wbcx.success;
}
fn resolve_type_vars_in_fn(fcx: @fn_ctxt,
@@ -185,5 +185,5 @@ fn resolve_type_vars_in_fn(fcx: @fn_ctxt,
if wbcx.success {
infer::resolve_borrowings(fcx.infcx);
}
ret wbcx.success;
return wbcx.success;
}

View File

@@ -90,14 +90,14 @@ fn get_base_type_def_id(inference_context: infer_ctxt,
alt get_base_type(inference_context, span, original_type) {
none {
ret none;
return none;
}
some(base_type) {
alt get(base_type).struct {
ty_enum(def_id, _) |
ty_class(def_id, _) |
ty_trait(def_id, _) {
ret some(def_id);
return some(def_id);
}
_ {
fail ~"get_base_type() returned a type that wasn't an \
@@ -319,7 +319,8 @@ class CoherenceChecker {
let monotype_a = self.universally_quantify_polytype(polytype_a);
let monotype_b = self.universally_quantify_polytype(polytype_b);
ret mk_subty(self.inference_context, monotype_a, monotype_b).is_ok()
return
mk_subty(self.inference_context, monotype_a, monotype_b).is_ok()
|| mk_subty(self.inference_context, monotype_b, monotype_a).is_ok();
}
@@ -341,13 +342,13 @@ class CoherenceChecker {
tps: type_parameters
};
ret subst(self.crate_context.tcx, substitutions, polytype.ty);
return subst(self.crate_context.tcx, substitutions, polytype.ty);
}
fn get_self_type_for_implementation(implementation: @Impl)
-> ty_param_bounds_and_ty {
ret self.crate_context.tcx.tcache.get(implementation.did);
return self.crate_context.tcx.tcache.get(implementation.did);
}
// Privileged scope checking
@@ -480,7 +481,7 @@ class CoherenceChecker {
}
}
ret results;
return results;
}
// Converts an implementation in the AST to an Impl structure.
@@ -497,7 +498,7 @@ class CoherenceChecker {
});
}
ret @{
return @{
did: local_def(item.id),
ident: item.ident,
methods: methods
@@ -521,7 +522,7 @@ class CoherenceChecker {
}
}
ret @{
return @{
did: local_def(item.id),
ident: item.ident,
methods: methods
@@ -539,7 +540,7 @@ class CoherenceChecker {
assert implementation.did.crate == local_crate;
alt self.crate_context.tcx.items.find(implementation.did.node) {
some(node_item(item, _)) {
ret item.span;
return item.span;
}
_ {
self.crate_context.tcx.sess.bug(~"span_of_impl() called on \

View File

@@ -190,7 +190,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span,
if impl_m.tps != if_m.tps {
tcx.sess.span_err(sp, ~"method `" + *if_m.ident +
~"` has an incompatible set of type parameters");
ret;
return;
}
if vec::len(impl_m.fty.inputs) != vec::len(if_m.fty.inputs) {
@@ -199,7 +199,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span,
*if_m.ident,
vec::len(impl_m.fty.inputs),
vec::len(if_m.fty.inputs)});
ret;
return;
}
// Perform substitutions so that the trait/impl methods are expressed
@@ -230,7 +230,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span,
require_same_types(
tcx, none, sp, impl_fty, if_fty,
|| ~"method `" + *if_m.ident + ~"` has an incompatible type");
ret;
return;
// Replaces bound references to the self region with `with_r`.
fn replace_bound_self(tcx: ty::ctxt, ty: ty::t,
@@ -485,7 +485,7 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item)
let def_id = local_def(it.id);
let tcx = ccx.tcx;
alt tcx.tcache.find(def_id) {
some(tpt) { ret tpt; }
some(tpt) { return tpt; }
_ {}
}
let rp = tcx.region_paramd_items.contains_key(it.id);
@@ -494,7 +494,7 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item)
let typ = ccx.to_ty(empty_rscope, t);
let tpt = no_params(typ);
tcx.tcache.insert(local_def(it.id), tpt);
ret tpt;
return tpt;
}
ast::item_fn(decl, tps, _) {
let bounds = ty_param_bounds(ccx, tps);
@@ -506,11 +506,11 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item)
debug!{"type of %s (id %d) is %s",
*it.ident, it.id, ty_to_str(tcx, tpt.ty)};
ccx.tcx.tcache.insert(local_def(it.id), tpt);
ret tpt;
return tpt;
}
ast::item_ty(t, tps) {
alt tcx.tcache.find(local_def(it.id)) {
some(tpt) { ret tpt; }
some(tpt) { return tpt; }
none { }
}
@@ -530,7 +530,7 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item)
};
tcx.tcache.insert(local_def(it.id), tpt);
ret tpt;
return tpt;
}
ast::item_enum(_, tps) {
// Create a new generic polytype.
@@ -538,21 +538,21 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item)
let t = ty::mk_enum(tcx, local_def(it.id), substs);
let tpt = {bounds: bounds, rp: rp, ty: t};
tcx.tcache.insert(local_def(it.id), tpt);
ret tpt;
return tpt;
}
ast::item_trait(tps, ms) {
let {bounds, substs} = mk_substs(ccx, tps, rp);
let t = ty::mk_trait(tcx, local_def(it.id), substs);
let tpt = {bounds: bounds, rp: rp, ty: t};
tcx.tcache.insert(local_def(it.id), tpt);
ret tpt;
return tpt;
}
ast::item_class(tps, _, _, _, _) {
let {bounds,substs} = mk_substs(ccx, tps, rp);
let t = ty::mk_class(tcx, local_def(it.id), substs);
let tpt = {bounds: bounds, rp: rp, ty: t};
tcx.tcache.insert(local_def(it.id), tpt);
ret tpt;
return tpt;
}
ast::item_impl(*) | ast::item_mod(_) |
ast::item_foreign_mod(_) { fail; }
@@ -564,7 +564,7 @@ fn ty_of_foreign_item(ccx: @crate_ctxt, it: @ast::foreign_item)
-> ty::ty_param_bounds_and_ty {
alt it.node {
ast::foreign_item_fn(fn_decl, params) {
ret ty_of_foreign_fn_decl(ccx, fn_decl, params,
return ty_of_foreign_fn_decl(ccx, fn_decl, params,
local_def(it.id));
}
}
@@ -627,7 +627,7 @@ fn ty_of_foreign_fn_decl(ccx: @crate_ctxt,
ret_style: ast::return_val});
let tpt = {bounds: bounds, rp: false, ty: t_fn};
ccx.tcx.tcache.insert(def_id, tpt);
ret tpt;
return tpt;
}
fn mk_ty_params(ccx: @crate_ctxt, atps: ~[ast::ty_param])

View File

@@ -233,17 +233,17 @@ fn single_type_contained_in(tcx: ty::ctxt, a: int_ty_set) ->
option<ty::t> {
debug!{"single_type_contained_in(a=%s)", uint::to_str(*a, 10u)};
if *a == INT_TY_SET_i8 { ret some(ty::mk_i8(tcx)); }
if *a == INT_TY_SET_u8 { ret some(ty::mk_u8(tcx)); }
if *a == INT_TY_SET_i16 { ret some(ty::mk_i16(tcx)); }
if *a == INT_TY_SET_u16 { ret some(ty::mk_u16(tcx)); }
if *a == INT_TY_SET_i32 { ret some(ty::mk_i32(tcx)); }
if *a == INT_TY_SET_u32 { ret some(ty::mk_u32(tcx)); }
if *a == INT_TY_SET_i64 { ret some(ty::mk_i64(tcx)); }
if *a == INT_TY_SET_u64 { ret some(ty::mk_u64(tcx)); }
if *a == INT_TY_SET_i { ret some(ty::mk_int(tcx)); }
if *a == INT_TY_SET_u { ret some(ty::mk_uint(tcx)); }
ret none;
if *a == INT_TY_SET_i8 { return some(ty::mk_i8(tcx)); }
if *a == INT_TY_SET_u8 { return some(ty::mk_u8(tcx)); }
if *a == INT_TY_SET_i16 { return some(ty::mk_i16(tcx)); }
if *a == INT_TY_SET_u16 { return some(ty::mk_u16(tcx)); }
if *a == INT_TY_SET_i32 { return some(ty::mk_i32(tcx)); }
if *a == INT_TY_SET_u32 { return some(ty::mk_u32(tcx)); }
if *a == INT_TY_SET_i64 { return some(ty::mk_i64(tcx)); }
if *a == INT_TY_SET_u64 { return some(ty::mk_u64(tcx)); }
if *a == INT_TY_SET_i { return some(ty::mk_int(tcx)); }
if *a == INT_TY_SET_u { return some(ty::mk_uint(tcx)); }
return none;
}
fn convert_integral_ty_to_int_ty_set(tcx: ty::ctxt, t: ty::t)
@@ -594,7 +594,7 @@ impl transaction_methods for infer_ctxt {
self.tvb.bindings = ~[];
self.rb.bindings = ~[];
ret r;
return r;
}
/// Execute `f`, unroll bindings on failure
@@ -615,7 +615,7 @@ impl transaction_methods for infer_ctxt {
while self.borrowings.len() != bl { self.borrowings.pop(); }
}
}
ret r;
return r;
}
/// Execute `f` then unroll any bindings it creates
@@ -625,7 +625,7 @@ impl transaction_methods for infer_ctxt {
let r <- f();
rollback_to(self.tvb, 0u);
rollback_to(self.rb, 0u);
ret r;
return r;
}
}
@@ -635,7 +635,7 @@ impl methods for infer_ctxt {
*self.ty_var_counter += 1u;
self.tvb.vals.insert(id,
root({lb: none, ub: none}, 0u));
ret tv_vid(id);
return tv_vid(id);
}
fn next_ty_var() -> ty::t {
@@ -652,7 +652,7 @@ impl methods for infer_ctxt {
self.tvib.vals.insert(id,
root(int_ty_set_all(), 0u));
ret tvi_vid(id);
return tvi_vid(id);
}
fn next_ty_var_integral() -> ty::t {
@@ -663,7 +663,7 @@ impl methods for infer_ctxt {
let id = *self.region_var_counter;
*self.region_var_counter += 1u;
self.rb.vals.insert(id, root(bnds, 0));
ret region_vid(id);
return region_vid(id);
}
fn next_region_var_with_scope_lb(scope_id: ast::node_id) -> ty::region {
@@ -686,15 +686,15 @@ impl methods for infer_ctxt {
fn resolve_type_vars_if_possible(typ: ty::t) -> ty::t {
alt resolve_type(self, typ, resolve_all) {
result::ok(new_type) { ret new_type; }
result::err(_) { ret typ; }
result::ok(new_type) { return new_type; }
result::err(_) { return typ; }
}
}
fn resolve_region_if_possible(oldr: ty::region) -> ty::region {
alt resolve_region(self, oldr, resolve_all) {
result::ok(newr) { ret newr; }
result::err(_) { ret oldr; }
result::ok(newr) { return newr; }
result::err(_) { return oldr; }
}
}
}
@@ -859,7 +859,7 @@ impl unify_methods for infer_ctxt {
a_id.to_str(), a_bounds.to_str(self),
b_id.to_str(), b_bounds.to_str(self)};
if a_id == b_id { ret uok(); }
if a_id == b_id { return uok(); }
// If both A's UB and B's LB have already been bound to types,
// see if we can make those types subtypes.
@@ -867,7 +867,7 @@ impl unify_methods for infer_ctxt {
(some(a_ub), some(b_lb)) {
let r = self.try(|| a_ub.sub(self, b_lb));
alt r {
ok(()) { ret result::ok(()); }
ok(()) { return result::ok(()); }
err(_) { /*fallthrough */ }
}
}
@@ -921,13 +921,13 @@ impl unify_methods for infer_ctxt {
// If we're already dealing with the same two variables,
// there's nothing to do.
if a_id == b_id { ret uok(); }
if a_id == b_id { return uok(); }
// Otherwise, take the intersection of the two sets of
// possible types.
let intersection = intersection(a_pt, b_pt);
if *intersection == INT_TY_SET_EMPTY {
ret err(ty::terr_no_integral_type);
return err(ty::terr_no_integral_type);
}
// Rank optimization
@@ -985,7 +985,7 @@ impl unify_methods for infer_ctxt {
intersection(a_pt, convert_integral_ty_to_int_ty_set(
self.tcx, b));
if *intersection == INT_TY_SET_EMPTY {
ret err(ty::terr_no_integral_type);
return err(ty::terr_no_integral_type);
}
self.set(vb, a_id, root(intersection, nde_a.rank));
uok()
@@ -1021,7 +1021,7 @@ impl unify_methods for infer_ctxt {
intersection(b_pt, convert_integral_ty_to_int_ty_set(
self.tcx, a));
if *intersection == INT_TY_SET_EMPTY {
ret err(ty::terr_no_integral_type);
return err(ty::terr_no_integral_type);
}
self.set(vb, b_id, root(intersection, nde_b.rank));
uok()
@@ -1156,9 +1156,9 @@ impl methods for resolve_state {
debug!{"Resolved to %s (modes=%x)",
ty_to_str(self.infcx.tcx, rty),
self.modes};
ret ok(rty);
return ok(rty);
}
some(e) { ret err(e); }
some(e) { return err(e); }
}
}
@@ -1174,7 +1174,7 @@ impl methods for resolve_state {
fn resolve_type(typ: ty::t) -> ty::t {
debug!{"resolve_type(%s)", typ.to_str(self.infcx)};
indent(fn&() -> ty::t {
if !ty::type_needs_infer(typ) { ret typ; }
if !ty::type_needs_infer(typ) { return typ; }
alt ty::get(typ).struct {
ty::ty_var(vid) {
@@ -1219,7 +1219,7 @@ impl methods for resolve_state {
fn resolve_region_var(rid: region_vid) -> ty::region {
if !self.should(resolve_rvar) {
ret ty::re_var(rid)
return ty::re_var(rid)
}
let nde = self.infcx.get(self.infcx.rb, rid);
let bounds = nde.possible_types;
@@ -1247,7 +1247,7 @@ impl methods for resolve_state {
fn resolve_ty_var(vid: tv_vid) -> ty::t {
if vec::contains(self.v_seen, vid) {
self.err = some(cyclic_ty(vid));
ret ty::mk_var(self.infcx.tcx, vid);
return ty::mk_var(self.infcx.tcx, vid);
} else {
vec::push(self.v_seen, vid);
let tcx = self.infcx.tcx;
@@ -1273,13 +1273,13 @@ impl methods for resolve_state {
}
};
vec::pop(self.v_seen);
ret t1;
return t1;
}
}
fn resolve_ty_var_integral(vid: tvi_vid) -> ty::t {
if !self.should(resolve_ivar) {
ret ty::mk_var_integral(self.infcx.tcx, vid);
return ty::mk_var_integral(self.infcx.tcx, vid);
}
let nde = self.infcx.get(self.infcx.tvib, vid);
@@ -1938,7 +1938,7 @@ impl of combine for sub {
debug!{"mts(%s <: %s)", a.to_str(*self), b.to_str(*self)};
if a.mutbl != b.mutbl && b.mutbl != m_const {
ret err(ty::terr_mutability);
return err(ty::terr_mutability);
}
alt b.mutbl {
@@ -1975,7 +1975,7 @@ impl of combine for sub {
fn tys(a: ty::t, b: ty::t) -> cres<ty::t> {
debug!{"%s.tys(%s, %s)", self.tag(),
a.to_str(*self), b.to_str(*self)};
if a == b { ret ok(a); }
if a == b { return ok(a); }
do indent {
alt (ty::get(a).struct, ty::get(b).struct) {
(ty::ty_bot, _) {
@@ -2146,7 +2146,7 @@ impl of combine for lub {
}
fn contraregions(a: ty::region, b: ty::region) -> cres<ty::region> {
ret glb(self.infcx()).regions(a, b);
return glb(self.infcx()).regions(a, b);
}
fn regions(a: ty::region, b: ty::region) -> cres<ty::region> {
@@ -2489,7 +2489,7 @@ fn lattice_tys<L:lattice_ops combine>(
debug!{"%s.lattice_tys(%s, %s)", self.tag(),
a.to_str(self.infcx()),
b.to_str(self.infcx())};
if a == b { ret ok(a); }
if a == b { return ok(a); }
do indent {
alt (ty::get(a).struct, ty::get(b).struct) {
(ty::ty_bot, _) { self.ty_bot(b) }
@@ -2568,7 +2568,7 @@ fn lattice_vars<V:copy vid, T:copy to_str st, L:lattice_ops combine>(
b_vid.to_str(), b_bounds.to_str(self.infcx())};
if a_vid == b_vid {
ret ok(a_t);
return ok(a_t);
}
// If both A and B have an UB type, then we can just compute the
@@ -2577,7 +2577,7 @@ fn lattice_vars<V:copy vid, T:copy to_str st, L:lattice_ops combine>(
alt (a_bnd, b_bnd) {
(some(a_ty), some(b_ty)) {
alt self.infcx().try(|| c_ts(a_ty, b_ty) ) {
ok(t) { ret ok(t); }
ok(t) { return ok(t); }
err(_) { /*fallthrough */ }
}
}
@@ -2610,7 +2610,7 @@ fn lattice_var_t<V:copy vid, T:copy to_str st, L:lattice_ops combine>(
some(a_bnd) {
// If a has an upper bound, return the LUB(a.ub, b)
debug!{"bnd=some(%s)", a_bnd.to_str(self.infcx())};
ret c_ts(a_bnd, b);
return c_ts(a_bnd, b);
}
none {
// If a does not have an upper bound, make b the upper bound of a

View File

@@ -11,7 +11,7 @@ fn indent<R>(op: fn() -> R) -> R {
debug!{">>"};
let r <- op();
debug!{"<< (Result = %?)", r};
ret r;
return r;
}
class _indenter {
@@ -27,12 +27,12 @@ fn indenter() -> _indenter {
type flag = hashmap<~str, ()>;
fn field_expr(f: ast::field) -> @ast::expr { ret f.node.expr; }
fn field_expr(f: ast::field) -> @ast::expr { return f.node.expr; }
fn field_exprs(fields: ~[ast::field]) -> ~[@ast::expr] {
let mut es = ~[];
for fields.each |f| { vec::push(es, f.node.expr); }
ret es;
return es;
}
// Takes a predicate p, returns true iff p is true for any subexpressions
@@ -52,7 +52,7 @@ fn loop_query(b: ast::blk, p: fn@(ast::expr_) -> bool) -> bool {
let v = visit::mk_vt(@{visit_expr: visit_expr
with *visit::default_visitor()});
visit::visit_block(b, rs, v);
ret *rs;
return *rs;
}
fn has_nonlocal_exits(b: ast::blk) -> bool {
@@ -68,7 +68,7 @@ fn may_break(b: ast::blk) -> bool {
}
fn local_rhs_span(l: @ast::local, def: span) -> span {
alt l.node.init { some(i) { ret i.expr.span; } _ { ret def; } }
alt l.node.init { some(i) { return i.expr.span; } _ { return def; } }
}
fn is_main_name(path: syntax::ast_map::path) -> bool {

View File

@@ -25,7 +25,7 @@ import driver::session::session;
/// that attempts to explain a lifetime in a way it might plausibly be
/// understood.
fn explain_region(cx: ctxt, region: ty::region) -> ~str {
ret alt region {
return alt region {
re_scope(node_id) => {
let scope_str = alt cx.items.find(node_id) {
some(ast_map::node_block(blk)) => {
@@ -167,7 +167,7 @@ fn mt_to_str(cx: ctxt, m: mt) -> ~str {
ast::m_imm { ~"" }
ast::m_const { ~"const " }
};
ret mstr + ty_to_str(cx, m.ty);
return mstr + ty_to_str(cx, m.ty);
}
fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str {
@@ -234,25 +234,25 @@ fn ty_to_str(cx: ctxt, typ: t) -> ~str {
ast::return_val { s += ty_to_str(cx, output); }
}
}
ret s;
return s;
}
fn method_to_str(cx: ctxt, m: method) -> ~str {
ret fn_to_str(
return fn_to_str(
cx, m.fty.purity, m.fty.proto, some(m.ident), m.fty.inputs,
m.fty.output, m.fty.ret_style) + ~";";
}
fn field_to_str(cx: ctxt, f: field) -> ~str {
ret *f.ident + ~": " + mt_to_str(cx, f.mt);
return *f.ident + ~": " + mt_to_str(cx, f.mt);
}
// if there is an id, print that instead of the structural type:
for ty::type_def_id(typ).each |def_id| {
// note that this typedef cannot have type parameters
ret ast_map::path_to_str(ty::item_path(cx, def_id));
return ast_map::path_to_str(ty::item_path(cx, def_id));
}
// pretty print the structural type representation:
ret alt ty::get(typ).struct {
return alt ty::get(typ).struct {
ty_nil { ~"()" }
ty_bot { ~"_|_" }
ty_bool { ~"bool" }
@@ -340,7 +340,7 @@ fn parameterized(cx: ctxt,
fn ty_to_short_str(cx: ctxt, typ: t) -> ~str {
let mut s = encoder::encoded_ty(cx, typ);
if str::len(s) >= 32u { s = str::slice(s, 0u, 32u); }
ret s;
return s;
}
// Local Variables: