about summary refs log tree commit diff
path: root/src/comp/middle
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2012-02-21 14:20:18 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2012-02-21 14:20:18 +0100
commit789a1ae356f75ed7db75afd485e009ce32b2bd74 (patch)
tree43659136118952f195e20c79a9b5c7a6fb922901 /src/comp/middle
parent9691ce18a2674e322be4b2e8f2e44888eb957170 (diff)
downloadrust-789a1ae356f75ed7db75afd485e009ce32b2bd74.tar.gz
rust-789a1ae356f75ed7db75afd485e009ce32b2bd74.zip
Clean up a number of TODOs in the trans modules
Rename the ones that I didn't handle to FIXME
Diffstat (limited to 'src/comp/middle')
-rw-r--r--src/comp/middle/trans/alt.rs14
-rw-r--r--src/comp/middle/trans/base.rs300
-rw-r--r--src/comp/middle/trans/build.rs11
-rw-r--r--src/comp/middle/trans/closure.rs34
-rw-r--r--src/comp/middle/trans/common.rs35
-rw-r--r--src/comp/middle/trans/debuginfo.rs57
-rw-r--r--src/comp/middle/trans/impl.rs21
-rw-r--r--src/comp/middle/trans/native.rs4
-rw-r--r--src/comp/middle/trans/shape.rs34
-rw-r--r--src/comp/middle/trans/tvec.rs57
-rw-r--r--src/comp/middle/trans/uniq.rs2
11 files changed, 272 insertions, 297 deletions
diff --git a/src/comp/middle/trans/alt.rs b/src/comp/middle/trans/alt.rs
index 38cd5e83af0..8827f27d1ed 100644
--- a/src/comp/middle/trans/alt.rs
+++ b/src/comp/middle/trans/alt.rs
@@ -38,12 +38,12 @@ enum opt_result {
     range_result(result, result),
 }
 fn trans_opt(bcx: block, o: opt) -> opt_result {
-    let ccx = bcx_ccx(bcx), bcx = bcx;
+    let ccx = bcx.ccx(), bcx = bcx;
     alt o {
       lit(l) {
         alt l.node {
           ast::expr_lit(@{node: ast::lit_str(s), _}) {
-            let strty = ty::mk_str(bcx_tcx(bcx));
+            let strty = ty::mk_str(bcx.tcx());
             let cell = empty_dest_cell();
             bcx = tvec::trans_str(bcx, s, by_val(cell));
             add_clean_temp(bcx, *cell, strty);
@@ -526,7 +526,7 @@ fn compile_submatch(bcx: block, m: match, vals: [ValueRef], f: mk_fail,
                 llvm::LLVMAddCase(sw, r.val, opt_cx.llbb);
                 bcx = r.bcx;
               }
-              _ { bcx_tcx(bcx).sess.bug("Someone forgot to\
+              _ { bcx.tcx().sess.bug("Someone forgot to\
                     document an invariant in compile_submatch"); }
             }
           }
@@ -599,10 +599,10 @@ fn make_phi_bindings(bcx: block, map: [exit_node],
     if success {
         // Copy references that the alias analysis considered unsafe
         ids.values {|node_id|
-            if bcx_ccx(bcx).copy_map.contains_key(node_id) {
+            if bcx.ccx().copy_map.contains_key(node_id) {
                 let local = alt bcx.fcx.lllocals.find(node_id) {
                   some(local_mem(x)) { x }
-                  _ { bcx_tcx(bcx).sess.bug("Someone \
+                  _ { bcx.tcx().sess.bug("Someone \
                         forgot to document an invariant in \
                         make_phi_bindings"); }
                 };
@@ -628,7 +628,7 @@ fn trans_alt(bcx: block, expr: @ast::expr, arms: [ast::arm],
 
 fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: [ast::arm],
                    dest: dest) -> block {
-    let bcx = scope_cx, tcx = bcx_tcx(bcx);
+    let bcx = scope_cx, tcx = bcx.tcx();
     let bodies = [], match = [];
 
     let {bcx, val, _} = trans_temp_expr(bcx, expr);
@@ -690,7 +690,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef,
     let ccx = bcx.fcx.ccx, bcx = bcx;
 
     // Necessary since bind_irrefutable_pat is called outside trans_alt
-    alt normalize_pat(bcx_tcx(bcx), pat).node {
+    alt normalize_pat(bcx.tcx(), pat).node {
       ast::pat_ident(_,inner) {
         if make_copy || ccx.copy_map.contains_key(pat.id) {
             let ty = node_id_type(bcx, pat.id);
diff --git a/src/comp/middle/trans/base.rs b/src/comp/middle/trans/base.rs
index a99c70b1519..b1603f35220 100644
--- a/src/comp/middle/trans/base.rs
+++ b/src/comp/middle/trans/base.rs
@@ -294,18 +294,18 @@ fn trans_native_call(cx: block, externs: hashmap<str, ValueRef>,
         get_simple_extern_fn(cx, externs, llmod, name, n);
     let call_args: [ValueRef] = [];
     for a: ValueRef in args {
-        call_args += [ZExtOrBitCast(cx, a, bcx_ccx(cx).int_type)];
+        call_args += [ZExtOrBitCast(cx, a, cx.ccx().int_type)];
     }
     ret Call(cx, llnative, call_args);
 }
 
 fn trans_free(cx: block, v: ValueRef) -> block {
-    Call(cx, bcx_ccx(cx).upcalls.free, [PointerCast(cx, v, T_ptr(T_i8()))]);
+    Call(cx, cx.ccx().upcalls.free, [PointerCast(cx, v, T_ptr(T_i8()))]);
     cx
 }
 
 fn trans_shared_free(cx: block, v: ValueRef) -> block {
-    Call(cx, bcx_ccx(cx).upcalls.shared_free,
+    Call(cx, cx.ccx().upcalls.shared_free,
          [PointerCast(cx, v, T_ptr(T_i8()))]);
     ret cx;
 }
@@ -330,17 +330,16 @@ fn dynastack_alloca(cx: block, t: TypeRef, n: ValueRef, ty: ty::t) ->
     if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(t)); }
     let bcx = cx;
     let dy_cx = raw_block(cx.fcx, cx.fcx.lldynamicallocas);
-    alt bcx_fcx(cx).llobstacktoken {
+    alt cx.fcx.llobstacktoken {
       none {
-        bcx_fcx(cx).llobstacktoken =
-            some(mk_obstack_token(bcx_ccx(cx), cx.fcx));
+        cx.fcx.llobstacktoken = some(mk_obstack_token(cx.ccx(), cx.fcx));
       }
       some(_) {/* no-op */ }
     }
 
-    let dynastack_alloc = bcx_ccx(bcx).upcalls.dynastack_alloc;
+    let dynastack_alloc = bcx.ccx().upcalls.dynastack_alloc;
     let llsz = Mul(dy_cx,
-                   C_uint(bcx_ccx(bcx), llsize_of_real(bcx_ccx(bcx), t)),
+                   C_uint(bcx.ccx(), llsize_of_real(bcx.ccx(), t)),
                    n);
 
     let lltydesc = get_tydesc_simple(cx, ty, false).val;
@@ -367,7 +366,7 @@ fn ptr_offs(bcx: block, base: ValueRef, sz: ValueRef) -> ValueRef {
 // to a given type.
 fn bump_ptr(bcx: block, t: ty::t, base: ValueRef, sz: ValueRef) ->
    ValueRef {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     let bumped = ptr_offs(bcx, base, sz);
     if check type_has_static_size(ccx, t) {
         let typ = T_ptr(type_of(ccx, t));
@@ -411,13 +410,13 @@ fn GEP_tup_like(bcx: block, t: ty::t, base: ValueRef, ixs: [int])
         be compute_off(bcx, off, comp_t, ixs, n+1u);
     }
 
-    if !ty::type_has_dynamic_size(bcx_tcx(bcx), t) {
+    if !ty::type_has_dynamic_size(bcx.tcx(), t) {
         ret rslt(bcx, GEPi(bcx, base, ixs));
     }
 
     #debug["GEP_tup_like(t=%s,base=%s,ixs=%?)",
-           ty_to_str(bcx_tcx(bcx), t),
-           val_str(bcx_ccx(bcx).tn, base),
+           ty_to_str(bcx.tcx(), t),
+           val_str(bcx.ccx().tn, base),
            ixs];
 
     // We require that ixs start with 0 and we expect the input to be a
@@ -426,7 +425,7 @@ fn GEP_tup_like(bcx: block, t: ty::t, base: ValueRef, ixs: [int])
     assert ixs[0] == 0;
 
     let (bcx, off, tar_t) = {
-        compute_off(bcx, C_int(bcx_ccx(bcx), 0), t, ixs, 1u)
+        compute_off(bcx, C_int(bcx.ccx(), 0), t, ixs, 1u)
     };
     ret rslt(bcx, bump_ptr(bcx, tar_t, base, off));
 }
@@ -440,7 +439,7 @@ fn GEP_enum(cx: block, llblobptr: ValueRef, enum_id: ast::def_id,
            variant_id: ast::def_id, ty_substs: [ty::t],
            ix: uint) : valid_variant_index(ix, cx, enum_id, variant_id) ->
    result {
-    let variant = ty::enum_variant_with_id(bcx_tcx(cx), enum_id, variant_id);
+    let variant = ty::enum_variant_with_id(cx.tcx(), enum_id, variant_id);
     // Synthesize a tuple type so that GEP_tup_like() can work its magic.
     // Separately, store the type of the element we're interested in.
 
@@ -450,7 +449,7 @@ fn GEP_enum(cx: block, llblobptr: ValueRef, enum_id: ast::def_id,
     for aty: ty::t in arg_tys {
             // Would be nice to have a way of stating the invariant
             // that ty_substs is valid for aty
-        let arg_ty = ty::substitute_type_params(bcx_tcx(cx), ty_substs, aty);
+        let arg_ty = ty::substitute_type_params(cx.tcx(), ty_substs, aty);
         true_arg_tys += [arg_ty];
     }
 
@@ -460,12 +459,12 @@ fn GEP_enum(cx: block, llblobptr: ValueRef, enum_id: ast::def_id,
     // error can't happen here, but that's in the future.)
     let elem_ty = true_arg_tys[ix];
 
-    let tup_ty = ty::mk_tup(bcx_tcx(cx), true_arg_tys);
+    let tup_ty = ty::mk_tup(cx.tcx(), true_arg_tys);
     // Cast the blob pointer to the appropriate type, if we need to (i.e. if
     // the blob pointer isn't dynamically sized).
 
     let llunionptr: ValueRef;
-    let ccx = bcx_ccx(cx);
+    let ccx = cx.ccx();
     if check type_has_static_size(ccx, tup_ty) {
         let llty = type_of(ccx, tup_ty);
         llunionptr = TruncOrBitCast(cx, llblobptr, T_ptr(llty));
@@ -475,12 +474,10 @@ fn GEP_enum(cx: block, llblobptr: ValueRef, enum_id: ast::def_id,
     let rs = GEP_tup_like(cx, tup_ty, llunionptr, [0, ix as int]);
     // Cast the result to the appropriate type, if necessary.
 
-    let rs_ccx = bcx_ccx(rs.bcx);
-    let val =
-        if check type_has_static_size(rs_ccx, elem_ty) {
-            let llelemty = type_of(rs_ccx, elem_ty);
-            PointerCast(rs.bcx, rs.val, T_ptr(llelemty))
-        } else { rs.val };
+    let val = if check type_has_static_size(ccx, elem_ty) {
+        let llelemty = type_of(ccx, elem_ty);
+        PointerCast(rs.bcx, rs.val, T_ptr(llelemty))
+    } else { rs.val };
 
     ret rslt(rs.bcx, val);
 }
@@ -491,9 +488,9 @@ fn trans_shared_malloc(cx: block, llptr_ty: TypeRef, llsize: ValueRef)
    -> result {
     // FIXME: need a table to collect tydesc globals.
 
-    let tydesc = C_null(T_ptr(bcx_ccx(cx).tydesc_type));
+    let tydesc = C_null(T_ptr(cx.ccx().tydesc_type));
     let rval =
-        Call(cx, bcx_ccx(cx).upcalls.shared_malloc,
+        Call(cx, cx.ccx().upcalls.shared_malloc,
              [llsize, tydesc]);
     ret rslt(cx, PointerCast(cx, rval, llptr_ty));
 }
@@ -506,7 +503,7 @@ fn trans_shared_malloc(cx: block, llptr_ty: TypeRef, llsize: ValueRef)
 fn opaque_box_body(bcx: block,
                       body_t: ty::t,
                       boxptr: ValueRef) -> ValueRef {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     let boxptr = PointerCast(bcx, boxptr, T_ptr(T_box_header(ccx)));
     let bodyptr = GEPi(bcx, boxptr, [1]);
     if check type_has_static_size(ccx, body_t) {
@@ -521,11 +518,11 @@ fn opaque_box_body(bcx: block,
 // header.
 fn trans_malloc_boxed_raw(bcx: block, t: ty::t,
                           &static_ti: option<@tydesc_info>) -> result {
-    let bcx = bcx, ccx = bcx_ccx(bcx);
+    let bcx = bcx, ccx = bcx.ccx();
 
     // Grab the TypeRef type of box_ptr, because that's what trans_raw_malloc
     // wants.
-    let box_ptr = ty::mk_imm_box(bcx_tcx(bcx), t);
+    let box_ptr = ty::mk_imm_box(bcx.tcx(), t);
     check (type_has_static_size(ccx, box_ptr));
     let llty = type_of(ccx, box_ptr);
 
@@ -567,7 +564,7 @@ fn field_of_tydesc(cx: block, t: ty::t, escapes: bool, field: int) ->
 fn linearize_ty_params(cx: block, t: ty::t) ->
    {params: [uint], descs: [ValueRef]} {
     let param_vals = [], param_defs = [];
-    ty::walk_ty(bcx_tcx(cx), t) {|t|
+    ty::walk_ty(cx.tcx(), t) {|t|
         alt ty::get(t).struct {
           ty::ty_param(pid, _) {
             if !vec::any(param_defs, {|d| d == pid}) {
@@ -585,14 +582,14 @@ fn trans_stack_local_derived_tydesc(cx: block, llsz: ValueRef,
                                     llalign: ValueRef, llroottydesc: ValueRef,
                                     llfirstparam: ValueRef, n_params: uint)
     -> ValueRef {
-    let llmyroottydesc = alloca(cx, bcx_ccx(cx).tydesc_type);
+    let llmyroottydesc = alloca(cx, cx.ccx().tydesc_type);
 
     // By convention, desc 0 is the root descriptor.
     let llroottydesc = Load(cx, llroottydesc);
     Store(cx, llroottydesc, llmyroottydesc);
 
     // Store a pointer to the rest of the descriptors.
-    let ccx = bcx_ccx(cx);
+    let ccx = cx.ccx();
     store_inbounds(cx, llfirstparam, llmyroottydesc,
                    [0, abi::tydesc_field_first_param]);
     store_inbounds(cx, C_uint(ccx, n_params), llmyroottydesc,
@@ -620,12 +617,12 @@ fn get_derived_tydesc(cx: block, t: ty::t, escapes: bool,
       none {/* fall through */ }
     }
 
-    bcx_ccx(cx).stats.n_derived_tydescs += 1u;
+    cx.ccx().stats.n_derived_tydescs += 1u;
     let bcx = raw_block(cx.fcx, cx.fcx.llderivedtydescs);
     let tys = linearize_ty_params(bcx, t);
-    let root_ti = get_static_tydesc(bcx_ccx(bcx), t, tys.params);
+    let root_ti = get_static_tydesc(bcx.ccx(), t, tys.params);
     static_ti = some(root_ti);
-    lazily_emit_all_tydesc_glue(bcx_ccx(cx), static_ti);
+    lazily_emit_all_tydesc_glue(cx.ccx(), static_ti);
     let root = root_ti.tydesc;
     let sz = size_of(bcx, t);
     bcx = sz.bcx;
@@ -634,13 +631,13 @@ fn get_derived_tydesc(cx: block, t: ty::t, escapes: bool,
 
     // Store the captured type descriptors in an alloca if the caller isn't
     // promising to do so itself.
-    let n_params = ty::count_ty_params(bcx_tcx(bcx), t);
+    let n_params = ty::count_ty_params(bcx.tcx(), t);
 
     assert n_params == tys.params.len();
     assert n_params == tys.descs.len();
 
     let llparamtydescs =
-        alloca(bcx, T_array(T_ptr(bcx_ccx(bcx).tydesc_type), n_params + 1u));
+        alloca(bcx, T_array(T_ptr(bcx.ccx().tydesc_type), n_params + 1u));
     let i = 0;
 
     // If the type descriptor escapes, we need to add in the root as
@@ -657,11 +654,11 @@ fn get_derived_tydesc(cx: block, t: ty::t, escapes: bool,
 
     let llfirstparam =
         PointerCast(bcx, llparamtydescs,
-                    T_ptr(T_ptr(bcx_ccx(bcx).tydesc_type)));
+                    T_ptr(T_ptr(bcx.ccx().tydesc_type)));
 
     let v;
     if escapes {
-        let ccx = bcx_ccx(bcx);
+        let ccx = bcx.ccx();
         let td_val =
             Call(bcx, ccx.upcalls.get_type_desc,
                  [C_null(T_ptr(T_nil())), sz.val,
@@ -695,7 +692,7 @@ fn get_tydesc(cx: block, t: ty::t, escapes: bool,
         ret get_derived_tydesc(cx, t, escapes, static_ti);
     }
     // Otherwise, generate a tydesc if necessary, and return it.
-    let info = get_static_tydesc(bcx_ccx(cx), t, []);
+    let info = get_static_tydesc(cx.ccx(), t, []);
     static_ti = some(info);
     ret rslt(cx, info.tydesc);
 }
@@ -731,7 +728,7 @@ fn set_always_inline(f: ValueRef) {
 }
 
 fn set_custom_stack_growth_fn(f: ValueRef) {
-    // TODO: Remove this hack to work around the lack of u64 in the FFI.
+    // FIXME: Remove this hack to work around the lack of u64 in the FFI.
     llvm::LLVMAddFunctionAttr(f, 0u as c_uint, 1u as c_uint);
 }
 
@@ -920,7 +917,7 @@ fn make_take_glue(cx: block, v: ValueRef, t: ty::t) {
         // sendable type descriptors are basically unique pointers,
         // they must be cloned when copied:
         let r = Load(bcx, v);
-        let s = Call(bcx, bcx_ccx(bcx).upcalls.create_shared_type_desc, [r]);
+        let s = Call(bcx, bcx.ccx().upcalls.create_shared_type_desc, [r]);
         Store(bcx, s, v);
         bcx
       }
@@ -944,7 +941,7 @@ fn make_take_glue(cx: block, v: ValueRef, t: ty::t) {
 }
 
 fn incr_refcnt_of_boxed(cx: block, box_ptr: ValueRef) -> block {
-    let ccx = bcx_ccx(cx);
+    let ccx = cx.ccx();
     maybe_validate_box(cx, box_ptr);
     let rc_ptr = GEPi(cx, box_ptr, [0, abi::box_field_refcnt]);
     let rc = Load(cx, rc_ptr);
@@ -957,7 +954,7 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
     // v is a pointer to the actual box component of the type here. The
     // ValueRef will have the wrong type here (make_generic_glue is casting
     // everything to a pointer to the type that the glue acts on).
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     let bcx = alt ty::get(t).struct {
       ty::ty_box(body_mt) {
         let v = PointerCast(bcx, v, type_of(ccx, t));
@@ -983,7 +980,7 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
       ty::ty_send_type {
         // sendable type descriptors are basically unique pointers,
         // they must be freed.
-        let ccx = bcx_ccx(bcx);
+        let ccx = bcx.ccx();
         let v = PointerCast(bcx, v, T_ptr(ccx.tydesc_type));
         Call(bcx, ccx.upcalls.free_shared_type_desc, [v]);
         bcx
@@ -1001,7 +998,7 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
 
 fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
     // NB: v0 is an *alias* of type t here, not a direct value.
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     let bcx = alt ty::get(t).struct {
       ty::ty_box(_) | ty::ty_opaque_box {
         decr_refcnt_maybe_free(bcx, Load(bcx, v0), t)
@@ -1034,7 +1031,7 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
 
 fn trans_res_drop(bcx: block, rs: ValueRef, did: ast::def_id,
                   inner_t: ty::t, tps: [ty::t]) -> block {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     let inner_t_s = ty::substitute_type_params(ccx.tcx, tps, inner_t);
     let tup_ty = ty::mk_tup(ccx.tcx, [ty::mk_int(ccx.tcx), inner_t_s]);
 
@@ -1070,14 +1067,14 @@ fn maybe_validate_box(_cx: block, _box_ptr: ValueRef) {
     // bugs.  But do not commit with this uncommented!  Big performance hit.
 
     // let cx = _cx, box_ptr = _box_ptr;
-    // let ccx = bcx_ccx(cx);
+    // let ccx = cx.ccx();
     // warn_not_to_commit(ccx, "validate_box() is uncommented");
     // let raw_box_ptr = PointerCast(cx, box_ptr, T_ptr(T_i8()));
     // Call(cx, ccx.upcalls.validate_box, [raw_box_ptr]);
 }
 
 fn decr_refcnt_maybe_free(bcx: block, box_ptr: ValueRef, t: ty::t) -> block {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     maybe_validate_box(bcx, box_ptr);
 
     let llbox_ty = T_opaque_box_ptr(ccx);
@@ -1120,7 +1117,7 @@ fn compare_scalar_types(cx: block, lhs: ValueRef, rhs: ValueRef,
       }
       _ {
         // Should never get here, because t is scalar.
-        bcx_ccx(cx).sess.bug("non-scalar type passed to \
+        cx.sess().bug("non-scalar type passed to \
                                  compare_scalar_types");
       }
     }
@@ -1131,7 +1128,7 @@ fn compare_scalar_types(cx: block, lhs: ValueRef, rhs: ValueRef,
 fn compare_scalar_values(cx: block, lhs: ValueRef, rhs: ValueRef,
                          nt: scalar_type, op: ast::binop) -> ValueRef {
     fn die_(cx: block) -> ! {
-        bcx_tcx(cx).sess.bug("compare_scalar_values: must be a\
+        cx.tcx().sess.bug("compare_scalar_values: must be a\
           comparison operator");
     }
     let die = bind die_(cx);
@@ -1205,7 +1202,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
                     f: val_and_ty_fn) -> block {
         if variant.args.len() == 0u { ret cx; }
         let fn_ty = variant.ctor_ty;
-        let ccx = bcx_ccx(cx);
+        let ccx = cx.ccx();
         let cx = cx;
         alt ty::get(fn_ty).struct {
           ty::ty_fn({inputs: args, _}) {
@@ -1222,7 +1219,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
             }
           }
           // Precondition?
-          _ { bcx_tcx(cx).sess.bug("iter_variant: not a function type"); }
+          _ { cx.tcx().sess.bug("iter_variant: not a function type"); }
         }
         ret cx;
     }
@@ -1249,7 +1246,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
         }
       }
       ty::ty_res(_, inner, tps) {
-        let tcx = bcx_tcx(cx);
+        let tcx = cx.tcx();
         let inner1 = ty::substitute_type_params(tcx, tps, inner);
         let inner_t_s = ty::substitute_type_params(tcx, tps, inner);
         let tup_t = ty::mk_tup(tcx, [ty::mk_int(tcx), inner_t_s]);
@@ -1257,7 +1254,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
         ret f(bcx, llfld_a, inner1);
       }
       ty::ty_enum(tid, tps) {
-        let variants = ty::enum_variants(bcx_tcx(cx), tid);
+        let variants = ty::enum_variants(cx.tcx(), tid);
         let n_variants = (*variants).len();
 
         // Cast the enums to types we can GEP into.
@@ -1265,7 +1262,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
             ret iter_variant(cx, av, variants[0], tps, tid, f);
         }
 
-        let ccx = bcx_ccx(cx);
+        let ccx = cx.ccx();
         let llenumty = T_opaque_enum_ptr(ccx);
         let av_enum = PointerCast(cx, av, llenumty);
         let lldiscrim_a_ptr = GEPi(cx, av_enum, [0, 0]);
@@ -1274,7 +1271,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
 
         // NB: we must hit the discriminant first so that structural
         // comparison know not to proceed when the discriminants differ.
-        cx = f(cx, lldiscrim_a_ptr, ty::mk_int(bcx_tcx(cx)));
+        cx = f(cx, lldiscrim_a_ptr, ty::mk_int(cx.tcx()));
         let unr_cx = sub_block(cx, "enum-iter-unr");
         Unreachable(unr_cx);
         let llswitch = Switch(cx, lldiscrim_a, unr_cx.llbb, n_variants);
@@ -1291,7 +1288,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
         }
         ret next_cx;
       }
-      _ { bcx_ccx(cx).sess.unimpl("type in iter_structural_ty"); }
+      _ { cx.sess().unimpl("type in iter_structural_ty"); }
     }
     ret cx;
 }
@@ -1370,7 +1367,7 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: int,
 
 fn call_tydesc_glue_full(cx: block, v: ValueRef, tydesc: ValueRef,
                          field: int, static_ti: option<@tydesc_info>) {
-    lazily_emit_tydesc_glue(bcx_ccx(cx), field, static_ti);
+    lazily_emit_tydesc_glue(cx.ccx(), field, static_ti);
 
     let static_glue_fn = none;
     alt static_ti {
@@ -1435,7 +1432,7 @@ fn call_cmp_glue(cx: block, lhs: ValueRef, rhs: ValueRef, t: ty::t,
         GEPi(bcx, lltydesc, [0, abi::tydesc_field_first_param]);
     lltydescs = Load(bcx, lltydescs);
 
-    let llfn = bcx_ccx(bcx).upcalls.cmp_type;
+    let llfn = bcx.ccx().upcalls.cmp_type;
 
     let llcmpresultptr = alloca(bcx, T_i1());
     Call(bcx, llfn, [llcmpresultptr, lltydesc, lltydescs,
@@ -1444,14 +1441,14 @@ fn call_cmp_glue(cx: block, lhs: ValueRef, rhs: ValueRef, t: ty::t,
 }
 
 fn take_ty(cx: block, v: ValueRef, t: ty::t) -> block {
-    if ty::type_needs_drop(bcx_tcx(cx), t) {
+    if ty::type_needs_drop(cx.tcx(), t) {
         ret call_tydesc_glue(cx, v, t, abi::tydesc_field_take_glue);
     }
     ret cx;
 }
 
 fn drop_ty(cx: block, v: ValueRef, t: ty::t) -> block {
-    if ty::type_needs_drop(bcx_tcx(cx), t) {
+    if ty::type_needs_drop(cx.tcx(), t) {
         ret call_tydesc_glue(cx, v, t, abi::tydesc_field_drop_glue);
     }
     ret cx;
@@ -1464,7 +1461,7 @@ fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block {
         decr_refcnt_maybe_free(bcx, v, t)
       }
       // Precondition?
-      _ { bcx_tcx(bcx).sess.bug("drop_ty_immediate: non-box ty"); }
+      _ { bcx.tcx().sess.bug("drop_ty_immediate: non-box ty"); }
     }
 }
 
@@ -1482,7 +1479,7 @@ fn take_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> result {
 }
 
 fn free_ty(cx: block, v: ValueRef, t: ty::t) -> block {
-    if ty::type_needs_drop(bcx_tcx(cx), t) {
+    if ty::type_needs_drop(cx.tcx(), t) {
         ret call_tydesc_glue(cx, v, t, abi::tydesc_field_free_glue);
     }
     ret cx;
@@ -1490,11 +1487,11 @@ fn free_ty(cx: block, v: ValueRef, t: ty::t) -> block {
 
 fn call_memmove(cx: block, dst: ValueRef, src: ValueRef,
                 n_bytes: ValueRef) -> result {
-    // TODO: Provide LLVM with better alignment information when the alignment
+    // FIXME: Provide LLVM with better alignment information when the alignment
     // is statically known (it must be nothing more than a constant int, or
     // LLVM complains -- not even a constant element of a tydesc works).
 
-    let ccx = bcx_ccx(cx);
+    let ccx = cx.ccx();
     let key = alt ccx.sess.targ_cfg.arch {
       session::arch_x86 | session::arch_arm { "llvm.memmove.p0i8.p0i8.i32" }
       session::arch_x86_64 { "llvm.memmove.p0i8.p0i8.i64" }
@@ -1515,7 +1512,7 @@ fn call_memmove(cx: block, dst: ValueRef, src: ValueRef,
 
 fn memmove_ty(bcx: block, dst: ValueRef, src: ValueRef, t: ty::t) ->
     block {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     if check type_has_static_size(ccx, t) {
         if ty::type_is_structural(t) {
             let llsz = llsize_of(ccx, type_of(ccx, t));
@@ -1558,7 +1555,7 @@ fn copy_val(cx: block, action: copy_action, dst: ValueRef,
 
 fn copy_val_no_check(bcx: block, action: copy_action, dst: ValueRef,
                      src: ValueRef, t: ty::t) -> block {
-    let ccx = bcx_ccx(bcx), bcx = bcx;
+    let ccx = bcx.ccx(), bcx = bcx;
     if ty::type_is_scalar(t) {
         Store(bcx, src, dst);
         ret bcx;
@@ -1588,7 +1585,7 @@ fn copy_val_no_check(bcx: block, action: copy_action, dst: ValueRef,
 fn move_val(cx: block, action: copy_action, dst: ValueRef,
             src: lval_result, t: ty::t) -> block {
     let src_val = src.val;
-    let tcx = bcx_tcx(cx), cx = cx;
+    let tcx = cx.tcx(), cx = cx;
     if ty::type_is_scalar(t) {
         if src.kind == owned { src_val = Load(cx, src_val); }
         Store(cx, src_val, dst);
@@ -1612,7 +1609,7 @@ fn move_val(cx: block, action: copy_action, dst: ValueRef,
         ret cx;
     }
     /* FIXME: suggests a type constraint */
-    bcx_ccx(cx).sess.bug("unexpected type in trans::move_val: " +
+    cx.sess().bug("unexpected type in trans::move_val: " +
                              ty_to_str(tcx, t));
 }
 
@@ -1649,7 +1646,7 @@ fn trans_lit(cx: block, lit: ast::lit, dest: dest) -> block {
     alt lit.node {
       ast::lit_str(s) { ret tvec::trans_str(cx, s, dest); }
       _ {
-        ret store_in_dest(cx, trans_crate_lit(bcx_ccx(cx), lit), dest);
+        ret store_in_dest(cx, trans_crate_lit(cx.ccx(), lit), dest);
       }
     }
 }
@@ -1657,7 +1654,7 @@ fn trans_lit(cx: block, lit: ast::lit, dest: dest) -> block {
 fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr,
                un_expr: @ast::expr, dest: dest) -> block {
     // Check for user-defined method call
-    alt bcx_ccx(bcx).method_map.find(un_expr.id) {
+    alt bcx.ccx().method_map.find(un_expr.id) {
       some(origin) {
         let callee_id = ast_util::op_expr_callee_id(un_expr);
         let fty = node_id_type(bcx, callee_id);
@@ -1688,7 +1685,7 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr,
         // Cast the body type to the type of the value. This is needed to
         // make enums work, since enums have a different LLVM type depending
         // on whether they're boxed or not
-        let ccx = bcx_ccx(bcx);
+        let ccx = bcx.ccx();
         if check type_has_static_size(ccx, e_ty) {
             let llety = T_ptr(type_of(ccx, e_ty));
             body = PointerCast(bcx, body, llety);
@@ -1701,7 +1698,7 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr,
         ret uniq::trans_uniq(bcx, e, un_expr.id, dest);
       }
       ast::deref {
-        bcx_ccx(bcx).sess.bug("deref expressions should have been \
+        bcx.sess().bug("deref expressions should have been \
                                translated using trans_lval(), not \
                                trans_unary()");
       }
@@ -1722,7 +1719,7 @@ fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef,
       ast::lt | ast::ge { llop = C_u8(abi::cmp_glue_op_lt); }
       ast::le | ast::gt { llop = C_u8(abi::cmp_glue_op_le); }
       // Precondition?
-      _ { bcx_tcx(cx).sess.bug("trans_compare got\
+      _ { cx.tcx().sess.bug("trans_compare got\
               non-comparison-op"); }
     }
 
@@ -1734,7 +1731,7 @@ fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef,
       ast::ne | ast::ge | ast::gt {
         ret rslt(rs.bcx, Not(rs.bcx, rs.val));
       }
-      _ { bcx_tcx(cx).sess.bug("trans_compare got\
+      _ { cx.tcx().sess.bug("trans_compare got\
               non-comparison-op"); }
     }
 }
@@ -1799,7 +1796,7 @@ fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop,
     assert (lhs_res.kind == owned);
 
     // A user-defined operator method
-    alt bcx_ccx(bcx).method_map.find(ex.id) {
+    alt bcx.ccx().method_map.find(ex.id) {
       some(origin) {
         let callee_id = ast_util::op_expr_callee_id(ex);
         let fty = node_id_type(bcx, callee_id);
@@ -1840,7 +1837,7 @@ fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop,
 fn autoderef(cx: block, v: ValueRef, t: ty::t) -> result_t {
     let v1: ValueRef = v;
     let t1: ty::t = t;
-    let ccx = bcx_ccx(cx);
+    let ccx = cx.ccx();
     while true {
         alt ty::get(t1).struct {
           ty::ty_box(mt) {
@@ -1912,7 +1909,7 @@ fn trans_lazy_binop(bcx: block, op: lazy_binop_ty, a: @ast::expr,
 fn trans_binary(bcx: block, op: ast::binop, lhs: @ast::expr,
                 rhs: @ast::expr, dest: dest, ex: @ast::expr) -> block {
     // User-defined operators
-    alt bcx_ccx(bcx).method_map.find(ex.id) {
+    alt bcx.ccx().method_map.find(ex.id) {
       some(origin) {
         let callee_id = ast_util::op_expr_callee_id(ex);
         let fty = node_id_type(bcx, callee_id);
@@ -2037,7 +2034,7 @@ fn trans_if(cx: block, cond: @ast::expr, thn: ast::blk,
             trans_block(else_cx, blk, else_dest)
           }
           // would be nice to have a constraint on ifs
-          _ { bcx_tcx(cx).sess.bug("Strange alternative in if"); }
+          _ { cx.tcx().sess.bug("Strange alternative in if"); }
         }
       }
       _ { else_cx }
@@ -2056,14 +2053,14 @@ fn trans_for(cx: block, local: @ast::local, seq: @ast::expr,
                                         body.span);
         Br(bcx, scope_cx.llbb);
         let curr = PointerCast(bcx, curr,
-                               T_ptr(type_of_or_i8(bcx_ccx(bcx), t)));
+                               T_ptr(type_of_or_i8(bcx.ccx(), t)));
         let bcx = alt::bind_irrefutable_pat(scope_cx, local.node.pat,
                                                   curr, false);
         bcx = trans_block(bcx, body, ignore);
         cleanup_and_Br(bcx, scope_cx, next_cx.llbb);
         ret next_cx;
     }
-    let ccx = bcx_ccx(cx);
+    let ccx = cx.ccx();
     let next_cx = sub_block(cx, "next");
     let seq_ty = expr_ty(cx, seq);
     let {bcx: bcx, val: seq} = trans_temp_expr(cx, seq);
@@ -2141,7 +2138,7 @@ type lval_maybe_callee = {bcx: block,
                           generic: generic_callee};
 
 fn null_env_ptr(bcx: block) -> ValueRef {
-    C_null(T_opaque_box_ptr(bcx_ccx(bcx)))
+    C_null(T_opaque_box_ptr(bcx.ccx()))
 }
 
 fn lval_from_local_var(bcx: block, r: local_var_result) -> lval_result {
@@ -2235,7 +2232,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, substs: [ty::t],
 fn lval_static_fn(bcx: block, fn_id: ast::def_id, id: ast::node_id,
                   substs: option<([ty::t], typeck::dict_res)>)
     -> lval_maybe_callee {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     let tys = node_id_type_params(bcx, id);
     let tpt = ty::lookup_item_type(ccx.tcx, fn_id);
     // The awkwardness below mostly stems from the fact that we're mixing
@@ -2283,7 +2280,7 @@ fn lval_static_fn(bcx: block, fn_id: ast::def_id, id: ast::node_id,
 
     // FIXME: Need to support external crust functions
     if fn_id.crate == ast::local_crate {
-        alt bcx_tcx(bcx).def_map.find(id) {
+        alt bcx.tcx().def_map.find(id) {
           some(ast::def_fn(_, ast::crust_fn)) {
             // Crust functions are just opaque pointers
             let val = PointerCast(bcx, val, T_ptr(T_i8()));
@@ -2297,7 +2294,6 @@ fn lval_static_fn(bcx: block, fn_id: ast::def_id, id: ast::node_id,
     if tys.len() > 0u {
         let tydescs = [], tis = [];
         for t in tys {
-            // TODO: Doesn't always escape.
             let ti = none;
             let td = get_tydesc(bcx, t, true, ti);
             tis += [ti];
@@ -2356,23 +2352,23 @@ fn trans_local_var(cx: block, def: ast::def) -> local_var_result {
       ast::def_self(did) {
         let slf = option::get(cx.fcx.llself);
         let ptr = PointerCast(cx, slf.v,
-                              T_ptr(type_of_or_i8(bcx_ccx(cx), slf.t)));
+                              T_ptr(type_of_or_i8(cx.ccx(), slf.t)));
         ret {val: ptr, kind: owned};
       }
       _ {
-        bcx_ccx(cx).sess.unimpl("unsupported def type in trans_local_def");
+        cx.sess().unimpl("unsupported def type in trans_local_def");
       }
     }
 }
 
 fn trans_path(cx: block, id: ast::node_id)
     -> lval_maybe_callee {
-    ret trans_var(cx, bcx_tcx(cx).def_map.get(id), id);
+    ret trans_var(cx, cx.tcx().def_map.get(id), id);
 }
 
 fn trans_var(cx: block, def: ast::def, id: ast::node_id)
     -> lval_maybe_callee {
-    let ccx = bcx_ccx(cx);
+    let ccx = cx.ccx();
     alt def {
       ast::def_fn(did, _) {
         ret lval_static_fn(cx, did, id, none);
@@ -2420,7 +2416,7 @@ fn trans_rec_field(bcx: block, base: @ast::expr,
     let fields = alt ty::get(ty).struct {
             ty::ty_rec(fs) { fs }
             // Constraint?
-            _ { bcx_tcx(bcx).sess.span_bug(base.span, "trans_rec_field:\
+            _ { bcx.tcx().sess.span_bug(base.span, "trans_rec_field:\
                  base expr has non-record type"); }
         };
     let ix = option::get(ty::field_idx(field, fields));
@@ -2436,12 +2432,12 @@ fn trans_index(cx: block, ex: @ast::expr, base: @ast::expr,
     let ix = trans_temp_expr(lv.bcx, idx);
     let v = lv.val;
     let bcx = ix.bcx;
-    let ccx = bcx_ccx(cx);
+    let ccx = cx.ccx();
 
     // Cast to an LLVM integer. Rust is less strict than LLVM in this regard.
     let ix_val;
-    let ix_size = llsize_of_real(bcx_ccx(cx), val_ty(ix.val));
-    let int_size = llsize_of_real(bcx_ccx(cx), ccx.int_type);
+    let ix_size = llsize_of_real(cx.ccx(), val_ty(ix.val));
+    let int_size = llsize_of_real(cx.ccx(), ccx.int_type);
     if ix_size < int_size {
         ix_val = ZExt(bcx, ix.val, ccx.int_type);
     } else if ix_size > int_size {
@@ -2451,9 +2447,9 @@ fn trans_index(cx: block, ex: @ast::expr, base: @ast::expr,
     let unit_ty = node_id_type(cx, ex.id);
     let unit_sz = size_of(bcx, unit_ty);
     bcx = unit_sz.bcx;
-    maybe_name_value(bcx_ccx(cx), unit_sz.val, "unit_sz");
+    maybe_name_value(cx.ccx(), unit_sz.val, "unit_sz");
     let scaled_ix = Mul(bcx, ix_val, unit_sz.val);
-    maybe_name_value(bcx_ccx(cx), scaled_ix, "scaled_ix");
+    maybe_name_value(cx.ccx(), scaled_ix, "scaled_ix");
     let lim = tvec::get_fill(bcx, v);
     let body = tvec::get_dataptr(bcx, v, type_of_or_i8(ccx, unit_ty));
     let bounds_check = ICmp(bcx, lib::llvm::IntUGE, scaled_ix, lim);
@@ -2473,7 +2469,7 @@ fn trans_index(cx: block, ex: @ast::expr, base: @ast::expr,
 }
 
 fn expr_is_lval(bcx: block, e: @ast::expr) -> bool {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     ty::expr_is_lval(ccx.method_map, e)
 }
 
@@ -2483,12 +2479,12 @@ fn trans_callee(bcx: block, e: @ast::expr) -> lval_maybe_callee {
       ast::expr_field(base, ident, _) {
         // Lval means this is a record field, so not a method
         if !expr_is_lval(bcx, e) {
-            alt bcx_ccx(bcx).method_map.find(e.id) {
+            alt bcx.ccx().method_map.find(e.id) {
               some(origin) { // An impl method
                 ret impl::trans_method_callee(bcx, e.id, base, origin);
               }
               // Precondition?
-              _ { bcx_tcx(bcx).sess.span_bug(e.span, "trans_callee: weird\
+              _ { bcx.tcx().sess.span_bug(e.span, "trans_callee: weird\
                     expr"); }
             }
         }
@@ -2516,7 +2512,7 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result {
         ret trans_index(cx, e, base, idx);
       }
       ast::expr_unary(ast::deref, base) {
-        let ccx = bcx_ccx(cx);
+        let ccx = cx.ccx();
         let sub = trans_temp_expr(cx, base);
         let t = expr_ty(cx, base);
         let val = alt ty::get(t).struct {
@@ -2537,13 +2533,13 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result {
           ty::ty_ptr(_) | ty::ty_uniq(_) { sub.val }
           // Precondition?
           _ {
-            bcx_tcx(cx).sess.span_bug(e.span, "trans_lval:\
+            cx.tcx().sess.span_bug(e.span, "trans_lval:\
                                                Weird argument in deref");
           }
         };
         ret lval_owned(sub.bcx, val);
       }
-      _ { bcx_ccx(cx).sess.span_bug(e.span, "non-lval in trans_lval"); }
+      _ { cx.sess().span_bug(e.span, "non-lval in trans_lval"); }
     }
 }
 
@@ -2597,7 +2593,7 @@ fn float_cast(bcx: block, lldsttype: TypeRef, llsrctype: TypeRef,
 
 fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id,
               dest: dest) -> block {
-    let ccx = bcx_ccx(cx);
+    let ccx = cx.ccx();
     let t_out = node_id_type(cx, id);
     alt ty::get(t_out).struct {
       ty::ty_iface(_, _) { ret impl::trans_cast(cx, e, id, dest); }
@@ -2670,7 +2666,7 @@ fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id,
 
 fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef,
                   e: @ast::expr) -> result {
-    let ccx = bcx_ccx(cx);
+    let ccx = cx.ccx();
     let e_ty = expr_ty(cx, e);
     let is_bot = ty::type_is_bot(e_ty);
     let lv = trans_temp_lval(cx, e);
@@ -2747,7 +2743,7 @@ fn trans_args(cx: block, llenv: ValueRef,
     let llargs: [ValueRef] = [];
     let lltydescs: [ValueRef] = [];
 
-    let ccx = bcx_ccx(cx);
+    let ccx = cx.ccx();
     let bcx = cx;
 
     let retty = ty::ty_fn_ret(fn_ty), full_retty = retty;
@@ -2846,7 +2842,7 @@ fn trans_call_inner(in_cx: block, fn_expr_ty: ty::t,
     -> block {
     with_scope(in_cx, "call") {|cx|
         let f_res = get_callee(cx);
-        let bcx = f_res.bcx, ccx = bcx_ccx(cx);
+        let bcx = f_res.bcx, ccx = cx.ccx();
 
         let faddr = f_res.val;
         let llenv, dict_param = none;
@@ -2958,7 +2954,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef {
     // The exception handling personality function. This is the C++
     // personality function __gxx_personality_v0, wrapped in our naming
     // convention.
-    let personality = bcx_ccx(bcx).upcalls.rust_personality;
+    let personality = bcx.ccx().upcalls.rust_personality;
     // The only landing pad clause will be 'cleanup'
     let llretval = LandingPad(pad_bcx, llretty, personality, 1u);
     // The landing pad block is a cleanup
@@ -2967,7 +2963,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef {
     // Because we may have unwound across a stack boundary, we must call into
     // the runtime to figure out which stack segment we are on and place the
     // stack limit back into the TLS.
-    Call(pad_bcx, bcx_ccx(bcx).upcalls.reset_stack_limit, []);
+    Call(pad_bcx, bcx.ccx().upcalls.reset_stack_limit, []);
 
     // We store the retval in a function-central alloca, so that calls to
     // Resume can find it.
@@ -2995,7 +2991,7 @@ fn trans_tup(bcx: block, elts: [@ast::expr], id: ast::node_id,
         ret bcx;
       }
       save_in(pos) { pos }
-      _ { bcx_tcx(bcx).sess.bug("trans_tup: weird dest"); }
+      _ { bcx.tcx().sess.bug("trans_tup: weird dest"); }
     };
     let temp_cleanups = [], i = 0;
     for e in elts {
@@ -3023,12 +3019,12 @@ fn trans_rec(bcx: block, fields: [ast::field],
         ret bcx;
       }
       save_in(pos) { pos }
-      _ { bcx_tcx(bcx).sess.bug("trans_rec: weird dest"); }
+      _ { bcx.tcx().sess.bug("trans_rec: weird dest"); }
     };
 
     let ty_fields = alt ty::get(t).struct {
       ty::ty_rec(f) { f }
-      _ { bcx_tcx(bcx).sess.bug("trans_rec: id doesn't\
+      _ { bcx.tcx().sess.bug("trans_rec: id doesn't\
            have a record type") } };
     let temp_cleanups = [];
     for fld in fields {
@@ -3116,7 +3112,7 @@ fn trans_temp_expr(bcx: block, e: @ast::expr) -> result {
 // - exprs returning nil or bot always get dest=ignore
 // - exprs with non-immediate type never get dest=by_val
 fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
-    let tcx = bcx_tcx(bcx);
+    let tcx = bcx.tcx();
     debuginfo::update_source_pos(bcx, e.span);
 
     #debug["trans_expr(%s,%?)", expr_to_str(e), dest];
@@ -3192,7 +3188,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
       }
       ast::expr_index(base, idx) {
         // If it is here, it's not an lval, so this is a user-defined index op
-        let origin = bcx_ccx(bcx).method_map.get(e.id);
+        let origin = bcx.ccx().method_map.get(e.id);
         let callee_id = ast_util::op_expr_callee_id(e);
         let fty = node_id_type(bcx, callee_id);
         ret trans_call_inner(bcx, fty, {|bcx|
@@ -3244,7 +3240,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
            check the value of that variable, doing nothing
            if it's set to false and acting like a check
            otherwise. */
-        let c = get_extern_const(bcx_ccx(bcx).externs, bcx_ccx(bcx).llmod,
+        let c = get_extern_const(bcx.ccx().externs, bcx.ccx().llmod,
                                  "check_claims", T_bool());
         ret with_cond(bcx, Load(bcx, c)) {|bcx|
             trans_check_expr(bcx, a, "Claim")
@@ -3269,7 +3265,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
         assert kind == owned;
         ret store_temp_expr(bcx, DROP_EXISTING, addr, src_r,
                             expr_ty(bcx, src),
-                            bcx_ccx(bcx).last_uses.contains_key(src.id));
+                            bcx.ccx().last_uses.contains_key(src.id));
       }
       ast::expr_move(dst, src) {
         // FIXME: calculate copy init-ness in typestate.
@@ -3296,14 +3292,14 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block {
         assert dest == ignore;
         ret trans_assign_op(bcx, e, op, dst, src);
       }
-      _ { bcx_tcx(bcx).sess.span_bug(e.span, "trans_expr reached\
+      _ { bcx.tcx().sess.span_bug(e.span, "trans_expr reached\
              fall-through case"); }
 
     }
 }
 
 fn lval_to_dps(bcx: block, e: @ast::expr, dest: dest) -> block {
-    let lv = trans_lval(bcx, e), ccx = bcx_ccx(bcx);
+    let lv = trans_lval(bcx, e), ccx = bcx.ccx();
     let {bcx, val, kind} = lv;
     let last_use = kind == owned && ccx.last_uses.contains_key(e.id);
     let ty = expr_ty(bcx, e);
@@ -3368,7 +3364,7 @@ fn load_if_immediate(cx: block, v: ValueRef, t: ty::t) -> ValueRef {
 }
 
 fn trans_log(lvl: @ast::expr, bcx: block, e: @ast::expr) -> block {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     if ty::type_is_bot(expr_ty(bcx, lvl)) {
        ret trans_expr(bcx, lvl, ignore);
     }
@@ -3427,7 +3423,7 @@ fn trans_fail_expr(bcx: block, sp_opt: option<span>,
     let bcx = bcx;
     alt fail_expr {
       some(expr) {
-        let ccx = bcx_ccx(bcx), tcx = ccx.tcx;
+        let ccx = bcx.ccx(), tcx = ccx.tcx;
         let expr_res = trans_temp_expr(bcx, expr);
         let e_ty = expr_ty(bcx, expr);
         bcx = expr_res.bcx;
@@ -3440,7 +3436,7 @@ fn trans_fail_expr(bcx: block, sp_opt: option<span>,
         } else if bcx.unreachable || ty::type_is_bot(e_ty) {
             ret bcx;
         } else {
-            bcx_ccx(bcx).sess.span_bug(
+            bcx.sess().span_bug(
                 expr.span, "fail called with unsupported type " +
                 ty_to_str(tcx, e_ty));
         }
@@ -3451,28 +3447,28 @@ fn trans_fail_expr(bcx: block, sp_opt: option<span>,
 
 fn trans_fail(bcx: block, sp_opt: option<span>, fail_str: str) ->
     block {
-    let V_fail_str = C_cstr(bcx_ccx(bcx), fail_str);
+    let V_fail_str = C_cstr(bcx.ccx(), fail_str);
     ret trans_fail_value(bcx, sp_opt, V_fail_str);
 }
 
 fn trans_fail_value(bcx: block, sp_opt: option<span>,
                     V_fail_str: ValueRef) -> block {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     let V_filename;
     let V_line;
     alt sp_opt {
       some(sp) {
-        let sess = bcx_ccx(bcx).sess;
+        let sess = bcx.sess();
         let loc = codemap::lookup_char_pos(sess.parse_sess.cm, sp.lo);
-        V_filename = C_cstr(bcx_ccx(bcx), loc.file.name);
+        V_filename = C_cstr(bcx.ccx(), loc.file.name);
         V_line = loc.line as int;
       }
-      none { V_filename = C_cstr(bcx_ccx(bcx), "<runtime>"); V_line = 0; }
+      none { V_filename = C_cstr(bcx.ccx(), "<runtime>"); V_line = 0; }
     }
     let V_str = PointerCast(bcx, V_fail_str, T_ptr(T_i8()));
     V_filename = PointerCast(bcx, V_filename, T_ptr(T_i8()));
     let args = [V_str, V_filename, C_int(ccx, V_line)];
-    let bcx = invoke(bcx, bcx_ccx(bcx).upcalls._fail, args);
+    let bcx = invoke(bcx, bcx.ccx().upcalls._fail, args);
     Unreachable(bcx);
     ret bcx;
 }
@@ -3499,7 +3495,7 @@ fn trans_break_cont(bcx: block, to_end: bool)
         unwind = alt check unwind.parent {
           parent_some(cx) { cx }
           parent_none {
-            bcx_ccx(bcx).sess.bug
+            bcx.sess().bug
                 (if to_end { "break" } else { "cont" } + " outside a loop");
           }
         };
@@ -3528,7 +3524,7 @@ fn trans_ret(bcx: block, e: option<@ast::expr>) -> block {
     ret bcx;
 }
 
-fn build_return(bcx: block) { Br(bcx, bcx_fcx(bcx).llreturn); }
+fn build_return(bcx: block) { Br(bcx, bcx.fcx.llreturn); }
 
 // fn trans_be(cx: &block, e: &@ast::expr) -> result {
 fn trans_be(cx: block, e: @ast::expr) : ast_util::is_call_expr(e) ->
@@ -3542,7 +3538,7 @@ fn init_local(bcx: block, local: @ast::local) -> block {
     let ty = node_id_type(bcx, local.node.id);
     let llptr = alt bcx.fcx.lllocals.find(local.node.id) {
       some(local_mem(v)) { v }
-      some(_) { bcx_tcx(bcx).sess.span_bug(local.span,
+      some(_) { bcx.tcx().sess.span_bug(local.span,
                         "init_local: Someone forgot to document why it's\
                          safe to assume local.node.init must be local_mem!");
       }
@@ -3550,7 +3546,7 @@ fn init_local(bcx: block, local: @ast::local) -> block {
       none {
         let initexpr = alt local.node.init {
                 some({expr, _}) { expr }
-                none { bcx_tcx(bcx).sess.span_bug(local.span,
+                none { bcx.tcx().sess.span_bug(local.span,
                         "init_local: Someone forgot to document why it's\
                          safe to assume local.node.init isn't none!"); }
             };
@@ -3586,7 +3582,7 @@ fn init_local(bcx: block, local: @ast::local) -> block {
 fn zero_alloca(cx: block, llptr: ValueRef, t: ty::t)
     -> block {
     let bcx = cx;
-    let ccx = bcx_ccx(cx);
+    let ccx = cx.ccx();
     if check type_has_static_size(ccx, t) {
         let llty = type_of(ccx, t);
         Store(bcx, C_null(llty), llptr);
@@ -3610,7 +3606,7 @@ fn zero_alloca(cx: block, llptr: ValueRef, t: ty::t)
 fn trans_stmt(cx: block, s: ast::stmt) -> block {
     #debug["trans_expr(%s)", stmt_to_str(s)];
 
-    if (!bcx_ccx(cx).sess.opts.no_asm_comments) {
+    if (!cx.sess().opts.no_asm_comments) {
         add_span_comment(cx, s.span, stmt_to_str(s));
     }
 
@@ -3626,7 +3622,7 @@ fn trans_stmt(cx: block, s: ast::stmt) -> block {
           ast::decl_local(locals) {
             for local in locals {
                 bcx = init_local(bcx, local);
-                if bcx_ccx(cx).sess.opts.extra_debuginfo {
+                if cx.sess().opts.extra_debuginfo {
                     debuginfo::create_local_var(bcx, local);
                 }
             }
@@ -3634,7 +3630,7 @@ fn trans_stmt(cx: block, s: ast::stmt) -> block {
           ast::decl_item(i) { trans_item(cx.fcx.ccx, *i); }
         }
       }
-      _ { bcx_ccx(cx).sess.unimpl("stmt variant"); }
+      _ { cx.sess().unimpl("stmt variant"); }
     }
 
     ret bcx;
@@ -3805,7 +3801,7 @@ fn with_cond(bcx: block, val: ValueRef, f: fn(block) -> block) -> block {
 
 fn trans_fn_cleanups(fcx: @fn_ctxt, cx: block) {
     option::may(fcx.llobstacktoken) {|lltoken|
-        Call(cx, fcx_ccx(fcx).upcalls.dynastack_free, [lltoken]);
+        Call(cx, fcx.ccx.upcalls.dynastack_free, [lltoken]);
     }
 }
 
@@ -3826,7 +3822,7 @@ fn block_locals(b: ast::blk, it: fn(@ast::local)) {
 }
 
 fn alloc_ty(cx: block, t: ty::t) -> result {
-    let bcx = cx, ccx = bcx_ccx(cx);
+    let bcx = cx, ccx = cx.ccx();
     let llty = type_of(ccx, t);
     let val = if type_has_static_size(ccx, t) {
         alloca(bcx, llty)
@@ -3853,12 +3849,12 @@ fn alloc_ty(cx: block, t: ty::t) -> result {
 
 fn alloc_local(cx: block, local: @ast::local) -> block {
     let t = node_id_type(cx, local.node.id);
-    let p = normalize_pat(bcx_tcx(cx), local.node.pat);
+    let p = normalize_pat(cx.tcx(), local.node.pat);
     let is_simple = alt p.node {
       ast::pat_ident(_, none) { true } _ { false }
     };
     // Do not allocate space for locals that can be kept immediate.
-    let ccx = bcx_ccx(cx);
+    let ccx = cx.ccx();
     if is_simple && !ccx.mutbl_map.contains_key(local.node.pat.id) &&
        !ccx.last_uses.contains_key(local.node.pat.id) &&
        ty::type_is_immediate(t) {
@@ -3870,7 +3866,7 @@ fn alloc_local(cx: block, local: @ast::local) -> block {
     let r = alloc_ty(cx, t);
     alt p.node {
       ast::pat_ident(pth, none) {
-        if bcx_ccx(cx).sess.opts.debuginfo {
+        if cx.sess().opts.debuginfo {
             let _: () = str::as_buf(path_to_ident(pth), {|buf|
                 llvm::LLVMSetValueName(r.val, buf)
             });
@@ -3978,10 +3974,8 @@ fn new_fn_ctxt(ccx: @crate_ctxt, path: path, llfndecl: ValueRef,
 // field of the fn_ctxt with
 fn create_llargs_for_fn_args(cx: @fn_ctxt, ty_self: self_arg,
                              args: [ast::arg], ty_params: [ast::ty_param]) {
-    // Skip the implicit arguments 0, and 1.  TODO: Pull out 2u and define
-    // it as a constant, since we're using it in several places in trans this
-    // way.
-    let arg_n = 2u;
+    // Skip the implicit arguments 0, and 1.
+    let arg_n = first_tp_arg;
     alt ty_self {
       impl_self(tt) {
         cx.llself = some({v: cx.llenv, t: tt});
@@ -3992,7 +3986,7 @@ fn create_llargs_for_fn_args(cx: @fn_ctxt, ty_self: self_arg,
         let lltydesc = llvm::LLVMGetParam(cx.llfn, arg_n as c_uint);
         let dicts = none;
         arg_n += 1u;
-        for bound in *fcx_tcx(cx).ty_param_bounds.get(tp.id) {
+        for bound in *cx.ccx.tcx.ty_param_bounds.get(tp.id) {
             alt bound {
               ty::bound_iface(_) {
                 let dict = llvm::LLVMGetParam(cx.llfn, arg_n as c_uint);
@@ -4023,7 +4017,7 @@ fn create_llargs_for_fn_args(cx: @fn_ctxt, ty_self: self_arg,
 
 fn copy_args_to_allocas(fcx: @fn_ctxt, bcx: block, args: [ast::arg],
                         arg_tys: [ty::arg]) -> block {
-    let tcx = bcx_tcx(bcx);
+    let tcx = bcx.tcx();
     let arg_n: uint = 0u, bcx = bcx;
     let epic_fail = fn@() -> ! {
         tcx.sess.bug("Someone forgot\
@@ -4048,7 +4042,7 @@ fn copy_args_to_allocas(fcx: @fn_ctxt, bcx: block, args: [ast::arg],
           }
           ast::by_ref {}
         }
-        if fcx_ccx(fcx).sess.opts.extra_debuginfo {
+        if fcx.ccx.sess.opts.extra_debuginfo {
             debuginfo::create_arg(bcx, args[arg_n], args[arg_n].ty.span);
         }
         arg_n += 1u;
@@ -4223,9 +4217,9 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id,
         // If this argument to this function is a enum, it'll have come in to
         // this function as an opaque blob due to the way that type_of()
         // works. So we have to cast to the destination's view of the type.
-        let llarg = alt fcx.llargs.find(va.id) { some(local_mem(x)) { x }
-          _ { bcx_tcx(bcx).sess.span_fatal(variant.span, "Someone forgot\
-                to document an invariant in trans_tag_variant"); } };
+        let llarg = alt check fcx.llargs.find(va.id) {
+          some(local_mem(x)) { x }
+        };
         let arg_ty = arg_tys[i].ty;
         if ty::type_has_params(arg_ty) {
             lldestptr = PointerCast(bcx, lldestptr, val_ty(llarg));
@@ -4527,14 +4521,14 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
 // on the stack).
 fn create_real_fn_pair(cx: block, llfnty: TypeRef, llfn: ValueRef,
                        llenvptr: ValueRef) -> ValueRef {
-    let pair = alloca(cx, T_fn_pair(bcx_ccx(cx), llfnty));
+    let pair = alloca(cx, T_fn_pair(cx.ccx(), llfnty));
     fill_fn_pair(cx, pair, llfn, llenvptr);
     ret pair;
 }
 
 fn fill_fn_pair(bcx: block, pair: ValueRef, llfn: ValueRef,
                 llenvptr: ValueRef) {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     let code_cell = GEPi(bcx, pair, [0, abi::fn_field_code]);
     Store(bcx, llfn, code_cell);
     let env_cell = GEPi(bcx, pair, [0, abi::fn_field_box]);
@@ -4716,7 +4710,7 @@ fn trans_constants(ccx: @crate_ctxt, crate: @ast::crate) {
 }
 
 fn vp2i(cx: block, v: ValueRef) -> ValueRef {
-    let ccx = bcx_ccx(cx);
+    let ccx = cx.ccx();
     ret PtrToInt(cx, v, ccx.int_type);
 }
 
@@ -4778,9 +4772,9 @@ fn declare_dbg_intrinsics(llmod: ModuleRef,
 
 fn trap(bcx: block) {
     let v: [ValueRef] = [];
-    alt bcx_ccx(bcx).intrinsics.find("llvm.trap") {
+    alt bcx.ccx().intrinsics.find("llvm.trap") {
       some(x) { Call(bcx, x, v); }
-      _ { bcx_ccx(bcx).sess.bug("unbound llvm.trap in trap"); }
+      _ { bcx.sess().bug("unbound llvm.trap in trap"); }
     }
 }
 
diff --git a/src/comp/middle/trans/build.rs b/src/comp/middle/trans/build.rs
index 95738143150..91dcb347135 100644
--- a/src/comp/middle/trans/build.rs
+++ b/src/comp/middle/trans/build.rs
@@ -6,8 +6,7 @@ import codemap::span;
 import lib::llvm::{ValueRef, TypeRef, BasicBlockRef, BuilderRef, ModuleRef};
 import lib::llvm::{Opcode, IntPredicate, RealPredicate, True, False,
                    CallConv};
-import common::{block, T_ptr, T_nil, T_i8, T_i1, T_void,
-                T_fn, val_ty, bcx_ccx, C_i32, val_str};
+import common::*;
 
 fn B(cx: block) -> BuilderRef {
     let b = *cx.fcx.ccx.builder;
@@ -95,8 +94,8 @@ fn Invoke(cx: block, Fn: ValueRef, Args: [ValueRef],
     assert (!cx.terminated);
     cx.terminated = true;
     #debug["Invoke(%s with arguments (%s))",
-           val_str(bcx_ccx(cx).tn, Fn),
-           str::connect(vec::map(Args, {|a|val_str(bcx_ccx(cx).tn, a)}),
+           val_str(cx.ccx().tn, Fn),
+           str::connect(vec::map(Args, {|a|val_str(cx.ccx().tn, a)}),
                         ", ")];
     unsafe {
         llvm::LLVMBuildInvoke(B(cx), Fn, vec::to_ptr(Args),
@@ -518,7 +517,7 @@ fn _UndefReturn(cx: block, Fn: ValueRef) -> ValueRef {
 }
 
 fn add_span_comment(bcx: block, sp: span, text: str) {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     if (!ccx.sess.opts.no_asm_comments) {
         let s = text + " (" + codemap::span_to_str(sp, ccx.sess.codemap)
             + ")";
@@ -528,7 +527,7 @@ fn add_span_comment(bcx: block, sp: span, text: str) {
 }
 
 fn add_comment(bcx: block, text: str) {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     if (!ccx.sess.opts.no_asm_comments) {
         check str::is_not_empty("$");
         let sanitized = str::replace(text, "$", "");
diff --git a/src/comp/middle/trans/closure.rs b/src/comp/middle/trans/closure.rs
index bb07da27ca8..e6cd6d07b74 100644
--- a/src/comp/middle/trans/closure.rs
+++ b/src/comp/middle/trans/closure.rs
@@ -167,12 +167,11 @@ fn allocate_cbox(bcx: block,
                  cdata_ty: ty::t)
     -> (block, ValueRef, [ValueRef]) {
 
-    // let ccx = bcx_ccx(bcx);
-    let ccx = bcx_ccx(bcx), tcx = ccx.tcx;
+    let ccx = bcx.ccx(), tcx = ccx.tcx;
 
     fn nuke_ref_count(bcx: block, box: ValueRef) {
         // Initialize ref count to arbitrary value for debugging:
-        let ccx = bcx_ccx(bcx);
+        let ccx = bcx.ccx();
         let box = PointerCast(bcx, box, T_opaque_box_ptr(ccx));
         let ref_cnt = GEPi(bcx, box, [0, abi::box_field_refcnt]);
         let rc = C_int(ccx, 0x12345678);
@@ -183,7 +182,7 @@ fn allocate_cbox(bcx: block,
                          cdata_ty: ty::t,
                          box: ValueRef,
                          &ti: option::t<@tydesc_info>) -> block {
-        let ccx = bcx_ccx(bcx);
+        let ccx = bcx.ccx();
         let bound_tydesc = GEPi(bcx, box, [0, abi::box_field_tydesc]);
         let {bcx, val: td} = base::get_tydesc(bcx, cdata_ty, true, ti);
         let td = Call(bcx, ccx.upcalls.create_shared_type_desc, [td]);
@@ -228,7 +227,7 @@ type closure_result = {
 };
 
 fn cast_if_we_can(bcx: block, llbox: ValueRef, t: ty::t) -> ValueRef {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     if check type_has_static_size(ccx, t) {
         let llty = type_of(ccx, t);
         ret PointerCast(bcx, llbox, llty);
@@ -255,13 +254,12 @@ fn store_environment(
             td
           }
           ty::ck_uniq {
-            Call(bcx, bcx_ccx(bcx).upcalls.create_shared_type_desc, [td])
+            Call(bcx, bcx.ccx().upcalls.create_shared_type_desc, [td])
           }
         };
     }
 
-    let ccx = bcx_ccx(bcx);
-    let tcx = bcx_tcx(bcx);
+    let ccx = bcx.ccx(), tcx = ccx.tcx;
 
     // compute the shape of the closure
     let (cdata_ty, bound_tys) =
@@ -356,7 +354,7 @@ fn build_closure(bcx0: block,
     // If we need to, package up the iterator body to call
     let env_vals = [];
     let bcx = bcx0;
-    let tcx = bcx_tcx(bcx);
+    let tcx = bcx.tcx();
 
     // Package up the captured upvars
     vec::iter(cap_vars) { |cap_var|
@@ -449,7 +447,7 @@ fn trans_expr_fn(bcx: block,
                  cap_clause: ast::capture_clause,
                  dest: dest) -> block {
     if dest == ignore { ret bcx; }
-    let ccx = bcx_ccx(bcx), bcx = bcx;
+    let ccx = bcx.ccx(), bcx = bcx;
     let fty = node_id_type(bcx, id);
     let llfnty = type_of_fn_from_ty(ccx, fty, []);
     let sub_path = bcx.fcx.path + [path_name("anon")];
@@ -493,7 +491,7 @@ fn trans_bind_1(cx: block, outgoing_fty: ty::t,
                 f_res: lval_maybe_callee,
                 args: [option<@ast::expr>], pair_ty: ty::t,
                 dest: dest) -> block {
-    let ccx = bcx_ccx(cx);
+    let ccx = cx.ccx();
     let bound: [@ast::expr] = [];
     for argopt: option<@ast::expr> in args {
         alt argopt { none { } some(e) { bound += [e]; } }
@@ -579,7 +577,7 @@ fn make_fn_glue(
     glue_fn: fn@(block, v: ValueRef, t: ty::t) -> block)
     -> block {
     let bcx = cx;
-    let tcx = bcx_tcx(cx);
+    let tcx = cx.tcx();
 
     let fn_env = fn@(ck: ty::closure_kind) -> block {
         let box_cell_v = GEPi(cx, v, [0, abi::fn_field_box]);
@@ -613,8 +611,7 @@ fn make_opaque_cbox_take_glue(
     }
 
     // Hard case, a deep copy:
-    let ccx = bcx_ccx(bcx);
-    let tcx = bcx_tcx(bcx);
+    let ccx = bcx.ccx(), tcx = ccx.tcx;
     let llopaquecboxty = T_opaque_box_ptr(ccx);
     let cbox_in = Load(bcx, cboxptr);
     with_cond(bcx, IsNotNull(bcx, cbox_in)) {|bcx|
@@ -657,11 +654,11 @@ fn make_opaque_cbox_drop_glue(
       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::mk_opaque_closure_ptr(bcx.tcx(), ck))
       }
       ty::ck_uniq {
         free_ty(bcx, Load(bcx, cboxptr),
-                ty::mk_opaque_closure_ptr(bcx_tcx(bcx), ck))
+                ty::mk_opaque_closure_ptr(bcx.tcx(), ck))
       }
     }
 }
@@ -676,8 +673,7 @@ fn make_opaque_cbox_free_glue(
       ty::ck_box | ty::ck_uniq { /* hard cases: */ }
     }
 
-    let ccx = bcx_ccx(bcx);
-    let tcx = bcx_tcx(bcx);
+    let ccx = bcx.ccx(), tcx = ccx.tcx;
     with_cond(bcx, IsNotNull(bcx, cbox)) {|bcx|
         // Load the type descr found in the cbox
         let lltydescty = T_ptr(ccx.tydesc_type);
@@ -862,7 +858,7 @@ fn trans_bind_thunk(ccx: @crate_ctxt,
         fcx.lltyparams += [{desc: dsc, dicts: dicts}];
     }
 
-    let a: uint = 2u; // retptr, env come first
+    let a: uint = first_tp_arg; // retptr, env come first
     let b: int = starting_idx;
     let outgoing_arg_index: uint = 0u;
     let llout_arg_tys: [TypeRef] =
diff --git a/src/comp/middle/trans/common.rs b/src/comp/middle/trans/common.rs
index 6de08e2cfef..2fcd42a4d9d 100644
--- a/src/comp/middle/trans/common.rs
+++ b/src/comp/middle/trans/common.rs
@@ -68,10 +68,6 @@ resource BuilderRef_res(B: BuilderRef) { llvm::LLVMDisposeBuilder(B); }
 
 // Crate context.  Every crate we compile has one of these.
 type crate_ctxt =
-    // A mapping from the def_id of each item in this crate to the address
-    // of the first instruction of the item's definition in the executable
-    // we're generating.
-    // TODO: hashmap<tup(tag_id,subtys), @tag_info>
     {sess: session::session,
      llmod: ModuleRef,
      td: target_data,
@@ -233,14 +229,14 @@ fn scope_clean_changed(info: scope_info) {
 }
 
 fn add_clean(cx: block, val: ValueRef, ty: ty::t) {
-    if !ty::type_needs_drop(bcx_tcx(cx), ty) { ret; }
+    if !ty::type_needs_drop(cx.tcx(), ty) { ret; }
     in_scope_cx(cx) {|info|
         info.cleanups += [clean(bind drop_ty(_, val, ty))];
         scope_clean_changed(info);
     }
 }
 fn add_clean_temp(cx: block, val: ValueRef, ty: ty::t) {
-    if !ty::type_needs_drop(bcx_tcx(cx), ty) { ret; }
+    if !ty::type_needs_drop(cx.tcx(), ty) { ret; }
     fn do_drop(bcx: block, val: ValueRef, ty: ty::t) ->
        block {
         if ty::type_is_immediate(ty) {
@@ -255,7 +251,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(bcx_tcx(cx), ty) { ret; }
+    if !ty::type_needs_drop(cx.tcx(), ty) { ret; }
     in_scope_cx(cx) {|info|
         info.cleanups += [clean_temp(val, bind drop_ty(_, val, ty))];
         scope_clean_changed(info);
@@ -365,6 +361,9 @@ type block = @{
     fcx: @fn_ctxt
 };
 
+// First two args are retptr, env
+const first_tp_arg: uint = 2u;
+
 // FIXME: we should be able to use option<@block_parent> here but
 // the infinite-enum check in rustboot gets upset.
 enum block_parent { parent_none, parent_some(block), }
@@ -409,14 +408,12 @@ fn block_parent(cx: block) -> block {
 }
 
 // Accessors
-// TODO: When we have overloading, simplify these names!
 
-pure fn bcx_tcx(bcx: block) -> ty::ctxt { ret bcx.fcx.ccx.tcx; }
-pure fn bcx_ccx(bcx: block) -> @crate_ctxt { ret bcx.fcx.ccx; }
-pure fn bcx_fcx(bcx: block) -> @fn_ctxt { ret bcx.fcx; }
-pure fn fcx_ccx(fcx: @fn_ctxt) -> @crate_ctxt { ret fcx.ccx; }
-pure fn fcx_tcx(fcx: @fn_ctxt) -> ty::ctxt { ret fcx.ccx.tcx; }
-pure fn ccx_tcx(ccx: @crate_ctxt) -> ty::ctxt { ret ccx.tcx; }
+impl bxc_cxs for block {
+    fn ccx() -> @crate_ctxt { self.fcx.ccx }
+    fn tcx() -> ty::ctxt { self.fcx.ccx.tcx }
+    fn sess() -> session { self.fcx.ccx.sess }
+}
 
 // LLVM type constructors.
 fn T_void() -> TypeRef {
@@ -611,7 +608,7 @@ fn T_array(t: TypeRef, n: uint) -> TypeRef {
 
 // Interior vector.
 //
-// TODO: Support user-defined vector sizes.
+// FIXME: Support user-defined vector sizes.
 fn T_vec2(targ_cfg: @session::config, t: TypeRef) -> TypeRef {
     ret T_struct([T_int(targ_cfg), // fill
                   T_int(targ_cfg), // alloc
@@ -850,7 +847,7 @@ pure fn valid_variant_index(ix: uint, cx: block, enum_id: ast::def_id,
     // change. (We're not adding new variants during trans.)
     unchecked{
         let variant =
-            ty::enum_variant_with_id(bcx_tcx(cx), enum_id, variant_id);
+            ty::enum_variant_with_id(cx.tcx(), enum_id, variant_id);
         ix < variant.args.len()
     }
 }
@@ -897,7 +894,7 @@ fn umin(cx: block, a: ValueRef, b: ValueRef) -> ValueRef {
 }
 
 fn align_to(cx: block, off: ValueRef, align: ValueRef) -> ValueRef {
-    let mask = build::Sub(cx, align, C_int(bcx_ccx(cx), 1));
+    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));
 }
@@ -915,7 +912,7 @@ fn path_str(p: path) -> str {
 }
 
 fn node_id_type(bcx: block, id: ast::node_id) -> ty::t {
-    let tcx = bcx_tcx(bcx);
+    let tcx = bcx.tcx();
     let t = ty::node_id_to_type(tcx, id);
     alt bcx.fcx.param_substs {
       some(substs) { ty::substitute_type_params(tcx, substs.tys, t) }
@@ -926,7 +923,7 @@ fn expr_ty(bcx: block, ex: @ast::expr) -> ty::t {
     node_id_type(bcx, ex.id)
 }
 fn node_id_type_params(bcx: block, id: ast::node_id) -> [ty::t] {
-    let tcx = bcx_tcx(bcx);
+    let tcx = bcx.tcx();
     let params = ty::node_id_to_type_params(tcx, id);
     alt bcx.fcx.param_substs {
       some(substs) {
diff --git a/src/comp/middle/trans/debuginfo.rs b/src/comp/middle/trans/debuginfo.rs
index efd9203911c..13b9d7673d3 100644
--- a/src/comp/middle/trans/debuginfo.rs
+++ b/src/comp/middle/trans/debuginfo.rs
@@ -225,7 +225,7 @@ fn line_from_span(cm: codemap::codemap, sp: span) -> uint {
 }
 
 fn create_block(cx: block) -> @metadata<block_md> {
-    let cache = get_cache(bcx_ccx(cx));
+    let cache = get_cache(cx.ccx());
     let cx = cx;
     while option::is_none(cx.block_span) {
         alt cx.parent {
@@ -235,10 +235,10 @@ fn create_block(cx: block) -> @metadata<block_md> {
     }
     let sp = option::get(cx.block_span);
 
-    let start = codemap::lookup_char_pos(bcx_ccx(cx).sess.codemap,
+    let start = codemap::lookup_char_pos(cx.sess().codemap,
                                          sp.lo);
     let fname = start.file.name;
-    let end = codemap::lookup_char_pos(bcx_ccx(cx).sess.codemap,
+    let end = codemap::lookup_char_pos(cx.sess().codemap,
                                        sp.hi);
     let tg = LexicalBlockTag;
     /*alt cached_metadata::<@metadata<block_md>>(
@@ -252,7 +252,7 @@ fn create_block(cx: block) -> @metadata<block_md> {
         parent_none { create_function(cx.fcx).node }
         parent_some(bcx) { create_block(bcx).node }
     };
-    let file_node = create_file(bcx_ccx(cx), fname);
+    let file_node = create_file(cx.ccx(), fname);
     let unique_id = alt cache.find(LexicalBlockTag) {
       option::some(v) { vec::len(v) as int }
       option::none { 0 }
@@ -434,11 +434,10 @@ fn create_boxed_type(cx: @crate_ctxt, outer: ty::t, _inner: ty::t,
     let fname = filename_from_span(cx, span);
     let file_node = create_file(cx, fname);
     //let cu_node = create_compile_unit_metadata(cx, fname);
-    let tcx = ccx_tcx(cx);
-    let uint_t = ty::mk_uint(tcx);
+    let uint_t = ty::mk_uint(cx.tcx);
     let refcount_type = create_basic_type(cx, uint_t,
                                           ast::ty_uint(ast::ty_u), span);
-    let scx = create_structure(file_node, ty_to_str(ccx_tcx(cx), outer), 0);
+    let scx = create_structure(file_node, ty_to_str(cx.tcx, outer), 0);
     add_member(scx, "refcnt", 0, sys::size_of::<uint>() as int,
                sys::align_of::<uint>() as int, refcount_type.node);
     add_member(scx, "boxed", 0, 8, //XXX member_size_and_align(??)
@@ -487,16 +486,15 @@ fn create_vec(cx: @crate_ctxt, vec_t: ty::t, elem_t: ty::t,
     let fname = filename_from_span(cx, vec_ty_span);
     let file_node = create_file(cx, fname);
     let elem_ty_md = create_ty(cx, elem_t, elem_ty);
-    let tcx = ccx_tcx(cx);
-    let scx = create_structure(file_node, ty_to_str(tcx, vec_t), 0);
-    let size_t_type = create_basic_type(cx, ty::mk_uint(tcx),
+    let scx = create_structure(file_node, ty_to_str(cx.tcx, vec_t), 0);
+    let size_t_type = create_basic_type(cx, ty::mk_uint(cx.tcx),
                                         ast::ty_uint(ast::ty_u), vec_ty_span);
     add_member(scx, "fill", 0, sys::size_of::<ctypes::size_t>() as int,
                sys::align_of::<ctypes::size_t>() as int, size_t_type.node);
     add_member(scx, "alloc", 0, sys::size_of::<ctypes::size_t>() as int,
                sys::align_of::<ctypes::size_t>() as int, size_t_type.node);
     let subrange = llmdnode([lltag(SubrangeTag), lli64(0), lli64(0)]);
-    let (arr_size, arr_align) = member_size_and_align(tcx, elem_ty);
+    let (arr_size, arr_align) = member_size_and_align(cx.tcx, elem_ty);
     let data_ptr = create_composite_type(ArrayTypeTag, "", file_node.node, 0,
                                          arr_size, arr_align, 0,
                                          option::some(elem_ty_md.node),
@@ -640,14 +638,14 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty)
       }
 
       ast::ty_vec(mt) {
-        let inner_t = ty::sequence_element_type(ccx_tcx(cx), t);
+        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);
       }
 
       ast::ty_path(_, id) {
-        alt ccx_tcx(cx).def_map.get(id) {
+        alt cx.tcx.def_map.get(id) {
           ast::def_prim_ty(pty) {
             ret create_basic_type(cx, t, pty, ty.span);
           }
@@ -679,7 +677,7 @@ fn create_var(type_tag: int, context: ValueRef, name: str, file: ValueRef,
 
 fn create_local_var(bcx: block, local: @ast::local)
     -> @metadata<local_var_md> unsafe {
-    let cx = bcx_ccx(bcx);
+    let cx = bcx.ccx();
     let cache = get_cache(cx);
     let tg = AutoVariableTag;
     alt cached_metadata::<@metadata<local_var_md>>(
@@ -688,10 +686,10 @@ fn create_local_var(bcx: block, local: @ast::local)
       option::none {}
     }
 
-    let name = path_to_ident(alt pat_util::normalize_pat(bcx_tcx(bcx),
+    let name = path_to_ident(alt pat_util::normalize_pat(bcx.tcx(),
                                            local.node.pat).node {
       ast::pat_ident(ident, _) { ident /*XXX deal w/ optional node binding*/ }
-      _ { bcx_tcx(bcx).sess.span_bug(local.span, "create_local_var: \
+      _ { bcx.tcx().sess.span_bug(local.span, "create_local_var: \
              weird pattern in local"); }
      });
     let loc = codemap::lookup_char_pos(cx.sess.codemap,
@@ -711,13 +709,13 @@ fn create_local_var(bcx: block, local: @ast::local)
     let llptr = alt bcx.fcx.lllocals.find(local.node.id) {
       option::some(local_mem(v)) { v }
       option::some(_) {
-        bcx_tcx(bcx).sess.span_bug(local.span, "local is bound to \
+        bcx.tcx().sess.span_bug(local.span, "local is bound to \
                 something weird");
       }
       option::none {
         alt bcx.fcx.lllocals.get(local.node.pat.id) {
           local_imm(v) { v }
-          _ { bcx_tcx(bcx).sess.span_bug(local.span, "local is bound to \
+          _ { bcx.tcx().sess.span_bug(local.span, "local is bound to \
                 something weird"); }
         }
       }
@@ -730,8 +728,7 @@ fn create_local_var(bcx: block, local: @ast::local)
 
 fn create_arg(bcx: block, arg: ast::arg, sp: span)
     -> @metadata<argument_md> unsafe {
-    let fcx = bcx_fcx(bcx);
-    let cx = fcx_ccx(fcx);
+    let fcx = bcx.fcx, cx = fcx.ccx;
     let cache = get_cache(cx);
     let tg = ArgVariableTag;
     alt cached_metadata::<@metadata<argument_md>>(
@@ -740,9 +737,6 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span)
       option::none {}
     }
 
-    /*let arg_n = alt cx.ast_map.get(arg.id) {
-      ast_map::node_arg(_, n) { n - 2u }
-    };*/
     let loc = codemap::lookup_char_pos(cx.sess.codemap,
                                        sp.lo);
     let ty = node_id_type(bcx, arg.id);
@@ -764,10 +758,10 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span)
 }
 
 fn update_source_pos(cx: block, s: span) {
-    if !bcx_ccx(cx).sess.opts.debuginfo {
+    if !cx.sess().opts.debuginfo {
         ret;
     }
-    let cm = bcx_ccx(cx).sess.codemap;
+    let cm = cx.sess().codemap;
     let blockmd = create_block(cx);
     let loc = codemap::lookup_char_pos(cm, s.lo);
     let scopedata = [lli32(loc.line as int),
@@ -779,7 +773,7 @@ fn update_source_pos(cx: block, s: span) {
 }
 
 fn create_function(fcx: @fn_ctxt) -> @metadata<subprogram_md> {
-    let cx = fcx_ccx(fcx);
+    let cx = fcx.ccx;
     let dbg_cx = option::get(cx.dbg_cx);
 
     #debug("~~");
@@ -794,7 +788,7 @@ fn create_function(fcx: @fn_ctxt) -> @metadata<subprogram_md> {
           ast::item_fn(decl, _, _) | ast::item_res(decl, _, _, _, _) {
             (item.ident, decl.output, item.id)
           }
-          _ { fcx_tcx(fcx).sess.span_bug(item.span, "create_function: item \
+          _ { fcx.ccx.sess.span_bug(item.span, "create_function: item \
                 bound to non-function"); }
         }
       }
@@ -806,7 +800,7 @@ fn create_function(fcx: @fn_ctxt) -> @metadata<subprogram_md> {
             ast::item_res(decl, _, _, _, ctor_id) {
               (item.ident, decl.output, ctor_id)
             }
-            _ { fcx_tcx(fcx).sess.span_bug(item.span, "create_function: \
+            _ { fcx.ccx.sess.span_bug(item.span, "create_function: \
                   expected an item_res here"); }
           }
       }
@@ -818,11 +812,11 @@ fn create_function(fcx: @fn_ctxt) -> @metadata<subprogram_md> {
           ast::expr_fn_block(decl, _) {
             (dbg_cx.names("fn"), decl.output, expr.id)
           }
-          _ { fcx_tcx(fcx).sess.span_bug(expr.span, "create_function: \
+          _ { fcx.ccx.sess.span_bug(expr.span, "create_function: \
                   expected an expr_fn or fn_block here"); }
         }
       }
-      _ { fcx_tcx(fcx).sess.bug("create_function: unexpected \
+      _ { fcx.ccx.sess.bug("create_function: unexpected \
             sort of node"); }
     };
 
@@ -846,8 +840,7 @@ fn create_function(fcx: @fn_ctxt) -> @metadata<subprogram_md> {
     let ty_node = if cx.sess.opts.extra_debuginfo {
         alt ret_ty.node {
           ast::ty_nil { llnull() }
-          _ { create_ty(cx, ty::node_id_to_type(ccx_tcx(cx), id),
-                        ret_ty).node }
+          _ { create_ty(cx, ty::node_id_to_type(cx.tcx, id), ret_ty).node }
         }
     } else {
         llnull()
diff --git a/src/comp/middle/trans/impl.rs b/src/comp/middle/trans/impl.rs
index 57721682982..8ca3d8577dc 100644
--- a/src/comp/middle/trans/impl.rs
+++ b/src/comp/middle/trans/impl.rs
@@ -63,7 +63,7 @@ fn trans_self_arg(bcx: block, base: @ast::expr) -> result {
     let basety = expr_ty(bcx, base);
     let m_by_ref = ast::expl(ast::by_ref);
     trans_arg_expr(bcx, {mode: m_by_ref, ty: basety},
-                   T_ptr(type_of_or_i8(bcx_ccx(bcx), basety)), base)
+                   T_ptr(type_of_or_i8(bcx.ccx(), basety)), base)
 }
 
 fn trans_method_callee(bcx: block, callee_id: ast::node_id,
@@ -110,7 +110,7 @@ fn wrapper_fn_ty(ccx: @crate_ctxt, dict_ty: TypeRef, fty: ty::t,
 fn trans_vtable_callee(bcx: block, env: callee_env, dict: ValueRef,
                        callee_id: ast::node_id, iface_id: ast::def_id,
                        n_method: uint) -> lval_maybe_callee {
-    let bcx = bcx, ccx = bcx_ccx(bcx), tcx = ccx.tcx;
+    let bcx = bcx, ccx = bcx.ccx(), tcx = ccx.tcx;
     let method = ty::iface_methods(tcx, iface_id)[n_method];
     let {ty: fty, llty: llfty} =
         wrapper_fn_ty(ccx, val_ty(dict), node_id_type(bcx, callee_id),
@@ -146,7 +146,7 @@ fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id,
                               substs: param_substs) -> lval_maybe_callee {
     alt find_dict_in_fn_ctxt(substs, n_param, n_bound) {
       typeck::dict_static(impl_did, tys, sub_origins) {
-        let tcx = bcx_tcx(bcx);
+        let tcx = bcx.tcx();
         if impl_did.crate != ast::local_crate {
             ret trans_param_callee(bcx, callee_id, base, iface_id,
                                    n_method, n_param, n_bound);
@@ -296,8 +296,9 @@ fn trans_impl_wrapper(ccx: @crate_ctxt, pt: path,
     let env_ty = T_ptr(T_struct([T_ptr(T_i8())] + extra_ptrs));
     let n_extra_ptrs = extra_ptrs.len();
 
-    let wrap_args = [T_ptr(T_dict())] + vec::slice(real_args, 0u, 2u) +
-        vec::slice(real_args, 2u + n_extra_ptrs, real_args.len());
+    let wrap_args = [T_ptr(T_dict())] +
+        vec::slice(real_args, 0u, first_tp_arg) +
+        vec::slice(real_args, first_tp_arg + n_extra_ptrs, real_args.len());
     let llfn_ty = T_fn(wrap_args, real_ret);
     trans_wrapper(ccx, pt, llfn_ty, {|llfn, bcx|
         let dict = PointerCast(bcx, LLVMGetParam(llfn, 0 as c_uint), env_ty);
@@ -397,7 +398,7 @@ fn dict_is_static(tcx: ty::ctxt, origin: typeck::dict_origin) -> bool {
 }
 
 fn get_dict(bcx: block, origin: typeck::dict_origin) -> result {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     alt origin {
       typeck::dict_static(impl_did, tys, sub_origins) {
         if dict_is_static(ccx.tcx, origin) {
@@ -455,7 +456,7 @@ fn dict_id(tcx: ty::ctxt, origin: typeck::dict_origin) -> dict_id {
 
 fn get_static_dict(bcx: block, origin: typeck::dict_origin)
     -> ValueRef {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     let id = dict_id(ccx.tcx, origin);
     alt ccx.dicts.find(id) {
       some(d) { ret d; }
@@ -476,7 +477,7 @@ fn get_static_dict(bcx: block, origin: typeck::dict_origin)
 
 fn get_dict_ptrs(bcx: block, origin: typeck::dict_origin)
     -> {bcx: block, ptrs: [ValueRef]} {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     fn get_vtable(ccx: @crate_ctxt, did: ast::def_id) -> ValueRef {
         if did.crate == ast::local_crate {
             ccx.item_ids.get(did.node)
@@ -512,7 +513,7 @@ fn get_dict_ptrs(bcx: block, origin: typeck::dict_origin)
         {bcx: bcx, ptrs: [get_vtable(ccx, did)]}
       }
       _ {
-        bcx_tcx(bcx).sess.bug("Unexpected dict_param in get_dict_ptrs");
+        bcx.tcx().sess.bug("Unexpected dict_param in get_dict_ptrs");
       }
     }
 }
@@ -520,7 +521,7 @@ fn get_dict_ptrs(bcx: block, origin: typeck::dict_origin)
 fn trans_cast(bcx: block, val: @ast::expr, id: ast::node_id, dest: dest)
     -> block {
     if dest == ignore { ret trans_expr(bcx, val, ignore); }
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     let v_ty = expr_ty(bcx, val);
     let {bcx, box, body} = trans_malloc_boxed(bcx, v_ty);
     add_clean_free(bcx, box, false);
diff --git a/src/comp/middle/trans/native.rs b/src/comp/middle/trans/native.rs
index 83c7bafe194..e42e866a1ef 100644
--- a/src/comp/middle/trans/native.rs
+++ b/src/comp/middle/trans/native.rs
@@ -214,7 +214,7 @@ fn trans_native_mod(ccx: @crate_ctxt,
                       llwrapfn: ValueRef, llargbundle: ValueRef,
                       num_tps: uint) {
             let i = 0u, n = vec::len(tys.arg_tys);
-            let implicit_args = 2u + num_tps; // ret + env
+            let implicit_args = first_tp_arg + num_tps; // ret + env
             while i < n {
                 let llargval = llvm::LLVMGetParam(
                     llwrapfn,
@@ -290,7 +290,7 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
             let n = vec::len(tys.arg_tys);
             let llretptr = load_inbounds(bcx, llargbundle, [0, n as int]);
             llargvals += [llretptr];
-            let llenvptr = C_null(T_opaque_box_ptr(bcx_ccx(bcx)));
+            let llenvptr = C_null(T_opaque_box_ptr(bcx.ccx()));
             llargvals += [llenvptr];
             while i < n {
                 let llargval = load_inbounds(bcx, llargbundle, [0, i as int]);
diff --git a/src/comp/middle/trans/shape.rs b/src/comp/middle/trans/shape.rs
index d1ea547aa83..c73aed68add 100644
--- a/src/comp/middle/trans/shape.rs
+++ b/src/comp/middle/trans/shape.rs
@@ -6,11 +6,7 @@ import lib::llvm::{True, False, ModuleRef, TypeRef, ValueRef};
 import driver::session;
 import driver::session::session;
 import trans::base;
-import middle::trans::common::{crate_ctxt, val_ty, C_bytes, C_int,
-                               C_named_struct, C_struct, T_enum_variant,
-                               block, result, rslt, bcx_ccx, bcx_tcx,
-                               type_has_static_size, umax, umin, align_to,
-                               tydesc_info};
+import middle::trans::common::*;
 import back::abi;
 import middle::ty;
 import middle::ty::field;
@@ -102,12 +98,12 @@ fn mk_global(ccx: @crate_ctxt, name: str, llval: ValueRef, internal: bool) ->
 // alignment at least as large as any other variant of the enum. This is an
 // important performance optimization.
 //
-// TODO: Use this in dynamic_size_of() as well.
+// FIXME: Use this in dynamic_size_of() as well.
 
 fn largest_variants(ccx: @crate_ctxt, tag_id: ast::def_id) -> [uint] {
     // Compute the minimum and maximum size and alignment for each variant.
     //
-    // TODO: We could do better here; e.g. we know that any variant that
+    // FIXME: We could do better here; e.g. we know that any variant that
     // contains (T,T) must be as least as large as any variant that contains
     // just T.
     let ranges = [];
@@ -117,7 +113,7 @@ fn largest_variants(ccx: @crate_ctxt, tag_id: ast::def_id) -> [uint] {
         let {a: min_size, b: min_align} = {a: 0u, b: 0u};
         for elem_t: ty::t in variant.args {
             if ty::type_has_params(elem_t) {
-                // TODO: We could do better here; this causes us to
+                // FIXME: We could do better here; this causes us to
                 // conservatively assume that (int, T) has minimum size 0,
                 // when in fact it has minimum size sizeof(int).
                 bounded = false;
@@ -183,7 +179,7 @@ fn largest_variants(ccx: @crate_ctxt, tag_id: ast::def_id) -> [uint] {
 // Computes the static size of a enum, without using mk_tup(), which is
 // bad for performance.
 //
-// TODO: Migrate trans over to use this.
+// FIXME: Migrate trans over to use this.
 
 fn round_up(size: u16, align: u8) -> u16 {
     assert (align >= 1u8);
@@ -606,7 +602,7 @@ type tag_metrics = {
 };
 
 fn size_of(bcx: block, t: ty::t) -> result {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     if check type_has_static_size(ccx, t) {
         rslt(bcx, llsize_of(ccx, base::type_of(ccx, t)))
     } else {
@@ -616,7 +612,7 @@ fn size_of(bcx: block, t: ty::t) -> result {
 }
 
 fn align_of(bcx: block, t: ty::t) -> result {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     if check type_has_static_size(ccx, t) {
         rslt(bcx, llalign_of(ccx, base::type_of(ccx, t)))
     } else {
@@ -626,7 +622,7 @@ fn align_of(bcx: block, t: ty::t) -> result {
 }
 
 fn metrics(bcx: block, t: ty::t) -> metrics {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     if check type_has_static_size(ccx, t) {
         let llty = base::type_of(ccx, t);
         { bcx: bcx, sz: llsize_of(ccx, llty), align: llalign_of(ccx, llty) }
@@ -699,8 +695,8 @@ fn dynamic_metrics(cx: block, t: ty::t) -> metrics {
         //     is aligned to max alignment of interior.
         //
 
-        let off = C_int(bcx_ccx(cx), 0);
-        let max_align = C_int(bcx_ccx(cx), 1);
+        let off = C_int(cx.ccx(), 0);
+        let max_align = C_int(cx.ccx(), 1);
         let bcx = cx;
         for e: ty::t in elts {
             let elt_align = align_of(bcx, e);
@@ -734,17 +730,17 @@ fn dynamic_metrics(cx: block, t: ty::t) -> metrics {
       }
       ty::ty_enum(tid, tps) {
         let bcx = cx;
-        let ccx = bcx_ccx(bcx);
+        let ccx = bcx.ccx();
 
         let compute_max_variant_size = fn@(bcx: block) -> result {
             // Compute max(variant sizes).
             let bcx = bcx;
             let max_size: ValueRef = C_int(ccx, 0);
-            let variants = ty::enum_variants(bcx_tcx(bcx), tid);
+            let variants = ty::enum_variants(bcx.tcx(), tid);
             for variant: ty::variant_info in *variants {
                 // Perform type substitution on the raw argument types.
                 let tys = vec::map(variant.args) {|raw_ty|
-                    ty::substitute_type_params(bcx_tcx(cx), tps, raw_ty)
+                    ty::substitute_type_params(cx.tcx(), tps, raw_ty)
                 };
                 let rslt = align_elements(bcx, tys);
                 bcx = rslt.bcx;
@@ -766,7 +762,7 @@ fn dynamic_metrics(cx: block, t: ty::t) -> metrics {
       }
       _ {
         // Precondition?
-        bcx_tcx(cx).sess.bug("dynamic_metrics: type has static \
+        cx.tcx().sess.bug("dynamic_metrics: type has static \
           size");
       }
     }
@@ -802,7 +798,7 @@ fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t {
 //fn tag_payload_offs(bcx: block, tag_id: ast::def_id, tps: [ty::t])
 //    -> ValueRef {
 //    alt tag_kind(tag_id) {
-//      tk_unit | tk_enum | tk_newtype { C_int(bcx_ccx(bcx), 0) }
+//      tk_unit | tk_enum | tk_newtype { C_int(bcx.ccx(), 0) }
 //      tk_complex {
 //        compute_tag_metrics(tag_id, tps)
 //      }
diff --git a/src/comp/middle/trans/tvec.rs b/src/comp/middle/trans/tvec.rs
index 35494cc82dd..04734fe2960 100644
--- a/src/comp/middle/trans/tvec.rs
+++ b/src/comp/middle/trans/tvec.rs
@@ -26,7 +26,7 @@ fn pointer_add(bcx: block, ptr: ValueRef, bytes: ValueRef) -> ValueRef {
 }
 
 fn alloc_raw(bcx: block, fill: ValueRef, alloc: ValueRef) -> result {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     let llvecty = ccx.opaque_vec_type;
     let vecsize = Add(bcx, alloc, llsize_of(ccx, llvecty));
     let {bcx: bcx, val: vecptr} =
@@ -44,8 +44,8 @@ type alloc_result =
      llunitty: TypeRef};
 
 fn alloc(bcx: block, vec_ty: ty::t, elts: uint) -> alloc_result {
-    let ccx = bcx_ccx(bcx);
-    let unit_ty = ty::sequence_element_type(bcx_tcx(bcx), vec_ty);
+    let ccx = bcx.ccx();
+    let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty);
     let llunitty = type_of_or_i8(ccx, unit_ty);
     let llvecty = T_vec(ccx, llunitty);
     let {bcx: bcx, val: unit_sz} = size_of(bcx, unit_ty);
@@ -67,22 +67,22 @@ fn alloc(bcx: block, vec_ty: ty::t, elts: uint) -> alloc_result {
 }
 
 fn duplicate(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> result {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     let fill = get_fill(bcx, vptr);
     let size = Add(bcx, fill, llsize_of(ccx, ccx.opaque_vec_type));
     let {bcx: bcx, val: newptr} =
         trans_shared_malloc(bcx, val_ty(vptr), size);
     let bcx = call_memmove(bcx, newptr, vptr, size).bcx;
-    let unit_ty = ty::sequence_element_type(bcx_tcx(bcx), vec_ty);
+    let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty);
     Store(bcx, fill, GEPi(bcx, newptr, [0, abi::vec_elt_alloc]));
-    if ty::type_needs_drop(bcx_tcx(bcx), unit_ty) {
+    if ty::type_needs_drop(bcx.tcx(), unit_ty) {
         bcx = iter_vec(bcx, newptr, vec_ty, base::take_ty);
     }
     ret rslt(bcx, newptr);
 }
 fn make_free_glue(bcx: block, vptr: ValueRef, vec_ty: ty::t) ->
    block {
-    let tcx = bcx_tcx(bcx), unit_ty = ty::sequence_element_type(tcx, vec_ty);
+    let tcx = bcx.tcx(), unit_ty = ty::sequence_element_type(tcx, vec_ty);
     base::with_cond(bcx, IsNotNull(bcx, vptr)) {|bcx|
         let bcx = if ty::type_needs_drop(tcx, unit_ty) {
             iter_vec(bcx, vptr, vec_ty, base::drop_ty)
@@ -93,7 +93,7 @@ fn make_free_glue(bcx: block, vptr: ValueRef, vec_ty: ty::t) ->
 
 fn trans_vec(bcx: block, args: [@ast::expr], id: ast::node_id,
              dest: dest) -> block {
-    let ccx = bcx_ccx(bcx), bcx = bcx;
+    let ccx = bcx.ccx(), bcx = bcx;
     if dest == base::ignore {
         for arg in args {
             bcx = base::trans_expr(bcx, arg, base::ignore);
@@ -113,7 +113,7 @@ fn trans_vec(bcx: block, args: [@ast::expr], id: ast::node_id,
     let dataptr = get_dataptr(bcx, vptr, llunitty);
     let i = 0u, temp_cleanups = [vptr];
     for e in args {
-        let lleltptr = if ty::type_has_dynamic_size(bcx_tcx(bcx), unit_ty) {
+        let lleltptr = if ty::type_has_dynamic_size(bcx.tcx(), unit_ty) {
             InBoundsGEP(bcx, dataptr, [Mul(bcx, C_uint(ccx, i), llunitsz)])
         } else { InBoundsGEP(bcx, dataptr, [C_uint(ccx, i)]) };
         bcx = base::trans_expr_save_in(bcx, e, lleltptr);
@@ -128,9 +128,9 @@ fn trans_vec(bcx: block, args: [@ast::expr], id: ast::node_id,
 fn trans_str(bcx: block, s: str, dest: dest) -> block {
     let veclen = str::len_bytes(s) + 1u; // +1 for \0
     let {bcx: bcx, val: sptr, _} =
-        alloc(bcx, ty::mk_str(bcx_tcx(bcx)), veclen);
+        alloc(bcx, ty::mk_str(bcx.tcx()), veclen);
 
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     let llcstr = C_cstr(ccx, s);
     let bcx =
         call_memmove(bcx, get_dataptr(bcx, sptr, T_i8()), llcstr,
@@ -141,9 +141,9 @@ fn trans_str(bcx: block, s: str, dest: dest) -> block {
 fn trans_append(cx: block, vec_ty: ty::t, lhsptr: ValueRef,
                 rhs: ValueRef) -> block {
     // Cast to opaque interior vector types if necessary.
-    let ccx = bcx_ccx(cx);
-    let unit_ty = ty::sequence_element_type(bcx_tcx(cx), vec_ty);
-    let dynamic = ty::type_has_dynamic_size(bcx_tcx(cx), unit_ty);
+    let ccx = cx.ccx();
+    let unit_ty = ty::sequence_element_type(cx.tcx(), vec_ty);
+    let dynamic = ty::type_has_dynamic_size(cx.tcx(), unit_ty);
     let (lhsptr, rhs) =
         if !dynamic {
             (lhsptr, rhs)
@@ -156,7 +156,7 @@ fn trans_append(cx: block, vec_ty: ty::t, lhsptr: ValueRef,
       ty::ty_vec(_) { false }
       _ {
           // precondition?
-          bcx_tcx(cx).sess.bug("Bad argument type in trans_append");
+          cx.tcx().sess.bug("Bad argument type in trans_append");
       }
     };
 
@@ -171,7 +171,7 @@ fn trans_append(cx: block, vec_ty: ty::t, lhsptr: ValueRef,
     if strings { new_fill = Sub(bcx, new_fill, C_int(ccx, 1)); }
     let opaque_lhs = PointerCast(bcx, lhsptr,
                                  T_ptr(T_ptr(ccx.opaque_vec_type)));
-    Call(bcx, bcx_ccx(cx).upcalls.vec_grow,
+    Call(bcx, cx.ccx().upcalls.vec_grow,
          [opaque_lhs, new_fill]);
     // Was overwritten if we resized
     let lhs = Load(bcx, lhsptr);
@@ -204,8 +204,8 @@ fn trans_append(cx: block, vec_ty: ty::t, lhsptr: ValueRef,
 
 fn trans_append_literal(bcx: block, vptrptr: ValueRef, vec_ty: ty::t,
                         vals: [@ast::expr]) -> block {
-    let ccx = bcx_ccx(bcx);
-    let elt_ty = ty::sequence_element_type(bcx_tcx(bcx), vec_ty);
+    let ccx = bcx.ccx();
+    let elt_ty = ty::sequence_element_type(bcx.tcx(), vec_ty);
     let ti = none;
     let {bcx: bcx, val: td} = get_tydesc(bcx, elt_ty, false, ti);
     base::lazily_emit_tydesc_glue(ccx, abi::tydesc_field_take_glue, ti);
@@ -217,7 +217,7 @@ fn trans_append_literal(bcx: block, vptrptr: ValueRef, vec_ty: ty::t,
         let r = base::spill_if_immediate(bcx, elt, elt_ty);
         let spilled = r.val;
         bcx = r.bcx;
-        Call(bcx, bcx_ccx(bcx).upcalls.vec_push,
+        Call(bcx, bcx.ccx().upcalls.vec_push,
              [opaque_v, td, PointerCast(bcx, spilled, T_ptr(T_i8()))]);
     }
     ret bcx;
@@ -225,12 +225,12 @@ fn trans_append_literal(bcx: block, vptrptr: ValueRef, vec_ty: ty::t,
 
 fn trans_add(bcx: block, vec_ty: ty::t, lhs: ValueRef,
              rhs: ValueRef, dest: dest) -> block {
-    let ccx = bcx_ccx(bcx);
+    let ccx = bcx.ccx();
     let strings = alt ty::get(vec_ty).struct {
       ty::ty_str { true }
       _ { false }
     };
-    let unit_ty = ty::sequence_element_type(bcx_tcx(bcx), vec_ty);
+    let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty);
     let llunitty = type_of_or_i8(ccx, unit_ty);
     let {bcx: bcx, val: llunitsz} = size_of(bcx, unit_ty);
 
@@ -245,12 +245,12 @@ fn trans_add(bcx: block, vec_ty: ty::t, lhs: ValueRef,
         (bcx, get_dataptr(bcx, new_vec_ptr, llunitty));
     let copy_fn = fn@(bcx: block, addr: ValueRef,
                       _ty: ty::t) -> block {
-        let ccx = bcx_ccx(bcx);
+        let ccx = bcx.ccx();
         let write_ptr = Load(bcx, write_ptr_ptr);
         let bcx = copy_val(bcx, INIT, write_ptr,
                            load_if_immediate(bcx, addr, unit_ty), unit_ty);
         let incr =
-            if ty::type_has_dynamic_size(bcx_tcx(bcx), unit_ty) {
+            if ty::type_has_dynamic_size(bcx.tcx(), unit_ty) {
                 llunitsz
             } else {
                 C_int(ccx, 1)
@@ -271,15 +271,15 @@ type iter_vec_block = fn(block, ValueRef, ty::t) -> block;
 
 fn iter_vec_raw(bcx: block, vptr: ValueRef, vec_ty: ty::t,
                 fill: ValueRef, f: iter_vec_block) -> block {
-    let ccx = bcx_ccx(bcx);
-    let unit_ty = ty::sequence_element_type(bcx_tcx(bcx), vec_ty);
+    let ccx = bcx.ccx();
+    let unit_ty = ty::sequence_element_type(bcx.tcx(), vec_ty);
     let llunitty = type_of_or_i8(ccx, unit_ty);
     let {bcx: bcx, val: unit_sz} = size_of(bcx, unit_ty);
     let vptr = PointerCast(bcx, vptr, T_ptr(T_vec(ccx, llunitty)));
     let data_ptr = get_dataptr(bcx, vptr, llunitty);
 
     // Calculate the last pointer address we want to handle.
-    // TODO: Optimize this when the size of the unit type is statically
+    // FIXME: Optimize this when the size of the unit type is statically
     // known to not use pointer casts, which tend to confuse LLVM.
     let data_end_ptr = pointer_add(bcx, data_ptr, fill);
 
@@ -294,7 +294,7 @@ fn iter_vec_raw(bcx: block, vptr: ValueRef, vec_ty: ty::t,
     CondBr(header_cx, not_yet_at_end, body_cx.llbb, next_cx.llbb);
     body_cx = f(body_cx, data_ptr, unit_ty);
     let increment =
-        if ty::type_has_dynamic_size(bcx_tcx(bcx), unit_ty) {
+        if ty::type_has_dynamic_size(bcx.tcx(), unit_ty) {
             unit_sz
         } else { C_int(ccx, 1) };
     AddIncomingToPhi(data_ptr, InBoundsGEP(body_cx, data_ptr, [increment]),
@@ -305,8 +305,7 @@ fn iter_vec_raw(bcx: block, vptr: ValueRef, vec_ty: ty::t,
 
 fn iter_vec(bcx: block, vptr: ValueRef, vec_ty: ty::t,
             f: iter_vec_block) -> block {
-    let ccx = bcx_ccx(bcx);
-    let vptr = PointerCast(bcx, vptr, T_ptr(ccx.opaque_vec_type));
+    let vptr = PointerCast(bcx, vptr, T_ptr(bcx.ccx().opaque_vec_type));
     ret iter_vec_raw(bcx, vptr, vec_ty, get_fill(bcx, vptr), f);
 }
 
diff --git a/src/comp/middle/trans/uniq.rs b/src/comp/middle/trans/uniq.rs
index b1b701fdc66..b2ff6577762 100644
--- a/src/comp/middle/trans/uniq.rs
+++ b/src/comp/middle/trans/uniq.rs
@@ -24,7 +24,7 @@ fn alloc_uniq(cx: block, uniq_ty: ty::t) -> result {
     bcx = r.bcx;
     let llsz = r.val;
 
-    let llptrty = T_ptr(type_of(bcx_ccx(bcx), contents_ty));
+    let llptrty = T_ptr(type_of(bcx.ccx(), contents_ty));
 
     r = trans_shared_malloc(bcx, llptrty, llsz);
     bcx = r.bcx;