librustc: Remove `fn@`, `fn~`, and `fn&` from librustc. rs=defun

This commit is contained in:
Patrick Walton 2013-03-01 12:11:07 -08:00
parent a3f728238b
commit 97fd421319
20 changed files with 58 additions and 52 deletions

View File

@ -253,9 +253,8 @@ pub mod core {
pub use cmp;
pub use condition;
pub use kinds;
pub use ops;
pub use option;
pub use kinds;
pub use sys;
pub use pipes;
}

View File

@ -15,7 +15,7 @@ use syntax::{ast, fold, attr};
use core::option;
use core::vec;
type in_cfg_pred = fn@(+attrs: ~[ast::attribute]) -> bool;
type in_cfg_pred = @fn(+attrs: ~[ast::attribute]) -> bool;
struct Context {
in_cfg: in_cfg_pred

View File

@ -29,7 +29,7 @@ use syntax::fold;
use syntax::print::pprust;
use syntax::{ast, ast_util};
type node_id_gen = fn@() -> ast::node_id;
type node_id_gen = @fn() -> ast::node_id;
struct Test {
span: span,

View File

@ -57,7 +57,7 @@ use writer = std::ebml::writer;
// used by astencode:
type abbrev_map = oldmap::HashMap<ty::t, tyencode::ty_abbrev>;
pub type encode_inlined_item = fn@(ecx: @EncodeContext,
pub type encode_inlined_item = @fn(ecx: @EncodeContext,
ebml_w: writer::Encoder,
path: &[ast_map::path_elt],
ii: ast::inlined_item);

View File

@ -81,7 +81,7 @@ pub fn parse_ident(st: @mut PState, last: char) -> ast::ident {
return parse_ident_(st, |a| is_last(last, a) );
}
fn parse_ident_(st: @mut PState, is_last: fn@(char) -> bool) ->
fn parse_ident_(st: @mut PState, is_last: @fn(char) -> bool) ->
ast::ident {
let mut rslt = ~"";
while !is_last(peek(st)) {

View File

@ -29,10 +29,10 @@ use middle::ty::Vid;
pub struct ctxt {
diag: span_handler,
// Def -> str Callback:
ds: fn@(def_id) -> ~str,
ds: @fn(def_id) -> ~str,
// The type context.
tcx: ty::ctxt,
reachable: fn@(node_id) -> bool,
reachable: @fn(node_id) -> bool,
abbrevs: abbrev_ctxt
}

View File

@ -843,7 +843,7 @@ fn encode_side_tables_for_ii(ecx: @e::EncodeContext,
let ebml_w = copy ebml_w;
ast_util::visit_ids_for_inlined_item(
ii,
fn@(id: ast::node_id) {
|id: ast::node_id| {
// Note: this will cause a copy of ebml_w, which is bad as
// it has mut fields. But I believe it's harmless since
// we generate balanced EBML.

View File

@ -251,7 +251,7 @@ fn req_loans_in_expr(ex: @ast::expr,
// Receivers in method calls are always passed by ref.
//
// Here, the field a.b is in fact a closure. Eventually, this
// should be an fn&, but for now it's an fn@. In any case,
// should be an &fn, but for now it's an @fn. In any case,
// the enclosing scope is either the call where it is a rcvr
// (if used like `a.b(...)`), the call where it's an argument
// (if used like `x(a.b)`), or the block (if used like `let x

View File

@ -46,7 +46,8 @@ fn collect_freevars(def_map: resolve::DefMap, blk: &ast::blk)
fn ignore_item(_i: @ast::item, &&_depth: int, _v: visit::vt<int>) { }
let walk_expr = fn@(expr: @ast::expr, &&depth: int, v: visit::vt<int>) {
let walk_expr: @fn(expr: @ast::expr, &&depth: int, v: visit::vt<int>) =
|expr, depth, v| {
match expr.node {
ast::expr_fn(_, _, _, _) => {
visit::visit_expr(expr, depth + 1, v);
@ -100,8 +101,11 @@ pub fn annotate_freevars(def_map: resolve::DefMap, crate: @ast::crate) ->
freevar_map {
let freevars = HashMap();
let walk_fn = fn@(_fk: &visit::fn_kind, _decl: &ast::fn_decl,
blk: &ast::blk, _sp: span, nid: ast::node_id) {
let walk_fn: @fn(&visit::fn_kind,
&ast::fn_decl,
&ast::blk,
span,
ast::node_id) = |_, _, blk, _, nid| {
let vars = collect_freevars(def_map, blk);
freevars.insert(nid, vars);
};

View File

@ -84,7 +84,7 @@ pub fn check_crate(tcx: ty::ctxt,
visit_expr: check_expr,
visit_fn: check_fn,
visit_ty: check_ty,
visit_item: fn@(i: @item, cx: Context, v: visit::vt<Context>) {
visit_item: |i, cx, v| {
visit::visit_item(i, Context { current_item: i.id,.. cx }, v);
},
.. *visit::default_visitor()
@ -93,7 +93,7 @@ pub fn check_crate(tcx: ty::ctxt,
tcx.sess.abort_if_errors();
}
type check_fn = fn@(Context, @freevar_entry);
type check_fn = @fn(Context, @freevar_entry);
// Yields the appropriate function to check the kind of closed over
// variables. `id` is the node_id for some expression that creates the

View File

@ -1003,7 +1003,7 @@ pub fn any_tuple_struct_pat(bcx: block, m: &[@Match], col: uint) -> bool {
})
}
pub type mk_fail = fn@() -> BasicBlockRef;
pub type mk_fail = @fn() -> BasicBlockRef;
pub fn pick_col(m: &[@Match]) -> uint {
fn score(p: @ast::pat) -> uint {

View File

@ -634,8 +634,8 @@ pub fn compare_scalar_values(cx: block,
}
}
pub type val_pair_fn = fn@(block, ValueRef, ValueRef) -> block;
pub type val_and_ty_fn = fn@(block, ValueRef, ty::t) -> block;
pub type val_pair_fn = @fn(block, ValueRef, ValueRef) -> block;
pub type val_and_ty_fn = @fn(block, ValueRef, ty::t) -> block;
pub fn load_inbounds(cx: block, p: ValueRef, idxs: &[uint]) -> ValueRef {
return Load(cx, GEPi(cx, p, idxs));

View File

@ -42,7 +42,7 @@ use syntax::print::pprust::expr_to_str;
// roughly as follows:
//
// struct rust_opaque_box { // see rust_internal.h
// unsigned ref_count; // only used for fn@()
// unsigned ref_count; // only used for @fn()
// type_desc *tydesc; // describes closure_data struct
// rust_opaque_box *prev; // (used internally by memory alloc)
// rust_opaque_box *next; // (used internally by memory alloc)
@ -57,7 +57,7 @@ use syntax::print::pprust::expr_to_str;
// };
//
// Note that the closure is itself a rust_opaque_box. This is true
// even for fn~ and fn&, because we wish to keep binary compatibility
// even for ~fn and &fn, because we wish to keep binary compatibility
// between all kinds of closures. The allocation strategy for this
// closure depends on the closure type. For a sendfn, the closure
// (and the referenced type descriptors) will be allocated in the
@ -440,11 +440,10 @@ pub fn trans_expr_fn(bcx: block,
}
pub fn make_closure_glue(
cx: block,
v: ValueRef,
t: ty::t,
glue_fn: fn@(block, v: ValueRef, t: ty::t) -> block) -> block
{
cx: block,
v: ValueRef,
t: ty::t,
glue_fn: @fn(block, v: ValueRef, t: ty::t) -> block) -> block {
let _icx = cx.insn_ctxt("closure::make_closure_glue");
let bcx = cx;
let tcx = cx.tcx();
@ -483,7 +482,7 @@ pub fn make_opaque_cbox_take_glue(
}
}
// fn~ requires a deep copy.
// ~fn requires a deep copy.
let ccx = bcx.ccx(), tcx = ccx.tcx;
let llopaquecboxty = T_opaque_box_ptr(ccx);
let cbox_in = Load(bcx, cboxptr);

View File

@ -61,14 +61,15 @@ use syntax::parse::token::ident_interner;
use syntax::print::pprust::expr_to_str;
use syntax::{ast, ast_map};
pub type namegen = fn@(~str) -> ident;
pub type namegen = @fn(~str) -> ident;
pub fn new_namegen(intr: @ident_interner) -> namegen {
return fn@(prefix: ~str) -> ident {
let f: @fn(~str) -> ident = |prefix| {
// XXX: Bad copies.
return intr.gensym(@fmt!("%s_%u",
prefix,
intr.gensym(@copy prefix).repr))
intr.gensym(@fmt!("%s_%u",
prefix,
intr.gensym(@copy prefix).repr))
};
f
}
pub type addrspace = c_uint;
@ -81,10 +82,11 @@ pub type addrspace = c_uint;
pub const default_addrspace: addrspace = 0;
pub const gc_box_addrspace: addrspace = 1;
pub type addrspace_gen = fn@() -> addrspace;
pub type addrspace_gen = @fn() -> addrspace;
pub fn new_addrspace_gen() -> addrspace_gen {
let i = @mut 1;
return fn@() -> addrspace { *i += 1; *i };
let result: addrspace_gen = || { *i += 1; *i };
result
}
pub struct tydesc_info {
@ -349,8 +351,8 @@ pub enum cleantype {
}
pub enum cleanup {
clean(fn@(block) -> block, cleantype),
clean_temp(ValueRef, fn@(block) -> block, cleantype),
clean(@fn(block) -> block, cleantype),
clean_temp(ValueRef, @fn(block) -> block, cleantype),
}
// Used to remember and reuse existing cleanup paths
@ -1034,7 +1036,7 @@ pub fn T_typaram_ptr(tn: @TypeNames) -> TypeRef {
}
pub fn T_opaque_cbox_ptr(cx: @CrateContext) -> TypeRef {
// closures look like boxes (even when they are fn~ or fn&)
// closures look like boxes (even when they are ~fn or &fn)
// see trans_closure.rs
return T_opaque_box_ptr(cx);
}

View File

@ -709,7 +709,7 @@ pub fn declare_tydesc(ccx: @CrateContext, t: ty::t) -> @mut tydesc_info {
return inf;
}
pub type glue_helper = fn@(block, ValueRef, ty::t);
pub type glue_helper = @fn(block, ValueRef, ty::t);
pub fn declare_generic_glue(ccx: @CrateContext, t: ty::t, llfnty: TypeRef,
+name: ~str) -> ValueRef {

View File

@ -520,9 +520,9 @@ pub fn get_base_and_len(bcx: block,
}
}
pub type val_and_ty_fn = fn@(block, ValueRef, ty::t) -> Result;
pub type val_and_ty_fn = @fn(block, ValueRef, ty::t) -> Result;
pub type iter_vec_block = fn(block, ValueRef, ty::t) -> block;
pub type iter_vec_block = &fn(block, ValueRef, ty::t) -> block;
pub fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t,
fill: ValueRef, f: iter_vec_block) -> block {

View File

@ -525,7 +525,7 @@ pub enum sty {
// "Fake" types, used for trans purposes
ty_type, // type_desc*
ty_opaque_box, // used by monomorphizer to represent any @ box
ty_opaque_closure_ptr(Sigil), // ptr to env for fn, fn@, fn~
ty_opaque_closure_ptr(Sigil), // ptr to env for &fn, @fn, ~fn
ty_unboxed_vec(mt),
}
@ -1102,8 +1102,8 @@ pub pure fn mach_sty(cfg: @session::config, t: t) -> sty {
}
pub fn default_arg_mode_for_ty(tcx: ctxt, ty: ty::t) -> ast::rmode {
// FIXME(#2202) --- We retain by-ref for fn& things to workaround a
// memory leak that otherwise results when @fn is upcast to &fn.
// FIXME(#2202) --- We retain by-ref for &fn things to workaround a
// memory leak that otherwise results when @fn is upcast to &fn.
match ty::get(ty).sty {
ty::ty_closure(ClosureTy {sigil: ast::BorrowedSigil, _}) => {
return ast::by_ref;

View File

@ -389,7 +389,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
self_info: Option<SelfInfo>) {
let tcx = fcx.ccx.tcx;
let assign = fn@(nid: ast::node_id, ty_opt: Option<ty::t>) {
let assign: @fn(ast::node_id, Option<ty::t>) = |nid, ty_opt| {
match ty_opt {
None => {
// infer the variable's type
@ -432,8 +432,8 @@ pub fn check_fn(ccx: @mut CrateCtxt,
}
// Add explicitly-declared locals.
let visit_local = fn@(local: @ast::local,
&&e: (), v: visit::vt<()>) {
let visit_local: @fn(@ast::local, &&e: (), visit::vt<()>) =
|local, e, v| {
let o_ty = match local.node.ty.node {
ast::ty_infer => None,
_ => Some(fcx.to_ty(local.node.ty))
@ -447,7 +447,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
};
// Add pattern bindings.
let visit_pat = fn@(p: @ast::pat, &&e: (), v: visit::vt<()>) {
let visit_pat: @fn(@ast::pat, &&e: (), visit::vt<()>) = |p, e, v| {
match p.node {
ast::pat_ident(_, path, _)
if pat_util::pat_is_binding(fcx.ccx.tcx.def_map, p) => {
@ -462,7 +462,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
visit::visit_pat(p, e, v);
};
let visit_block = fn@(b: &ast::blk, &&e: (), v: visit::vt<()>) {
let visit_block: @fn(&ast::blk, &&e: (), visit::vt<()>) = |b, e, v| {
// non-obvious: the `blk` variable maps to region lb, so
// we have to keep this up-to-date. This
// is... unfortunate. It'd be nice to not need this.

View File

@ -315,7 +315,7 @@ diagnostic emitter which records when we hit a fatal error. If the task
fails without recording a fatal error then we've encountered a compiler
bug and need to present an error.
*/
pub fn monitor(+f: fn~(diagnostic::Emitter)) {
pub fn monitor(+f: ~fn(diagnostic::Emitter)) {
use core::cell::Cell;
use core::comm::*;
let (p, ch) = stream();
@ -326,8 +326,10 @@ pub fn monitor(+f: fn~(diagnostic::Emitter)) {
let ch_capture = ch.clone();
// The 'diagnostics emitter'. Every error, warning, etc. should
// go through this function.
let demitter = fn@(cmsp: Option<(@codemap::CodeMap, codemap::span)>,
msg: &str, lvl: diagnostic::level) {
let demitter: @fn(Option<(@codemap::CodeMap, codemap::span)>,
&str,
diagnostic::level) =
|cmsp, msg, lvl| {
if lvl == diagnostic::fatal {
ch_capture.send(fatal);
}

View File

@ -59,7 +59,7 @@ pub fn field_exprs(fields: ~[ast::field]) -> ~[@ast::expr] {
// Takes a predicate p, returns true iff p is true for any subexpressions
// of b -- skipping any inner loops (loop, while, loop_body)
pub fn loop_query(b: &ast::blk, p: fn@(ast::expr_) -> bool) -> bool {
pub fn loop_query(b: &ast::blk, p: @fn(ast::expr_) -> bool) -> bool {
let rs = @mut false;
let visit_expr: @fn(@ast::expr,
&&flag: @mut bool,
@ -82,7 +82,7 @@ pub fn loop_query(b: &ast::blk, p: fn@(ast::expr_) -> bool) -> bool {
// Takes a predicate p, returns true iff p is true for any subexpressions
// of b -- skipping any inner loops (loop, while, loop_body)
pub fn block_query(b: &ast::blk, p: fn@(@ast::expr) -> bool) -> bool {
pub fn block_query(b: &ast::blk, p: @fn(@ast::expr) -> bool) -> bool {
let rs = @mut false;
let visit_expr: @fn(@ast::expr,
&&flag: @mut bool,