diff options
| author | Graydon Hoare <[email protected]> | 2011-03-16 14:58:02 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-03-16 14:58:02 -0700 |
| commit | 54587bdccb7b6771cfc704a30fc0ef2c65824a15 (patch) | |
| tree | 6f154f9b038e9542b364e87ae887858a96bdb4a9 /src/comp/middle/trans.rs | |
| parent | Add some more dlopen-related suppressions for the Mac (diff) | |
| download | rust-54587bdccb7b6771cfc704a30fc0ef2c65824a15.tar.xz rust-54587bdccb7b6771cfc704a30fc0ef2c65824a15.zip | |
Switch all vases of vec += elt to vec += vec. Prohibit former in rustboot. Tweak std lib vec fns in process.
Diffstat (limited to 'src/comp/middle/trans.rs')
| -rw-r--r-- | src/comp/middle/trans.rs | 120 |
1 files changed, 64 insertions, 56 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index d0569afc..7bea575f 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -20,7 +20,6 @@ import middle.ty.pat_ty; import middle.ty.plain_ty; import util.common; -import util.common.append; import util.common.istr; import util.common.new_def_hash; import util.common.new_str_hash; @@ -476,7 +475,7 @@ fn type_of_explicit_args(@crate_ctxt cx, for (ty.arg arg in inputs) { if (ty.type_has_dynamic_size(arg.ty)) { check (arg.mode == ast.alias); - atys += T_typaram_ptr(cx.tn); + atys += vec(T_typaram_ptr(cx.tn)); } else { let TypeRef t; alt (arg.mode) { @@ -487,7 +486,7 @@ fn type_of_explicit_args(@crate_ctxt cx, t = type_of_inner(cx, arg.ty, false); } } - atys += t; + atys += vec(t); } } ret atys; @@ -510,22 +509,22 @@ fn type_of_fn_full(@crate_ctxt cx, // Arg 0: Output pointer. if (ty.type_has_dynamic_size(output)) { - atys += T_typaram_ptr(cx.tn); + atys += vec(T_typaram_ptr(cx.tn)); } else { - atys += T_ptr(type_of_inner(cx, output, false)); + atys += vec(T_ptr(type_of_inner(cx, output, false))); } // Arg 1: Task pointer. - atys += T_taskptr(cx.tn); + atys += vec(T_taskptr(cx.tn)); // Arg 2: Env (closure-bindings / self-obj) alt (obj_self) { case (some[TypeRef](?t)) { check (t as int != 0); - atys += t; + atys += vec(t); } case (_) { - atys += T_opaque_closure_ptr(cx.tn); + atys += vec(T_opaque_closure_ptr(cx.tn)); } } @@ -533,7 +532,7 @@ fn type_of_fn_full(@crate_ctxt cx, if (obj_self == none[TypeRef]) { auto i = 0u; while (i < ty_param_count) { - atys += T_ptr(T_tydesc(cx.tn)); + atys += vec(T_ptr(T_tydesc(cx.tn))); i += 1u; } } @@ -542,10 +541,11 @@ fn type_of_fn_full(@crate_ctxt cx, // If it's an iter, the 'output' type of the iter is actually the // *input* type of the function we're given as our iter-block // argument. - atys += T_fn_pair(cx.tn, + atys += + vec(T_fn_pair(cx.tn, type_of_fn_full(cx, ast.proto_fn, none[TypeRef], vec(rec(mode=ast.val, ty=output)), - plain_ty(ty.ty_nil), 0u)); + plain_ty(ty.ty_nil), 0u))); } // ... then explicit args. @@ -568,12 +568,12 @@ fn type_of_native_fn(@crate_ctxt cx, ast.native_abi abi, @ty.t output) -> TypeRef { let vec[TypeRef] atys = vec(); if (abi == ast.native_abi_rust) { - atys += T_taskptr(cx.tn); + atys += vec(T_taskptr(cx.tn)); auto t = ty.ty_native_fn(abi, inputs, output); auto ty_param_count = ty.count_ty_params(plain_ty(t)); auto i = 0u; while (i < ty_param_count) { - atys += T_ptr(T_tydesc(cx.tn)); + atys += vec(T_ptr(T_tydesc(cx.tn))); i += 1u; } } @@ -623,14 +623,14 @@ fn type_of_inner(@crate_ctxt cx, @ty.t t, bool boxed) -> TypeRef { case (ty.ty_tup(?elts)) { let vec[TypeRef] tys = vec(); for (@ty.t elt in elts) { - tys += type_of_inner(cx, elt, boxed); + tys += vec(type_of_inner(cx, elt, boxed)); } llty = T_struct(tys); } case (ty.ty_rec(?fields)) { let vec[TypeRef] tys = vec(); for (ty.field f in fields) { - tys += type_of_inner(cx, f.ty, boxed); + tys += vec(type_of_inner(cx, f.ty, boxed)); } llty = T_struct(tys); } @@ -650,7 +650,7 @@ fn type_of_inner(@crate_ctxt cx, @ty.t t, bool boxed) -> TypeRef { type_of_fn_full(cx, m.proto, some[TypeRef](self_ty), m.inputs, m.output, 0u); - mtys += T_ptr(mty); + mtys += vec(T_ptr(mty)); } let TypeRef vtbl = T_struct(mtys); let TypeRef pair = T_struct(vec(T_ptr(vtbl), @@ -870,10 +870,10 @@ fn trans_upcall2(builder b, @glue_fns glues, ValueRef lltaskptr, let ValueRef llglue = glues.upcall_glues.(n); let vec[ValueRef] call_args = vec(llupcall); - call_args += b.PtrToInt(lltaskptr, T_int()); + call_args += vec( b.PtrToInt(lltaskptr, T_int())); for (ValueRef a in args) { - call_args += b.ZExtOrBitCast(a, T_int()); + call_args += vec(b.ZExtOrBitCast(a, T_int())); } ret b.FastCall(llglue, call_args); @@ -1112,7 +1112,7 @@ fn GEP_tup_like(@block_ctxt cx, @ty.t t, if (! ty.type_has_dynamic_size(t)) { let vec[ValueRef] v = vec(); for (int i in ixs) { - v += C_int(i); + v += vec(C_int(i)); } ret res(cx, cx.build.GEP(base, v)); } @@ -1159,8 +1159,8 @@ fn GEP_tup_like(@block_ctxt cx, @ty.t t, let vec[@ty.t] prefix = vec(); let int i = 0; while (i < ix) { - append[@ty.t](prefix, ty.get_element_type(t, i as uint)); - i +=1 ; + _vec.push[@ty.t](prefix, ty.get_element_type(t, i as uint)); + i += 1 ; } auto selected = ty.get_element_type(t, i as uint); @@ -1310,8 +1310,8 @@ fn linearize_ty_params(@block_ctxt cx, @ty.t t) } } if (!seen) { - r.vals += r.cx.fcx.lltydescs.get(pid); - r.defs += pid; + r.vals += vec(r.cx.fcx.lltydescs.get(pid)); + r.defs += vec(pid); } } case (_) { } @@ -2365,7 +2365,7 @@ fn trans_unary(@block_ctxt cx, ast.unop op, auto box_ty = node_ann_type(sub.bcx.fcx.ccx, a); sub = trans_malloc_boxed(sub.bcx, e_ty); find_scope_cx(cx).cleanups += - clean(bind drop_ty(_, sub.val, box_ty)); + vec(clean(bind drop_ty(_, sub.val, box_ty))); auto box = sub.val; auto rc = sub.bcx.build.GEP(box, @@ -2646,7 +2646,8 @@ fn trans_vec_add(@block_ctxt cx, @ty.t t, r = copy_ty(r.bcx, INIT, tmp, lhs, t); auto bcx = trans_vec_append(r.bcx, t, tmp, rhs).bcx; tmp = load_scalar_or_boxed(bcx, tmp, t); - find_scope_cx(cx).cleanups += clean(bind drop_ty(_, tmp, t)); + find_scope_cx(cx).cleanups += + vec(clean(bind drop_ty(_, tmp, t))); ret res(bcx, tmp); } @@ -2800,9 +2801,9 @@ fn join_results(@block_ctxt parent_cx, for (result r in ins) { if (! is_terminated(r.bcx)) { - live += r; - vals += r.val; - bbs += r.bcx.llbb; + live += vec(r); + vals += vec(r.val); + bbs += vec(r.bcx.llbb); } } @@ -2875,7 +2876,8 @@ fn trans_for(@block_ctxt cx, cx.build.Br(scope_cx.llbb); auto local_res = alloc_local(scope_cx, local); auto bcx = copy_ty(local_res.bcx, INIT, local_res.val, curr, t).bcx; - scope_cx.cleanups += clean(bind drop_slot(_, local_res.val, t)); + scope_cx.cleanups += + vec(clean(bind drop_slot(_, local_res.val, t))); bcx = trans_block(bcx, body).bcx; bcx.build.Br(next_cx.llbb); ret res(next_cx, C_nil()); @@ -3245,7 +3247,8 @@ fn trans_pat_binding(@block_ctxt cx, @ast.pat pat, ValueRef llval) llvm.LLVMSetValueName(dst, _str.buf(id)); bcx.fcx.lllocals.insert(def_id, dst); - bcx.cleanups += clean(bind drop_slot(_, dst, ty)); + bcx.cleanups += + vec(clean(bind drop_slot(_, dst, ty))); ret copy_ty(bcx, INIT, dst, llval, ty); } @@ -3368,7 +3371,7 @@ fn lval_generic_fn(@block_ctxt cx, for (@ty.t t in tys) { auto td = get_tydesc(bcx, t); bcx = td.bcx; - append[ValueRef](tydescs, td.val); + _vec.push[ValueRef](tydescs, td.val); } auto gen = rec( item_type = tpt._1, tydescs = tydescs ); @@ -3692,7 +3695,7 @@ fn trans_bind_thunk(@crate_ctxt cx, val = bcx.build.PointerCast(val, llout_arg_ty); } - llargs += val; + llargs += vec(val); b += 1; } @@ -3706,7 +3709,7 @@ fn trans_bind_thunk(@crate_ctxt cx, llout_arg_ty); } - llargs += passed_arg; + llargs += vec(passed_arg); a += 1u; } } @@ -3750,7 +3753,7 @@ fn trans_bind(@block_ctxt cx, @ast.expr f, case (none[@ast.expr]) { } case (some[@ast.expr](?e)) { - append[@ast.expr](bound, e); + _vec.push[@ast.expr](bound, e); } } } @@ -3786,8 +3789,8 @@ fn trans_bind(@block_ctxt cx, @ast.expr f, auto arg = trans_expr(bcx, e); bcx = arg.bcx; - append[ValueRef](bound_vals, arg.val); - append[@ty.t](bound_tys, ty.expr_ty(e)); + _vec.push[ValueRef](bound_vals, arg.val); + _vec.push[@ty.t](bound_tys, ty.expr_ty(e)); i += 1u; } @@ -3914,7 +3917,7 @@ fn trans_bind(@block_ctxt cx, @ast.expr f, pair_box); find_scope_cx(cx).cleanups += - clean(bind drop_slot(_, pair_v, pair_ty)); + vec(clean(bind drop_slot(_, pair_v, pair_ty))); ret res(bcx, pair_v); } @@ -3959,23 +3962,24 @@ fn trans_args(@block_ctxt cx, } } if (ty.type_has_dynamic_size(retty)) { - llargs += bcx.build.PointerCast(llretslot, - T_typaram_ptr(cx.fcx.ccx.tn)); + llargs += vec(bcx.build.PointerCast(llretslot, + T_typaram_ptr(cx.fcx.ccx.tn))); } else if (ty.count_ty_params(retty) != 0u) { // It's possible that the callee has some generic-ness somewhere in // its return value -- say a method signature within an obj or a fn // type deep in a structure -- which the caller has a concrete view // of. If so, cast the caller's view of the restlot to the callee's // view, for the sake of making a type-compatible call. - llargs += cx.build.PointerCast(llretslot, - T_ptr(type_of(bcx.fcx.ccx, retty))); + llargs += + vec(cx.build.PointerCast(llretslot, + T_ptr(type_of(bcx.fcx.ccx, retty)))); } else { - llargs += llretslot; + llargs += vec(llretslot); } // Arg 1: Task pointer. - llargs += bcx.fcx.lltaskptr; + llargs += vec(bcx.fcx.lltaskptr); // Arg 2: Env (closure-bindings / self-obj) alt (llobj) { @@ -3983,10 +3987,10 @@ fn trans_args(@block_ctxt cx, // Every object is always found in memory, // and not-yet-loaded (as part of an lval x.y // doted method-call). - llargs += bcx.build.Load(ob); + llargs += vec(bcx.build.Load(ob)); } case (_) { - llargs += llenv; + llargs += vec(llenv); } } @@ -3997,7 +4001,7 @@ fn trans_args(@block_ctxt cx, alt (lliterbody) { case (none[ValueRef]) {} case (some[ValueRef](?lli)) { - llargs += lli; + llargs += vec(lli); } } @@ -4054,7 +4058,7 @@ fn trans_args(@block_ctxt cx, val = bcx.build.PointerCast(val, lldestty); } - llargs += val; + llargs += vec(val); i += 1u; } @@ -4116,7 +4120,8 @@ fn trans_call(@block_ctxt cx, @ast.expr f, // Retval doesn't correspond to anything really tangible in the frame, // but it's a ref all the same, so we put a note here to drop it when // we're done in this scope. - find_scope_cx(cx).cleanups += clean(bind drop_ty(_, retval, ret_ty)); + find_scope_cx(cx).cleanups += + vec(clean(bind drop_ty(_, retval, ret_ty))); } ret res(bcx, retval); @@ -4130,7 +4135,8 @@ fn trans_tup(@block_ctxt cx, vec[ast.elt] elts, auto tup_val = tup_res.val; bcx = tup_res.bcx; - find_scope_cx(cx).cleanups += clean(bind drop_ty(_, tup_val, t)); + find_scope_cx(cx).cleanups += + vec(clean(bind drop_ty(_, tup_val, t))); let int i = 0; for (ast.elt e in elts) { @@ -4171,7 +4177,8 @@ fn trans_vec(@block_ctxt cx, vec[@ast.expr] args, auto llty = type_of(bcx.fcx.ccx, t); auto vec_val = vi2p(bcx, sub.val, llty); - find_scope_cx(bcx).cleanups += clean(bind drop_ty(_, vec_val, t)); + find_scope_cx(bcx).cleanups += + vec(clean(bind drop_ty(_, vec_val, t))); auto body = bcx.build.GEP(vec_val, vec(C_int(0), C_int(abi.vec_elt_data))); @@ -4226,7 +4233,8 @@ fn trans_rec(@block_ctxt cx, vec[ast.field] fields, auto rec_val = rec_res.val; bcx = rec_res.bcx; - find_scope_cx(cx).cleanups += clean(bind drop_ty(_, rec_val, t)); + find_scope_cx(cx).cleanups += + vec(clean(bind drop_ty(_, rec_val, t))); let int i = 0; auto base_val = C_nil(); @@ -4499,7 +4507,7 @@ fn trans_put(@block_ctxt cx, &option.t[@ast.expr] e) -> result { llarg = bcx.build.Load(llarg); } - llargs += llarg; + llargs += vec(llarg); } } @@ -4557,7 +4565,7 @@ fn init_local(@block_ctxt cx, @ast.local local) -> result { auto bcx = cx; find_scope_cx(cx).cleanups += - clean(bind drop_slot(_, llptr, ty)); + vec(clean(bind drop_slot(_, llptr, ty))); alt (local.init) { case (some[@ast.expr](?e)) { @@ -5026,7 +5034,7 @@ fn trans_vtbl(@crate_ctxt cx, TypeRef self_ty, trans_fn(mcx, m.node.meth, m.node.id, some[TypeRef](self_ty), ty_params, m.node.ann); - methods += llfn; + methods += vec(llfn); } auto vtbl = C_struct(methods); auto gvar = llvm.LLVMAddGlobal(cx.llmod, @@ -5085,14 +5093,14 @@ fn trans_obj(@crate_ctxt cx, &ast._obj ob, ast.def_id oid, // Malloc a box for the body and copy args in. let vec[@ty.t] obj_fields = vec(); for (ty.arg a in arg_tys) { - append[@ty.t](obj_fields, a.ty); + _vec.push[@ty.t](obj_fields, a.ty); } // Synthesize an obj body type. auto tydesc_ty = plain_ty(ty.ty_type); let vec[@ty.t] tps = vec(); for (ast.ty_param tp in ty_params) { - append[@ty.t](tps, tydesc_ty); + _vec.push[@ty.t](tps, tydesc_ty); } let @ty.t typarams_ty = plain_ty(ty.ty_tup(tps)); |