diff options
| author | Graydon Hoare <graydon@mozilla.com> | 2012-01-09 16:12:37 -0800 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2012-01-09 16:12:48 -0800 |
| commit | 8387896ddaa5fbe2ba39b9ad06fd02e1bfcb76e7 (patch) | |
| tree | d326dd79d45136f7cd2960491e89607d671172e5 /src/comp | |
| parent | f6ecbe88ca67769ccb9def337ada9ae25235e00e (diff) | |
| download | rust-8387896ddaa5fbe2ba39b9ad06fd02e1bfcb76e7.tar.gz rust-8387896ddaa5fbe2ba39b9ad06fd02e1bfcb76e7.zip | |
Remove proto_sugar and 'lambda' as keyword, commit to fn@.
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/metadata/tydecode.rs | 2 | ||||
| -rw-r--r-- | src/comp/metadata/tyencode.rs | 2 | ||||
| -rw-r--r-- | src/comp/middle/capture.rs | 10 | ||||
| -rw-r--r-- | src/comp/middle/freevars.rs | 4 | ||||
| -rw-r--r-- | src/comp/middle/kind.rs | 4 | ||||
| -rw-r--r-- | src/comp/middle/trans_closure.rs | 10 | ||||
| -rw-r--r-- | src/comp/middle/tstate/pre_post_conditions.rs | 2 | ||||
| -rw-r--r-- | src/comp/middle/ty.rs | 7 | ||||
| -rw-r--r-- | src/comp/middle/typeck.rs | 22 | ||||
| -rw-r--r-- | src/comp/syntax/ast.rs | 7 | ||||
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 12 | ||||
| -rw-r--r-- | src/comp/syntax/print/pprust.rs | 3 | ||||
| -rw-r--r-- | src/comp/syntax/visit.rs | 2 |
13 files changed, 40 insertions, 47 deletions
diff --git a/src/comp/metadata/tydecode.rs b/src/comp/metadata/tydecode.rs index ae65c284fc2..fae174ad113 100644 --- a/src/comp/metadata/tydecode.rs +++ b/src/comp/metadata/tydecode.rs @@ -234,7 +234,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { ret parse_ty_rust_fn(st, conv, ast::proto_send); } 'F' { - ret parse_ty_rust_fn(st, conv, ast::proto_shared(ast::sugar_normal)); + ret parse_ty_rust_fn(st, conv, ast::proto_shared); } 'f' { ret parse_ty_rust_fn(st, conv, ast::proto_bare); diff --git a/src/comp/metadata/tyencode.rs b/src/comp/metadata/tyencode.rs index f5c4c91d0ac..2260ea63206 100644 --- a/src/comp/metadata/tyencode.rs +++ b/src/comp/metadata/tyencode.rs @@ -203,7 +203,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { fn enc_proto(w: io::writer, proto: proto) { alt proto { proto_send. { w.write_char('s'); } - proto_shared(_) { w.write_char('F'); } + proto_shared. { w.write_char('F'); } proto_block. { w.write_char('B'); } proto_bare. { w.write_char('f'); } } diff --git a/src/comp/middle/capture.rs b/src/comp/middle/capture.rs index 0dd1956ff41..c34450fa528 100644 --- a/src/comp/middle/capture.rs +++ b/src/comp/middle/capture.rs @@ -34,7 +34,7 @@ fn check_capture_clause(tcx: ty::ctxt, let freevars = freevars::get_freevars(tcx, fn_expr_id); let seen_defs = map::new_int_hash(); - let check_capture_item = lambda(&&cap_item: @ast::capture_item) { + let check_capture_item = fn@(&&cap_item: @ast::capture_item) { let cap_def = tcx.def_map.get(cap_item.id); if !vec::any(*freevars, {|fv| fv.def == cap_def}) { tcx.sess.span_warn( @@ -52,7 +52,7 @@ fn check_capture_clause(tcx: ty::ctxt, } }; - let check_not_upvar = lambda(&&cap_item: @ast::capture_item) { + let check_not_upvar = fn@(&&cap_item: @ast::capture_item) { alt tcx.def_map.get(cap_item.id) { ast::def_upvar(_, _, _) { tcx.sess.span_err( @@ -64,7 +64,7 @@ fn check_capture_clause(tcx: ty::ctxt, } }; - let check_block_captures = lambda(v: [@ast::capture_item]) { + let check_block_captures = fn@(v: [@ast::capture_item]) { if check vec::is_not_empty(v) { let cap_item0 = vec::head(v); tcx.sess.span_err( @@ -78,7 +78,7 @@ fn check_capture_clause(tcx: ty::ctxt, check_block_captures(cap_clause.copies); check_block_captures(cap_clause.moves); } - ast::proto_bare. | ast::proto_shared(_) | ast::proto_send. { + ast::proto_bare. | ast::proto_shared. | ast::proto_send. { vec::iter(cap_clause.copies, check_capture_item); vec::iter(cap_clause.moves, check_capture_item); vec::iter(cap_clause.moves, check_not_upvar); @@ -113,7 +113,7 @@ fn compute_capture_vars(tcx: ty::ctxt, let implicit_mode = alt fn_proto { ast::proto_block. { cap_ref } - ast::proto_bare. | ast::proto_shared(_) | ast::proto_send. { cap_copy } + ast::proto_bare. | ast::proto_shared. | ast::proto_send. { cap_copy } }; vec::iter(*freevars) { |fvar| diff --git a/src/comp/middle/freevars.rs b/src/comp/middle/freevars.rs index 46ceb4257ff..e1d481ca5c5 100644 --- a/src/comp/middle/freevars.rs +++ b/src/comp/middle/freevars.rs @@ -37,7 +37,7 @@ fn collect_freevars(def_map: resolve::def_map, blk: ast::blk) fn ignore_item(_i: @ast::item, &&_depth: int, _v: visit::vt<int>) { } let walk_expr = - lambda (expr: @ast::expr, &&depth: int, v: visit::vt<int>) { + fn@ (expr: @ast::expr, &&depth: int, v: visit::vt<int>) { alt expr.node { ast::expr_fn(proto, decl, _, captures) { if proto != ast::proto_bare { @@ -89,7 +89,7 @@ fn annotate_freevars(def_map: resolve::def_map, crate: @ast::crate) -> freevar_map { let freevars = new_int_hash(); - let walk_fn = lambda (_fk: visit::fn_kind, _decl: ast::fn_decl, + let walk_fn = fn@ (_fk: visit::fn_kind, _decl: ast::fn_decl, blk: ast::blk, _sp: span, nid: ast::node_id) { let vars = collect_freevars(def_map, blk); freevars.insert(nid, vars); diff --git a/src/comp/middle/kind.rs b/src/comp/middle/kind.rs index 2e3060b2c2b..85ea75a95ec 100644 --- a/src/comp/middle/kind.rs +++ b/src/comp/middle/kind.rs @@ -61,7 +61,7 @@ fn with_appropriate_checker(cx: ctx, id: node_id, let fty = ty::node_id_to_monotype(cx.tcx, id); alt ty::ty_fn_proto(cx.tcx, fty) { proto_send. { b(check_send); } - proto_shared(_) { b(check_copy); } + proto_shared. { b(check_copy); } proto_block. { /* no check needed */ } proto_bare. { b(check_none); } } @@ -106,7 +106,7 @@ fn check_fn_cap_clause(cx: ctx, }); //log("freevar_ids", freevar_ids); with_appropriate_checker(cx, id) { |checker| - let check_var = lambda(&&cap_item: @capture_item) { + let check_var = fn@(&&cap_item: @capture_item) { let cap_def = cx.tcx.def_map.get(cap_item.id); let cap_def_id = ast_util::def_id_of_def(cap_def).node; if !vec::member(cap_def_id, freevar_ids) { diff --git a/src/comp/middle/trans_closure.rs b/src/comp/middle/trans_closure.rs index dd343e14b4f..5cbd72c4bef 100644 --- a/src/comp/middle/trans_closure.rs +++ b/src/comp/middle/trans_closure.rs @@ -208,7 +208,7 @@ fn allocate_cbox(bcx: @block_ctxt, let ccx = bcx_ccx(bcx); - let alloc_in_heap = lambda(bcx: @block_ctxt, + let alloc_in_heap = fn@(bcx: @block_ctxt, xchgheap: bool, &temp_cleanups: [ValueRef]) -> (@block_ctxt, ValueRef) { @@ -520,7 +520,7 @@ fn trans_expr_fn(bcx: @block_ctxt, let llfn = decl_internal_cdecl_fn(ccx.llmod, s, llfnty); register_fn(ccx, sp, sub_cx.path, "anon fn", [], id); - let trans_closure_env = lambda(ck: ty::closure_kind) -> ValueRef { + let trans_closure_env = fn@(ck: ty::closure_kind) -> ValueRef { let cap_vars = capture::compute_capture_vars( ccx.tcx, id, proto, cap_clause); let {llbox, cboxptr_ty, bcx} = build_closure(bcx, cap_vars, ck); @@ -532,7 +532,7 @@ fn trans_expr_fn(bcx: @block_ctxt, let closure = alt proto { ast::proto_block. { trans_closure_env(ty::closure_block) } - ast::proto_shared(_) { trans_closure_env(ty::closure_shared) } + ast::proto_shared. { trans_closure_env(ty::closure_shared) } ast::proto_send. { trans_closure_env(ty::closure_send) } ast::proto_bare. { let closure = C_null(T_opaque_cbox_ptr(ccx)); @@ -660,7 +660,7 @@ fn make_fn_glue( let bcx = cx; let tcx = bcx_tcx(cx); - let fn_env = lambda(ck: ty::closure_kind) -> @block_ctxt { + let fn_env = fn@(ck: ty::closure_kind) -> @block_ctxt { let box_cell_v = GEPi(cx, v, [0, abi::fn_field_box]); let box_ptr_v = Load(cx, box_cell_v); make_null_test(cx, box_ptr_v) {|bcx| @@ -675,7 +675,7 @@ fn make_fn_glue( ty::ty_fn({proto: ast::proto_send., _}) { fn_env(ty::closure_send) } - ty::ty_fn({proto: ast::proto_shared(_), _}) { + ty::ty_fn({proto: ast::proto_shared., _}) { fn_env(ty::closure_shared) } _ { fail "make_fn_glue invoked on non-function type" } diff --git a/src/comp/middle/tstate/pre_post_conditions.rs b/src/comp/middle/tstate/pre_post_conditions.rs index 89d18ca2c2d..e4d00120aac 100644 --- a/src/comp/middle/tstate/pre_post_conditions.rs +++ b/src/comp/middle/tstate/pre_post_conditions.rs @@ -348,7 +348,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { expr_fn(_, _, _, cap_clause) { find_pre_post_expr_fn_upvars(fcx, e); - let use_cap_item = lambda(&&cap_item: @capture_item) { + let use_cap_item = fn@(&&cap_item: @capture_item) { let d = local_node_id_to_local_def_id(fcx, cap_item.id); option::may(d, { |id| use_var(fcx, id) }); }; diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index 84db898d21e..f1a1858267a 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -1020,7 +1020,7 @@ pure fn kind_can_be_sent(k: kind) -> bool { fn proto_kind(p: proto) -> kind { alt p { ast::proto_block. { kind_noncopyable } - ast::proto_shared(_) { kind_copyable } + ast::proto_shared. { kind_copyable } ast::proto_send. { kind_sendable } ast::proto_bare. { kind_sendable } } @@ -1563,7 +1563,7 @@ fn ty_fn_proto(cx: ctxt, fty: t) -> ast::proto { ty::ty_fn(f) { ret f.proto; } ty::ty_native_fn(_, _) { // FIXME: This should probably be proto_bare - ret ast::proto_shared(ast::sugar_normal); + ret ast::proto_shared; } _ { cx.sess.bug("ty_fn_proto() called on non-fn type"); } } @@ -1947,8 +1947,7 @@ mod unify { (_, ast::proto_block.) { true } (ast::proto_bare., _) { true } - // Equal prototypes (modulo sugar) are always subprotos: - (ast::proto_shared(_), ast::proto_shared(_)) { true } + // Equal prototypes are always subprotos: (_, _) { p_sub == p_sup } }; } diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index ee97ce4a15f..c55d26ce81c 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -553,7 +553,7 @@ fn ty_of_obj_ctor(tcx: ty::ctxt, mode: mode, id: ast::ident, ob: ast::_obj, let t_field = ast_ty_to_ty(tcx, mode, f.ty); t_inputs += [{mode: ast::by_copy, ty: t_field}]; } - let t_fn = ty::mk_fn(tcx, {proto: ast::proto_shared(ast::sugar_normal), + let t_fn = ty::mk_fn(tcx, {proto: ast::proto_shared, inputs: t_inputs, output: t_obj.ty, ret_style: ast::return_val, constraints: []}); let tpt = {bounds: ty_param_bounds(tcx, mode, ty_params), ty: t_fn}; @@ -697,7 +697,7 @@ mod collect { } // FIXME: this will be different for constrained types ty::mk_fn(cx.tcx, - {proto: ast::proto_shared(ast::sugar_normal), + {proto: ast::proto_shared, inputs: args, output: tag_ty, ret_style: ast::return_val, constraints: []}) }; @@ -799,13 +799,13 @@ mod collect { let t_res = ty::mk_res(cx.tcx, local_def(it.id), t_arg.ty, params); let t_ctor = ty::mk_fn(cx.tcx, { - proto: ast::proto_shared(ast::sugar_normal), + proto: ast::proto_shared, inputs: [{mode: ast::by_copy with t_arg}], output: t_res, ret_style: ast::return_val, constraints: [] }); let t_dtor = ty::mk_fn(cx.tcx, { - proto: ast::proto_shared(ast::sugar_normal), + proto: ast::proto_shared, inputs: [t_arg], output: ty::mk_nil(cx.tcx), ret_style: ast::return_val, constraints: [] }); @@ -1172,9 +1172,9 @@ fn gather_locals(ccx: @crate_ctxt, }; let tcx = ccx.tcx; - let next_var_id = lambda () -> int { let rv = *nvi; *nvi += 1; ret rv; }; + let next_var_id = fn@ () -> int { let rv = *nvi; *nvi += 1; ret rv; }; let assign = - lambda (nid: ast::node_id, ty_opt: option::t<ty::t>) { + fn@ (nid: ast::node_id, ty_opt: option::t<ty::t>) { let var_id = next_var_id(); locals.insert(nid, var_id); alt ty_opt { @@ -1206,7 +1206,7 @@ fn gather_locals(ccx: @crate_ctxt, // Add explicitly-declared locals. let visit_local = - lambda (local: @ast::local, &&e: (), v: visit::vt<()>) { + fn@ (local: @ast::local, &&e: (), v: visit::vt<()>) { let local_ty = ast_ty_to_ty_crate_infer(ccx, local.node.ty); assign(local.node.id, local_ty); visit::visit_local(local, e, v); @@ -1214,7 +1214,7 @@ fn gather_locals(ccx: @crate_ctxt, // Add pattern bindings. let visit_pat = - lambda (p: @ast::pat, &&e: (), v: visit::vt<()>) { + fn@ (p: @ast::pat, &&e: (), v: visit::vt<()>) { alt p.node { ast::pat_bind(_, _) { assign(p.id, none); } _ {/* no-op */ } @@ -1726,7 +1726,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier, // of arguments when we typecheck the functions. This isn't really the // right way to do this. let check_args = - lambda (check_blocks: bool) -> bool { + fn@ (check_blocks: bool) -> bool { let i = 0u; let bot = false; for a_opt: option::t<@ast::expr> in args { @@ -2179,7 +2179,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier, fn lower_bound_proto(proto: ast::proto) -> ast::proto { // FIXME: This is right for bare fns, possibly not others alt proto { - ast::proto_bare. { ast::proto_shared(ast::sugar_normal) } + ast::proto_bare. { ast::proto_shared } _ { proto } } } @@ -2632,7 +2632,7 @@ fn check_const(ccx: @crate_ctxt, _sp: span, e: @ast::expr, id: ast::node_id) { let fcx: @fn_ctxt = @{ret_ty: rty, purity: ast::pure_fn, - proto: ast::proto_shared(ast::sugar_normal), + proto: ast::proto_shared, var_bindings: ty::unify::mk_var_bindings(), locals: new_int_hash::<int>(), next_var_id: @mutable 0, diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs index c5e9a13616f..1acbabd65f9 100644 --- a/src/comp/syntax/ast.rs +++ b/src/comp/syntax/ast.rs @@ -110,15 +110,10 @@ tag pat_ { tag mutability { mut; imm; maybe_mut; } -tag proto_sugar { - sugar_normal; - sugar_sexy; -} - tag proto { proto_bare; proto_send; - proto_shared(proto_sugar); + proto_shared; proto_block; } diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 2b45115f5b9..2eeb5cbf136 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -168,7 +168,7 @@ fn bad_expr_word_table() -> hashmap<str, ()> { let words = new_str_hash(); for word in ["mod", "if", "else", "while", "do", "alt", "for", "break", "cont", "ret", "be", "fail", "type", "resource", "check", - "assert", "claim", "native", "fn", "lambda", "pure", + "assert", "claim", "native", "fn", "fn@", "pure", "unsafe", "block", "import", "export", "let", "const", "log", "tag", "obj", "copy", "sendfn", "impl", "iface"] { words.insert(word, ()); @@ -514,8 +514,8 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty { t = parse_ty_fn(proto, p); } else if eat_word(p, "block") { t = parse_ty_fn(ast::proto_block, p); - } else if eat_word(p, "lambda") { - t = parse_ty_fn(ast::proto_shared(ast::sugar_sexy), p); + } else if eat_word(p, "fn@") { + t = parse_ty_fn(ast::proto_shared, p); } else if eat_word(p, "sendfn") { t = parse_ty_fn(ast::proto_send, p); } else if eat_word(p, "obj") { @@ -821,8 +821,8 @@ fn parse_bottom_expr(p: parser) -> pexpr { ret pexpr(parse_fn_expr(p, proto)); } else if eat_word(p, "block") { ret pexpr(parse_fn_expr(p, ast::proto_block)); - } else if eat_word(p, "lambda") { - ret pexpr(parse_fn_expr(p, ast::proto_shared(ast::sugar_sexy))); + } else if eat_word(p, "fn@") { + ret pexpr(parse_fn_expr(p, ast::proto_shared)); } else if eat_word(p, "sendfn") { ret pexpr(parse_fn_expr(p, ast::proto_send)); } else if eat_word(p, "unchecked") { @@ -2117,7 +2117,7 @@ fn parse_item_tag(p: parser, attrs: [ast::attribute]) -> @ast::item { fn parse_fn_ty_proto(p: parser) -> ast::proto { if p.peek() == token::AT { p.bump(); - ast::proto_shared(ast::sugar_normal) + ast::proto_shared } else { ast::proto_bare } diff --git a/src/comp/syntax/print/pprust.rs b/src/comp/syntax/print/pprust.rs index b4a47a8db38..fc0a67dee23 100644 --- a/src/comp/syntax/print/pprust.rs +++ b/src/comp/syntax/print/pprust.rs @@ -1685,8 +1685,7 @@ fn proto_to_str(p: ast::proto) -> str { ast::proto_bare. { "fn" } ast::proto_block. { "block" } ast::proto_send. { "sendfn" } - ast::proto_shared(ast::sugar_normal.) { "fn@" } - ast::proto_shared(ast::sugar_sexy.) { "lambda" } + ast::proto_shared. { "fn@" } }; } diff --git a/src/comp/syntax/visit.rs b/src/comp/syntax/visit.rs index 7fec9e97e06..1c38095d519 100644 --- a/src/comp/syntax/visit.rs +++ b/src/comp/syntax/visit.rs @@ -19,7 +19,7 @@ tag fn_kind { fk_item_fn(ident, [ty_param]); //< an item declared with fn() fk_method(ident, [ty_param]); fk_res(ident, [ty_param]); - fk_anon(proto); //< an anonymous function like lambda(...) + fk_anon(proto); //< an anonymous function like fn@(...) fk_fn_block; //< a block {||...} } |
