From 8b911587dfed1cc1973b361865c3632a2e2cffde Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 10 Jan 2012 06:49:15 -0800 Subject: rename sendfn to fn~, lambda to fn@ --- src/comp/middle/capture.rs | 4 +-- src/comp/middle/kind.rs | 4 +-- src/comp/middle/trans_closure.rs | 66 ++++++++++++++++++---------------------- src/comp/middle/ty.rs | 30 +++++++++--------- src/comp/middle/typeck.rs | 12 ++++---- 5 files changed, 54 insertions(+), 62 deletions(-) (limited to 'src/comp/middle') diff --git a/src/comp/middle/capture.rs b/src/comp/middle/capture.rs index c34450fa528..e1c1c63d02f 100644 --- a/src/comp/middle/capture.rs +++ b/src/comp/middle/capture.rs @@ -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_box. | ast::proto_uniq. { 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_box. | ast::proto_uniq. { cap_copy } }; vec::iter(*freevars) { |fvar| diff --git a/src/comp/middle/kind.rs b/src/comp/middle/kind.rs index 85ea75a95ec..5b1cc73ede0 100644 --- a/src/comp/middle/kind.rs +++ b/src/comp/middle/kind.rs @@ -60,8 +60,8 @@ fn with_appropriate_checker(cx: ctx, id: node_id, b: block(fn(ctx, ty::t, sp: span))) { 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_uniq. { b(check_send); } + proto_box. { b(check_copy); } proto_block. { /* no check needed */ } proto_bare. { b(check_none); } } diff --git a/src/comp/middle/trans_closure.rs b/src/comp/middle/trans_closure.rs index 5cbd72c4bef..92ceed4879d 100644 --- a/src/comp/middle/trans_closure.rs +++ b/src/comp/middle/trans_closure.rs @@ -136,8 +136,8 @@ fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> str { fn mk_tydesc_ty(tcx: ty::ctxt, ck: ty::closure_kind) -> ty::t { ret alt ck { - ty::closure_block. | ty::closure_shared. { ty::mk_type(tcx) } - ty::closure_send. { ty::mk_send_type(tcx) } + ty::ck_block. | ty::ck_box. { ty::mk_type(tcx) } + ty::ck_uniq. { ty::mk_send_type(tcx) } }; } @@ -236,15 +236,15 @@ fn allocate_cbox(bcx: @block_ctxt, // Allocate the box: let temp_cleanups = []; let (bcx, box, rc) = alt ck { - ty::closure_shared. { + ty::ck_box. { let (bcx, box) = alloc_in_heap(bcx, false, temp_cleanups); (bcx, box, 1) } - ty::closure_send. { + ty::ck_uniq. { let (bcx, box) = alloc_in_heap(bcx, true, temp_cleanups); (bcx, box, 0x12345678) // use arbitrary value for debugging } - ty::closure_block. { + ty::ck_block. { let {bcx, val: box} = trans::alloc_ty(bcx, cbox_ty); (bcx, box, 0x12345678) // use arbitrary value for debugging } @@ -288,10 +288,10 @@ fn store_environment( ck: ty::closure_kind, td: ValueRef) -> ValueRef { ret alt ck { - ty::closure_block. | ty::closure_shared. { + ty::ck_block. | ty::ck_box. { td } - ty::closure_send. { + ty::ck_uniq. { Call(bcx, bcx_ccx(bcx).upcalls.create_shared_type_desc, [td]) } }; @@ -310,7 +310,7 @@ fn store_environment( // store data tydesc. alt ck { - ty::closure_shared. | ty::closure_send. { + ty::ck_box. | ty::ck_uniq. { let bound_tydesc = GEPi(bcx, llbox, [0, abi::cbox_elt_tydesc]); let ti = none; @@ -331,7 +331,7 @@ fn store_environment( let td = maybe_clone_tydesc(bcx, ck, closure_td.val); Store(bcx, td, bound_tydesc); } - ty::closure_block. { /* skip this for blocks, not really relevant */ } + ty::ck_block. { /* skip this for blocks, not really relevant */ } } // cbox_ty has the form of a tuple: (a, b, c) we want a ptr to a @@ -425,7 +425,7 @@ fn build_closure(bcx0: @block_ctxt, let ty = ty::node_id_to_monotype(tcx, nid); alt cap_var.mode { capture::cap_ref. { - assert ck == ty::closure_block; + assert ck == ty::ck_block; ty = ty::mk_mut_ptr(tcx, ty); env_vals += [env_ref(lv.val, ty, lv.kind)]; } @@ -492,8 +492,8 @@ fn load_environment(enclosing_cx: @block_ctxt, bcx = upvarptr.bcx; let llupvarptr = upvarptr.val; alt ck { - ty::closure_block. { llupvarptr = Load(bcx, llupvarptr); } - ty::closure_send. | ty::closure_shared. { } + ty::ck_block. { llupvarptr = Load(bcx, llupvarptr); } + ty::ck_uniq. | ty::ck_box. { } } let def_id = ast_util::def_id_of_def(cap_var.def); fcx.llupvars.insert(def_id.node, llupvarptr); @@ -531,9 +531,9 @@ 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_send. { trans_closure_env(ty::closure_send) } + ast::proto_block. { trans_closure_env(ty::ck_block) } + ast::proto_box. { trans_closure_env(ty::ck_box) } + ast::proto_uniq. { trans_closure_env(ty::ck_uniq) } ast::proto_bare. { let closure = C_null(T_opaque_cbox_ptr(ccx)); trans_closure(sub_cx, sp, decl, body, llfn, no_self, [], @@ -625,7 +625,7 @@ fn trans_bind_1(cx: @block_ctxt, outgoing_fty: ty::t, let {llbox, cboxptr_ty, bcx} = store_environment( bcx, vec::map(lltydescs, {|d| {desc: d, dicts: none}}), env_vals + vec::map(bound, {|x| env_expr(x)}), - ty::closure_shared); + ty::ck_box); // Make thunk let llthunk = @@ -672,12 +672,8 @@ fn make_fn_glue( ret alt ty::struct(tcx, t) { ty::ty_native_fn(_, _) | ty::ty_fn({proto: ast::proto_bare., _}) { bcx } ty::ty_fn({proto: ast::proto_block., _}) { bcx } - ty::ty_fn({proto: ast::proto_send., _}) { - fn_env(ty::closure_send) - } - ty::ty_fn({proto: ast::proto_shared., _}) { - fn_env(ty::closure_shared) - } + ty::ty_fn({proto: ast::proto_uniq., _}) { fn_env(ty::ck_uniq) } + ty::ty_fn({proto: ast::proto_box., _}) { fn_env(ty::ck_box) } _ { fail "make_fn_glue invoked on non-function type" } }; } @@ -689,13 +685,9 @@ fn make_opaque_cbox_take_glue( -> @block_ctxt { // Easy cases: alt ck { - ty::closure_block. { - ret bcx; - } - ty::closure_shared. { - ret incr_refcnt_of_boxed(bcx, Load(bcx, cboxptr)); - } - ty::closure_send. { /* hard case: */ } + ty::ck_block. { ret bcx; } + ty::ck_box. { ret incr_refcnt_of_boxed(bcx, Load(bcx, cboxptr)); } + ty::ck_uniq. { /* hard case: */ } } // Hard case, a deep copy: @@ -731,12 +723,12 @@ fn make_opaque_cbox_drop_glue( cboxptr: ValueRef) // ptr to the opaque closure -> @block_ctxt { alt ck { - ty::closure_block. { bcx } - ty::closure_shared. { + ty::ck_block. { bcx } + ty::ck_box. { decr_refcnt_maybe_free(bcx, Load(bcx, cboxptr), ty::mk_opaque_closure_ptr(bcx_tcx(bcx), ck)) } - ty::closure_send. { + ty::ck_uniq. { free_ty(bcx, Load(bcx, cboxptr), ty::mk_opaque_closure_ptr(bcx_tcx(bcx), ck)) } @@ -749,8 +741,8 @@ fn make_opaque_cbox_free_glue( cbox: ValueRef) // ptr to the opaque closure -> @block_ctxt { alt ck { - ty::closure_block. { ret bcx; } - ty::closure_shared. | ty::closure_send. { /* hard cases: */ } + ty::ck_block. { ret bcx; } + ty::ck_box. | ty::ck_uniq. { /* hard cases: */ } } let ccx = bcx_ccx(bcx); @@ -777,11 +769,11 @@ fn make_opaque_cbox_free_glue( // Free the ty descr (if necc) and the box itself alt ck { - ty::closure_block. { fail "Impossible."; } - ty::closure_shared. { + ty::ck_block. { fail "Impossible."; } + ty::ck_box. { trans_free_if_not_gc(bcx, cbox) } - ty::closure_send. { + ty::ck_uniq. { let bcx = free_ty(bcx, tydesc, mk_tydesc_ty(tcx, ck)); trans_shared_free(bcx, cbox) } diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index e0c6d6f4ba2..76a9b4c69c7 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -181,9 +181,9 @@ export variant_info; export walk_ty; export occurs_check_fails; export closure_kind; -export closure_block; -export closure_shared; -export closure_send; +export ck_block; +export ck_box; +export ck_uniq; export param_bound, param_bounds, bound_copy, bound_send, bound_iface; export param_bounds_to_kind; @@ -234,9 +234,9 @@ type raw_t = {struct: sty, type t = uint; tag closure_kind { - closure_block; - closure_shared; - closure_send; + ck_block; + ck_box; + ck_uniq; } type fn_ty = {proto: ast::proto, @@ -1020,8 +1020,8 @@ 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_send. { kind_sendable } + ast::proto_box. { kind_copyable } + ast::proto_uniq. { kind_sendable } ast::proto_bare. { kind_sendable } } } @@ -1057,9 +1057,9 @@ fn type_kind(cx: ctxt, ty: t) -> kind { // anything about its fields. ty_obj(_) { kind_copyable } ty_fn(f) { proto_kind(f.proto) } - ty_opaque_closure_ptr(closure_block.) { kind_noncopyable } - ty_opaque_closure_ptr(closure_shared.) { kind_copyable } - ty_opaque_closure_ptr(closure_send.) { kind_sendable } + ty_opaque_closure_ptr(ck_block.) { kind_noncopyable } + ty_opaque_closure_ptr(ck_box.) { kind_copyable } + ty_opaque_closure_ptr(ck_uniq.) { kind_sendable } // Those with refcounts-to-inner raise pinned to shared, // lower unique to shared. Therefore just set result to shared. ty_box(_) | ty_iface(_, _) { kind_copyable } @@ -1422,9 +1422,9 @@ fn hash_type_structure(st: sty) -> uint { for typ: t in tys { h = hash_subty(h, typ); } ret h; } - ty_opaque_closure_ptr(closure_block.) { ret 41u; } - ty_opaque_closure_ptr(closure_shared.) { ret 42u; } - ty_opaque_closure_ptr(closure_send.) { ret 43u; } + ty_opaque_closure_ptr(ck_block.) { ret 41u; } + ty_opaque_closure_ptr(ck_box.) { ret 42u; } + ty_opaque_closure_ptr(ck_uniq.) { ret 43u; } } } @@ -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; + ret ast::proto_box; } _ { cx.sess.bug("ty_fn_proto() called on non-fn type"); } } diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index c55d26ce81c..bfa3463935a 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, + let t_fn = ty::mk_fn(tcx, {proto: ast::proto_box, 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, + {proto: ast::proto_box, 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, + proto: ast::proto_box, 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, + proto: ast::proto_box, inputs: [t_arg], output: ty::mk_nil(cx.tcx), ret_style: ast::return_val, constraints: [] }); @@ -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::proto_bare. { ast::proto_box } _ { 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, + proto: ast::proto_box, var_bindings: ty::unify::mk_var_bindings(), locals: new_int_hash::(), next_var_id: @mutable 0, -- cgit 1.4.1-3-g733a5